составление расписания для студентов (ошибка в коде логи c ..) - PullRequest
0 голосов
/ 29 марта 2020

У меня возникает эта проблема, когда я пытаюсь нарисовать эту «временную таблицу» для студентов в нашем институте, если у меня лекция на полдня, я делаю это collspan = 2, но в следующей ячейке я вижу ошибку принадлежит на следующий день ...? извините, если я не очень хорошо описываю свою проблему, но я надеюсь, что изображение, предоставленное моим кодом, сработает для вас.

void emploi()
        {

            bool flag = false;
            int jour = 1;
            while (jour <= 6)
            {
                switch (jour)
                {
                    case 1: cell1.Text = "Lundi"; break; case 2: cell1.Text = "Mardi"; break; case 3: cell1.Text = "Mercredi"; break; case 4: cell1.Text = "Jeudi"; break;case 5: cell1.Text = "Vendredi"; break;case 6: cell1.Text = "Samedi"; break; 
                }

                tRow.Cells.Add(cell1); cell1 = new TableCell();
                foreach (var v in emp.function_Afficher_Group("TDI202"))
                { flag = false;

                    if (v.Seance.Substring(0, 1) == jour.ToString())
                    {

                        if (v.Seance.Substring(1) == "S1")
                        {

                            cell1.ID = jour + "/" + v.Seance.Substring(2);
                            SeanceInfo.Text = v.Module + Environment.NewLine + v.Salle + Environment.NewLine + v.Formateur + Environment.NewLine;
                            cell1.Controls.Add(SeanceInfo); 
                            fillcombos(jour + "S1",2019,false);
                            SeanceInfo.Click += (object sender, EventArgs e) => {LinkButton button = sender as LinkButton;button.Visible = false;};

                        }
                        if (v.Seance.Substring(1) == "S2")
                        {

                            cell1.ID = jour + "/" + v.Seance.Substring(2);
                            SeanceInfo.Text = v.Module + Environment.NewLine + v.Salle + Environment.NewLine + v.Formateur + Environment.NewLine;
                            cell1.Controls.Add(SeanceInfo);
                            fillcombos(jour + "S2", 2019, false);
                            SeanceInfo.Click += (object sender, EventArgs e) => { LinkButton button = sender as LinkButton; button.Visible = false; };
                        }
                        if (v.Seance.Substring(1) == "S3")
                        {

                            cell1.ID = jour + "/" + v.Seance.Substring(2);
                            SeanceInfo.Text = v.Module + Environment.NewLine + v.Salle + Environment.NewLine + v.Formateur + Environment.NewLine;
                            cell1.Controls.Add(SeanceInfo);
                            fillcombos(jour + "S3", 2019, false);
                            SeanceInfo.Click += (object sender, EventArgs e) => { LinkButton button = sender as LinkButton; button.Visible = false; };
                        }
                        if (v.Seance.Substring(1) == "S4")
                        {

                            cell1.ID = jour + "/" + v.Seance.Substring(2);
                            SeanceInfo.Text = v.Module + Environment.NewLine + v.Salle + Environment.NewLine + v.Formateur + Environment.NewLine;
                            cell1.Controls.Add(SeanceInfo);
                            fillcombos(jour + "S4", 2019, false);
                            SeanceInfo.Click += (object sender, EventArgs e) => { LinkButton button = sender as LinkButton; button.Visible = false; };
                        }


                        if (cell1.ID == jour + "/2")
                        {
                            int ind = tRow.Cells.Count-1;
                            if ((tRow.Cells[ind].Controls[0] as LinkButton).Text == (cell1.Controls[0] as LinkButton).Text && (cell1.Controls[0] as LinkButton).Text!= "" + Environment.NewLine + "" + Environment.NewLine + "" + Environment.NewLine)
                            {
                                tRow.Cells[ind].ColumnSpan = 2;
                                flag = true;

                            }

                        }    
                        if (cell1.ID == jour + "/4")
                        {
                            int ind = tRow.Cells.Count - 1;
                            if ((tRow.Cells[ind].Controls[0] as LinkButton).Text == (cell1.Controls[0] as LinkButton).Text && (cell1.Controls[0] as LinkButton).Text != "" + Environment.NewLine + "" + Environment.NewLine + "" + Environment.NewLine)
                            {
                                tRow.Cells[ind].ColumnSpan = 2;
                                flag = true;
                            }

                        }

                        if ((cell1.Controls[0] as LinkButton).Text == ""+Environment.NewLine+""+ Environment.NewLine +""+ Environment.NewLine)
                            cell1.BackColor = System.Drawing.Color.LightGray ;
                          cell1.CssClass = "myCells"; (cell1.Controls[0] as LinkButton).CssClass = "tt";
                        if (flag == false)
                        {
                            tRow.Cells.Add(cell1); cell1 = new TableCell(); SeanceInfo = new LinkButton(); dropForm = new DropDownList();
                        }

                    }
                }
                Table1.Rows.Add(tRow);
                tRow = new TableRow();
                jour++;
            }
        }

