protected void dv_DataBound(object sender, EventArgs e) { //if (dv.CurrentMode == DetailsViewMode.Edit) //{ // //var control = (STG.SRP.Classes.FileDownloadCtl)dv.FindControl("FileUploadCtl"); // //if (control!=null) control.ProcessRender(); //} var cr = CustomRegistrationFields.FetchObject(); }
protected void rptr_ItemCommand(object source, RepeaterCommandEventArgs e) { if (e.CommandName == "cancel") { Response.Redirect("~/FamilyAccountList.aspx"); } lblError.Text = string.Empty; if (Page.IsValid) { if (e.CommandName == "save") { var p = Patron.FetchObject(int.Parse(SA.Text)); DateTime _d; var DOB = e.Item.FindControl("DOB") as TextBox; if (DOB != null && DOB.Text != "") { if (DateTime.TryParse(DOB.Text, out _d)) { p.DOB = _d; } } p.Age = FormatHelper.SafeToInt(((TextBox)(e.Item).FindControl("Age")).Text); //p.Custom2 = (((TextBox)(e.Item).FindControl("Custom2")).Text); p.SchoolGrade = ((TextBox)(e.Item).FindControl("SchoolGrade")).Text; p.FirstName = ((TextBox)(e.Item).FindControl("FirstName")).Text; p.MiddleName = ((TextBox)(e.Item).FindControl("MiddleName")).Text; p.LastName = ((TextBox)(e.Item).FindControl("LastName")).Text; p.Gender = ((DropDownList)(e.Item).FindControl("Gender")).SelectedValue; p.EmailAddress = ((TextBox)(e.Item).FindControl("EmailAddress")).Text; p.PhoneNumber = ((TextBox)(e.Item).FindControl("PhoneNumber")).Text; p.PhoneNumber = FormatHelper.FormatPhoneNumber(p.PhoneNumber); p.StreetAddress1 = ((TextBox)(e.Item).FindControl("StreetAddress1")).Text; p.StreetAddress2 = ((TextBox)(e.Item).FindControl("StreetAddress2")).Text; p.City = ((TextBox)(e.Item).FindControl("City")).Text; p.State = ((TextBox)(e.Item).FindControl("State")).Text; p.ZipCode = ((TextBox)(e.Item).FindControl("ZipCode")).Text; p.ZipCode = FormatHelper.FormatZipCode(p.ZipCode); p.Country = ((TextBox)(e.Item).FindControl("Country")).Text; p.County = ((TextBox)(e.Item).FindControl("County")).Text; p.ParentGuardianFirstName = ((TextBox)(e.Item).FindControl("ParentGuardianFirstName")).Text; p.ParentGuardianLastName = ((TextBox)(e.Item).FindControl("ParentGuardianLastName")).Text; p.ParentGuardianMiddleName = ((TextBox)(e.Item).FindControl("ParentGuardianMiddleName")).Text; p.LibraryCard = ((TextBox)(e.Item).FindControl("LibraryCard")).Text; //p.PrimaryLibrary = FormatHelper.SafeToInt(((DropDownList)(e.Item).FindControl("PrimaryLibrary")).SelectedValue); //p.SchoolName = ((DropDownList)(e.Item).FindControl("SchoolName")).SelectedValue; //p.SchoolType = FormatHelper.SafeToInt(((DropDownList)(e.Item).FindControl("SchoolType")).SelectedValue); //p.District = ((DropDownList)(e.Item).FindControl("District")).SelectedValue; //p.SDistrict = ((DropDownList)(e.Item).FindControl("SDistrict")).SelectedValue.SafeToInt(); p.PrimaryLibrary = FormatHelper.SafeToInt(((DropDownList)(e.Item).FindControl("PrimaryLibrary")).SelectedValue); p.SchoolName = ((DropDownList)(e.Item).FindControl("SchoolName")).SelectedValue; p.SchoolType = FormatHelper.SafeToInt(((DropDownList)(e.Item).FindControl("SchoolType")).SelectedValue); var lc = LibraryCrosswalk.FetchObjectByLibraryID(p.PrimaryLibrary); if (lc != null) { p.District = lc.DistrictID == 0 ? ((DropDownList)(e.Item).FindControl("District")).SelectedValue : lc.DistrictID.ToString(); } else { p.District = ((DropDownList)(e.Item).FindControl("District")).SelectedValue; } var sc = SchoolCrosswalk.FetchObjectBySchoolID(p.SchoolName.SafeToInt()); if (sc != null) { p.SDistrict = sc.DistrictID == 0 ? ((DropDownList)(e.Item).FindControl("SDistrict")).SelectedValue.SafeToInt() : sc.DistrictID; p.SchoolType = sc.SchTypeID == 0 ? FormatHelper.SafeToInt(((DropDownList)(e.Item).FindControl("SchoolType")).SelectedValue) : sc.SchTypeID; } else { p.SDistrict = ((DropDownList)(e.Item).FindControl("SDistrict")).SelectedValue.SafeToInt(); } p.Teacher = ((TextBox)(e.Item).FindControl("Teacher")).Text; p.GroupTeamName = ((TextBox)(e.Item).FindControl("GroupTeamName")).Text; p.LiteracyLevel1 = FormatHelper.SafeToInt(((TextBox)(e.Item).FindControl("LiteracyLevel1")).Text); p.LiteracyLevel2 = FormatHelper.SafeToInt(((TextBox)(e.Item).FindControl("LiteracyLevel2")).Text); var cr = CustomRegistrationFields.FetchObject(); p.Custom1 = cr.DDValues1 == "" ? ((TextBox)(e.Item).FindControl("Custom1")).Text : ((DropDownList)(e.Item).FindControl("Custom1DD")).SelectedValue; p.Custom2 = cr.DDValues2 == "" ? ((TextBox)(e.Item).FindControl("Custom2")).Text : ((DropDownList)(e.Item).FindControl("Custom2DD")).SelectedValue; p.Custom3 = cr.DDValues3 == "" ? ((TextBox)(e.Item).FindControl("Custom3")).Text : ((DropDownList)(e.Item).FindControl("Custom3DD")).SelectedValue; p.Custom4 = cr.DDValues4 == "" ? ((TextBox)(e.Item).FindControl("Custom4")).Text : ((DropDownList)(e.Item).FindControl("Custom4DD")).SelectedValue; p.Custom5 = cr.DDValues5 == "" ? ((TextBox)(e.Item).FindControl("Custom5")).Text : ((DropDownList)(e.Item).FindControl("Custom5DD")).SelectedValue; p.AvatarID = FormatHelper.SafeToInt(((System.Web.UI.HtmlControls.HtmlInputText)e.Item.FindControl("AvatarID")).Value); // do the save p.Update(); rptr.DataSource = Patron.GetPatronForEdit(p.PID); rptr.DataBind(); ((BaseSRPPage)Page).TranslateStrings(rptr); lblError.Text = "Family account information has been saved.<br><br>"; } } }
protected void rptr_ItemDataBound(object sender, RepeaterItemEventArgs e) { var ctl = (DropDownList)e.Item.FindControl("Gender"); var txt = (TextBox)e.Item.FindControl("GenderTxt"); var i = ctl.Items.FindByValue(txt.Text); if (i != null) { ctl.SelectedValue = txt.Text; } ctl = (DropDownList)e.Item.FindControl("PrimaryLibrary"); txt = (TextBox)e.Item.FindControl("PrimaryLibraryTxt"); i = ctl.Items.FindByValue(txt.Text); if (i != null) { ctl.SelectedValue = txt.Text; } ctl = (DropDownList)e.Item.FindControl("SchoolType"); txt = (TextBox)e.Item.FindControl("SchoolTypeTxt"); i = ctl.Items.FindByValue(txt.Text); if (i != null) { ctl.SelectedValue = txt.Text; } //-- ctl = (DropDownList)e.Item.FindControl("SchoolName"); txt = (TextBox)e.Item.FindControl("SchoolNameTxt"); i = ctl.Items.FindByValue(txt.Text); if (i != null) { ctl.SelectedValue = txt.Text; } ctl = (DropDownList)e.Item.FindControl("SDistrict"); txt = (TextBox)e.Item.FindControl("SDistrictTxt"); i = ctl.Items.FindByValue(txt.Text); if (i != null) { ctl.SelectedValue = txt.Text; } ctl = (DropDownList)e.Item.FindControl("District"); txt = (TextBox)e.Item.FindControl("DistrictTxt"); i = ctl.Items.FindByValue(txt.Text); if (i != null) { ctl.SelectedValue = txt.Text; } //-- var cr = CustomRegistrationFields.FetchObject(); if (cr.DDValues1 != "") { var ds = Codes.GetAlByTypeID(int.Parse(cr.DDValues1)); ctl = (DropDownList)e.Item.FindControl("Custom1DD"); txt = (TextBox)e.Item.FindControl("Custom1DDTXT"); ctl.Items.Clear(); ctl.Items.Add(new ListItem("[Select a Value]", "")); for (int j = 0; j < ds.Tables[0].Rows.Count; j++) { ctl.Items.Add(new ListItem(ds.Tables[0].Rows[j]["Code"].ToString())); } i = ctl.Items.FindByValue(txt.Text); if (i != null) { ctl.SelectedValue = txt.Text; } } if (cr.DDValues2 != "") { var ds = Codes.GetAlByTypeID(int.Parse(cr.DDValues2)); ctl = (DropDownList)e.Item.FindControl("Custom2DD"); txt = (TextBox)e.Item.FindControl("Custom2DDTXT"); ctl.Items.Clear(); ctl.Items.Add(new ListItem("[Select a Value]", "")); for (int j = 0; j < ds.Tables[0].Rows.Count; j++) { ctl.Items.Add(new ListItem(ds.Tables[0].Rows[j]["Code"].ToString())); } i = ctl.Items.FindByValue(txt.Text); if (i != null) { ctl.SelectedValue = txt.Text; } } if (cr.DDValues3 != "") { var ds = Codes.GetAlByTypeID(int.Parse(cr.DDValues3)); ctl = (DropDownList)e.Item.FindControl("Custom3DD"); txt = (TextBox)e.Item.FindControl("Custom3DDTXT"); ctl.Items.Clear(); ctl.Items.Add(new ListItem("[Select a Value]", "")); for (int j = 0; j < ds.Tables[0].Rows.Count; j++) { ctl.Items.Add(new ListItem(ds.Tables[0].Rows[j]["Code"].ToString())); } i = ctl.Items.FindByValue(txt.Text); if (i != null) { ctl.SelectedValue = txt.Text; } } if (cr.DDValues4 != "") { var ds = Codes.GetAlByTypeID(int.Parse(cr.DDValues4)); ctl = (DropDownList)e.Item.FindControl("Custom4DD"); txt = (TextBox)e.Item.FindControl("Custom4DDTXT"); ctl.Items.Clear(); ctl.Items.Add(new ListItem("[Select a Value]", "")); for (int j = 0; j < ds.Tables[0].Rows.Count; j++) { ctl.Items.Add(new ListItem(ds.Tables[0].Rows[j]["Code"].ToString())); } i = ctl.Items.FindByValue(txt.Text); if (i != null) { ctl.SelectedValue = txt.Text; } } if (cr.DDValues5 != "") { var ds = Codes.GetAlByTypeID(int.Parse(cr.DDValues5)); ctl = (DropDownList)e.Item.FindControl("Custom5DD"); txt = (TextBox)e.Item.FindControl("Custom5DDTXT"); ctl.Items.Clear(); ctl.Items.Add(new ListItem("[Select a Value]", "")); for (int j = 0; j < ds.Tables[0].Rows.Count; j++) { ctl.Items.Add(new ListItem(ds.Tables[0].Rows[j]["Code"].ToString())); } i = ctl.Items.FindByValue(txt.Text); if (i != null) { ctl.SelectedValue = txt.Text; } } }
protected void rptr_ItemCommand(object source, RepeaterCommandEventArgs e) { var masterPage = (IControlRoomMaster)((BaseControlRoomPage)Page).Master; if (e.CommandName.ToLower() == "back") { Response.Redirect("Default.aspx"); } if (e.CommandName.ToLower() == "refresh") { LoadControl(); if (masterPage != null) { masterPage.PageMessage = SRPResources.RefreshOK; } return; } lblError.Text = ""; Page.Validate(); if (Page.IsValid) { if (e.CommandName.ToLower() == "save" || e.CommandName.ToLower() == "saveandback") { var p = new Patron(); if (!IsAdd()) { p = Patron.FetchObject(int.Parse(SA.Text)); } DateTime _d; p.Username = ((TextBox)(e.Item).FindControl("Username")).Text; p.Password = ((TextBox)(e.Item).FindControl("Password")).Text; var DOB = e.Item.FindControl("DOB") as TextBox; if (DOB != null && DOB.Text != "") { if (DateTime.TryParse(DOB.Text, out _d)) { p.DOB = _d; } } p.Age = FormatHelper.SafeToInt(((TextBox)(e.Item).FindControl("Age")).Text); //p.Custom2 = (((TextBox)(e.Item).FindControl("Custom2")).Text); p.MasterAcctPID = int.Parse(MasterPatronID); p.SchoolGrade = ((TextBox)(e.Item).FindControl("SchoolGrade")).Text; p.FirstName = ((TextBox)(e.Item).FindControl("FirstName")).Text; p.MiddleName = ((TextBox)(e.Item).FindControl("MiddleName")).Text; p.LastName = ((TextBox)(e.Item).FindControl("LastName")).Text; p.Gender = ((DropDownList)(e.Item).FindControl("Gender")).SelectedValue; p.EmailAddress = ((TextBox)(e.Item).FindControl("EmailAddress")).Text; p.PhoneNumber = ((TextBox)(e.Item).FindControl("PhoneNumber")).Text; p.PhoneNumber = FormatHelper.FormatPhoneNumber(p.PhoneNumber); p.StreetAddress1 = ((TextBox)(e.Item).FindControl("StreetAddress1")).Text; p.StreetAddress2 = ((TextBox)(e.Item).FindControl("StreetAddress2")).Text; p.City = ((TextBox)(e.Item).FindControl("City")).Text; p.State = ((TextBox)(e.Item).FindControl("State")).Text; p.ZipCode = ((TextBox)(e.Item).FindControl("ZipCode")).Text; p.ZipCode = FormatHelper.FormatZipCode(p.ZipCode); p.Country = ((TextBox)(e.Item).FindControl("Country")).Text; p.County = ((TextBox)(e.Item).FindControl("County")).Text; p.ParentGuardianFirstName = ((TextBox)(e.Item).FindControl("ParentGuardianFirstName")).Text; p.ParentGuardianLastName = ((TextBox)(e.Item).FindControl("ParentGuardianLastName")).Text; p.ParentGuardianMiddleName = ((TextBox)(e.Item).FindControl("ParentGuardianMiddleName")).Text; p.LibraryCard = ((TextBox)(e.Item).FindControl("LibraryCard")).Text; //p.PrimaryLibrary = ((DropDownList)(e.Item).FindControl("PrimaryLibrary")).SelectedValue.SafeToInt(); //p.SchoolName = ((DropDownList)(e.Item).FindControl("SchoolName")).SelectedValue; //p.District = ((DropDownList)(e.Item).FindControl("District")).SelectedValue; //p.SDistrict = ((DropDownList)(e.Item).FindControl("SDistrict")).SelectedValue.SafeToInt(); //p.SchoolType = ((DropDownList)(e.Item).FindControl("SchoolType")).SelectedValue.SafeToInt(); p.PrimaryLibrary = ((DropDownList)(e.Item).FindControl("PrimaryLibrary")).SelectedValue.SafeToInt(); p.SchoolName = ((DropDownList)(e.Item).FindControl("SchoolName")).SelectedValue; p.SchoolType = ((DropDownList)(e.Item).FindControl("SchoolType")).SelectedValue.SafeToInt(); var lc = LibraryCrosswalk.FetchObjectByLibraryID(p.PrimaryLibrary); if (lc != null) { p.District = lc.DistrictID == 0 ? ((DropDownList)(e.Item).FindControl("District")).SelectedValue : lc.DistrictID.ToString(); } else { p.District = ((DropDownList)(e.Item).FindControl("District")).SelectedValue; } var sc = SchoolCrosswalk.FetchObjectBySchoolID(p.SchoolName.SafeToInt()); if (sc != null) { p.SDistrict = sc.DistrictID == 0 ? ((DropDownList)(e.Item).FindControl("SDistrict")).SelectedValue.SafeToInt() : sc.DistrictID; p.SchoolType = sc.SchTypeID == 0 ? FormatHelper.SafeToInt(((DropDownList)(e.Item).FindControl("SchoolType")).SelectedValue) : sc.SchTypeID; } else { p.SDistrict = ((DropDownList)(e.Item).FindControl("SDistrict")).SelectedValue.SafeToInt(); } p.Teacher = ((TextBox)(e.Item).FindControl("Teacher")).Text; p.GroupTeamName = ((TextBox)(e.Item).FindControl("GroupTeamName")).Text; p.LiteracyLevel1 = ((TextBox)(e.Item).FindControl("LiteracyLevel1")).Text.SafeToInt(); p.LiteracyLevel2 = ((TextBox)(e.Item).FindControl("LiteracyLevel2")).Text.SafeToInt(); try { p.ParentPermFlag = ((CheckBox)(e.Item).FindControl("ParentPermFlag")).Checked; p.Over18Flag = ((CheckBox)(e.Item).FindControl("Over18Flag")).Checked; p.ShareFlag = ((CheckBox)(e.Item).FindControl("ShareFlag")).Checked; p.TermsOfUseflag = ((CheckBox)(e.Item).FindControl("TermsOfUseflag")).Checked; } catch { } var cr = CustomRegistrationFields.FetchObject(); p.Custom1 = cr.DDValues1 == "" ? ((TextBox)(e.Item).FindControl("Custom1")).Text : ((DropDownList)(e.Item).FindControl("Custom1DD")).SelectedValue; p.Custom2 = cr.DDValues2 == "" ? ((TextBox)(e.Item).FindControl("Custom2")).Text : ((DropDownList)(e.Item).FindControl("Custom2DD")).SelectedValue; p.Custom3 = cr.DDValues3 == "" ? ((TextBox)(e.Item).FindControl("Custom3")).Text : ((DropDownList)(e.Item).FindControl("Custom3DD")).SelectedValue; p.Custom4 = cr.DDValues4 == "" ? ((TextBox)(e.Item).FindControl("Custom4")).Text : ((DropDownList)(e.Item).FindControl("Custom4DD")).SelectedValue; p.Custom5 = cr.DDValues5 == "" ? ((TextBox)(e.Item).FindControl("Custom5")).Text : ((DropDownList)(e.Item).FindControl("Custom5DD")).SelectedValue; p.AvatarID = FormatHelper.SafeToInt(((DropDownList)e.Item.FindControl("AvatarID")).SelectedValue); p.ProgID = FormatHelper.SafeToInt(((DropDownList)e.Item.FindControl("ProgID")).SelectedValue); p.IsMasterAccount = ((CheckBox)(e.Item).FindControl("IsMasterAccount")).Checked; // do the save if (IsAdd()) { if (p.IsValid(BusinessRulesValidationMode.INSERT)) { p.Insert(); PatronID = p.PID.ToString(); SA.Text = PatronID; Session["CURR_PATRON_MODE"] = "EDIT"; LoadControl(); masterPage.PageMessage = SRPResources.AddedOK; if (e.CommandName.ToLower() == "saveandback") { Response.Redirect("Default.aspx"); } } else { string message = String.Format(SRPResources.ApplicationError1, "<ul>"); foreach (BusinessRulesValidationMessage m in p.ErrorCodes) { message = string.Format(String.Format("{0}<li>{{0}}</li>", message), m.ErrorMessage); } message = string.Format("{0}</ul>", message); masterPage.PageError = message; } var parent = Patron.FetchObject(p.MasterAcctPID); if (parent != null && !parent.IsMasterAccount) { parent.IsMasterAccount = true; parent.Update(); Session["CURR_PATRON"] = parent; PatronsRibbon.GetByAppContext((BaseControlRoomPage)Page); } } else { if (p.IsValid(BusinessRulesValidationMode.UPDATE)) { p.Update(); masterPage.PageMessage = SRPResources.SaveOK; if (e.CommandName.ToLower() == "saveandback") { Response.Redirect("Default.aspx"); } else { LoadControl(); } } else { string message = String.Format(SRPResources.ApplicationError1, "<ul>"); foreach (BusinessRulesValidationMessage m in p.ErrorCodes) { message = string.Format(String.Format("{0}<li>{{0}}</li>", message), m.ErrorMessage); } message = string.Format("{0}</ul>", message); masterPage.PageError = message; } } } } }
public bool SaveAccount() { try { var patron = (Patron)Session["Patron"]; var p = new Patron(); DateTime _d; var DOB = rptr.Items[0].FindControl("DOB") as TextBox; if (DOB != null && DOB.Text != "") { if (DateTime.TryParse(DOB.Text, out _d)) { p.DOB = _d; } } p.Age = FormatHelper.SafeToInt(((TextBox)(rptr.Items[0]).FindControl("Age")).Text); p.ProgID = FormatHelper.SafeToInt(((DropDownList)(rptr.Items[0]).FindControl("ProgID")).SelectedValue); p.Username = ((TextBox)(rptr.Items[0]).FindControl("Username")).Text; p.Password = ((TextBox)(rptr.Items[0]).FindControl("Password")).Text; p.IsMasterAccount = false; p.MasterAcctPID = patron.PID; p.SchoolGrade = ((TextBox)(rptr.Items[0]).FindControl("SchoolGrade")).Text; p.FirstName = ((TextBox)(rptr.Items[0]).FindControl("FirstName")).Text; p.MiddleName = ((TextBox)(rptr.Items[0]).FindControl("MiddleName")).Text; p.LastName = ((TextBox)(rptr.Items[0]).FindControl("LastName")).Text; p.Gender = ((DropDownList)(rptr.Items[0]).FindControl("Gender")).SelectedValue; p.EmailAddress = ((TextBox)(rptr.Items[0]).FindControl("EmailAddress")).Text; p.PhoneNumber = ((TextBox)(rptr.Items[0]).FindControl("PhoneNumber")).Text; p.PhoneNumber = FormatHelper.FormatPhoneNumber(p.PhoneNumber); p.StreetAddress1 = ((TextBox)(rptr.Items[0]).FindControl("StreetAddress1")).Text; p.StreetAddress2 = ((TextBox)(rptr.Items[0]).FindControl("StreetAddress2")).Text; p.City = ((TextBox)(rptr.Items[0]).FindControl("City")).Text; p.State = ((TextBox)(rptr.Items[0]).FindControl("State")).Text; p.ZipCode = ((TextBox)(rptr.Items[0]).FindControl("ZipCode")).Text; p.ZipCode = FormatHelper.FormatZipCode(p.ZipCode); p.Country = ((TextBox)(rptr.Items[0]).FindControl("Country")).Text; p.County = ((TextBox)(rptr.Items[0]).FindControl("County")).Text; p.ParentGuardianFirstName = ((TextBox)(rptr.Items[0]).FindControl("ParentGuardianFirstName")).Text; p.ParentGuardianLastName = ((TextBox)(rptr.Items[0]).FindControl("ParentGuardianLastName")).Text; p.ParentGuardianMiddleName = ((TextBox)(rptr.Items[0]).FindControl("ParentGuardianMiddleName")).Text; p.LibraryCard = ((TextBox)(rptr.Items[0]).FindControl("LibraryCard")).Text; //p.District = ((DropDownList)(rptr.Items[0]).FindControl("District")).SelectedValue; //p.SDistrict = ((DropDownList)(rptr.Items[0]).FindControl("SDistrict")).SelectedValue.SafeToInt(); p.PrimaryLibrary = FormatHelper.SafeToInt(((DropDownList)(rptr.Items[0]).FindControl("PrimaryLibrary")).SelectedValue); p.SchoolName = ((DropDownList)(rptr.Items[0]).FindControl("SchoolName")).SelectedValue; p.SchoolType = FormatHelper.SafeToInt(((DropDownList)(rptr.Items[0]).FindControl("SchoolType")).SelectedValue); var lc = LibraryCrosswalk.FetchObjectByLibraryID(p.PrimaryLibrary); if (lc != null) { p.District = lc.DistrictID == 0 ? ((DropDownList)(rptr.Items[0]).FindControl("District")).SelectedValue : lc.DistrictID.ToString(); } else { p.District = ((DropDownList)(rptr.Items[0]).FindControl("District")).SelectedValue; } var sc = SchoolCrosswalk.FetchObjectBySchoolID(p.SchoolName.SafeToInt()); if (sc != null) { p.SDistrict = sc.DistrictID == 0 ? ((DropDownList)(rptr.Items[0]).FindControl("SDistrict")).SelectedValue.SafeToInt() : sc.DistrictID; p.SchoolType = sc.SchTypeID == 0 ? FormatHelper.SafeToInt(((DropDownList)(rptr.Items[0]).FindControl("SchoolType")).SelectedValue) : sc.SchTypeID; } else { p.SDistrict = ((DropDownList)(rptr.Items[0]).FindControl("SDistrict")).SelectedValue.SafeToInt(); } p.Teacher = ((TextBox)(rptr.Items[0]).FindControl("Teacher")).Text; p.GroupTeamName = ((TextBox)(rptr.Items[0]).FindControl("GroupTeamName")).Text; p.LiteracyLevel1 = FormatHelper.SafeToInt(((TextBox)(rptr.Items[0]).FindControl("LiteracyLevel1")).Text); p.LiteracyLevel2 = FormatHelper.SafeToInt(((TextBox)(rptr.Items[0]).FindControl("LiteracyLevel2")).Text); p.ParentPermFlag = true; p.Over18Flag = true; p.ShareFlag = true; p.TermsOfUseflag = true; var cr = CustomRegistrationFields.FetchObject(); p.Custom1 = cr.DDValues1 == "" ? ((TextBox)(rptr.Items[0]).FindControl("Custom1")).Text : ((DropDownList)(rptr.Items[0]).FindControl("Custom1DD")).SelectedValue; p.Custom2 = cr.DDValues2 == "" ? ((TextBox)(rptr.Items[0]).FindControl("Custom2")).Text : ((DropDownList)(rptr.Items[0]).FindControl("Custom2DD")).SelectedValue; p.Custom3 = cr.DDValues3 == "" ? ((TextBox)(rptr.Items[0]).FindControl("Custom3")).Text : ((DropDownList)(rptr.Items[0]).FindControl("Custom3DD")).SelectedValue; p.Custom4 = cr.DDValues4 == "" ? ((TextBox)(rptr.Items[0]).FindControl("Custom4")).Text : ((DropDownList)(rptr.Items[0]).FindControl("Custom4DD")).SelectedValue; p.Custom5 = cr.DDValues5 == "" ? ((TextBox)(rptr.Items[0]).FindControl("Custom5")).Text : ((DropDownList)(rptr.Items[0]).FindControl("Custom5DD")).SelectedValue; p.AvatarID = FormatHelper.SafeToInt(((System.Web.UI.HtmlControls.HtmlInputText)rptr.Items[0].FindControl("AvatarID")).Value); if (p.IsValid(BusinessRulesValidationMode.INSERT)) { p.Insert(); var prog = Programs.FetchObject(p.ProgID); var list = new List <Badge>(); if (prog.RegistrationBadgeID != 0) { AwardPoints.AwardBadgeToPatron(prog.RegistrationBadgeID, p, ref list); } AwardPoints.AwardBadgeToPatronViaMatchingAwards(p, ref list); patron.IsMasterAccount = true; patron.Update(); } else { string message = String.Format(SRPResources.ApplicationError1, "<ul>"); foreach (BusinessRulesValidationMessage m in p.ErrorCodes) { message = string.Format(String.Format("{0}<li>{{0}}</li>", message), m.ErrorMessage); } message = string.Format("{0}</ul>", message); lblError.Text = message; return(false); } } catch (Exception ex) { lblError.Text = String.Format(SRPResources.ApplicationError1, ex.Message); return(false); } return(true); }
public bool SaveAccount() { try { var p = new Patron(); DateTime _d; var DOB = rptr.Items[0].FindControl("DOB") as TextBox; if (DOB != null && DOB.Text != "") { if (DateTime.TryParse(DOB.Text, out _d)) { p.DOB = _d; } } p.Age = FormatHelper.SafeToInt(((TextBox)(rptr.Items[0]).FindControl("Age")).Text); p.ProgID = FormatHelper.SafeToInt(((DropDownList)(rptr.Items[0]).FindControl("ProgID")).SelectedValue); p.Username = ((TextBox)(rptr.Items[0]).FindControl("Username")).Text; p.Password = ((TextBox)(rptr.Items[0]).FindControl("Password")).Text; var famAcct = (RadioButtonList)rptr.Items[0].FindControl("FamilyAccount"); p.IsMasterAccount = (famAcct.SelectedValue == "Yes" && MasterPID.Text.Length == 0); p.SchoolGrade = ((TextBox)(rptr.Items[0]).FindControl("SchoolGrade")).Text; p.FirstName = ((TextBox)(rptr.Items[0]).FindControl("FirstName")).Text; p.MiddleName = ((TextBox)(rptr.Items[0]).FindControl("MiddleName")).Text; p.LastName = ((TextBox)(rptr.Items[0]).FindControl("LastName")).Text; p.Gender = ((DropDownList)(rptr.Items[0]).FindControl("Gender")).SelectedValue; p.EmailAddress = ((TextBox)(rptr.Items[0]).FindControl("EmailAddress")).Text; p.PhoneNumber = ((TextBox)(rptr.Items[0]).FindControl("PhoneNumber")).Text; p.PhoneNumber = FormatHelper.FormatPhoneNumber(p.PhoneNumber); p.StreetAddress1 = ((TextBox)(rptr.Items[0]).FindControl("StreetAddress1")).Text; p.StreetAddress2 = ((TextBox)(rptr.Items[0]).FindControl("StreetAddress2")).Text; p.City = ((TextBox)(rptr.Items[0]).FindControl("City")).Text; p.State = ((TextBox)(rptr.Items[0]).FindControl("State")).Text; p.ZipCode = ((TextBox)(rptr.Items[0]).FindControl("ZipCode")).Text; p.ZipCode = FormatHelper.FormatZipCode(p.ZipCode); p.Country = ((TextBox)(rptr.Items[0]).FindControl("Country")).Text; p.County = ((TextBox)(rptr.Items[0]).FindControl("County")).Text; p.ParentGuardianFirstName = ((TextBox)(rptr.Items[0]).FindControl("ParentGuardianFirstName")).Text; p.ParentGuardianLastName = ((TextBox)(rptr.Items[0]).FindControl("ParentGuardianLastName")).Text; p.ParentGuardianMiddleName = ((TextBox)(rptr.Items[0]).FindControl("ParentGuardianMiddleName")).Text; p.LibraryCard = ((TextBox)(rptr.Items[0]).FindControl("LibraryCard")).Text; //p.District = ((DropDownList)(rptr.Items[0]).FindControl("District")).SelectedValue; //p.SDistrict = ((DropDownList)(rptr.Items[0]).FindControl("SDistrict")).SelectedValue.SafeToInt(); p.PrimaryLibrary = FormatHelper.SafeToInt(((DropDownList)(rptr.Items[0]).FindControl("PrimaryLibrary")).SelectedValue); p.SchoolName = ((DropDownList)(rptr.Items[0]).FindControl("SchoolName")).SelectedValue; p.SchoolType = FormatHelper.SafeToInt(((DropDownList)(rptr.Items[0]).FindControl("SchoolType")).SelectedValue); var lc = LibraryCrosswalk.FetchObjectByLibraryID(p.PrimaryLibrary); if (lc != null) { p.District = lc.DistrictID == 0 ? ((DropDownList)(rptr.Items[0]).FindControl("District")).SelectedValue : lc.DistrictID.ToString(); } else { p.District = ((DropDownList)(rptr.Items[0]).FindControl("District")).SelectedValue; } var sc = SchoolCrosswalk.FetchObjectBySchoolID(p.SchoolName.SafeToInt()); if (sc != null) { p.SDistrict = sc.DistrictID == 0 ? ((DropDownList)(rptr.Items[0]).FindControl("SDistrict")).SelectedValue.SafeToInt() : sc.DistrictID; p.SchoolType = sc.SchTypeID == 0 ? FormatHelper.SafeToInt(((DropDownList)(rptr.Items[0]).FindControl("SchoolType")).SelectedValue) : sc.SchTypeID; } else { p.SDistrict = ((DropDownList)(rptr.Items[0]).FindControl("SDistrict")).SelectedValue.SafeToInt(); } p.Teacher = ((TextBox)(rptr.Items[0]).FindControl("Teacher")).Text; p.GroupTeamName = ((TextBox)(rptr.Items[0]).FindControl("GroupTeamName")).Text; p.LiteracyLevel1 = FormatHelper.SafeToInt(((TextBox)(rptr.Items[0]).FindControl("LiteracyLevel1")).Text); p.LiteracyLevel2 = FormatHelper.SafeToInt(((TextBox)(rptr.Items[0]).FindControl("LiteracyLevel2")).Text); p.ParentPermFlag = ((CheckBox)(rptr.Items[0]).FindControl("ParentPermFlag")).Checked; p.Over18Flag = int.Parse(RegistrationAge.Text) > 18; p.ShareFlag = ((CheckBox)(rptr.Items[0]).FindControl("ShareFlag")).Checked; p.TermsOfUseflag = ((CheckBox)(rptr.Items[0]).FindControl("TermsOfUseflag")).Checked; var cr = CustomRegistrationFields.FetchObject(); p.Custom1 = cr.DDValues1 == "" ? ((TextBox)(rptr.Items[0]).FindControl("Custom1")).Text : ((DropDownList)(rptr.Items[0]).FindControl("Custom1DD")).SelectedValue; p.Custom2 = cr.DDValues2 == "" ? ((TextBox)(rptr.Items[0]).FindControl("Custom2")).Text : ((DropDownList)(rptr.Items[0]).FindControl("Custom2DD")).SelectedValue; p.Custom3 = cr.DDValues3 == "" ? ((TextBox)(rptr.Items[0]).FindControl("Custom3")).Text : ((DropDownList)(rptr.Items[0]).FindControl("Custom3DD")).SelectedValue; p.Custom4 = cr.DDValues4 == "" ? ((TextBox)(rptr.Items[0]).FindControl("Custom4")).Text : ((DropDownList)(rptr.Items[0]).FindControl("Custom4DD")).SelectedValue; p.Custom5 = cr.DDValues5 == "" ? ((TextBox)(rptr.Items[0]).FindControl("Custom5")).Text : ((DropDownList)(rptr.Items[0]).FindControl("Custom5DD")).SelectedValue; //p.Custom1 = ((TextBox)(rptr.Items[0]).FindControl("Custom1")).Text; //p.Custom2 = ((TextBox)(rptr.Items[0]).FindControl("Custom2")).Text; //p.Custom3 = ((TextBox)(rptr.Items[0]).FindControl("Custom3")).Text; //p.Custom4 = ((TextBox)(rptr.Items[0]).FindControl("Custom4")).Text; //p.Custom5 = ((TextBox)(rptr.Items[0]).FindControl("Custom5")).Text; p.AvatarID = FormatHelper.SafeToInt(((System.Web.UI.HtmlControls.HtmlInputText)rptr.Items[0].FindControl("AvatarID")).Value); var registeringMasterAccount = true; if (RegisteringFamily.Text != "0") { registeringMasterAccount = false; p.MasterAcctPID = int.Parse(MasterPID.Text); } if (p.IsValid(BusinessRulesValidationMode.INSERT)) { p.Insert(); var prog = Programs.FetchObject(p.ProgID); var list = new List <Badge>(); if (prog.RegistrationBadgeID != 0) { AwardPoints.AwardBadgeToPatron(prog.RegistrationBadgeID, p, ref list); #region replaced by call above // var now = DateTime.Now; // var pb = new PatronBadges { BadgeID = prog.RegistrationBadgeID, DateEarned = now, PID = p.PID }; // pb.Insert(); // var EarnedBadge = Badge.GetBadge(prog.RegistrationBadgeID); // //if badge generates notification, then generate the notification // if (EarnedBadge.GenNotificationFlag) // { // var not = new Notifications // { // PID_To = p.PID, // PID_From = 0, //0 == System Notification // Subject = EarnedBadge.NotificationSubject, // Body = EarnedBadge.NotificationBody, // isQuestion = false, // AddedDate = now, // LastModDate = now, // AddedUser = p.Username, // LastModUser = "******" // }; // not.Insert(); // } // //if badge generates prize, then generate the prize // if (EarnedBadge.IncludesPhysicalPrizeFlag) // { // var ppp = new DAL.PatronPrizes // { // PID = p.PID, // PrizeSource = 1, // PrizeName = EarnedBadge.PhysicalPrizeName, // RedeemedFlag = false, // AddedUser = p.Username, // LastModUser = "******", // AddedDate = now, // LastModDate = now // }; // ppp.Insert(); // } // // if badge generates award code, then generate the code // if (EarnedBadge.AssignProgramPrizeCode) // { // var RewardCode = ""; // // get the Code value // // save the code value for the patron // RewardCode = ProgramCodes.AssignCodeForPatron(p.ProgID, p.ProgID); // // generate the notification // var not = new Notifications // { // PID_To = p.PID, // PID_From = 0, //0 == System Notification // Subject = EarnedBadge.PCNotificationSubject, // Body = EarnedBadge.PCNotificationBody.Replace("{ProgramRewardCode}", RewardCode), // isQuestion = false, // AddedDate = now, // LastModDate = now, // AddedUser = p.Username, // LastModUser = "******" // }; // not.Insert(); // } #endregion } AwardPoints.AwardBadgeToPatronViaMatchingAwards(p, ref list); var sBadges = ""; sBadges = list.Aggregate(sBadges, (current, b) => current + "|" + b.BID.ToString()); if (p.IsMasterAccount && sBadges.Length > 0) { GoToUrl = ("~/BadgeAward.aspx?b=" + sBadges); // if family account and is master, and has badges, rememebr to show them } if (!p.IsMasterAccount && p.MasterAcctPID == 0 && sBadges.Length > 0) { GoToUrl = ("~/BadgeAward.aspx?b=" + sBadges); // if not family master or not family at all and badges, rememebr to show ... } if (registeringMasterAccount) { MasterPID.Text = p.PID.ToString(); Session["PatronLoggedIn"] = true; Session["Patron"] = p; Session["ProgramID"] = p.ProgID; Session["PatronProgramID"] = p.ProgID; Session["CurrentProgramID"] = p.ProgID; } } else { string message = String.Format(SRPResources.ApplicationError1, "<ul>"); foreach (BusinessRulesValidationMessage m in p.ErrorCodes) { message = string.Format(String.Format("{0}<li>{{0}}</li>", message), m.ErrorMessage); } message = string.Format("{0}</ul>", message); lblError.Text = message; return(false); } } catch (Exception ex) { lblError.Text = String.Format(SRPResources.ApplicationError1, ex.Message); return(false); } return(true); }