//Method to count the chosen module units: protected void chosencount_DataBinding(object sender, System.EventArgs e) { //Counts the units of chosen modules, stores them in quantity, then displays them in the literal value Literal lt = (Literal)(sender); int quantity2 = Convert.ToInt32((Eval("units"))); chosenTotal += quantity2; lt.Text = quantity2.ToString(); //Saves compulsory value in string chosenT.Text = chosenTotal.ToString(); //Updates and stores compulsory modules value compT.DataBind(); compTotal = Convert.ToInt32(compT.Text); //Calculates final total by adding compulsory units to chosen units finalTotal = compTotal + chosenTotal; TotalValue2.Text = finalTotal.ToString(); TotalValue2.DataBind(); //Shows newly calculated compulsory + chosen units value, hides old value (just compulsory) TotalValue2.Visible = true; TotalValue.Visible = false; //If 120 units accumulated, remove option to add more modules (prevents over 120 units occuring) if (finalTotal == 120) { Selection.Visible = false; NoSelect.Visible = true; } }
protected void unitscount2_DataBinding(object sender, System.EventArgs e) { //Finding unit values, adding each to quantity's total, then updating literal text with calculated total Literal lt = (Literal)(sender); int quantity2 = Convert.ToInt32((Eval("units"))); unitsTotal2 += quantity2; lt.Text = quantity2.ToString(); //Optional units total stored opttotal.Text = unitsTotal2.ToString(); //Total units updated + displayed comptotal.DataBind(); unitsTotal = Convert.ToInt32(comptotal.Text); //Re-Calculating final total (compulsory units + added optional units) finalTotal = unitsTotal2 + unitsTotal; TotalValue2.Text = finalTotal.ToString(); TotalValue2.DataBind(); //Display re-calculated total, hide old total TotalValue2.Visible = true; TotalValue.Visible = false; //Storing unit total to string to carry in URL (for checking at confirmation) int linktotal = finalTotal; int userID = Convert.ToInt32(Request.QueryString["userID"]); int studentID = Convert.ToInt32(Request.QueryString["studentID"]); int Level = Convert.ToInt32(Request.QueryString["Level"]); Modules.DataBind(); CompMods = Modules.Text; //Adding unit total for carrying to modules area (so optional units can be added to total) ModLink.NavigateUrl = "RegWizardModules.aspx?UserID=" + userID + "&Level=" + Level + "&studentID=" + studentID; ModLink.DataBind(); //Adding unit total for carrying to confirmation (for 120 units required check) ConfirmLink.NavigateUrl = "RegWizardCompMod.aspx?UserID=" + userID + "&Level=" + Level + "&studentID=" + studentID + "&units=" + finalTotal + "&Events=" + CompMods; ConfirmLink.DataBind(); //If 120 units are acquired, disable the optional module link so students can't go over units if (finalTotal == 120) { ModLink.Visible = false; } }
//Method runs when user clicks confirm, checks for correct amount of units & confirms or rejects protected void ConfirmBtn_Click(object sender, EventArgs e) { TotalValue.DataBind(); TotalValue2.DataBind(); int units1 = Convert.ToInt32(TotalValue.Text); int units2 = Convert.ToInt32(TotalValue2.Text); string uID = Request.QueryString["userID"]; string sID = Request.QueryString["studentID"]; string level = Request.QueryString["level"]; //If either unit count is fulfilled, redirect back to main wizard if (units1 == 120 || units2 == 120) { //Redirect to add compulsory modules: Response.Redirect("RegWizardCompMod.aspx?UserID=" + uID + "&studentID=" + sID + "&level=" + level); } else { //Alert user they have insufficient units Response.Write("<script>alert('Please ensure you have selected 120 units.');</script>"); } }