/* * 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: * 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; } }
/* * Pre: * Post: Returns true if the input object has the same student and reason as the current one */ public override bool Equals(object obj) { StudentCoordinate other = (StudentCoordinate)obj; return(other.student.id == student.id && other.reason.Equals(reason)); }
/* * Pre: * Post: The new coordinate student is added to the audition's list of coordinates * @param coordinate holds the coordinate information */ public void addStudentCoordinate(StudentCoordinate coordinate) { coordinates.Add(coordinate); }