// Display Undergrad, Faculty, or GradStudent Form Depending on Type of Object Found void displayRelevantFormPart(OwlMember p) { if (p.GetType() == typeof(UndergraduateStudent)) { FormController.activateUndergraduateStudent(this); FormController.deactivateGraduateStudent(this); FormController.deactivateFaculty(this); FormController.deactivateChairperson(this); } else if (p.GetType() == typeof(GraduateStudent)) { FormController.activateGraduateStudent(this); FormController.deactivateUndergraduateStudent(this); FormController.deactivateFaculty(this); FormController.deactivateChairperson(this); } else if (p.GetType() == typeof(FacultyMember)) { FormController.deactivateGraduateStudent(this); FormController.deactivateUndergraduateStudent(this); FormController.activateFaculty(this); FormController.deactivateChairperson(this); } else if (p.GetType() == typeof(FacultyChairPerson)) { FormController.deactivateGraduateStudent(this); FormController.deactivateUndergraduateStudent(this); FormController.deactivateFaculty(this); FormController.activateChairperson(this); } }//end displayRelevatnFormPart
} // end DisplayFacultyForm private void btnEdit_Click(object sender, EventArgs e) { bool success; btnFind.Enabled = false; btnDelete.Enabled = false; btnSaveEditUpdate.Enabled = false; success = findAnItem("Edit/Update"); if (success) { btnSaveEditUpdate.Enabled = true; btnEdit.Enabled = false; OwlMember p = thisOwlMemberList.getAnItem(currentIndex); txtOwlMemberName.Text = p.OwlName; txtOwlMemberID.Text = p.owlID.ToString(); txtOwlMemberBirthDate.Text = Convert.ToDateTime(p.owlBirthDate).ToString("MM/dd/yyyy"); MessageBox.Show("Edit/UPDATE current Owl (as shown). Press Save Updates Button", "Edit/Update Notice", MessageBoxButtons.OK); // if (thisOwlList.getAnItem(currentIndex).GetType().ToString() == "EmpMan.Undergrad") if (p.GetType() == typeof(UndergraduateStudent)) { FormController.activateUndergraduateStudent(this); FormController.deactivateFaculty(this); FormController.deactivateGraduateStudent(this); FormController.deactivateChairperson(this); FormController.deactivateAddButtons(this); txtStudentMajor.Text = ((Student)p).studentMajor; txtStudentGPA.Text = ((Student)p).studentGPA.ToString(); txtUndergraduateStudentTuition.Text = (((UndergraduateStudent)p).getUndergraduateStudentTuition()).ToString(); txtUndergraduateStudentYear.Text = (((UndergraduateStudent)p).getUndergraduateStudentYear()); txtUndergraduateStudentCredits.Text = (((UndergraduateStudent)p).getUndergraduateStudentCredits()).ToString(); } else if (p.GetType() == typeof(GraduateStudent)) { FormController.activateGraduateStudent(this); FormController.deactivateFaculty(this); FormController.deactivateUndergraduateStudent(this); FormController.deactivateChairperson(this); FormController.deactivateAddButtons(this); txtStudentMajor.Text = ((Student)p).studentMajor; txtStudentGPA.Text = ((Student)p).studentGPA.ToString(); txtGraduateStudentStipend.Text = (((GraduateStudent)p).getGraduateStudentStipend()).ToString(); txtGraduateStudentDegreeProgram.Text = (((GraduateStudent)p).getGraduateStudentDegreeProgram()).ToString(); } } }
private void btnSaveEditUpdate_Click(object sender, EventArgs e) { bool isFound = false; int member2 = thisOwlMemberList.searchOwlMemberList(Convert.ToInt32(txtTargetID.Text), out isFound); if (isFound) { OwlMember p = thisOwlMemberList.getAnItem(member2); if (MessageBox.Show("Are you sure you want to Save update", "", MessageBoxButtons.YesNoCancel) == DialogResult.Yes) { if (p.GetType() == typeof(UndergraduateStudent)) { bool one = validator.ValidateID(txtOwlMemberID.Text); bool two = validator.ValidGPA(txtStudentGPA.Text); bool three = validator.ValidateCredits(txtUndergraduateStudentCredits.Text); bool four = validator.ValidateMajor(txtStudentMajor.Text); bool five = validator.ValidateName(txtOwlMemberName.Text); bool six = validator.ValidateTuition(txtUndergraduateStudentTuition.Text); bool seven = validator.ValidateYear(cbUndergraduateStudentYear.Text); if (one == false || two == false || three == false || four == false || five == false || six == false || seven == false) { txtTargetID.Focus(); MessageBox.Show("Go back"); } else { p.Save(this); thisOwlMemberList.displayMembers(); FormController.clear(this); } } if (p.GetType() == typeof(GraduateStudent)) { bool one = validator.ValidateID(txtOwlMemberID.Text); bool two = validator.ValidGPA(txtStudentGPA.Text); bool three = validator.ValidateGraduateStipend(txtGraduateStudentStipend.Text); bool four = validator.ValidateMajor(txtStudentMajor.Text); bool five = validator.ValidateName(txtOwlMemberName.Text); bool six = validator.ValidateDegreeProgram(cbGraduateStudentDegreeProgram.Text); if (one == false || two == false || three == false || four == false || five == false || six == false) { txtTargetID.Focus(); MessageBox.Show("Go back"); } else { p.Save(this); thisOwlMemberList.displayMembers(); FormController.clear(this); } } if (p.GetType() == typeof(FacultyMember)) { bool one = validator.ValidateID(txtOwlMemberID.Text); bool two = validator.ValidateName(txtOwlMemberName.Text); bool three = validator.ValidateDepartment(txtFacultyDepartment.Text); bool four = validator.ValidateRank(cbFacultyRank.Text); if (one == false || two == false || three == false || four == false) { txtTargetID.Focus(); MessageBox.Show("Go back"); } else { p.Save(this); thisOwlMemberList.displayMembers(); FormController.clear(this); } } if (p.GetType() == typeof(FacultyChairPerson)) { bool one = validator.ValidateID(txtOwlMemberID.Text); bool two = validator.ValidateName(txtOwlMemberName.Text); bool three = validator.ValidateDepartment(txtFacultyDepartment.Text); bool four = validator.ValidateRank(cbFacultyRank.Text); bool five = validator.ValidateChairpersonStipend(txtChairPersonStipend.Text); if (one == false || two == false || three == false || four == false || five == false) { txtTargetID.Focus(); MessageBox.Show("Go back"); } else { p.Save(this); thisOwlMemberList.displayMembers(); FormController.clear(this); } } } else { FormController.clear(this); } } }