/// <summary> /// Load the auditions for the students where the freeze date has not yet passed /// </summary> private void loadAuditions() { int studentId = -1; if (ddlAuditionType.SelectedIndex > 0 && Int32.TryParse(lblStudId.InnerText, out studentId)) { DataTable table = DbInterfaceStudentAudition.GetDistrictOrStateAuditionsForDropdownByYear(studentId, ddlAuditionType.SelectedValue.Equals("District")); cboAudition.DataSource = null; cboAudition.Items.Clear(); cboAudition.DataSourceID = ""; if (table.Rows.Count > 0) { cboAudition.DataSource = table; cboAudition.DataTextField = "DropDownInfo"; cboAudition.DataValueField = "AuditionId"; cboAudition.Items.Add(new ListItem("")); cboAudition.DataBind(); } else { showWarningMessage("This student has no editable auditions for the selected year. Either no auditions have been created or the Freeze Date has passed."); } } }
/* * Pre: * Post: The information associated with the selected audition is loaded to the page */ protected void cboAudition_SelectedIndexChanged(object sender, EventArgs e) { rblLength.SelectedIndex = -1; lblCurrentLength.Text = ""; //load associated audition information if (!cboAudition.SelectedValue.ToString().Equals("")) { if (!txtStudentId.Text.Equals("")) { Student student = DbInterfaceStudent.LoadStudentData(Convert.ToInt32(txtStudentId.Text)); if (student != null) { DistrictAudition districtAudition = DbInterfaceStudentAudition.GetStudentDistrictAudition( Convert.ToInt32(cboAudition.SelectedValue), student); if (districtAudition != null) { lblCurrentLength.Text = districtAudition.auditionLength.ToString(); } else { showErrorMessage("Error: An error occurred while loading the audition information."); } } else { showWarningMessage("Please reselect the student"); } } } }
/* * Remove coordinates from database */ protected void btnSubmit_Click(object sender, EventArgs e) { if (coordinatesToDelete.Count() > 0) { bool success = true; // Delete all auditions between the two students with the selected audition type foreach (Tuple <int, int, string> coordination in coordinatesToDelete) { success = success && DbInterfaceStudentAudition.RemoveCoordinatesByStudentIdAndType(coordination.Item1, coordination.Item2, coordination.Item3, ddlAuditionType.SelectedValue.ToUpper().Equals("DISTRICT")); } if (success) { clearAll(); showSuccessMessage("The coordinations were successfully deleted."); } else { showErrorMessage("The coordinations could not be deleted"); } } else { showInfoMessage("There were no coordinates to delete."); } }
/* * Pre: * Post: Get audition information for the input year, audition type, and student * if a matching audition exists * @param studentId is the unique id of the student * @year is the year of the audition * @auditionType signifies whether the points are being entered for HS Virtuoso * or Composition */ private void loadAudition(int studentId, int year, string auditionType) { //get student Student student = DbInterfaceStudent.LoadStudentData(studentId); //get audition if (student != null) { audition = DbInterfaceStudentAudition.GetStudentHsOrCompositionAudition(student, year, auditionType); Session[auditionVar] = audition; //set points on screen if (audition != null) { setPoints(); } else { rblAttendance.SelectedIndex = 0; ddlRoomAward.SelectedIndex = 0; ddlRoomAward.Enabled = true; lblPoints.Text = "10"; } } else { showErrorMessage("Error: There was an error loading the student data."); } }
/* * Pre: * Post: Get audition information for the input year, audition type, and student * if a matching audition exists * @param studentId is the unique id of the student * @year is the year of the audition * @auditionType signifies whether the points are being entered for HS Virtuoso * or Composition */ private void loadAudition(int studentId, int year, string auditionType) { //get student Student student = DbInterfaceStudent.LoadStudentData(studentId); //get audition if (student != null) { audition = DbInterfaceStudentAudition.GetStudentHsOrCompositionAudition(student, year, auditionType); Session[auditionVar] = audition; //set points on screen if (audition != null) { setPoints(); } else { rblAttendance.SelectedIndex = 1; ddlRoomAward.SelectedIndex = 0; lblPoints.InnerText = "0"; btnSubmit.Text = "Submit"; ddlRoomAward.Enabled = true; } } else { lblErrorMsg.Text = "There was an error loading the student data"; lblErrorMsg.Visible = true; } }
/* * Pre: * Post: Loads the information of the selected audition and saves it to a session variable */ private void resetAuditionVar() { try { int auditionId = Convert.ToInt32(cboAudition.SelectedValue); int studentId = Convert.ToInt32(Convert.ToInt32(txtStudentId.Text)); Student student = DbInterfaceStudent.LoadStudentData(studentId); //get all audition info associated with audition id and save as session variable if (student != null) { audition = new StateAudition(auditionId, student, false); audition = DbInterfaceStudentAudition.GetStudentStateAudition(audition.districtAudition, auditionId); if (audition != null) { Session[auditionVar] = audition; //if the audition was a duet, show label to inform user that the points for the //partner will also be updated if (audition.auditionType.ToUpper().Equals("DUET")) { showInfoMessage("The composition points of the student's duet partner will also be updated."); } setPoints(); } } } catch (Exception e) { Utility.LogError("Badger Point Entry", "resetAuditionVar", "", "Message: " + e.Message + " Stack Trace: " + e.StackTrace, -1); } }
/* * 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: * Post: Loads the appropriate years in the dropdown */ private void loadYearDropdown() { int firstYear = DbInterfaceStudentAudition.GetFirstAuditionYear(); for (int i = DateTime.Now.Year; i >= firstYear; i--) { ddlYear.Items.Add(new ListItem(i.ToString(), i.ToString())); } }
/* * Pre: The audition must have previously existed in the system * Post: The coordinates in the input list are removed from the system for each of the current student's auditions * @param coordinatesToRemove contains a list of coordinates that were removed * from the audition */ private void removeCoordinates(List <StudentCoordinateSimple> coordinatesToRemove) { List <int> currStudAuditionIds = DbInterfaceStudentAudition.GetStudentDistrictAuditionIds(DbInterfaceStudent.GetStudentYearId(student.id)); foreach (int id in currStudAuditionIds) { DbInterfaceStudentAudition.RemoveAuditionCoordinates(coordinatesToRemove, id); } }
/// <summary> /// Load the coordinated students for the audition (do not load duets b/c they must be deleted by deleting the audition) /// If the student has several auditions for the event, the coordination will /// be removed for all auditions. /// </summary> protected void cboAudition_SelectedIndexChanged(object sender, EventArgs e) { int auditionId = -1; if (cboAudition.SelectedIndex > -1 && Int32.TryParse(cboAudition.SelectedValue, out auditionId)) { DataTable table = DbInterfaceStudentAudition.GetUniqueAuditionCoordinates(auditionId); // Clear table while (tblCoordinates.Rows.Count > 1) { tblCoordinates.Rows.RemoveAt(1); } for (int i = 0; i < table.Rows.Count; i++) { TableRow row = new TableRow(); TableCell chkBoxCell = new TableCell(); TableCell studentIdCell = new TableCell(); TableCell coordinateStudentIdCell = new TableCell(); TableCell coordinateLastNameCell = new TableCell(); TableCell coordinateFirstNameCell = new TableCell(); TableCell coordinateTypeCell = new TableCell(); CheckBox chkBox = new CheckBox(); chkBoxCell.Controls.Add(chkBox); // Save student ids in invisible cells to access later studentIdCell.Text = lblStudId.InnerText; coordinateStudentIdCell.Text = table.Rows[i]["StudentId"].ToString(); studentIdCell.Visible = false; coordinateStudentIdCell.Visible = false; // Set remaining cell text coordinateLastNameCell.Text = table.Rows[i]["LastName"].ToString(); coordinateFirstNameCell.Text = table.Rows[i]["FirstName"].ToString(); coordinateTypeCell.Text = table.Rows[i]["CoordType"].ToString(); // Add cells to new row row.Cells.Add(chkBoxCell); row.Cells.Add(studentIdCell); row.Cells.Add(coordinateStudentIdCell); row.Cells.Add(coordinateLastNameCell); row.Cells.Add(coordinateFirstNameCell); row.Cells.Add(coordinateTypeCell); // Add new row to table tblCoordinates.Rows.Add(row); // Save table to session variable as an array saveTableToSession(tblCoordinates, coordinateTable); } } pnlCoordinates.Visible = true; }
/* * Pre: * Post: The audition ids are set for the current student's auditions for the year * @param districtAudition signifies whether the current coordinate is being created for * a district or state audition */ private void setAuditionIds(bool districtAudition) { if (districtAudition) { auditionIds = DbInterfaceStudentAudition.GetStudentDistrictAuditionIds(yearId); } else { auditionIds = DbInterfaceStudentAudition.GetStudentStateAuditionIds(yearId); } }
/* * Pre: The audition must have been previously added to the database * Post: The audition points are added to the database */ public bool submitPoints() { //enter points bool success = DbInterfaceStudentAudition.EnterStateAuditionPoints(this); //add partner points if audition is a duet if (auditionType.ToUpper().Equals("DUET")) { submitDuetPartnerPoints(); } return(success); }
/* * Pre: studentId must exist as a StudentId in the system * Post: The existing data for the student associated to the studentId * is loaded to the page. * @param studentId is the StudentId of the student being registered * @returns the student information */ private Student LoadStudentData(int studentId) { Student student = null; try { student = DbInterfaceStudent.LoadStudentData(studentId); //get general student information if (student != null) { lblStudentId.Text = studentId.ToString(); txtFirstName.Text = student.firstName; txtLastName.Text = student.lastName; lblName.Text = student.lastName + ", " + student.firstName + " " + student.middleInitial; // Get editable auditions DataTable table = DbInterfaceStudentAudition.GetDistrictAuditionsForDropdown(student, false); cboAudition.DataSource = null; cboAudition.Items.Clear(); cboAudition.DataSourceID = ""; if (table.Rows.Count > 0 && (student.grade.Equals("11") || student.grade.Equals("12"))) { cboAudition.DataSource = table; cboAudition.Items.Add(new ListItem("")); cboAudition.DataBind(); } else if (!(student.grade.Equals("11") || student.grade.Equals("12"))) { showWarningMessage("The selected student is not in 11/12th grade, the audition length cannot be adjusted."); } else { showWarningMessage("This student has no editable auditions. Add a new registration for this student with the 'Add Registration' option"); } } else { showErrorMessage("An error occurred loading the student data"); } } catch (Exception e) { showErrorMessage("An error occurred loading the student data"); Utility.LogError("Add Extra Audition Time", "LoadStudentData", "studentId: " + studentId, "Message: " + e.Message + " Stack Trace: " + e.StackTrace, -1); } return(student); }
/* * Pre: studentId must exist as a StudentId in the system * Post: The existing data for the student associated to the studentId * is loaded to the page. * @param studentId is the StudentId of the student being registered */ private Student loadStudentData(int studentId, bool initialLoad) { Student student = null; try { student = DbInterfaceStudent.LoadStudentData(studentId); //get eligible auditions if (student != null) { DataTable table = DbInterfaceStudentAudition.GetStateAuditionsForPointEntryDropdown(student, Convert.ToInt32(ddlYear.SelectedValue)); cboAudition.DataSource = null; cboAudition.Items.Clear(); cboAudition.DataSourceID = ""; //load student name txtFirstName.Text = student.firstName; txtLastName.Text = student.lastName; lblStudent.Text = student.firstName + " " + student.lastName; if (table.Rows.Count > 0) { cboAudition.DataSource = table; cboAudition.DataTextField = "DropDownInfo"; cboAudition.DataValueField = "AuditionId"; cboAudition.Items.Add(new ListItem("")); cboAudition.DataBind(); } else if (!initialLoad) { showWarningMessage("The student has no eligible auditions for the selected year."); } upStudentSearch.Visible = false; pnlInfo.Visible = true; } else { showErrorMessage("Error: An error occurred while loading the student data."); } } catch (Exception e) { showErrorMessage("Error: An error occurred while loading the student data."); Utility.LogError("Badger Point Entry", "loadStudentData", "studentId: " + studentId, "Message: " + e.Message + " Stack Trace: " + e.StackTrace, -1); } return(student); }
/* * 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; } }
/* * Pre: The audition must have been previously added to the database * Post: The audition points for the duet partner associated with the current audition are updated */ private bool submitDuetPartnerPoints() { //get partner id int duetPartnerId = DbInterfaceStudentAudition.GetAuditionDuetPartnerAuditionId(auditionId); int temp; //switch audition id to duet partner's id for point entry temp = auditionId; auditionId = duetPartnerId; //enter points bool success = DbInterfaceStudentAudition.EnterStateAuditionPoints(this); //change back to original id auditionId = temp; return(success); }
/* * Pre: The compositions must have previously existed in the database * Post: The composition and theory points are updated in the database */ public bool submitPoints() { bool success = true; foreach (AuditionCompositions audComp in compositions) { success = success && DbInterfaceStudentAudition.UpdateAuditionCompositionPoints(this, audComp, "District"); } success = success && DbInterfaceStudentAudition.UpdateAuditionTheoryPoints(this, theoryPoints); //add partner points if audition is a duet if (auditionType.ToUpper().Equals("DUET")) { submitDuetPartnerPoints(); } return(success); }
/* * Pre: * Post: Adds the new audtion to the database and updates all * coordinate information for the student */ public bool addToDatabase() { bool success = DbInterfaceStudentAudition.CreateStudentDistrictAudition(this); if (success) { //create coordinates if (coordinates.Count > 0) { success = success && createCoordinateRides(); } //update coordinate rides that already exist for the student List <int> existingAuditionIds = DbInterfaceStudentAudition.GetStudentDistrictAuditionIds(yearId); success = success && DbInterfaceStudentAudition.UpdateExistingCoordinates(existingAuditionIds); } return(success); }
/* * Pre: * Post: Loads the information of the selected audition and saves it to a session variable */ private void resetAuditionVar() { try { int auditionId = Convert.ToInt32(cboAudition.SelectedValue); int studentId = Convert.ToInt32(Convert.ToInt32(txtStudentId.Text)); Student student = DbInterfaceStudent.LoadStudentData(studentId); //get all audition info associated with audition id and save as session variable if (student != null) { audition = DbInterfaceStudentAudition.GetStudentDistrictAudition(auditionId, student); if (audition != null) { Session[auditionVar] = audition; //if the audition was a duet, show label to inform user that the points for the //partner will also be updated if (audition.auditionType.ToUpper().Equals("DUET")) { lblDuetPartnerInfo.Visible = true; } else { lblDuetPartnerInfo.Visible = false; } loadCompositions(); txtTheoryPoints.Text = audition.theoryPoints.ToString(); calculatePointTotal(); } } } catch (Exception e) { lblErrorMsg.Text = "An error occurred"; lblErrorMsg.Visible = true; Utility.LogError("District Point Entry", "resetAuditionVar", "", "Message: " + e.Message + " Stack Trace: " + e.StackTrace, -1); } }
protected void btnSubmit_Click(object sender, EventArgs e) { if (rblLength.SelectedIndex >= 0 && cboAudition.SelectedIndex > 0) { int auditionId = Convert.ToInt32(cboAudition.SelectedValue); if (DbInterfaceStudentAudition.UpdateAuditionLength(auditionId, Convert.ToInt32(rblLength.SelectedValue))) { ClearPage(); showSuccessMessage("The audition length was successfully updated."); } else { showErrorMessage("The audition length could not be updated."); } } else { showInfoMessage("No changes were made to the audition length."); } }
/* * Pre: studentId must exist as a StudentId in the system * Post: The existing data for the student associated to the studentId * is loaded to the page. * @param studentId is the StudentId of the student being registered */ private Student loadStudentData(int studentId, bool initialLoad) { Student student = DbInterfaceStudent.LoadStudentData(studentId); //get eligible auditions if (student != null) { DataTable table = DbInterfaceStudentAudition.GetDistrictAuditionsForPointEntryDropdown(student, Convert.ToInt32(ddlYear.SelectedValue)); cboAudition.DataSource = null; cboAudition.Items.Clear(); cboAudition.DataSourceID = ""; //load student name txtFirstName.Text = student.firstName; txtLastName.Text = student.lastName; lblStudent.Text = student.firstName + " " + student.lastName; if (table.Rows.Count > 0) { cboAudition.DataSource = table; cboAudition.DataTextField = "DropDownInfo"; cboAudition.DataValueField = "AuditionId"; cboAudition.Items.Add(new ListItem("")); cboAudition.DataBind(); } else if (!initialLoad) { showWarningMessage("This student has no district auditions to award points to for the selected year."); } pnlInfo.Visible = true; upStudentSearch.Visible = false; } else { showErrorMessage("An error occurred while loading the student's audition data."); } return(student); }
/* * Pre: The audition must have been previously added to the database * Post: The audition points for the duet partner associated with the current audition are updated */ private bool submitDuetPartnerPoints() { //get partner id int duetPartnerId = DbInterfaceStudentAudition.GetAuditionDuetPartnerAuditionId(auditionId); int temp; bool success = true; //switch audition id to duet partner's id for point entry temp = auditionId; auditionId = duetPartnerId; //enter points foreach (AuditionCompositions audComp in compositions) { success = success && DbInterfaceStudentAudition.UpdateAuditionCompositionPoints(this, audComp, "District"); } //change back to original id auditionId = temp; return(success); }
/* * Pre: studentId must exist as a StudentId in the system * Post: The existing data for the student associated to the studentId * is loaded to the page. * @param studentId is the StudentId of the student being registered */ private Student loadStudentData(int studentId) { Student student = DbInterfaceStudent.LoadStudentData(studentId); //get eligible auditions if (student != null) { DataTable table = DbInterfaceStudentAudition.GetDistrictAuditionsForDropdownByYear(student, Convert.ToInt32(ddlYear.SelectedValue)); cboAudition.DataSource = null; cboAudition.Items.Clear(); cboAudition.DataSourceID = ""; //load student name txtFirstName.Text = student.firstName; txtLastName.Text = student.lastName; lblStudent.Text = student.firstName + " " + student.lastName; if (table.Rows.Count > 0) { cboAudition.DataSource = table; cboAudition.DataTextField = "DropDownInfo"; cboAudition.DataValueField = "AuditionId"; cboAudition.Items.Add(new ListItem("")); cboAudition.DataBind(); } else { lblAuditionError.InnerText = "This student has no district auditions to award points to for the selected year"; lblAuditionError.Visible = true; } } else { lblErrorMsg.Text = "An error occurred while loading the student's audition data"; lblErrorMsg.Visible = true; } return(student); }
/* * Pre: The audition must already exist in the database * Post: The audition is updated with the current information */ public bool updateInDatabase() { return(DbInterfaceStudentAudition.UpdateStudentHsOrCompositionAudition(this)); }
/* * Pre: * Post: The audition information is deleted from the database * @returns true if the audition is successfully deleted and false otherwise */ public bool deleteFromDatabase() { return(DbInterfaceStudentAudition.DeleteStudentDistrictAudition(auditionId)); }
/* * Pre: * Post: Adds the new audition to the database and sets the audition's id */ public bool addToDatabase() { return(DbInterfaceStudentAudition.CreateStudentHsOrCompositionAudition(this)); }
/* * Pre: The current audition must already exist in the system * Post: The audition points are loaded if there are any */ private void getAuditionPoints() { points = DbInterfaceStudentAudition.GetStateAuditionPoints(auditionId); }
/* * Pre: * Post: The requirements for the audition track and grade are * retrieved from the database */ private void getRequirements() { DbInterfaceStudentAudition.GetAuditionTrackRequirements(this); }