private void BindData() { var checkoutAttribute = CheckoutAttributeManager.GetCheckoutAttributeById(this.CheckoutAttributeId); if (this.HasLocalizableContent) { var languages = this.GetLocalizableLanguagesSupported(); rptrLanguageTabs.DataSource = languages; rptrLanguageTabs.DataBind(); rptrLanguageDivs.DataSource = languages; rptrLanguageDivs.DataBind(); } if (checkoutAttribute != null) { this.txtName.Text = checkoutAttribute.Name; this.txtTextPrompt.Text = checkoutAttribute.TextPrompt; this.cbAttributeRequired.Checked = checkoutAttribute.IsRequired; this.cbShippableProductRequired.Checked = checkoutAttribute.ShippableProductRequired; this.cbIsTaxExempt.Checked = checkoutAttribute.IsTaxExempt; CommonHelper.SelectListItem(this.ddlTaxCategory, checkoutAttribute.TaxCategoryId); CommonHelper.SelectListItem(this.ddlAttributeControlType, checkoutAttribute.AttributeControlTypeId); this.txtDisplayOrder.Value = checkoutAttribute.DisplayOrder; } }
public CheckoutAttribute SaveInfo() { string name = txtName.Text; string textPrompt = txtTextPrompt.Text; int taxCategoryId = int.Parse(this.ddlTaxCategory.SelectedItem.Value); bool isRequired = cbAttributeRequired.Checked; bool shippableProductRequired = cbShippableProductRequired.Checked; bool isTaxExempt = cbIsTaxExempt.Checked; int attributeControlTypeId = int.Parse(this.ddlAttributeControlType.SelectedItem.Value); int displayOrder = txtDisplayOrder.Value; var checkoutAttribute = CheckoutAttributeManager.GetCheckoutAttributeById(this.CheckoutAttributeId); if (checkoutAttribute != null) { checkoutAttribute = CheckoutAttributeManager.UpdateCheckoutAttribute(checkoutAttribute.CheckoutAttributeId, name, textPrompt, isRequired, shippableProductRequired, isTaxExempt, taxCategoryId, attributeControlTypeId, displayOrder); } else { checkoutAttribute = CheckoutAttributeManager.InsertCheckoutAttribute(name, textPrompt, isRequired, shippableProductRequired, isTaxExempt, taxCategoryId, attributeControlTypeId, displayOrder); } SaveLocalizableContent(checkoutAttribute); return(checkoutAttribute); }
protected void gvValues_RowDeleting(object sender, GridViewDeleteEventArgs e) { int cavId = (int)gvValues.DataKeys[e.RowIndex]["CheckoutAttributeValueId"]; CheckoutAttributeManager.DeleteCheckoutAttributeValue(cavId); BindData(); }
protected void gvValues_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName == "UpdateCheckoutAttributeValue") { int index = Convert.ToInt32(e.CommandArgument); GridViewRow row = gvValues.Rows[index]; HiddenField hfCheckoutAttributeValueId = row.FindControl("hfCheckoutAttributeValueId") as HiddenField; SimpleTextBox txtName = row.FindControl("txtName") as SimpleTextBox; DecimalTextBox txtPriceAdjustment = row.FindControl("txtPriceAdjustment") as DecimalTextBox; DecimalTextBox txtWeightAdjustment = row.FindControl("txtWeightAdjustment") as DecimalTextBox; CheckBox cbIsPreSelected = row.FindControl("cbIsPreSelected") as CheckBox; NumericTextBox txtDisplayOrder = row.FindControl("txtDisplayOrder") as NumericTextBox; int cavId = int.Parse(hfCheckoutAttributeValueId.Value); string name = txtName.Text; decimal priceAdjustment = txtPriceAdjustment.Value; decimal weightAdjustment = txtWeightAdjustment.Value; bool isPreSelected = cbIsPreSelected.Checked; int displayOrder = txtDisplayOrder.Value; var cav = CheckoutAttributeManager.GetCheckoutAttributeValueById(cavId, 0); if (cav != null) { cav = CheckoutAttributeManager.UpdateCheckoutAttributeValue(cav.CheckoutAttributeValueId, cav.CheckoutAttributeId, name, priceAdjustment, weightAdjustment, isPreSelected, displayOrder); SaveLocalizableContentGrid(cav); } BindData(); } }
protected void btnAdd_Click(object sender, EventArgs e) { try { var checkoutAttribute = CheckoutAttributeManager.GetCheckoutAttributeById(this.CheckoutAttributeId, 0); if (checkoutAttribute != null) { var cav = CheckoutAttributeManager.InsertCheckoutAttributeValue(checkoutAttribute.CheckoutAttributeId, txtNewName.Text, txtNewPriceAdjustment.Value, txtNewWeightAdjustment.Value, cbNewIsPreSelected.Checked, txtNewDisplayOrder.Value); SaveLocalizableContent(cav); if (checkoutAttribute != null) { string url = string.Format("CheckoutAttributeDetails.aspx?CheckoutAttributeID={0}&TabID={1}", checkoutAttribute.CheckoutAttributeId, "pnlValues"); Response.Redirect(url); } } } catch (Exception exc) { processAjaxError(exc); } }
void BindGrid() { var checkoutAttributes = CheckoutAttributeManager.GetAllCheckoutAttributes(false); gvCheckoutAttributes.DataSource = checkoutAttributes; gvCheckoutAttributes.DataBind(); }
protected void SaveLocalizableContentGrid(CheckoutAttributeValue cav) { if (cav == null) { return; } if (!this.HasLocalizableContent) { return; } foreach (GridViewRow row in gvValues.Rows) { Repeater rptrLanguageDivs2 = row.FindControl("rptrLanguageDivs2") as Repeater; if (rptrLanguageDivs2 != null) { HiddenField hfCheckoutAttributeValueId = row.FindControl("hfCheckoutAttributeValueId") as HiddenField; int cavId = int.Parse(hfCheckoutAttributeValueId.Value); if (cavId == cav.CheckoutAttributeValueId) { foreach (RepeaterItem item in rptrLanguageDivs2.Items) { if (item.ItemType == ListItemType.Item || item.ItemType == ListItemType.AlternatingItem) { var txtLocalizedName = (TextBox)item.FindControl("txtLocalizedName"); var lblLanguageId = (Label)item.FindControl("lblLanguageId"); int languageId = int.Parse(lblLanguageId.Text); string name = txtLocalizedName.Text; bool allFieldsAreEmpty = string.IsNullOrEmpty(name); var content = CheckoutAttributeManager.GetCheckoutAttributeValueLocalizedByCheckoutAttributeValueIdAndLanguageId(cav.CheckoutAttributeValueId, languageId); if (content == null) { if (!allFieldsAreEmpty && languageId > 0) { //only insert if one of the fields are filled out (avoid too many empty records in db...) content = CheckoutAttributeManager.InsertCheckoutAttributeValueLocalized(cav.CheckoutAttributeValueId, languageId, name); } } else { if (languageId > 0) { content = CheckoutAttributeManager.UpdateCheckoutAttributeValueLocalized(content.CheckoutAttributeValueLocalizedId, content.CheckoutAttributeValueId, languageId, name); } } } } } } } }
protected List <CheckoutAttribute> GetCheckoutAttributes() { ShoppingCart cart = GetCart(); if (cart == null || cart.Count == 0) { return(new List <CheckoutAttribute>()); } bool shoppingCartRequiresShipping = ShippingManager.ShoppingCartRequiresShipping(cart); var checkoutAttributes = CheckoutAttributeManager.GetAllCheckoutAttributes(!shoppingCartRequiresShipping); return(checkoutAttributes); }
protected void SaveLocalizableContent(CheckoutAttribute checkoutAttribute) { if (checkoutAttribute == null) { return; } if (!this.HasLocalizableContent) { return; } foreach (RepeaterItem item in rptrLanguageDivs.Items) { if (item.ItemType == ListItemType.Item || item.ItemType == ListItemType.AlternatingItem) { var txtLocalizedName = (TextBox)item.FindControl("txtLocalizedName"); var txtLocalizedTextPrompt = (TextBox)item.FindControl("txtLocalizedTextPrompt"); var lblLanguageId = (Label)item.FindControl("lblLanguageId"); int languageId = int.Parse(lblLanguageId.Text); string name = txtLocalizedName.Text; string textPrompt = txtLocalizedTextPrompt.Text; bool allFieldsAreEmpty = (string.IsNullOrEmpty(name) && string.IsNullOrEmpty(textPrompt)); var content = CheckoutAttributeManager.GetCheckoutAttributeLocalizedByCheckoutAttributeIdAndLanguageId(checkoutAttribute.CheckoutAttributeId, languageId); if (content == null) { if (!allFieldsAreEmpty && languageId > 0) { //only insert if one of the fields are filled out (avoid too many empty records in db...) content = CheckoutAttributeManager.InsertCheckoutAttributeLocalized(checkoutAttribute.CheckoutAttributeId, languageId, name, textPrompt); } } else { if (languageId > 0) { content = CheckoutAttributeManager.UpdateCheckoutAttributeLocalized(content.CheckoutAttributeLocalizedId, content.CheckoutAttributeId, languageId, name, textPrompt); } } } } }
private void BindData() { var checkoutAttribute = CheckoutAttributeManager.GetCheckoutAttributeById(this.CheckoutAttributeId, 0); if (checkoutAttribute != null) { if (checkoutAttribute.ShouldHaveValues) { pnlData.Visible = true; pnlMessage.Visible = false; if (this.HasLocalizableContent) { var languages = this.GetLocalizableLanguagesSupported(); rptrLanguageTabs.DataSource = languages; rptrLanguageTabs.DataBind(); rptrLanguageDivs.DataSource = languages; rptrLanguageDivs.DataBind(); } var values = CheckoutAttributeManager.GetCheckoutAttributeValues(checkoutAttribute.CheckoutAttributeId, 0); if (values.Count > 0) { gvValues.Visible = true; gvValues.DataSource = values; gvValues.DataBind(); } else { gvValues.Visible = false; } } else { pnlData.Visible = false; pnlMessage.Visible = true; lblMessage.Text = GetLocaleResourceString("Admin.CheckoutAttributeInfo.ValuesNotRequiredForThisControlType"); } } else { pnlData.Visible = false; pnlMessage.Visible = true; lblMessage.Text = GetLocaleResourceString("Admin.CheckoutAttributeValues.AvailableAfterSaving"); } }
protected void rptrLanguageDivs_ItemDataBound(object sender, RepeaterItemEventArgs e) { if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem) { var txtLocalizedName = (TextBox)e.Item.FindControl("txtLocalizedName"); var txtLocalizedTextPrompt = (TextBox)e.Item.FindControl("txtLocalizedTextPrompt"); var lblLanguageId = (Label)e.Item.FindControl("lblLanguageId"); int languageId = int.Parse(lblLanguageId.Text); var content = CheckoutAttributeManager.GetCheckoutAttributeLocalizedByCheckoutAttributeIdAndLanguageId(this.CheckoutAttributeId, languageId); if (content != null) { txtLocalizedName.Text = content.Name; txtLocalizedTextPrompt.Text = content.TextPrompt; } } }
protected void DeleteButton_Click(object sender, EventArgs e) { try { var attribute = CheckoutAttributeManager.GetCheckoutAttributeById(this.CheckoutAttributeId); if (attribute != null) { CheckoutAttributeManager.DeleteCheckoutAttribute(this.CheckoutAttributeId); CustomerActivityManager.InsertActivity( "DeleteCheckoutAttribute", GetLocaleResourceString("ActivityLog.DeleteCheckoutAttribute"), attribute.Name); } Response.Redirect("checkoutattributes.aspx"); } catch (Exception exc) { ProcessException(exc); } }
protected void rptrLanguageDivs2_ItemDataBound(object sender, RepeaterItemEventArgs e) { if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem) { var txtLocalizedName = (TextBox)e.Item.FindControl("txtLocalizedName"); var lblLanguageId = (Label)e.Item.FindControl("lblLanguageId"); var hfCheckoutAttributeValueId = (HiddenField)e.Item.Parent.Parent.FindControl("hfCheckoutAttributeValueId"); int languageId = int.Parse(lblLanguageId.Text); int cavId = Convert.ToInt32(hfCheckoutAttributeValueId.Value); var cav = CheckoutAttributeManager.GetCheckoutAttributeValueById(cavId, 0); if (cav != null) { var content = CheckoutAttributeManager.GetCheckoutAttributeValueLocalizedByCheckoutAttributeValueIdAndLanguageId(cavId, languageId); if (content != null) { txtLocalizedName.Text = content.Name; } } } }