Пример #1
0
 private void dgview_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
 {
     if (GlobalData.usedSubjects() && (GlobalData.Bind.Current is Subject))
     {
         var editor = new SubjectEditor(GlobalData.Bind.Current as Subject);
         editor.ShowDialog();
         if (editor.DialogResult == DialogResult.Yes)
         {
             GlobalData.useSubjects();
         }
     }
     else if (GlobalData.usedStudents() && (GlobalData.Bind.Current is Student))
     {
         var editor = new StudentEditor(GlobalData.Bind.Current as Student);
         editor.ShowDialog();
         if (editor.DialogResult == DialogResult.Yes)
         {
             GlobalData.useStudents();
         }
     }
 }
Пример #2
0
 private void btn_add_Click(object sender, EventArgs e)
 {
     if (GlobalData.usedSubjects())
     {
         var editor = new SubjectEditor(null);
         editor.ShowDialog();
         if (editor.DialogResult == DialogResult.Yes)
         {
             GlobalData.useSubjects();
         }
     }
     else if (GlobalData.usedStudents())
     {
         var editor = new StudentEditor(null);
         editor.ShowDialog();
         if (editor.DialogResult == DialogResult.Yes)
         {
             GlobalData.useStudents();
         }
     }
 }
Пример #3
0
        private void btn_delete_Click(object sender, EventArgs e)
        {
            if (GlobalData.usedSubjects())
            {
                Subject subject = GlobalData.Bind.Current as Subject;
                IEnumerable <Student> studentsWithSubject = GlobalData.Students.Where(stud => stud.Subjects.Contains(subject));
                studentsWithSubject.ToList().ForEach(stud => stud.Subjects.Remove(subject));

                GlobalData.Bind.RemoveCurrent();
                GlobalData.refreshData();
            }
            else if (GlobalData.usedStudents())
            {
                Student student = GlobalData.Bind.Current as Student;
                IEnumerable <Subject> subjectsWithStudent = GlobalData.Subjects.Where(subj => subj.Students.Contains(student));
                subjectsWithStudent.ToList().ForEach(subj => subj.Students.Remove(student));

                GlobalData.Bind.RemoveCurrent();
                GlobalData.refreshData();
            }
        }