private void buttonRefresh_Click(object sender, EventArgs e) { var students = new FormStudentList(faculty, section); students.FormClosed += new FormClosedEventHandler(dash_FormClosed); students.Show(); this.Hide(); }
private void studentsButton_Click(object sender, EventArgs e, SectionModel section) { //Console.WriteLine("Students clicked on " + section.SectionName); var students = new FormStudentList(faculty, section); students.FormClosed += new FormClosedEventHandler(dash_FormClosed); students.Show(); this.Hide(); }
private void AddStudentForm_FormClosed(object sender, FormClosedEventArgs e) { var myParent = this.Owner; myParent.Hide(); var students = new FormStudentList(faculty, section); students.FormClosed += new FormClosedEventHandler(dash_FormClosed); students.Show(); }
private void ButtonAdd_Click(object sender, EventArgs e) { StudentUserModel student = new StudentUserModel(); student.FirstName = textBoxStudentFirstName.Text.Trim(); student.LastName = textBoxStudentLastName.Text.Trim(); student.AcademicId = textBoxStudentId.Text; try { student.IsValid(); UserController controller = new UserController(); try { BaseUserModel createdStudent = controller.Create(student); SectionStudentController controller1 = new SectionStudentController(); controller1.Create(section.Id, createdStudent.Id); ClassController ccontroller = new ClassController(); List <ClassModel> classList = ccontroller.GetBySectionId(section.Id); AttendanceController acontroller = new AttendanceController(); foreach (ClassModel Class in classList) { AttendanceModel attendance = new AttendanceModel(); attendance.StudentId = createdStudent.Id; attendance.ClassId = Class.Id; try { acontroller.Create(attendance); } catch (Exception ex) { MessageBox.Show(ex.Message); } } MessageBox.Show(student.FullName + " added in " + section.SectionName); var students = new FormStudentList(faculty, section); students.FormClosed += new FormClosedEventHandler(dash_FormClosed); students.Show(); this.Hide(); } catch (NullReferenceException ex) { MessageBox.Show(ex.Message); } } catch (SQLiteException ex) { try { UserController controller = new UserController(); var gotStudent = controller.GetByAcademicId(student.AcademicId); string message = "Student already exists in our database. Are you sure you want to add " + gotStudent.FullName + "(" + gotStudent.AcademicId + ")?"; DialogResult dialogResult = MessageBox.Show(message, "Confirm", MessageBoxButtons.YesNo); if (dialogResult == DialogResult.Yes) { try { SectionStudentController controller1 = new SectionStudentController(); controller1.Create(section.Id, gotStudent.Id); MessageBox.Show(gotStudent.FullName + " added in " + section.SectionName); var students = new FormStudentList(faculty, section); students.FormClosed += new FormClosedEventHandler(dash_FormClosed); students.Show(); this.Hide(); } catch (SQLiteException exc) { if (exc.ErrorCode == 19) { MessageBox.Show("Error: Student already exists in this section"); } } catch (Exception exv) { MessageBox.Show(exv.Message); } } else if (dialogResult == DialogResult.No) { this.Hide(); } } catch (Exception exc) { MessageBox.Show(exc.Message); } } catch (Exception ex) { MessageBox.Show(ex.Message); } }