public void checkChanges() { int lecID = 200003; string description = ""; int start = 13; int end = 17; int day = 1; int month = 5; int year = 2017; List <string> list = SQLFunctions.getChanges(); if (list != null) { for (int j = 0; j < list.Count; j += 7) { lecID = Convert.ToInt32(list[j]); if (lecID != 0) { List <int> studentList = SQLFunctions.getStudentsIDfromLectureID(lecID); if (studentList == null || !studentList.Contains(userStudnet.getUserID())) { continue; } } description = list[j + 1]; start = Convert.ToInt32(list[j + 2]); end = Convert.ToInt32(list[j + 3]); day = Convert.ToInt32(list[j + 4]); month = Convert.ToInt32(list[j + 5]); year = Convert.ToInt32(list[j + 6]); DateTime date = new DateTime(year, month, day); DayOfWeek weekday = date.DayOfWeek; foreach (var k in tableLayoutPanel3.Controls) { if (k is Label) { var z = (Label)k; if (z.Text.Contains(date.ToString())) { for (int i = start; i < end; i++) { string labelName = checkDay(weekday) + i.ToString(); foreach (var c in tableLayoutPanel3.Controls) { if (c is Label) { var x = (Label)c; if (x.Name == labelName) { x.Text = description; x.BackColor = Color.Wheat; } } } } } } } } } }
public void checkChanges() { List <int> LectureIDS = new List <int>(); List <List <int> > studentList = new List <List <int> >(); List <int> studentsInLecture = new List <int>(); int lecID = 200003; string description = ""; int start = 13; int end = 17; int day = 1; int month = 5; int year = 2017; DataTable changes_dt = SQLFunctions.getChanges(); DataTable studentsTimeTable = SQLFunctions.getStudentsTimetable(id); if (changes_dt != null && studentsTimeTable != null) { for (int i = 0; i < changes_dt.Rows.Count; i++) { LectureIDS.Add(Convert.ToInt32(changes_dt.Rows[i]["LectureID"])); } for (int i = 0; i < LectureIDS.Count; i++) { for (int j = 0; j < studentsTimeTable.Rows.Count; j++) { if (LectureIDS[i] == 0 || Convert.ToInt32(studentsTimeTable.Rows[j]["LectureID"]) == LectureIDS[i]) { studentsInLecture.Add(Convert.ToInt32(studentsTimeTable.Rows[j]["StudentID"])); } if (studentsInLecture != null) { studentList.Add(studentsInLecture); } } } for (int j = 0; j < changes_dt.Rows.Count; j++) { for (int h = 0; h < studentsTimeTable.Rows.Count; h++) { if (Convert.ToInt32(studentsTimeTable.Rows[h]["LectureID"]) == LectureIDS[j] || LectureIDS[j] == 0) { lecID = Convert.ToInt32(changes_dt.Rows[j]["LectureID"]); if (lecID != 0) { if (studentList[j] == null || !studentList[j].Contains(userStudnet.getUserID())) { continue; } } description = changes_dt.Rows[j]["Description"].ToString(); start = Convert.ToInt32(changes_dt.Rows[j]["Starts"]); end = Convert.ToInt32(changes_dt.Rows[j]["Ends"]);; day = Convert.ToInt32(changes_dt.Rows[j]["day"]); month = Convert.ToInt32(changes_dt.Rows[j]["month"]); year = Convert.ToInt32(changes_dt.Rows[j]["year"]); DateTime date = new DateTime(year, month, day); DayOfWeek weekday = date.DayOfWeek; foreach (var k in tableLayoutPanel3.Controls) { if (k is Label) { var z = (Label)k; if (z.Text.Contains(date.ToShortDateString())) { for (int i = start; i < end; i++) { string labelName = checkDay(weekday) + i.ToString(); foreach (var c in tableLayoutPanel3.Controls) { if (c is Label) { var x = (Label)c; if (x.Name == labelName) { x.Text = description; x.BackColor = Color.Aqua; } } } } } } } } } } } }