protected void rptr_ItemCommand(object source, RepeaterCommandEventArgs e) { Session["SA"] = "0"; if (e.CommandName == "pwd") { Session["SA"] = e.CommandArgument.ToString(); Response.Redirect("~/Account/ChangeFamMemberPwd.aspx"); } if (e.CommandName == "log") { Session["SA"] = e.CommandArgument.ToString(); Response.Redirect("~/Account/EnterFamMemberLog.aspx"); } if (e.CommandName == "login") { var newPID = int.Parse(e.CommandArgument.ToString()); if ((int)Session["MasterAcctPID"] != newPID && !Patron.CanManageSubAccount((int)Session["MasterAcctPID"], newPID)) { // kick them out Response.Redirect("~"); } var newPatron = Patron.FetchObject(newPID); new SessionTools(Session).EstablishPatron(newPatron); var pgm = DAL.Programs.FetchObject(newPatron.ProgID); /* recalulate goal cache to accomdate changes in program length and point multipliers */ ProgramGamePointConversion pgc = null; foreach (ActivityType activityTypeValue in Enum.GetValues(typeof(ActivityType))) { int activityTypeId = (int)activityTypeValue; var temp = ProgramGamePointConversion.FetchObjectByActivityId(pgm.PID, +activityTypeId); if (temp != null && temp.PointCount > 0) { pgc = temp; } } if (pgc != null) { newPatron.RecalculateGoalCache(pgm, pgc); newPatron.Update(); } TestingBL.CheckPatronNeedsPreTest(); TestingBL.CheckPatronNeedsPreTest(); Response.Redirect("~"); } }
protected void rptr_ItemCommand(object source, RepeaterCommandEventArgs e) { Session["SA"] = "0"; if (e.CommandName == "pwd") { Session["SA"] = e.CommandArgument.ToString(); Response.Redirect("~/Account/ChangeFamMemberPwd.aspx"); } if (e.CommandName == "log") { Session["SA"] = e.CommandArgument.ToString(); Response.Redirect("~/Account/EnterFamMemberLog.aspx"); } if (e.CommandName == "login") { var newPID = int.Parse(e.CommandArgument.ToString()); if ((int)Session["MasterAcctPID"] != newPID && !Patron.CanManageSubAccount((int)Session["MasterAcctPID"], newPID)) { // kick them out Response.Redirect("~"); } var newPatron = Patron.FetchObject(newPID); new SessionTools(Session).EstablishPatron(newPatron); //Session["Patron"] = bp; //Session["ProgramID"] = bp.ProgID; //Session["TenantID"] = bp.TenID; TestingBL.CheckPatronNeedsPreTest(); TestingBL.CheckPatronNeedsPreTest(); Response.Redirect("~"); } }
public void DoBusinessRulesNext(int curStep) { // code needs to have the steps in order for the ifs to flow properly on panels with now fields showing if (curStep == 1) { //get Age var sDOB = ((TextBox)rptr.Items[0].FindControl("DOB")).Text; var sAge = ((TextBox)rptr.Items[0].FindControl("Age")).Text; var sGrade = ((TextBox)rptr.Items[0].FindControl("SchoolGrade")).Text; var age = -1; if (!string.IsNullOrEmpty(sDOB)) { var DOB = DateTime.Parse(sDOB); age = DateTime.Now.Year - DOB.Year; } else { int.TryParse(sAge, out age); } RegistrationAge.Text = age.ToString(); // Get Default Program for the Age // Set Program to that var grade = -1; if (sGrade.Length > 0) { int.TryParse(sGrade, out grade); } var pgmDD = (DropDownList)rptr.Items[0].FindControl("ProgID"); if (pgmDD.Items.Count == 2) { // single program - just select the program pgmDD.SelectedIndex = 1; } else if (pgmDD.SelectedValue == "0" || string.IsNullOrEmpty(pgmDD.SelectedValue)) { var defaultProgram = Programs.GetDefaultProgramForAgeAndGrade(age, grade).ToString(); if (pgmDD.Items.FindByValue(defaultProgram) != null) { pgmDD.SelectedValue = defaultProgram; } } if (MasterPID.Text.Length > 0) // Already registered the master account and now looping for family accounts { var curPanel = rptr.Items[0].FindControl("Panel" + curStep.ToString()); var newPanel = rptr.Items[0].FindControl("Panel" + (curStep + 2).ToString()); curPanel.Visible = false; newPanel.Visible = true; Step.Text = (curStep + 2).ToString(); } else { if (age > 17 && SRPSettings.GetSettingValue("AllowFamilyAccounts").SafeToBoolYes()) { // Ask about adult var curPanel = rptr.Items[0].FindControl("Panel" + curStep.ToString()); var newPanel = rptr.Items[0].FindControl("Panel" + (curStep + 1).ToString()); curPanel.Visible = false; newPanel.Visible = true; Step.Text = (curStep + 1).ToString(); } else { var curPanel = rptr.Items[0].FindControl("Panel" + curStep.ToString()); var newPanel = rptr.Items[0].FindControl("Panel" + (curStep + 2).ToString()); curPanel.Visible = false; newPanel.Visible = true; Step.Text = (curStep + 2).ToString(); } } } // Finished Current Step = 1 if (curStep == 2) { var curPanel = rptr.Items[0].FindControl("Panel" + curStep.ToString()); var newPanel = rptr.Items[0].FindControl("Panel" + (curStep + 1).ToString()); curPanel.Visible = false; newPanel.Visible = true; Step.Text = (curStep + 1).ToString(); } // Finished Current Step = 2 if (curStep == 3) { var curPanel = rptr.Items[0].FindControl("Panel" + curStep.ToString()); var newPanel = rptr.Items[0].FindControl("Panel" + (curStep + 1).ToString()); curPanel.Visible = false; newPanel.Visible = true; Step.Text = (curStep + 1).ToString(); // do we show this next panel? var newPanelVisibility = ((TextBox)rptr.Items[0].FindControl("Panel" + (curStep + 1).ToString() + "Visibility")).Text; if (newPanelVisibility == "0") { curStep = curStep + 1; // If not, move to the next panel } } // Finished Current Step = 3 if (curStep == 4) { var curPanel = rptr.Items[0].FindControl("Panel" + curStep.ToString()); var newPanel = rptr.Items[0].FindControl("Panel" + (curStep + 1).ToString()); curPanel.Visible = false; newPanel.Visible = true; Step.Text = (curStep + 1).ToString(); // do we show this next panel? var newPanelVisibility = ((TextBox)rptr.Items[0].FindControl("Panel" + (curStep + 1).ToString() + "Visibility")).Text; if (newPanelVisibility == "0") { curStep = curStep + 1; // If not, move to the next panel } } // Finished Current Step = 4 if (curStep == 5) { var curPanel = rptr.Items[0].FindControl("Panel" + curStep.ToString()); var newPanel = rptr.Items[0].FindControl("Panel" + (curStep + 1).ToString()); curPanel.Visible = false; newPanel.Visible = true; Step.Text = (curStep + 1).ToString(); // deal with parental consent, by program var PID = int.Parse(((DropDownList)rptr.Items[0].FindControl("ProgID")).SelectedValue); var prog = new Programs(); prog.Fetch(PID); ((Label)rptr.Items[0].FindControl("lblConsent")).Text = prog.ParentalConsentText; ((Panel)rptr.Items[0].FindControl("pnlConsent")).Visible = prog.ParentalConsentFlag; // // do we show this next panel? var newPanelVisibility = ((TextBox)rptr.Items[0].FindControl("Panel" + (curStep + 1).ToString() + "Visibility")).Text; if (newPanelVisibility == "0" && !prog.ParentalConsentFlag) { curStep = curStep + 1; // If not, move to the next panel } } // Finished Current Step = 5 if (curStep == 6) { var curPanel = rptr.Items[0].FindControl("Panel" + curStep.ToString()); var newPanel = rptr.Items[0].FindControl("Panel" + (curStep + 1).ToString()); curPanel.Visible = false; newPanel.Visible = true; Step.Text = (curStep + 1).ToString(); } // Finished Current Step = 6 if (curStep == 7) { if (!SaveAccount()) { return; } var curPanel = rptr.Items[0].FindControl("Panel" + curStep.ToString()); var newPanel = FindControl("Panel" + (curStep + 1).ToString()); curPanel.Visible = false; //newPanel.Visible = true; Step.Text = (curStep + 1).ToString(); var famAcct = (DropDownList)rptr.Items[0].FindControl("FamilyAccount"); if (famAcct.SelectedValue == "Yes") { curStep = 9; // Move to the next panel Step.Text = "9"; curPanel = FindControl("Panel" + curStep.ToString()); curPanel.Visible = true; btnPrev.Enabled = false; btnDone.Visible = true; return; } else { // we're done with registration, we can just jump right in TestingBL.CheckPatronNeedsPreTest(); TestingBL.CheckPatronNeedsPostTest(); Session[SessionKey.PatronMessage] = ((BaseSRPPage)Page).GetResourceString("registration-success"); Session[SessionKey.PatronMessageGlyphicon] = "thumbs-up"; Response.Redirect("~"); } newPanel.Visible = true; btnPrev.Enabled = false; } // Finished Current Step = 7 if (curStep == 8) { var curPanel = FindControl("Panel" + curStep.ToString()); var newPanel = FindControl("Panel" + (curStep + 1).ToString()); curPanel.Visible = false; newPanel.Visible = true; Step.Text = (curStep + 1).ToString(); btnPrev.Enabled = false; // log them in and take them home Response.Redirect(GoToUrl); } // Finished Current Step = 8 if (curStep == 9) { // Reset Steps, flag as family members, restart the wizard var curPanel = FindControl("Panel" + curStep.ToString()); var newPanel = rptr.Items[0].FindControl("Panel1"); curPanel.Visible = false; newPanel.Visible = true; btnPrev.Enabled = false; btnDone.Visible = false; Step.Text = "1"; Panel0.Visible = true; RegisteringFamily.Text = "1"; RegistrationAge.Text = "0"; ((TextBox)rptr.Items[0].FindControl("ParentGuardianFirstName")).Text = parentGuardianFirst.Text; ((TextBox)rptr.Items[0].FindControl("ParentGuardianMiddleName")).Text = parentGuardianMiddle.Text; ((TextBox)rptr.Items[0].FindControl("ParentGuardianLastName")).Text = parentGuardianLast.Text; ((TextBox)rptr.Items[0].FindControl("Username")).Text = string.Empty; ((TextBox)rptr.Items[0].FindControl("Password")).Text = string.Empty; ((TextBox)rptr.Items[0].FindControl("Password")).Attributes.Add("Value", string.Empty); ((TextBox)rptr.Items[0].FindControl("Password2")).Text = string.Empty; ((TextBox)rptr.Items[0].FindControl("Password2")).Attributes.Add("Value", string.Empty); ((TextBox)rptr.Items[0].FindControl("Age")).Text = string.Empty; ((TextBox)rptr.Items[0].FindControl("DOB")).Text = string.Empty; ((TextBox)rptr.Items[0].FindControl("SchoolGrade")).Text = string.Empty; ((DropDownList)rptr.Items[0].FindControl("ProgID")).SelectedValue = string.Empty; ((TextBox)rptr.Items[0].FindControl("FirstName")).Text = string.Empty; ((TextBox)rptr.Items[0].FindControl("MiddleName")).Text = string.Empty; ((DropDownList)rptr.Items[0].FindControl("Gender")).SelectedValue = string.Empty; ((TextBox)rptr.Items[0].FindControl("LiteracyLevel1")).Text = string.Empty; ((TextBox)rptr.Items[0].FindControl("LiteracyLevel2")).Text = string.Empty; } // Finished Current Step = 9 }
public void DoBusinessRulesNext(int curStep) { // code needs to have the steps in order for the ifs to flow properly on panels with now fields showing if (curStep == 1) { //get Age var sDOB = ((TextBox)rptr.Items[0].FindControl("DOB")).Text; var sAge = ((TextBox)rptr.Items[0].FindControl("Age")).Text; var sGrade = ((TextBox)rptr.Items[0].FindControl("SchoolGrade")).Text; var age = -1; if (!string.IsNullOrEmpty(sDOB)) { var DOB = DateTime.Parse(sDOB); age = DateTime.Now.Year - DOB.Year; } else { int.TryParse(sAge, out age); } RegistrationAge.Text = age.ToString(); // Get Default Program for the Age // Set Program to that var grade = -1; if (sGrade.Length > 0) { int.TryParse(sGrade, out grade); } var pgmDD = (DropDownList)rptr.Items[0].FindControl("ProgID"); if (pgmDD.Items.Count == 2) { // single program - just select the program pgmDD.SelectedIndex = 1; } else if (pgmDD.SelectedValue == "0" || string.IsNullOrEmpty(pgmDD.SelectedValue)) { var defaultProgram = Programs.GetDefaultProgramForAgeAndGrade(age, grade).ToString(); if (pgmDD.Items.FindByValue(defaultProgram) != null) { pgmDD.SelectedValue = defaultProgram; } } if (MasterPID.Text.Length > 0) // Already registered the master account and now looping for family accounts { var curPanel = rptr.Items[0].FindControl("Panel" + curStep.ToString()); var newPanel = rptr.Items[0].FindControl("Panel" + (curStep + 2).ToString()); curPanel.Visible = false; newPanel.Visible = true; Step.Text = (curStep + 2).ToString(); } else { if (age > 17 && SRPSettings.GetSettingValue("AllowFamilyAccounts").SafeToBoolYes()) { // Ask about adult var curPanel = rptr.Items[0].FindControl("Panel" + curStep.ToString()); var newPanel = rptr.Items[0].FindControl("Panel" + (curStep + 1).ToString()); curPanel.Visible = false; newPanel.Visible = true; Step.Text = (curStep + 1).ToString(); } else { var curPanel = rptr.Items[0].FindControl("Panel" + curStep.ToString()); var newPanel = rptr.Items[0].FindControl("Panel" + (curStep + 2).ToString()); curPanel.Visible = false; newPanel.Visible = true; Step.Text = (curStep + 2).ToString(); } } } // Finished Current Step = 1 if (curStep == 2) { var curPanel = rptr.Items[0].FindControl("Panel" + curStep.ToString()); var newPanel = rptr.Items[0].FindControl("Panel" + (curStep + 1).ToString()); curPanel.Visible = false; newPanel.Visible = true; Step.Text = (curStep + 1).ToString(); } // Finished Current Step = 2 if (curStep == 3) { var pgmDD = (DropDownList)rptr.Items[0].FindControl("ProgID"); var selectedProgram = DAL.Programs.FetchObject(int.Parse(pgmDD.SelectedValue)); if (!selectedProgram.IsRegistrationOpen) { string programNotOpen; if (DateTime.Now < selectedProgram.StartDate) { programNotOpen = string.Format("This program opens for registration on {0}", selectedProgram.StartDate.ToLongDateString()); } else { programNotOpen = string.Format("Registration for this program ended on {0}", selectedProgram.EndDate.ToLongDateString()); } new SessionTools(Session).AlertPatron(programNotOpen, PatronMessageLevels.Danger, "exclamation-sign"); return; } var goal = rptr.Items[0].FindControl("Goal") as TextBox; if (goal != null && selectedProgram.GoalDefault > 0) { goal.Text = selectedProgram.GoalDefault.ToString(); } var sReqField = (HiddenField)rptr.Items[0].FindControl("ASchoolFieldIsRequired"); var aSchoolFieldIsRequired = bool.Parse(sReqField.Value) == true; if (selectedProgram.HideSchoolInRegistration == true && aSchoolFieldIsRequired == false) { ((Panel)rptr.Items[0].FindControl("SchoolArea")).Visible = false; } else { ((Panel)rptr.Items[0].FindControl("SchoolArea")).Visible = true; } var curPanel = rptr.Items[0].FindControl("Panel" + curStep.ToString()); var newPanel = rptr.Items[0].FindControl("Panel" + (curStep + 1).ToString()); curPanel.Visible = false; newPanel.Visible = true; Step.Text = (curStep + 1).ToString(); // do we show this next panel? var newPanelVisibility = ((TextBox)rptr.Items[0].FindControl("Panel" + (curStep + 1).ToString() + "Visibility")).Text; if (newPanelVisibility == "0") { curStep = curStep + 1; // If not, move to the next panel } } // Finished Current Step = 3 if (curStep == 4) { var curPanel = rptr.Items[0].FindControl("Panel" + curStep.ToString()); var newPanel = rptr.Items[0].FindControl("Panel" + (curStep + 1).ToString()); curPanel.Visible = false; newPanel.Visible = true; Step.Text = (curStep + 1).ToString(); var PID = int.Parse(((DropDownList)rptr.Items[0].FindControl("ProgID")).SelectedValue); var selectedProgram = DAL.Programs.FetchObject(PID); // disable goal field when the user has a set goal ((TextBox)rptr.Items[0].FindControl("Goal")).Enabled = (selectedProgram.GoalMin != selectedProgram.GoalMax); // Goal needs to be modified by ProgramGamePointConversion /* If daily goal is enabled we need to find what method point system uses. Just select the first item that is relevant.. */ foreach (ActivityType activityTypeValue in Enum.GetValues(typeof(ActivityType))) { int activityTypeId = (int)activityTypeValue; var pgc = ProgramGamePointConversion.FetchObjectByActivityId(PID, activityTypeId); if (pgc != null && pgc.PointCount > 0) { var range = (RangeValidator)rptr.Items[0].FindControl("GoalRangeValidator"); range.MinimumValue = selectedProgram.GoalMin.ToString(); range.MaximumValue = selectedProgram.GoalMax.ToString(); range.Text = $"{range.MinimumValue}-{range.MaximumValue}"; var limitsInfoText = StringResources.getString("registration-goal-limits-note"); ((Label)rptr.Items[0].FindControl("RegistrationGoalInfoNoteLabel")).Text = String.Format(limitsInfoText, range.MinimumValue, range.MaximumValue); /* save the activity type id */ ViewState["ActivityTypeId"] = activityTypeId.ToString(); var intervalString = selectedProgram.GetGoalInterval.ToString(); ((Literal)rptr.Items[0].FindControl("GoalLabel")).Text = $"{intervalString} Goal ({activityTypeValue.ToString()}):"; // found a valid point conversion for goal so break break; } } // do we show this next panel? var newPanelVisibility = ((TextBox)rptr.Items[0].FindControl("Panel" + (curStep + 1).ToString() + "Visibility")).Text; if (newPanelVisibility == "0") { curStep = curStep + 1; // If not, move to the next panel } } // Finished Current Step = 4 if (curStep == 5) { var curPanel = rptr.Items[0].FindControl("Panel" + curStep.ToString()); var newPanel = rptr.Items[0].FindControl("Panel" + (curStep + 1).ToString()); curPanel.Visible = false; newPanel.Visible = true; Step.Text = (curStep + 1).ToString(); // deal with parental consent, by program var PID = int.Parse(((DropDownList)rptr.Items[0].FindControl("ProgID")).SelectedValue); var prog = new Programs(); prog.Fetch(PID); ((Literal)rptr.Items[0].FindControl("lblConsent")).Text = Server.HtmlDecode(prog.ParentalConsentText); ((Panel)rptr.Items[0].FindControl("pnlConsent")).Visible = prog.ParentalConsentFlag; // do we show this next panel? var newPanelVisibility = ((TextBox)rptr.Items[0].FindControl("Panel" + (curStep + 1).ToString() + "Visibility")).Text; if (newPanelVisibility == "0" && !prog.ParentalConsentFlag) { curStep = curStep + 1; // If not, move to the next panel } } // Finished Current Step = 5 if (curStep == 6) { var curPanel = rptr.Items[0].FindControl("Panel" + curStep.ToString()); var newPanel = rptr.Items[0].FindControl("Panel" + (curStep + 1).ToString()); curPanel.Visible = false; newPanel.Visible = true; Step.Text = (curStep + 1).ToString(); } // Finished Current Step = 6 if (curStep == 7) { if (!SaveAccount()) { return; } var curPanel = rptr.Items[0].FindControl("Panel" + curStep.ToString()); var newPanel = FindControl("Panel" + (curStep + 1).ToString()); curPanel.Visible = false; //newPanel.Visible = true; Step.Text = (curStep + 1).ToString(); var famAcct = (DropDownList)rptr.Items[0].FindControl("FamilyAccount"); if (famAcct.SelectedValue == "Yes") { curStep = 9; // Move to the next panel Step.Text = "9"; curPanel = FindControl("Panel" + curStep.ToString()); curPanel.Visible = true; btnPrev.Enabled = false; btnDone.Visible = true; return; } else { // we're done with registration, we can just jump right in TestingBL.CheckPatronNeedsPreTest(); TestingBL.CheckPatronNeedsPostTest(); Session[SessionKey.PatronMessage] = ((BaseSRPPage)Page).GetResourceString("registration-success"); Session[SessionKey.PatronMessageGlyphicon] = "thumbs-up"; Response.Redirect("~"); } newPanel.Visible = true; btnPrev.Enabled = false; } // Finished Current Step = 7 if (curStep == 8) { var curPanel = FindControl("Panel" + curStep.ToString()); var newPanel = FindControl("Panel" + (curStep + 1).ToString()); curPanel.Visible = false; newPanel.Visible = true; Step.Text = (curStep + 1).ToString(); btnPrev.Enabled = false; // log them in and take them home Response.Redirect(GoToUrl); } // Finished Current Step = 8 if (curStep == 9) { // Reset Steps, flag as family members, restart the wizard var curPanel = FindControl("Panel" + curStep.ToString()); var newPanel = rptr.Items[0].FindControl("Panel1"); curPanel.Visible = false; newPanel.Visible = true; btnPrev.Enabled = false; btnDone.Visible = false; Step.Text = "1"; Panel0.Visible = true; RegisteringFamily.Text = "1"; RegistrationAge.Text = "0"; ((TextBox)rptr.Items[0].FindControl("ParentGuardianFirstName")).Text = parentGuardianFirst.Text; ((TextBox)rptr.Items[0].FindControl("ParentGuardianMiddleName")).Text = parentGuardianMiddle.Text; ((TextBox)rptr.Items[0].FindControl("ParentGuardianLastName")).Text = parentGuardianLast.Text; ((TextBox)rptr.Items[0].FindControl("Username")).Text = string.Empty; ((TextBox)rptr.Items[0].FindControl("Password")).Text = string.Empty; ((TextBox)rptr.Items[0].FindControl("Password")).Attributes.Add("Value", string.Empty); ((TextBox)rptr.Items[0].FindControl("Password2")).Text = string.Empty; ((TextBox)rptr.Items[0].FindControl("Password2")).Attributes.Add("Value", string.Empty); ((TextBox)rptr.Items[0].FindControl("Age")).Text = string.Empty; ((TextBox)rptr.Items[0].FindControl("DOB")).Text = string.Empty; ((TextBox)rptr.Items[0].FindControl("SchoolGrade")).Text = string.Empty; ((DropDownList)rptr.Items[0].FindControl("ProgID")).SelectedValue = string.Empty; ((TextBox)rptr.Items[0].FindControl("FirstName")).Text = string.Empty; ((TextBox)rptr.Items[0].FindControl("MiddleName")).Text = string.Empty; ((DropDownList)rptr.Items[0].FindControl("Gender")).SelectedValue = string.Empty; ((TextBox)rptr.Items[0].FindControl("LiteracyLevel1")).Text = string.Empty; ((TextBox)rptr.Items[0].FindControl("LiteracyLevel2")).Text = string.Empty; } // Finished Current Step = 9 }