/// <summary> /// Inserts the Run details and stores transaction id and cost into the session for paypal to use. /// </summary> /// Created by: Andrew Heim 11-29-12 private void insertRunRegistrantDetails() { BusinessTier bt = new BusinessTier(); List<Dictionary<string,string>> runRegInfo = (List<Dictionary<string, string>>)Session["regInfo"]; DataSet ds = bt.registerRunGroup(runRegInfo); Session["transactionID"] = ds.Tables[1].Rows[0][0]; double cost = 0; foreach(Dictionary<string,string> row in runRegInfo) { cost += double.Parse(row["cost"]); } Session["cost"] = cost; }
/// <summary> /// Button event for "Proceed to checkout" button /// Adds the current runner to the list of runners in the session, then registers them /// If all goes well, redirects to checkout. Otherwise, informs the user /// </summary> /// <param name="sender"></param> /// <param name="e"></param> /// Jason Vance - 11/23/2012 protected void btnProceedToCheckout_Click(object sender, EventArgs e) { Dictionary<String, String> runnerInfo; List<Dictionary<String, String>> runners; BusinessTier bt = new BusinessTier(); DataSet result; try { // Get the runners on the session runners = (List<Dictionary<String, String>>)Session["runners"]; // If there were no runners on the session, assign a new List to the variable if (runners == null) { runners = new List<Dictionary<String, String>>(); } // Get the runner info from the form runnerInfo = extractRunnerInfo(); Session["eventID"] = hdnEventId.Value; // Validate the entered information DataSet ds = bt.validateRunReg(runnerInfo); // If there were problems let the user know if (ds.Tables[0].Rows.Count > 0) { showErrorMessages(ds); PresentationHelpers.FocusControlOnPageLoad(lblError.ClientID, this.Page); return; // Get out so the user can fix what's wrong } else { lblError.Text = ""; } // If we're editing an existing runner if (hdnEditingRunner.Value == "yes") { if (!runnerIsDuplicate(runnerInfo)) { // Replace the old runner with the new runner int index = Convert.ToInt32(hdnNameId.Value); runners[index] = runnerInfo; // reset the hidden fields hdnNameId.Value = "-1"; hdnEditingRunner.Value = "no"; // Tell the user that editing worked lblFormSuccess.Text = txtFirstName.Text + " was edited"; } else { lblError.Text = "This runner is already registered"; PresentationHelpers.FocusControlOnPageLoad(lblError.ClientID, this.Page); return; } } else { if (!runnerIsDuplicate(runnerInfo)) { // Add the runner to the list of runners runners.Add(runnerInfo); // Tell the user that adding worked lblFormSuccess.Text = txtFirstName.Text + " was added"; } else { lblError.Text = "This runner is already registered"; PresentationHelpers.FocusControlOnPageLoad(lblError.ClientID, this.Page); return; } } // Register the runners result = bt.registerRunGroup(runners); // If there were problems let the user know if (result.Tables[0].Rows.Count > 0) { showErrorMessages(result); // Empty out all fields to avoid registering a runner twice emptyFormFields(); // Let the user know that the runner was added to the list populateRunnersSoFar(); } else { lblError.Text = ""; // There weren't any problems registering, so send the user to checkout Session.Add("regInfo", runners); Response.Redirect("Checkout.aspx",false); } } catch (Exception ex) { ErrorLog.logError(ex); Response.Redirect("Oops.aspx"); } }