private void AddClassesStudent_Load(object sender, EventArgs e) { List <Student> StudentList = StudentDB.StudentLoad(); foreach (Student student in StudentList) { string entry = student.StudentID + " " + student.FirstName + " " + student.LastName + " " + student.Grade; comboBox1.Items.Add(entry); } Student newStudent = StudentDB.TempLoad(); label2.Text = newStudent.StudentID.ToString(); textBox1.Text = newStudent.FirstName; textBox2.Text = newStudent.LastName; newStudent = StudentDB.StudentFind(Convert.ToInt32(label2.Text)); txtGrade.Text = newStudent.Grade.ToString(); List <Classes> ClassList = ClassesDB.ClassLoad(); foreach (Classes classes in ClassList) { checkedListBox1.Items.Add(classes.ClassID + " " + classes.ClassTitle + " " + classes.ClassTrack); } if (newStudent.ClassID != null) { for (int i = 0; i < checkedListBox1.Items.Count; i++) { foreach (int classid in newStudent.ClassID) { string[] id = checkedListBox1.Items[i].ToString().Split(' '); if (classid == Convert.ToInt32(id[0])) { checkedListBox1.SetItemChecked(i, true); } } } } }
private void button3_Click(object sender, EventArgs e) { dataGridView1.Rows.Clear(); dataGridView1.Refresh(); List <Student> StudentList = StudentDB.StudentLoad(); dataGridView1.ColumnCount = 12; dataGridView1.Columns[0].Name = "Student ID"; dataGridView1.Columns[1].Name = "First Name"; dataGridView1.Columns[2].Name = "Last Name"; dataGridView1.Columns[3].Name = "Grade"; dataGridView1.Columns[4].Name = "Class 1"; dataGridView1.Columns[5].Name = "Class 2"; dataGridView1.Columns[6].Name = "Class 3"; dataGridView1.Columns[7].Name = "Class 4"; dataGridView1.Columns[8].Name = "Class 5"; dataGridView1.Columns[9].Name = "Class 6"; dataGridView1.Columns[10].Name = "Class 7"; dataGridView1.Columns[11].Name = "Class 8"; foreach (Student student in StudentList) { int count = 0; List <string> SCL = new List <string>() { "", "", "", "", "", "", "", "" }; foreach (int classid in student.ClassID) { SCL[count] = CLR(classid); count++; } string[] row = new string[] { student.StudentID.ToString(), student.FirstName, student.LastName, student.Grade.ToString(), SCL[0], SCL[1], SCL[2], SCL[3], SCL[4], SCL[5], SCL[6], SCL[7] }; dataGridView1.Rows.Add(row); } }