/// <summary> /// Confirms the transaction in the database and displays the transaction info /// </summary> /// Creator: Olivia Johnson 11-28-12 private void runConfirmation() { BusinessTier bt = new BusinessTier(); DataSet ds = new DataSet(); Decimal totalCost = 0; int numOfRunners = 0; Decimal childCost = 0; Decimal adultCost = 0; int numOfAdults = 0; int numOfChildren = 0; string childPrice = bt.getRunDetails(Session["eventID"].ToString()).Tables[1].Rows[0][12].ToString(); try { ds = bt.confirmRunPayment(customerInfo); foreach (DataRow dr in ds.Tables[1].Rows) { totalCost += Convert.ToDecimal(dr[12].ToString()); numOfRunners++; if (dr["cost"] == childPrice) //if participant is older than 12, count them as an adult. numOfChildren++; else numOfAdults++; //If participant is younger than 12, count them as a child if (dr[7].ToString() != "") //if there is a confirm email sendConfirmationEmail("5k Run Event", dr[1].ToString(), dr[7].ToString()); } lblticketType1.Text = "5k Child Ticket x" + numOfChildren; lblprice1.Text = (childCost * numOfChildren).ToString("C"); lblticketType2.Text = "5k Adult Ticket x" + numOfAdults; lblprice2.Text = (adultCost * numOfAdults).ToString("C"); lbltotalCost.Text = totalCost.ToString("C"); foreach (DataRow dr in ds.Tables[1].Rows) { if (dr[7].ToString() != "") //if there is a confirm email sendConfirmationEmail("5k Run Event", dr[1].ToString(), dr[7].ToString()); } } catch (Exception ex) { ErrorLog.logError(ex); Response.Redirect("Oops.aspx"); } }
/// <summary> /// Traverses the List of regInfo Dictionary objects and counts the number of adults and children. Then DisplayRunOrDinner is called to /// fill in the dinner checkout table /// </summary> /// Created by: Olivia Johnson 11-18-12 private void displayRunRegistrantDetails() { try { BusinessTier bt = new BusinessTier(); List<Dictionary<String, String>> regInfoList = (List<Dictionary<String, String>>)Session["regInfo"]; int numOfChildren = 0, numOfAdults = 0; string childPrice = bt.getRunDetails(Session["eventID"].ToString()).Tables[1].Rows[0][12].ToString(); foreach (Dictionary<String, String> registeredRunner in regInfoList) { if (registeredRunner["cost"] == childPrice) //if participant is older than 12, count them as an adult. numOfChildren++; else numOfAdults++; //If participant is younger than 12, count them as a child } displayRunOrDinner(numOfChildren, numOfAdults); } catch (Exception ex) { ErrorLog.logError(ex); Response.Redirect("Oops.aspx"); } }
/// <summary> /// Retrieves the ticket price for each ticket type from the database based on the eventID /// </summary> /// <param name="type">String storing the type of ticket - adult or child</param> /// <returns>String storing the price for either an adult ticket or child ticket</returns> /// Created by: Olivia Johnson 11-18-12 private String getTicketPrice(String type) { BusinessTier bt = new BusinessTier(); if (eventType == "Dinner") { if (type == "child") return bt.getDinnerDetails(Session["eventID"].ToString()).Tables[1].Rows[0][12].ToString(); else return bt.getDinnerDetails(Session["eventID"].ToString()).Tables[1].Rows[0][13].ToString(); } else { if (type == "child") return bt.getRunDetails(Session["eventID"].ToString()).Tables[1].Rows[0][12].ToString(); else return bt.getRunDetails(Session["eventID"].ToString()).Tables[1].Rows[0][13].ToString(); } }
/// <summary> /// Populates the run page details if a valid eventID is part of the query string /// </summary> /// <param name="sender"></param> /// <param name="e"></param> /// Jason Vance - 11/19/2012 protected void Page_Load(object sender, EventArgs e) { try { // Clear out the result labels if they need to be lblError.Text = ""; lblFormSuccess.Text = ""; // Get the event id String eventId = Request.QueryString["eventID"]; BusinessTier bt = new BusinessTier(); DataSet ds = null; // If the event id is good, then fill in the page information if (eventId != null) { ds = bt.getRunDetails(eventId); populateRunDetails(ds); ds = bt.getRunParticipants(eventId); populatePartcipantsBox(ds); // Populate our on-going list of runners populateRunnersSoFar(); } else { Response.Redirect("Oops.aspx"); } // Keep the postbask url of the add runner button consistent, needed because buttons to edit runners change the url btnAddAnotherRunner.PostBackUrl = "RunRegistration.aspx?eventID=" + Request.QueryString["eventID"]; } catch (Exception ex) { ErrorLog.logError(ex); Response.Redirect("Oops.aspx"); } }