// ============================================= // This Method To Confirm for Create Student // ============================================== private void RibbonAddStudent_Click(object sender, ExecutedRoutedEventArgs e) { if (newStudent.ComboGroup.SelectedIndex >= 0) { try { if (newStudent.StudentID == 0) { if (newStudent.StudentCodeTxt.Text != "") { Students student = new Students(); student.StudentCode = newStudent.StudentCodeTxt.Text; student.StudentFirstName = newStudent.StudentFirstNameTxt.Text; student.StudentLastName = newStudent.StudentLastNameTxt.Text; student.GroupID = Int32.Parse(newStudent.ComboGroup.SelectedValue.ToString()); CourseData.db.Students.InsertOnSubmit(student); CourseData.db.SubmitChanges(); studentView.LoadData(); newStudent.Clear(); // UI Control ribbonControl.SelectedTab = studentTab; ShowView(studentView); UIElement[] viUI = { courseTab, studentTab }; UIElement[] coUI = { NewStudentTab }; this.VisibilityAndCollapsedUI(viUI, coUI); MessageBox.Show("Added Student", "Course"); } else { MessageBox.Show("Student Code Can't Empty"); } } else { if (newStudent.StudentCodeTxt.Text != "") { Students student = (from s in CourseData.db.Students where s.StudentID == Int32.Parse(studentView.studentGrid.SelectedValue.ToString()) select s).FirstOrDefault(); student.StudentID = newStudent.StudentID; student.StudentCode = newStudent.StudentCodeTxt.Text; student.StudentFirstName = newStudent.StudentFirstNameTxt.Text; student.StudentLastName = newStudent.StudentLastNameTxt.Text; student.StudentGroup = newStudent.ComboGroup.SelectedItem as StudentGroup; CourseData.db.SubmitChanges(); ribbonControl.SelectedTab = studentTab; newStudent.Clear(); ShowView(studentView); studentView.LoadData(); UIElement[] viUI = { courseTab, studentTab }; UIElement[] coUI = { NewStudentTab }; VisibilityAndCollapsedUI(viUI, coUI); MessageBox.Show("Modified Student", "Student"); } } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } } else { MessageBox.Show("Select Group"); } }
partial void DeleteStudents(Students instance);
partial void UpdateStudents(Students instance);
partial void InsertStudents(Students instance);
private void detach_Students(Students entity) { this.SendPropertyChanging(); entity.StudentGroup = null; }
private void attach_Students(Students entity) { this.SendPropertyChanging(); entity.StudentGroup = this; }