private void Submit_Click(object sender, EventArgs e) { try { String desctiption = FeedbackDetails.Text; if (comboBoxLecturers.Text == "" && comboBoxStudents.Text == "" && MentorBox.Text == "") { throw new Exception("Feedback person is required"); } if (string.IsNullOrWhiteSpace(desctiption)) { throw new Exception("Activity feedback is required"); } ActivityFeedback af = new ActivityFeedback(Program.activityFeedback.Count + 1, DateTime.Now, desctiption, Program.empUser, resEmp, resStud); Program.activityFeedback.Add(af); Program.create_ActivityFeedback_In_DB(af); Program.empUser.addCreatedActivityFeedback(af); if (resEmp != null) { resEmp.addRecievedActivityFeedback(af); Program.update_ActivityFeedback_Recieve_Employee_In_DB(af); } if (resStud != null) { resStud.addStudentActivityFeedbacks(af); Program.update_ActivityFeedback_Recieve_Student_In_DB(af); } } catch (Exception ex) { MessageBox.Show(ex.Message, "Activity feedback is required", MessageBoxButtons.OK); } }
public ActivityFeedback(int id, DateTime dateTime, string description, Employee createEmployee, Employee recieveEmployee, Student recieveStudent) { this.id = id; this.dateTime = dateTime; this.description = description; this.createEmployee = createEmployee; this.recieveEmployee = recieveEmployee; this.recieveStudent = recieveStudent; if (createEmployee != null) { createEmployee.addCreatedActivityFeedback(this); } if (recieveEmployee != null) { recieveEmployee.addRecievedActivityFeedback(this); } if (recieveStudent != null) { recieveStudent.addStudentActivityFeedbacks(this); } }