private void btn_Delete_Click(object sender, EventArgs e) { BLGrade update = new BLGrade(); if (update.UpdateMark(StudentIDUpdate, ClassIDUpdate, null) == true) { BLGrade grades = new BLGrade(); if (cbb_Classes_GradeForm.Text != string.Empty) { var list = grades.DetailGradeInfo_cbb_Classes(cbb_Classes_GradeForm.Text, this.ProfessorID.ToString()); dgv_Grade.DataSource = list.ToList(); } else { var list = grades.DetailGradeInfo_cbb_Subjects(cbb_Subjects_GradeForm.Text, this.ProfessorID.ToString()); dgv_Grade.DataSource = list.ToList(); } foreach (DataGridViewRow row in dgv_Grade.Rows) { if (row.Cells[5].Value == null) { row.Cells[5].Value = string.Empty; } } MessageBox.Show(" Deleted !"); } else { MessageBox.Show(" Something wrong !"); } }
private void btn_OK_Click(object sender, EventArgs e) { var readfile = new BLGrade(); switch (readfile.Readfile(txb_Path.Text)) { case 2: { MessageBox.Show("Load all the grades in this file successfully !"); BLGrade grades = new BLGrade(); if (cbb_Classes_GradeForm.Text != string.Empty) { var list = grades.DetailGradeInfo_cbb_Classes(cbb_Classes_GradeForm.Text, this.ProfessorID.ToString()); dgv_Grade.DataSource = list.ToList(); } else { var list = grades.DetailGradeInfo_cbb_Subjects(cbb_Subjects_GradeForm.Text, this.ProfessorID.ToString()); dgv_Grade.DataSource = list.ToList(); } foreach (DataGridViewRow row in dgv_Grade.Rows) { if (row.Cells[5].Value == null) { row.Cells[5].Value = string.Empty; } } break; } case 1: { MessageBox.Show("This file have something wrong (the Student ID or Class ID) \n Can't read that, please try again !"); break; } case 0: { MessageBox.Show(" Can't find out this file, please check the file path again ! Is it exists ? "); break; } } txb_Path.Clear(); }
private void cbb_Subjects_GradeForm_SelectedIndexChanged(object sender, EventArgs e) { cbb_Classes_GradeForm.Text = string.Empty; BLGrade grades = new BLGrade(); var list = grades.DetailGradeInfo_cbb_Subjects(cbb_Subjects_GradeForm.Text, this.ProfessorID.ToString()); dgv_Grade.DataSource = list.ToList(); cbb_Classes_GradeForm.Items.Clear(); var temp = (from s in list select new { s.ClassID }).Distinct(); foreach (DataGridViewRow row in dgv_Grade.Rows) { if (row.Cells[5].Value == null) { row.Cells[5].Value = string.Empty; } } foreach (var a in temp) { cbb_Classes_GradeForm.Items.Add(a.ClassID); } }