protected void Page_Load(object sender, EventArgs e) { // Figure out if site allows using global discount levels allowGlobalDiscountLevels = ECommerceSettings.AllowGlobalDiscountLevels(CMSContext.CurrentSiteName); pnlGeneral.GroupingText = GetString("com.customeredit.general"); pnlContacts.GroupingText = GetString("com.customeredit.contacts"); pnlUserInfo.GroupingText = GetString("com.customeredit.userinfo"); chkHasLogin.Text = GetString("Customer_Edit_Login_Edit.lblHasLogin"); rqvUserName.ErrorMessage = GetString("Customer_Edit_Login_Edit.rqvUserName"); rqvPassword2.ErrorMessage = GetString("Customer_Edit_Login_Edit.rqvPassword2"); // Init buttons btnEditUser.Text = GetString("general.edit"); if (Customer != null) { InitForm(); LoadForm(); } chkHasLogin.Attributes["onclick"] = "ShowHideLoginControls()"; // Register script to show / hide user controls string script = @" function ShowHideLoginControls() {{ checkbox = document.getElementById('" + chkHasLogin.ClientID + @"'); line1 = document.getElementById('loginLine1'); line2 = document.getElementById('loginLine2'); line3 = document.getElementById('loginLine3'); if ((checkbox != null) && (checkbox.checked)) {{ line1.style.display = ''; line2.style.display = ''; line3.style.display = ''; }} else {{ line1.style.display = 'none'; line2.style.display = 'none'; line3.style.display = 'none'; }} }}"; ltlScript.Text = ScriptHelper.GetScript(script); if (pnlEdit.Visible) { ltlScript.Text += ScriptHelper.GetScript("ShowHideLoginControls()"); } // Hide edit user button when requested plcButton.Visible = !HideOKButton; btnOk.Visible = !HideOKButton; }
protected void Page_Load(object sender, EventArgs e) { if (!CMSContext.CurrentUser.IsAuthorizedPerUIElement("CMS.Ecommerce", "Customers.General")) { RedirectToCMSDeskUIElementAccessDenied("CMS.Ecommerce", "Customers.General"); } // Figure out if site allows using global discount levels allowGlobalDiscountLevels = ECommerceSettings.AllowGlobalDiscountLevels(CMSContext.CurrentSiteName); this.pnlGeneral.GroupingText = GetString("com.customeredit.general"); this.pnlContacts.GroupingText = GetString("com.customeredit.contacts"); this.pnlUserInfo.GroupingText = GetString("com.customeredit.userinfo"); chkHasLogin.Text = GetString("Customer_Edit_Login_Edit.lblHasLogin"); rqvUserName.ErrorMessage = GetString("Customer_Edit_Login_Edit.rqvUserName"); rqvPassword2.ErrorMessage = GetString("Customer_Edit_Login_Edit.rqvPassword2"); // Control initializations lblPassword1.Text = GetString("Customer_Edit_Login_Edit.lblPassword1"); lblPassword2.Text = GetString("Customer_Edit_Login_Edit.lblPassword2"); btnEditUser.Text = GetString("general.edit"); // Init controls btnOk.Text = GetString("General.OK"); lblCustomerLastName.Text = GetString("Customers_Edit.CustomerLastNameLabel"); lblCustomerFirstName.Text = GetString("Customers_Edit.CustomerFirstNameLabel"); lblCustomerCompany.Text = GetString("Customers_Edit.CustomerCompanyLabel"); lblCustomerFax.Text = GetString("customers_edit.CustomerFax"); lblCustomerPhone.Text = GetString("customers_edit.CustomerPhone"); lblCustomerPreferredCurrency.Text = GetString("customers_edit.CustomerCurrency"); lblCustomerPreferredShippingOption.Text = GetString("customers_edit.CustomerShipping"); lblCustomerPrefferedPaymentOption.Text = GetString("customers_edit.CustomerPayment"); lblCustomerEmail.Text = GetString("general.email"); lblCustomerCountry.Text = GetString("Customers_Edit.CustomerCountry"); lblTaxRegistrationID.Text = GetString("Customers_Edit.lblTaxRegistrationID"); lblOrganizationID.Text = GetString("Customers_Edit.lblOrganizationID"); lblCustomerGlobalDiscountLevel.Text = GetString("Customers_Edit.lblCustomerGlobalDiscountLevel"); lblCustomerDiscountLevel.Text = GetString("Customers_Edit.lblCustomerDiscountLevel"); string emptyRecordText = GetString(allowGlobalDiscountLevels ? "general.UseGlobal" : "general.empty"); drpDiscountLevel.SpecialFields = new string[, ] { { emptyRecordText, "0" } }; // Init current site id currentSiteId = CMSContext.CurrentSiteID; customerid = QueryHelper.GetInteger("customerid", 0); if (customerid > 0) { customerObj = CustomerInfoProvider.GetCustomerInfo(customerid); // Check if customer belongs to current site if (!CheckCustomerSiteID(customerObj)) { customerObj = null; } EditedObject = customerObj; if (customerObj != null) { // Display site discount level only for reistered customers plcSiteDiscount.Visible = customerObj.CustomerIsRegistered; if (customerObj.CustomerIsRegistered) { UserInfo ui = UserInfoProvider.GetUserInfo(customerObj.CustomerUserID); if (ui != null) { pnlEdit.Visible = false; pnlStatic.Visible = true; lblUserNameStaticValue.Text = HTMLHelper.HTMLEncode(Functions.GetFormattedUserName(ui.UserName)); btnEditUser.OnClientClick = "modalDialog('" + CMSContext.ResolveDialogUrl("~/CMSModules/Membership/Pages/Users/User_Edit_Frameset.aspx") + "?userid=" + customerObj.CustomerUserID + "&siteId=" + ConfiguredSiteID + "', 'UserEdit', 950, 700); return false;"; } // Hide global discount level selector when global levels not allowed plcGlobalDiscount.Visible = allowGlobalDiscountLevels; } else { plcDiscounts.Visible = false; plcPreferences.Visible = false; pnlEdit.Visible = true; pnlStatic.Visible = false; } // Fill editing form if (!RequestHelper.IsPostBack()) { // Fill form txtCustomerCompany.Text = customerObj.CustomerCompany; txtCustomerEmail.Text = customerObj.CustomerEmail; txtCustomerFax.Text = customerObj.CustomerFax; txtCustomerFirstName.Text = customerObj.CustomerFirstName; txtCustomerLastName.Text = customerObj.CustomerLastName; txtCustomerPhone.Text = customerObj.CustomerPhone; txtOraganizationID.Text = customerObj.CustomerOrganizationID; txtTaxRegistrationID.Text = customerObj.CustomerTaxRegistrationID; chkCustomerEnabled.Checked = customerObj.CustomerEnabled; if (customerObj.CustomerCountryID > 0) { drpCountry.CountryID = customerObj.CustomerCountryID; } if (customerObj.CustomerStateID > 0) { drpCountry.StateID = customerObj.CustomerStateID; } // show that the customer was created or updated successfully if (QueryHelper.GetString("saved", "") == "1") { lblInfo.Visible = true; lblInfo.Text = GetString("General.ChangesSaved"); int hideBreadcrumbs = QueryHelper.GetInteger("hidebreadcrumbs", 0); if (hideBreadcrumbs > 0) { // Refresh the parent page when called from Orders section string javaScript = @"if(window.parent.wopener != null) {{ window.parent.wopener.location.replace(window.parent.wopener.location); }}"; ScriptHelper.RegisterClientScriptBlock(this.Page, typeof(string), "RefreshParentScript", ScriptHelper.GetScript(javaScript)); } } } } LoadDataSelectors(customerObj); } chkHasLogin.Attributes["onclick"] = "ShowHideLoginControls()"; // Register script to show / hide SKU controls string script = @" function ShowHideLoginControls() {{ checkbox = document.getElementById('" + this.chkHasLogin.ClientID + @"'); line1 = document.getElementById('loginLine1'); line2 = document.getElementById('loginLine2'); line3 = document.getElementById('loginLine3'); if ((checkbox != null) && (checkbox.checked)) {{ line1.style.display = ''; line2.style.display = ''; line3.style.display = ''; }} else {{ line1.style.display = 'none'; line2.style.display = 'none'; line3.style.display = 'none'; }} }}"; this.ltlScript.Text = ScriptHelper.GetScript(script); if (pnlEdit.Visible) { this.ltlScript.Text += ScriptHelper.GetScript("ShowHideLoginControls()"); } if (QueryHelper.GetBoolean("refreshHeader", false)) { StringBuilder sb = new StringBuilder(); sb.Append("if (window.parent.frames['CustomerHeader'] != null) {"); sb.Append("var loc = window.parent.frames['CustomerHeader'].location; if(!(/onlyRefresh=1/.test(loc))) {loc += '&onlyRefresh=1';} window.parent.frames['CustomerHeader'].location.replace(loc);"); sb.Append("}"); ScriptHelper.RegisterStartupScript(this, typeof(string), "RefreshHeaderScript", sb.ToString(), true); } }