/* * Pre: The audition must have previously existed in the system * Post: The audition information is updated in the database * @param coordinatesToRemove contains a list of coordinates that were removed * from the audition * @returns true if the audition is successfully updated and false otherwise */ public bool updateInDatabase(List <StudentCoordinateSimple> coordinatesToRemove) { bool success = DbInterfaceStudentAudition.UpdateStudentDistrictAudition(this); //update coordinates if (success) { //if coordinates were removed from the audition, remove them in the database if (coordinatesToRemove.Count > 0) { removeCoordinates(coordinatesToRemove); } //update coordinates foreach (StudentCoordinate coord in coordinates) { success = success && DbInterfaceStudentAudition.CreateAuditionCoordinate(auditionId, coord.auditionIds.ElementAt(0), coord.reason); success = success && DbInterfaceStudentAudition.UpdateExistingCoordinates(DbInterfaceStudentAudition.GetStudentDistrictAuditionIds(DbInterfaceStudent.GetStudentYearId(coord.student.id))); } if (coordinates.Count > 0) { success = success && DbInterfaceStudentAudition.UpdateExistingCoordinates(DbInterfaceStudentAudition.GetStudentDistrictAuditionIds(DbInterfaceStudent.GetStudentYearId(student.id))); } } return(success); }
/* * Pre: * Post: If the entered data is valid, the coordination is set between the two students */ protected void btnSubmit_Click(object sender, EventArgs e) { bool success = true; if (dataIsValid()) { string reason = ddlReason.SelectedValue; bool isDistrictAudition = ddlAuditionType.SelectedValue.Equals("District"); // Put all students into a list List <Tuple <Student, StudentCoordinate> > students = new List <Tuple <Student, StudentCoordinate> >(); for (int i = 1; i < tblCoordinates.Rows.Count; i++) { Student student = DbInterfaceStudent.LoadStudentData(Convert.ToInt32(tblCoordinates.Rows[i].Cells[1].Text)); // Get the student's coordinates and add to list if (student != null) { StudentCoordinate coordinate = new StudentCoordinate(student, reason, true, isDistrictAudition); students.Add(new Tuple <Student, StudentCoordinate>(student, coordinate)); } else { success = false; } } // Coordinate all students for (int i = 0; i < students.Count - 1; i++) { StudentCoordinate student1Coordinates = students.ElementAt(i).Item2; for (int j = i + 1; j < students.Count; j++) // Coordinate student1 with all of the remaining students in the list { StudentCoordinate student2Coordinates = students.ElementAt(j).Item2; foreach (int student1Id in student1Coordinates.auditionIds) { foreach (int student2Id in student2Coordinates.auditionIds) { success = success && DbInterfaceStudentAudition.CreateAuditionCoordinate(student1Id, student2Id, reason); } } } } //display message depending on whether or not the operation was successful if (success) { showSuccessMessage("The students were successfully coordinated."); clearPage(); } else { showErrorMessage("Error: An error occurred while coordinating the students."); } } }
/* * Pre: Auditions of both students must have been previously created * Post: A new coordinating student entry is created */ private bool createCoordinateRides() { bool success = true; foreach (StudentCoordinate coord in coordinates) { foreach (int i in coord.auditionIds) { success = success && DbInterfaceStudentAudition.CreateAuditionCoordinate(auditionId, i, coord.reason); } } return(success); }
/* * Pre: * Post: If the entered data is valid, the coordination is set between the two students */ protected void btnRegister_Click(object sender, EventArgs e) { bool success = true; clearErrors(); if (dataIsValid()) { string reason = ddlReason.SelectedValue; bool isDistrictAudition = ddlAuditionType.SelectedValue.Equals("District"); //get student data Student student1 = DbInterfaceStudent.LoadStudentData(Convert.ToInt32(lblStudent1Id.InnerText)); Student student2 = DbInterfaceStudent.LoadStudentData(Convert.ToInt32(lblStudent2Id.InnerText)); //get coordinate data if (student1 != null & student2 != null) { StudentCoordinate coord1 = new StudentCoordinate(student1, reason, true, isDistrictAudition); StudentCoordinate coord2 = new StudentCoordinate(student2, reason, true, isDistrictAudition); //coordinate each audition between the two students foreach (int i in coord1.auditionIds) { foreach (int j in coord2.auditionIds) { success = success && DbInterfaceStudentAudition.CreateAuditionCoordinate(i, j, reason); } } } else { success = false; } } //display message depending on whether or not the operation was successful if (success) { displaySuccessMessageAndOptions(); } else { lblMainError.Text = "An error occurred while coordinating the students."; lblMainError.Visible = true; } }