protected override void ClearForm() { this.PrimaryKeyIndex = 0; DisplayProfileTabs(false); txtSubProfileName.Text = string.Empty; txtSubFirstName.Text = string.Empty; txtSubLastName.Text = string.Empty; chkUseParentShippingAddress.Checked = false; AddressEdit_SubShipping.Clear(); AddressEdit_SubShipping.Visible = true; SubProfileNotesEdit_Shipping.Clear(); //preferences SubProfilePrefsEdit1.Clear(); //allergens SubProfileAllgsEdit1.Clear(); }
void chkUseParentShippingAddress_CheckedChanged(object sender, EventArgs e) { if (CurrentUserProfile == null) { CurrentUserProfile = hccUserProfile.GetById(this.PrimaryKeyIndex); } if (chkUseParentShippingAddress.Checked) { AddressEdit_SubShipping.Clear(); AddressEdit_SubShipping.Visible = false; if (CurrentUserProfile != null) { //CurrentUserProfile.ShippingAddressID = null; CurrentUserProfile.UseParentShipping = true; CurrentUserProfile.Save(); Page.Response.Redirect(Page.Request.Url.ToString(), true); } else { if (txtSubProfileName.Text == "" || txtSubFirstName.Text == "" || txtSubLastName.Text == "") { lblSubProfileFeedback.Text = "Please fill Basic Info before filling Shipping Info"; lblSubProfileFeedback.ForeColor = System.Drawing.Color.Red; } else { try { CurrentUserProfile = hccUserProfile.GetById(this.PrimaryKeyIndex); hccUserProfile parentProfile = hccUserProfile.GetById(CurrentParentProfileId); if (CurrentUserProfile == null && parentProfile != null) { hccUserProfile newProfile = new hccUserProfile { ParentProfileID = CurrentParentProfileId, CreatedBy = (Guid)Helpers.LoggedUser.ProviderUserKey, CreatedDate = DateTime.Now, IsActive = true, MembershipID = parentProfile.MembershipID }; newProfile.Save(); this.PrimaryKeyIndex = newProfile.UserProfileID; CurrentUserProfile = newProfile; } if (CurrentUserProfile != null) { CurrentUserProfile.IsActive = chkSubIsActive.Checked; if (txtSubProfileName.Text.Trim() != CurrentUserProfile.ProfileName) { CurrentUserProfile.ProfileName = txtSubProfileName.Text.Trim(); } if (txtSubFirstName.Text.Trim() != CurrentUserProfile.FirstName) { CurrentUserProfile.FirstName = txtSubFirstName.Text.Trim(); } if (txtSubLastName.Text.Trim() != CurrentUserProfile.LastName) { CurrentUserProfile.LastName = txtSubLastName.Text.Trim(); } //save addresses if (chkUseParentShippingAddress.Checked) { if (CurrentUserProfile.ShippingAddressID != 0) { CurrentUserProfile.UseParentShipping = true; //CurrentUserProfile.ShippingAddressID = parentProfile.ShippingAddressID; } else { CurrentUserProfile.UseParentShipping = true; CurrentUserProfile.ShippingAddressID = AddressEdit_SubShipping.PrimaryKeyIndex; } } else { AddressEdit_SubShipping.Save(); CurrentUserProfile.UseParentShipping = false; CurrentUserProfile.ShippingAddressID = AddressEdit_SubShipping.PrimaryKeyIndex; } //preferences SubProfilePrefsEdit1.PrimaryKeyIndex = CurrentUserProfile.UserProfileID; SubProfilePrefsEdit1.Save(); //allergens SubProfileAllgsEdit1.PrimaryKeyIndex = CurrentUserProfile.UserProfileID; SubProfileAllgsEdit1.Save(); CurrentUserProfile.Save(); //DisplayProfileTabs(false); lblSubProfileFeedback.Text = "Sub-Profile Saved - " + DateTime.Now.ToString("MM/dd/yyy hh:mm:ss"); lblSubProfileFeedback.ForeColor = System.Drawing.Color.Green; OnSaved(new ControlSavedEventArgs(this.PrimaryKeyIndex)); } } catch { throw; } } } } else { AddressEdit_SubShipping.Visible = true; if (CurrentUserProfile != null) { CurrentUserProfile.UseParentShipping = false; CurrentUserProfile.Save(); } } }
protected override void SaveForm() { try { CurrentUserProfile = hccUserProfile.GetById(this.PrimaryKeyIndex); hccUserProfile parentProfile = hccUserProfile.GetById(CurrentParentProfileId); if (CurrentUserProfile == null && parentProfile != null) { hccUserProfile newProfile = new hccUserProfile { ParentProfileID = CurrentParentProfileId, CreatedBy = (Guid)Helpers.LoggedUser.ProviderUserKey, CreatedDate = DateTime.Now, IsActive = true, MembershipID = parentProfile.MembershipID }; newProfile.Save(); this.PrimaryKeyIndex = newProfile.UserProfileID; CurrentUserProfile = newProfile; } if (CurrentUserProfile != null) { CurrentUserProfile.IsActive = chkSubIsActive.Checked; if (txtSubProfileName.Text.Trim() != CurrentUserProfile.ProfileName) { CurrentUserProfile.ProfileName = txtSubProfileName.Text.Trim(); } if (txtSubFirstName.Text.Trim() != CurrentUserProfile.FirstName) { CurrentUserProfile.FirstName = txtSubFirstName.Text.Trim(); } if (txtSubLastName.Text.Trim() != CurrentUserProfile.LastName) { CurrentUserProfile.LastName = txtSubLastName.Text.Trim(); } //save addresses if (chkUseParentShippingAddress.Checked) { if (CurrentUserProfile.ShippingAddressID != 0) { CurrentUserProfile.UseParentShipping = true; //CurrentUserProfile.ShippingAddressID = parentProfile.ShippingAddressID; } else { CurrentUserProfile.UseParentShipping = true; CurrentUserProfile.ShippingAddressID = AddressEdit_SubShipping.PrimaryKeyIndex; } } else { AddressEdit_SubShipping.Save(); CurrentUserProfile.UseParentShipping = false; CurrentUserProfile.ShippingAddressID = AddressEdit_SubShipping.PrimaryKeyIndex; } //preferences SubProfilePrefsEdit1.PrimaryKeyIndex = CurrentUserProfile.UserProfileID; SubProfilePrefsEdit1.Save(); //allergens SubProfileAllgsEdit1.PrimaryKeyIndex = CurrentUserProfile.UserProfileID; SubProfileAllgsEdit1.Save(); CurrentUserProfile.Save(); } //DisplayProfileTabs(false); lblSubProfileFeedback.Text = "Sub-Profile Saved - " + DateTime.Now.ToString("MM/dd/yyy hh:mm:ss"); lblSubProfileFeedback.ForeColor = System.Drawing.Color.Green; OnSaved(new ControlSavedEventArgs(this.PrimaryKeyIndex)); ClearForm(); } catch { throw; } }
protected override void LoadForm() { try { //form fields CurrentUserProfile = hccUserProfile.GetById(this.PrimaryKeyIndex); AddressEdit_SubShipping.Clear(); chkUseParentShippingAddress.Checked = false; if (CurrentUserProfile != null) { chkSubIsActive.Checked = CurrentUserProfile.IsActive; txtSubProfileName.Text = CurrentUserProfile.ProfileName; txtSubFirstName.Text = CurrentUserProfile.FirstName; txtSubLastName.Text = CurrentUserProfile.LastName; //shipping address if (CurrentUserProfile.UseParentShipping) { AddressEdit_SubShipping.Clear(); AddressEdit_SubShipping.Visible = false; chkUseParentShippingAddress.Checked = true; } else { AddressEdit_SubShipping.Clear(); AddressEdit_SubShipping.Visible = true; if (CurrentUserProfile.ShippingAddressID.HasValue) { AddressEdit_SubShipping.PrimaryKeyIndex = CurrentUserProfile.ShippingAddressID.Value; AddressEdit_SubShipping.Bind(); } } //preferences SubProfilePrefsEdit1.PrimaryKeyIndex = CurrentUserProfile.UserProfileID; //allergens SubProfileAllgsEdit1.PrimaryKeyIndex = CurrentUserProfile.UserProfileID; //shipping notes SubProfileNotesEdit_Shipping.CurrentUserProfileId = CurrentUserProfile.UserProfileID; SubProfileNotesEdit_Shipping.AllowAddEdit = NotesAllowAddEdit; SubProfileNotesEdit_Shipping.AllowDisplayToUser = NotesAllowDisplayToUser; DisplayProfileTabs(true); SubProfileNotesEdit_Shipping.Bind(); } SubProfilePrefsEdit1.NotesAllowAddEdit = NotesAllowAddEdit; SubProfilePrefsEdit1.NotesAllowDisplayToUser = NotesAllowDisplayToUser; SubProfileAllgsEdit1.NotesAllowAddEdit = NotesAllowAddEdit; SubProfileAllgsEdit1.NotesAllowDisplayToUser = NotesAllowDisplayToUser; SubProfilePrefsEdit1.Bind(); SubProfileAllgsEdit1.Bind(); } catch (Exception) { throw; } }