enter image description here

1 Ответ

0 голосов
/ 29 марта 2020

решено ----> строка с комментарием // *******

void emploi()
        {

            bool flag = false;
            int jour = 1;
            while (jour <= 6)
            {
                switch (jour)
                {
                    case 1: cell1.Text = "Lundi"; break; case 2: cell1.Text = "Mardi"; break; case 3: cell1.Text = "Mercredi"; break; case 4: cell1.Text = "Jeudi"; break;case 5: cell1.Text = "Vendredi"; break;case 6: cell1.Text = "Samedi"; break; 
                }

                tRow.Cells.Add(cell1); cell1 = new TableCell();
                foreach (var v in emp.function_Afficher_Group("TDI202"))
                { flag = false;

                    if (v.Seance.Substring(0, 1) == jour.ToString())
                    {

                        if (v.Seance.Substring(1) == "S1")
                        {

                            cell1.ID = jour + "/" + v.Seance.Substring(2);
                            SeanceInfo.Text = v.Module + Environment.NewLine + v.Salle + Environment.NewLine + v.Formateur + Environment.NewLine;
                            cell1.Controls.Add(SeanceInfo); 
                            fillcombos(jour + "S1",2019,false);
                            SeanceInfo.Click += (object sender, EventArgs e) => {LinkButton button = sender as LinkButton;button.Visible = false;};

                        }
                        if (v.Seance.Substring(1) == "S2")
                        {

                            cell1.ID = jour + "/" + v.Seance.Substring(2);
                            SeanceInfo.Text = v.Module + Environment.NewLine + v.Salle + Environment.NewLine + v.Formateur + Environment.NewLine;
                            cell1.Controls.Add(SeanceInfo);
                            fillcombos(jour + "S2", 2019, false);
                            SeanceInfo.Click += (object sender, EventArgs e) => { LinkButton button = sender as LinkButton; button.Visible = false; };
                        }
                        if (v.Seance.Substring(1) == "S3")
                        {

                            cell1.ID = jour + "/" + v.Seance.Substring(2);
                            SeanceInfo.Text = v.Module + Environment.NewLine + v.Salle + Environment.NewLine + v.Formateur + Environment.NewLine;
                            cell1.Controls.Add(SeanceInfo);
                            fillcombos(jour + "S3", 2019, false);
                            SeanceInfo.Click += (object sender, EventArgs e) => { LinkButton button = sender as LinkButton; button.Visible = false; };
                        }
                        if (v.Seance.Substring(1) == "S4")
                        {

                            cell1.ID = jour + "/" + v.Seance.Substring(2);
                            SeanceInfo.Text = v.Module + Environment.NewLine + v.Salle + Environment.NewLine + v.Formateur + Environment.NewLine;
                            cell1.Controls.Add(SeanceInfo);
                            fillcombos(jour + "S4", 2019, false);
                            SeanceInfo.Click += (object sender, EventArgs e) => { LinkButton button = sender as LinkButton; button.Visible = false; };
                        }


                        if (cell1.ID == jour + "/2")
                        {
                            int ind = tRow.Cells.Count-1;
                            if ((tRow.Cells[ind].Controls[0] as LinkButton).Text == (cell1.Controls[0] as LinkButton).Text && (cell1.Controls[0] as LinkButton).Text!= "" + Environment.NewLine + "" + Environment.NewLine + "" + Environment.NewLine)
                            {
                                tRow.Cells[ind].ColumnSpan = 2;
                                flag = true;

                            }

                        }    
                        if (cell1.ID == jour + "/4")
                        {
                            int ind = tRow.Cells.Count - 1;
                            if ((tRow.Cells[ind].Controls[0] as LinkButton).Text == (cell1.Controls[0] as LinkButton).Text && (cell1.Controls[0] as LinkButton).Text != "" + Environment.NewLine + "" + Environment.NewLine + "" + Environment.NewLine)
                            {
                                tRow.Cells[ind].ColumnSpan = 2;
                                flag = true;
                            }

                        }

                        if ((cell1.Controls[0] as LinkButton).Text == ""+Environment.NewLine+""+ Environment.NewLine +""+ Environment.NewLine)
                            cell1.BackColor = System.Drawing.Color.LightGray ;
                          cell1.CssClass = "myCells"; (cell1.Controls[0] as LinkButton).CssClass = "tt";
                        if (flag == false)
                        {
                            tRow.Cells.Add(cell1); cell1 = new TableCell(); SeanceInfo = new LinkButton(); dropForm = new DropDownList();
                        }

                    }
                    cell1 = new TableCell(); //*****added this before leaving the foreach
                }
                Table1.Rows.Add(tRow);
                tRow = new TableRow();
                jour++;
            }
        }
...