private void classapprovallistGV_RowEnter(object sender, DataGridViewCellEventArgs e) { int id = int.Parse(classapprovallistGV.Rows[e.RowIndex].Cells["ID"].Value.ToString()); studClass = db.StudentClasses.Where(i => i.StudentClassesID == id).ToList().Single(); StudentNameTB.Text = studClass.Student.FirstName + ' ' + studClass.Student.LastName; gradetb.Text = studClass.Grade == null ? "Grade Pending..": studClass.Grade.ToString(); statusCB.SelectedIndex = -1; }
private void SaveClasses() { try { foreach (Class item in regLS.Items) { var newStudentCl = new StudentClass() { ClassID = item.CID, StudentClassesID = db.StudentClasses.Max(x => x.StudentClassesID) + 1, StudentID = Convert.ToInt32(crStudentIDTB.Text), Grade = null, ApprovedBy = null, SignOffBy = null }; db.StudentClasses.Add(newStudentCl); db.SaveChanges(); } } catch { MessageBox.Show("Error - Cannot Add Classes"); } }