protected void SaveButton_Click(object sender, EventArgs e) { if (Page.IsValid) { // UPDATE THE SETTINGS StoreSettingsManager settings = AbleContext.Current.Store.Settings; settings.AffiliateParameterName = StringHelper.Truncate(AffiliateParameter.Text.Trim(), 200); settings.AffiliateTrackerUrl = StringHelper.Truncate(TrackerUrl.Text.Trim(), 200); settings.AffiliateAllowSelfSignup = SelfSignup.Checked; settings.AffiliateReferralRule = AlwaysConvert.ToEnum <ReferralRule>(AffiliateReferralRule.SelectedValue, ReferralRule.NewSignupsOnly); settings.AffiliatePersistence = ((AffiliateReferralPeriod)AlwaysConvert.ToByte(AffiliatePersistence.SelectedValue)); AffiliateReferralPeriod referralPeriod = ((AffiliateReferralPeriod)AlwaysConvert.ToByte(AffiliatePersistence.SelectedValue)); if ((referralPeriod != AffiliateReferralPeriod.Persistent && referralPeriod != AffiliateReferralPeriod.FirstOrder)) { settings.AffiliateReferralPeriod = AlwaysConvert.ToInt16(ReferralPeriod.Text); } else { settings.AffiliateReferralPeriod = 0; } settings.AffiliateCommissionRate = AlwaysConvert.ToDecimal(CommissionRate.Text); settings.AffiliateCommissionIsPercent = (CommissionType.SelectedIndex > 0); settings.AffiliateCommissionOnTotal = (CommissionType.SelectedIndex == 2); settings.Save(); AffiliateSettingsMessage.Text = string.Format(AffiliateSettingsMessage.Text, LocaleHelper.LocalNow); AffiliateSettingsMessage.Visible = true; } }
protected void SaveButton_Click(object sender, EventArgs e) { short quantity = AlwaysConvert.ToInt16(KitQuantity.Text); if (quantity > 0) { ProductVariant productVariant = null; if (_KitProduct.Product.ProductOptions.Count > 0) { productVariant = ProductVariantDataSource.LoadForOptionList(_KitProduct.Product.Id, selectedOptions); } if (productVariant != null) { _KitProduct.OptionList = productVariant.OptionList; } _KitProduct.Name = DisplayName.Text; _KitProduct.Quantity = quantity; _KitProduct.PriceModeId = AlwaysConvert.ToByte(PriceMode.SelectedIndex); _KitProduct.Price = AlwaysConvert.ToDecimal(Price.Text); _KitProduct.WeightModeId = AlwaysConvert.ToByte(WeightMode.SelectedIndex); _KitProduct.Weight = AlwaysConvert.ToDecimal(Weight.Text); _KitProduct.IsSelected = IsSelected.Checked; _KitProduct.Save(); } Response.Redirect(string.Format("EditKit.aspx?CategoryId={0}&ProductId={1}", _CategoryId, _ProductId)); }
protected void ReferralPeriod_SelectedIndexChanged(object sender, EventArgs e) { AffiliateReferralPeriod referralPeriod = (AffiliateReferralPeriod)AlwaysConvert.ToByte(ReferralPeriod.SelectedValue); EnableReferralDaysUI((referralPeriod != AffiliateReferralPeriod.Persistent && referralPeriod != AffiliateReferralPeriod.FirstOrder)); ReferralDays.Text = _Affiliate.ReferralDays.ToString(); }
private void SaveInputField() { _InputField.Name = Name.Text; if (!_InputField.IsMerchantField) { _InputField.IsRequired = Required.Checked; } _InputField.UserPrompt = UserPrompt.Text; _InputField.InputTypeId = AlwaysConvert.ToInt16(InputTypeId.SelectedValue); _InputField.Columns = AlwaysConvert.ToByte(Columns.Text); _InputField.Rows = AlwaysConvert.ToByte(Rows.Text); _InputField.MaxLength = AlwaysConvert.ToInt16(MaxLength.Text); if (_InputField.IsMerchantField) { _InputField.UseShopBy = UseShopBy.Checked; } //_InputField.IsMerchantField = (bool)ViewState["IsMerchantField"]; //LOOP THROUGH GRID ROWS AND SET MATRIX int rowIndex = 0; int selectedChoice = AlwaysConvert.ToInt(Request.Form["SelectedChoice"]); foreach (GridViewRow row in ChoicesGrid.Rows) { string choiceText = ((TextBox)row.FindControl("ChoiceText")).Text; string choiceValue = ((TextBox)row.FindControl("ChoiceValue")).Text; bool isSelected = ((CheckBox)row.FindControl("IsSelected")).Checked; InputChoice thisChoice = _InputField.InputChoices[rowIndex]; thisChoice.ChoiceText = choiceText; thisChoice.ChoiceValue = choiceValue; thisChoice.IsSelected = isSelected; rowIndex++; } _InputField.Save(); }
protected void AffiliatePersistence_SelectedIndexChanged(Object sender, EventArgs e) { AffiliateReferralPeriod referralPeriod = (AffiliateReferralPeriod)AlwaysConvert.ToByte(AffiliatePersistence.SelectedValue); trReferralPeriod.Visible = (referralPeriod != AffiliateReferralPeriod.Persistent && referralPeriod != AffiliateReferralPeriod.FirstOrder); ReferralPeriod.Text = AbleContext.Current.Store.Settings.AffiliateReferralPeriod.ToString();; }
protected OrderFilter GetOrderFilter() { // CREATE CRITERIA INSTANCE OrderFilter criteria = new OrderFilter(); if (OrderStartDate.SelectedStartDate > DateTime.MinValue) { criteria.OrderDateStart = OrderStartDate.SelectedStartDate; } if (OrderEndDate.SelectedEndDate > DateTime.MinValue && OrderEndDate.SelectedEndDate < DateTime.MaxValue) { criteria.OrderDateEnd = OrderEndDate.SelectedEndDate; } criteria.OrderNumberRange = OrderNumberFilter.Text; criteria.PaymentStatus = (OrderPaymentStatus)AlwaysConvert.ToByte(PaymentStatusFilter.SelectedValue); criteria.ShipmentStatus = (OrderShipmentStatus)AlwaysConvert.ToByte(ShipmentStatusFilter.SelectedValue); // ADD IN ORDER STATUS FILTER int statusId = 0; if (StatusFilter.SelectedValue == "-2") { IList <OrderStatus> statuses = OrderStatusDataSource.LoadAll(); foreach (OrderStatus status in statuses) { if (status.IsValid) { criteria.OrderStatus.Add(status.Id); } } } else if (StatusFilter.SelectedValue == "-3") { IList <OrderStatus> statuses = OrderStatusDataSource.LoadAll(); foreach (OrderStatus status in statuses) { if (!status.IsValid) { criteria.OrderStatus.Add(status.Id); } } } else { statusId = AlwaysConvert.ToInt(StatusFilter.SelectedValue); if (statusId > 0) { criteria.OrderStatus.Add(statusId); } } // ADD IN KEYWORD FILTER criteria.Keyword = KeywordSearchText.Text; criteria.KeywordField = (KeywordFieldType)Enum.Parse(typeof(KeywordFieldType), KeywordSearchField.SelectedValue, true); // RETURN THE CRITERIA OBJECT Session["OrderFilter"] = criteria; Session["OrderFilterSelectedStatus"] = StatusFilter.SelectedValue; return(criteria); }
protected void ProductSearchDs_Selecting(object sender, ObjectDataSourceSelectingEventArgs e) { CrossSellState csf = (CrossSellState)AlwaysConvert.ToByte(Filter.SelectedValue); e.InputParameters["crossSellFilter"] = csf; SearchResultsGrid.Columns[2].Visible = ShowImages.Checked; if (_DisplayCategorySearch) { e.InputParameters["categoryId"] = AlwaysConvert.ToInt(HiddenSelectedCategoryId.Value); } }
protected void SaveButton_Click(object sender, System.EventArgs e) { if (Page.IsValid) { _Affiliate.Name = Name.Text; _Affiliate.ReferralDays = AlwaysConvert.ToInt16(ReferralDays.Text); _Affiliate.CommissionRate = AlwaysConvert.ToDecimal(CommissionRate.Text); _Affiliate.CommissionIsPercent = (CommissionType.SelectedIndex > 0); _Affiliate.CommissionOnTotal = (CommissionType.SelectedIndex == 2); _Affiliate.WebsiteUrl = WebsiteUrl.Text; _Affiliate.Email = Email.Text; _Affiliate.Group = GroupDataSource.Load(AlwaysConvert.ToInt(AffiliateGroup.SelectedValue)); AffiliateReferralPeriod referralPeriod = (AffiliateReferralPeriod)AlwaysConvert.ToByte(ReferralPeriod.SelectedValue); _Affiliate.ReferralPeriodId = (byte)referralPeriod; _Affiliate.ReferralPeriod = referralPeriod; if (referralPeriod != AffiliateReferralPeriod.Persistent && referralPeriod != AffiliateReferralPeriod.FirstOrder) { _Affiliate.ReferralDays = AlwaysConvert.ToInt16(ReferralDays.Text); } else { _Affiliate.ReferralDays = 0; } //ADDRESS INFORMATION _Affiliate.FirstName = FirstName.Text; _Affiliate.LastName = LastName.Text; _Affiliate.Company = Company.Text; _Affiliate.Address1 = Address1.Text; _Affiliate.Address2 = Address2.Text; _Affiliate.City = City.Text; _Affiliate.Province = Province.Text; _Affiliate.PostalCode = PostalCode.Text; _Affiliate.CountryCode = CountryCode.SelectedValue; _Affiliate.PhoneNumber = PhoneNumber.Text; _Affiliate.FaxNumber = FaxNumber.Text; _Affiliate.MobileNumber = MobileNumber.Text; _Affiliate.Save(); // SAVE TAX ID User user = _Affiliate.Group != null && _Affiliate.Group.Users.Count > 0 ? _Affiliate.Group.Users[0] : null; if (user != null) { user.TaxExemptionReference = TaxId.Text; user.Save(); } SavedMessage.Visible = true; SavedMessage.Text = string.Format(SavedMessage.Text, LocaleHelper.LocalNow); } }
protected void SaveButton_Click(object sender, System.EventArgs e) { //Save the option itself _Option.Name = OptionName.Text; _Option.HeaderText = HeaderText.Text; _Option.ShowThumbnails = ShowThumbnails.Checked; _Option.ThumbnailColumns = AlwaysConvert.ToByte(ThumbnailColumns.Text); _Option.ThumbnailHeight = AlwaysConvert.ToInt16(ThumbnailHeight.Text); _Option.ThumbnailWidth = AlwaysConvert.ToInt16(ThumbnailWidth.Text); _Option.Save(); SavedMessage.Text = string.Format(SavedMessage.Text, LocaleHelper.LocalNow); SavedMessage.Visible = true; }
private void SaveWishlist() { Wishlist wishlist = AbleContext.Current.User.PrimaryWishlist; int rowIndex = 0; foreach (GridViewRow saverow in WishlistGrid.Rows) { int wishlistItemId = (int)WishlistGrid.DataKeys[rowIndex].Value; int itemIndex = wishlist.WishlistItems.IndexOf(wishlistItemId); if (itemIndex > -1) { WishlistItem item = wishlist.WishlistItems[itemIndex]; TextBox desired = saverow.FindControl("Desired") as TextBox; if (desired != null) { item.Desired = AlwaysConvert.ToInt16(desired.Text, item.Desired); if (item.Desired <= 0) { item.Delete(); } } DropDownList priority = saverow.FindControl("Priority") as DropDownList; if (priority != null) { item.Priority = AlwaysConvert.ToByte(priority.SelectedValue); if (item.Priority < 0) { item.Priority = 0; } if (item.Priority > 4) { item.Priority = 4; } } TextBox comment = saverow.FindControl("Comment") as TextBox; if (comment != null) { item.Comment = StringHelper.StripHtml(comment.Text); } rowIndex++; } } wishlist.Save(); }
private int CreateInput() { if (Page.IsValid) { InputField input = new InputField(); input.ProductTemplateId = _ProductTemplateId; input.Name = Name.Text; input.UserPrompt = UserPrompt.Text; input.InputTypeId = AlwaysConvert.ToInt16(InputTypeId.SelectedValue); input.Columns = AlwaysConvert.ToByte(Columns.Text); input.Rows = AlwaysConvert.ToByte(Rows.Text); input.MaxLength = AlwaysConvert.ToInt16(MaxLength.Text); input.IsMerchantField = (bool)ViewState["IsMerchantField"]; if (!input.IsMerchantField) { input.IsRequired = Required.Checked; } input.UseShopBy = trUseShopBy.Visible ? UseShopBy.Checked : false; input.Save(); return(input.Id); } return(0); }
private ShipStationExportOptions GetExportOptions() { ShipStationExportOptions exportOptions = new ShipStationExportOptions(); if (OrderStartDate.SelectedStartDate > DateTime.MinValue) { exportOptions.FromDate = OrderStartDate.SelectedStartDate; } if (OrderEndDate.SelectedEndDate > DateTime.MinValue && OrderEndDate.SelectedEndDate < DateTime.MaxValue) { exportOptions.EndDate = OrderEndDate.SelectedEndDate; } exportOptions.IncludeExportedOrders = IncludeExported.Checked; exportOptions.NewOrderStatusId = AlwaysConvert.ToInt(NewOrderStatus.SelectedValue); exportOptions.OrderNumbers = OrderNumberFilter.Text.Trim(); exportOptions.OrderStatusId = AlwaysConvert.ToInt(StatusFilter.SelectedValue); exportOptions.ShipmentStatus = (OrderShipmentStatus)AlwaysConvert.ToByte(ShipmentStatusFilter.SelectedValue); exportOptions.PaymentStatus = (OrderPaymentStatus)AlwaysConvert.ToByte(PaymentStatusFilter.SelectedValue); // RETURN THE CRITERIA OBJECT return(exportOptions); }
protected void SaveButton_Click(object sender, EventArgs e) { if (Page.IsValid) { // DUPLICATE TAX RULE NAMES SHOULD NOT BE ALLOWED int taxRuleId = TaxRuleDataSource.GetTaxRuleIdByName(Name.Text); if (taxRuleId > 0) { // TAX RULE(S) WITH SAME NAME ALREADY EXIST CustomValidator customNameValidator = new CustomValidator(); customNameValidator.ControlToValidate = "Name"; customNameValidator.Text = "*"; customNameValidator.ErrorMessage = "A Tax Rule with the same name already exists."; customNameValidator.IsValid = false; phNameValidator.Controls.Add(customNameValidator); return; } //SAVE TAX RULE TaxRule taxRule = new TaxRule(); taxRule.Name = Name.Text; taxRule.TaxRate = AlwaysConvert.ToDecimal(TaxRate.Text); taxRule.UseBillingAddress = AlwaysConvert.ToBool(UseBillingAddress.SelectedValue.Equals("1"), false); taxRule.TaxCodeId = AlwaysConvert.ToInt(TaxCode.SelectedValue); taxRule.Priority = AlwaysConvert.ToInt16(Priority.Text); taxRule.UsePerItemTax = PerUnitCalculation.Checked; taxRule.Save(); //UPDATE TAX CODES taxRule.TaxCodes.Clear(); taxRule.Save(); foreach (ListItem listItem in TaxCodes.Items) { if (listItem.Selected) { TaxCode taxCode = TaxCodeDataSource.Load(AlwaysConvert.ToInt(listItem.Value)); taxRule.TaxCodes.Add(taxCode); listItem.Selected = false; } } //UPDATE ZONES taxRule.ShipZones.Clear(); if (ZoneRule.SelectedIndex > 0) { foreach (ListItem item in ZoneList.Items) { ShipZone shipZone = ShipZoneDataSource.Load(AlwaysConvert.ToInt(item.Value)); if (item.Selected) { taxRule.ShipZones.Add(shipZone); } } } //UPDATE GROUP FILTER taxRule.Groups.Clear(); taxRule.GroupRule = (FilterRule)GroupRule.SelectedIndex; if (taxRule.GroupRule != FilterRule.All) { foreach (ListItem item in GroupList.Items) { Group group = GroupDataSource.Load(AlwaysConvert.ToInt(item.Value)); if (item.Selected) { taxRule.Groups.Add(group); } } } //IF NO GROUPS ARE SELECTED, APPLY TO ALL GROUPS if (taxRule.Groups.Count == 0) { taxRule.GroupRule = FilterRule.All; } // UPDATE ROUNDING RULE taxRule.RoundingRuleId = AlwaysConvert.ToByte(RoundingRule.SelectedValue); taxRule.Save(); //UPDATE THE ADD MESSAGE Response.Redirect("TaxRules.aspx"); } }
private bool SaveReview() { // SAVE REVIEWER PROFILE User user = AbleContext.Current.User; //MAKE SURE ANONYMOUS USER DOES NOT TRY TO USE REGISTERED USER EMAIL if (user.IsAnonymous) { IList <User> users = UserDataSource.LoadForEmail(Email.Text); if (users.Count > 0) { CustomValidator invalidEmail = new CustomValidator(); invalidEmail.Text = "*"; invalidEmail.ErrorMessage = "Your email address is already registered. You must log in to post the review."; invalidEmail.IsValid = false; invalidEmail.ValidationGroup = "ProductReviewForm"; phEmailValidators.Controls.Add(invalidEmail); return(false); } user.Save(); } _Profile = user.ReviewerProfile; // TRY TO LOAD PROFILE BY EMAIL if (_Profile == null) { _Profile = ReviewerProfileDataSource.LoadForEmail(Email.Text); if (_Profile != null) { if (_ProductReview == null) { _ProductReview = ProductReviewDataSource.LoadForProductAndReviewerProfile(_ProductId, _Profile.Id); } // ATTEMPT TO SUBMIT A 2ND REVIEW FOR THIS PRODUCT BY AN ANNONYMOUS USER if (_ProductReview != null && String.IsNullOrEmpty(Request.Form[OverwriteReviewButton.UniqueID])) { // WARN THE USER THAT A REVIEW IS ALREADY SUBMITTED BY SAME EMAIL ADDRESS CustomValidator reviewAlreadySubmitted = new CustomValidator(); reviewAlreadySubmitted.Text = "*"; reviewAlreadySubmitted.ErrorMessage = "You have already submitted a review for this product, do you want to overwrite your previous review?"; reviewAlreadySubmitted.IsValid = false; reviewAlreadySubmitted.ValidationGroup = "ProductReviewForm"; phEmailValidators.Controls.Add(reviewAlreadySubmitted); OverwriteReviewButton.Visible = true; SubmitReviewButton.Visible = false; return(false); } } } if (_Profile == null) { _Profile = new ReviewerProfile(); } _Profile.Email = ((user.IsAnonymous && String.IsNullOrEmpty(GetUserEmail())) ? Email.Text : GetUserEmail()); _Profile.DisplayName = StringHelper.StripHtml(Name.Text, true); _Profile.Location = StringHelper.StripHtml(Location.Text, true); _Profile.Save(); //IF PROFILE IS NULL, AN ERROR OCCURRED VALIDATING THE EMAIL if (_Profile != null) { //EITHER LOAD THE EXISTING REVIEW OR CREATE NEW if (_ProductReview == null) { _ProductReview = ProductReviewDataSource.LoadForProductAndReviewerProfile(_ProductId, _Profile.Id); } if (_ProductReview == null) { _ProductReview = new ProductReview(); } _ProductReview.ReviewerProfile = _Profile; _ProductReview.Product = _Product; _ProductReview.ReviewDate = LocaleHelper.LocalNow; _ProductReview.Rating = AlwaysConvert.ToByte(Rating.SelectedValue); _ProductReview.ReviewTitle = StringHelper.StripHtml(ReviewTitle.Text, true); _ProductReview.ReviewBody = StringHelper.StripHtml(ReviewBody.Text, true); _ProductReview.Save(AbleContext.Current.User, true, true); return(true); } return(false); }
private void UpdateField(Category category, string field) { if (field != null) { string cleanField = field.Trim().ToLowerInvariant(); string fieldValue = GetValueFromFormPost(category.Id, cleanField); switch (cleanField) { case "customurl": bool isValid = false; string oldCustomUrl = category.CustomUrl; string newCustomUrl = fieldValue.Trim(); if (!string.IsNullOrEmpty(newCustomUrl) && string.IsNullOrEmpty(oldCustomUrl) || oldCustomUrl != newCustomUrl) { isValid = !CustomUrlDataSource.IsAlreadyUsed(newCustomUrl); } else { isValid = true; } if (isValid) { category.CustomUrl = fieldValue; } break; case "displaypage": if (IsValidListItemValue(category, field, fieldValue, true)) { category.Webpage = WebpageDataSource.Load(AlwaysConvert.ToInt(fieldValue)); } break; case "visibilityid": if (IsValidListItemValue(category, field, fieldValue, false)) { category.VisibilityId = AlwaysConvert.ToByte(fieldValue); } break; case "description": category.Description = fieldValue; break; case "metadescription": category.MetaDescription = fieldValue; break; case "metakeywords": category.MetaKeywords = fieldValue; break; case "name": if (!string.IsNullOrEmpty(fieldValue)) { category.Name = fieldValue; } break; case "summary": category.Summary = fieldValue; break; case "thumbnailalttext": category.ThumbnailAltText = fieldValue; break; case "thumbnailurl": category.ThumbnailUrl = fieldValue; break; case "pagetitle": category.Title = fieldValue; break; case "htmlhead": category.HtmlHead = fieldValue; break; } } }
private void SaveProduct() { // get a reference to the loaded product // this assists in file comparions between add/edit page Product product = _Product; // basic product information pane product.Name = Name.Text; product.ManufacturerId = AlwaysConvert.ToInt(ManufacturerList.SelectedValue); product.Price = AlwaysConvert.ToDecimal(Price.Text); product.ModelNumber = ModelNumber.Text; product.MSRP = AlwaysConvert.ToDecimal(Msrp.Text); product.Weight = AlwaysConvert.ToDecimal(Weight.Text); product.CostOfGoods = AlwaysConvert.ToDecimal(CostOfGoods.Text); product.GTIN = Gtin.Text; product.Sku = Sku.Text; product.IsFeatured = IsFeatured.Checked; // descriptions product.Summary = Summary.Text; product.Description = Description.Text; product.ExtendedDescription = ExtendedDescription.Text; // shipping, tax, and inventory product.WarehouseId = AlwaysConvert.ToInt(Warehouse.SelectedValue); product.VendorId = AlwaysConvert.ToInt(Vendor.SelectedValue); product.ShippableId = (byte)AlwaysConvert.ToInt(IsShippable.SelectedValue); product.Length = AlwaysConvert.ToDecimal(Length.Text); product.Width = AlwaysConvert.ToDecimal(Width.Text); product.Height = AlwaysConvert.ToDecimal(Height.Text); product.TaxCodeId = AlwaysConvert.ToInt(TaxCode.SelectedValue); if (CurrentInventoryMode.Visible) { product.InventoryModeId = AlwaysConvert.ToByte(CurrentInventoryMode.SelectedIndex); if (product.InventoryMode == InventoryMode.Product) { product.InStock = AlwaysConvert.ToInt(InStock.Text); product.AvailabilityDate = AvailabilityDate.SelectedDate; product.InStockWarningLevel = AlwaysConvert.ToInt(LowStock.Text); product.AllowBackorder = BackOrder.Checked; } else if (product.InventoryMode == InventoryMode.Variant) { product.AllowBackorder = BackOrder.Checked; } product.EnableRestockNotifications = EnableRestockNotifications.Checked; } // advanced settings product.WrapGroupId = AlwaysConvert.ToInt(WrapGroup.SelectedValue); product.AllowReviews = AllowReviewsPanel.Visible ? AllowReviews.Checked : true; product.Visibility = (CatalogVisibility)Visibility.SelectedIndex; product.HidePrice = HidePrice.Checked; product.Webpage = WebpageDataSource.Load(AlwaysConvert.ToInt(DisplayPage.SelectedValue)); product.IsProhibited = IsProhibited.Checked; product.IsGiftCertificate = GiftCertificate.Checked; product.DisablePurchase = DisablePurchase.Checked; product.UseVariablePrice = UseVariablePrice.Checked; product.MinimumPrice = AlwaysConvert.ToDecimal(MinPrice.Text); product.MaximumPrice = AlwaysConvert.ToDecimal(MaxPrice.Text); product.HandlingCharges = AlwaysConvert.ToDecimal(HandlingCharges.Text); product.MinQuantity = AlwaysConvert.ToInt16(MinQuantity.Text); product.MaxQuantity = AlwaysConvert.ToInt16(MaxQuantity.Text); product.HtmlHead = HtmlHead.Text.Trim(); product.SearchKeywords = SearchKeywords.Text.Trim(); _Product.EnableGroups = AlwaysConvert.ToBool(EnableGroups.SelectedValue, false); _Product.ProductGroups.DeleteAll(); foreach (ListItem item in ProductGroups.Items) { if (item.Selected) { int groupId = AlwaysConvert.ToInt(item.Value); ProductGroup pg = new ProductGroup(_Product, GroupDataSource.Load(groupId)); _Product.ProductGroups.Add(pg); } } // search engines and feeds product.CustomUrl = CustomUrl.Text; CustomUrlValidator.OriginalValue = _Product.CustomUrl; product.ExcludeFromFeed = !IncludeInFeed.Checked; product.Title = ProductTitle.Text.Trim(); product.MetaDescription = MetaDescriptionValue.Text.Trim(); product.MetaKeywords = MetaKeywordsValue.Text.Trim(); product.GoogleCategory = GoogleCategory.Text; product.Condition = Condition.SelectedValue; product.Gender = Gender.SelectedValue; product.AgeGroup = AgeGroup.SelectedValue; product.Color = Color.Text; product.Size = Size.Text; product.AdwordsGrouping = AdwordsGrouping.Text; product.AdwordsLabels = AdwordsLabels.Text; product.ExcludedDestination = ExcludedDestination.SelectedValue; product.AdwordsRedirect = AdwordsRedirect.Text; product.PublishFeedAsVariants = PublishAsVariants.Checked; // TAX CLOUD PRODUCT TIC if (trTIC.Visible && !string.IsNullOrEmpty(HiddenTIC.Value)) { product.TIC = AlwaysConvert.ToInt(HiddenTIC.Value); } else { product.TIC = null; } // save product product.Save(); ModalPopupExtender.Hide(); }
protected void ExportButton_Click(Object sender, EventArgs e) { GenericExportManager <InventorySummary> exportManager = GenericExportManager <InventorySummary> .Instance; GenericExportOptions <InventorySummary> options = new GenericExportOptions <InventorySummary>(); options.CsvFields = new string[] { "Name", "InStock", "InStockWarningLevel", "AvailabilityDate", "VisibilityId" }; IList <ProductInventoryDetail> inventoryDetail = ProductInventoryDataSource.GetLowProductInventory((InventoryLevel)AlwaysConvert.ToByte(InventoryLevel.SelectedValue), AlwaysConvert.ToInt(Manufacturers.SelectedValue), AlwaysConvert.ToInt(Vendors.SelectedValue)); IList <InventorySummary> inventorySummaries = new List <InventorySummary>(); foreach (ProductInventoryDetail detailItem in inventoryDetail) { inventorySummaries.Add(new InventorySummary(GetName(detailItem), detailItem.InStock, detailItem.InStockWarningLevel, detailItem.AvailabilityDate, detailItem.VisibilityId)); } options.ExportData = inventorySummaries; options.FileTag = string.Format("PRODUCT_LOW_INVENTORY({0})", LocaleHelper.LocalNow.ToShortDateString()); exportManager.BeginExport(options); }
protected void InitializeCatalogItems() { String items = Request.QueryString["Objects"]; if (String.IsNullOrEmpty(items)) { return; } String[] itemsArray = items.Split(','); List <String> categoryIds = new List <String>(); List <String> productIds = new List <String>(); List <String> linkIds = new List <String>(); List <String> webpageIds = new List <String>(); // Sort out items in saperate lists foreach (String item in itemsArray) { String[] itemValues = item.Split(':'); int catalogNodeId = AlwaysConvert.ToInt(itemValues[0]); CatalogNodeType catalogNodeType = (CatalogNodeType)AlwaysConvert.ToByte(itemValues[1]); switch (catalogNodeType) { case CatalogNodeType.Category: categoryIds.Add(catalogNodeId.ToString()); break; case CatalogNodeType.Product: productIds.Add(catalogNodeId.ToString()); break; case CatalogNodeType.Link: linkIds.Add(catalogNodeId.ToString()); break; case CatalogNodeType.Webpage: webpageIds.Add(catalogNodeId.ToString()); break; } } trIncludeContents.Visible = (categoryIds.Count > 0); if (categoryIds.Count > 0) { ICriteria criteria = CommerceBuilder.DomainModel.NHibernateHelper.CreateCriteria <Category>(); criteria.Add(Restrictions.In("Id", categoryIds.ToArray())); _Categories = CategoryDataSource.LoadForCriteria(criteria); if (_Categories != null && _Categories.Count > 0) { foreach (Category category in _Categories) { _CatalogItems.Add(category); } } } if (productIds.Count > 0) { ICriteria criteria = CommerceBuilder.DomainModel.NHibernateHelper.CreateCriteria <Product>(); criteria.Add(Restrictions.In("Id", productIds.ToArray())); _Products = ProductDataSource.LoadForCriteria(criteria); if (_Products != null && _Products.Count > 0) { foreach (Product product in _Products) { _CatalogItems.Add(product); } } } if (linkIds.Count > 0) { ICriteria criteria = CommerceBuilder.DomainModel.NHibernateHelper.CreateCriteria <Link>(); criteria.Add(Restrictions.In("Id", linkIds.ToArray())); _Links = LinkDataSource.LoadForCriteria(criteria); if (_Links != null && _Links.Count > 0) { foreach (Link link in _Links) { _CatalogItems.Add(link); } } } if (webpageIds.Count > 0) { ICriteria criteria = CommerceBuilder.DomainModel.NHibernateHelper.CreateCriteria <Webpage>(); criteria.Add(Restrictions.In("Id", webpageIds.ToArray())); _Webpages = WebpageDataSource.LoadForCriteria(criteria); if (_Webpages != null && _Webpages.Count > 0) { foreach (Webpage webpage in _Webpages) { _CatalogItems.Add(webpage); } } } if (!Page.IsPostBack) { if (_CatalogItems.Count == 1) { ICatalogable catalogable = _CatalogItems[0]; switch (catalogable.Visibility) { case CatalogVisibility.Public: VisPublic.Checked = true; break; case CatalogVisibility.Private: VisPrivate.Checked = true; break; case CatalogVisibility.Hidden: VisHidden.Checked = true; break; default: VisPrivate.Checked = true; break; } } else if (_CatalogItems.Count > 1) { VisPrivate.Checked = false; VisPublic.Checked = false; VisHidden.Checked = false; } } }
/// <summary> /// Parses the given input value and converts it to a byte. Default return value is 0. /// </summary> /// <param name="parseValue">The input value to parse</param> /// <returns>The converted byte value</returns> public static byte ToByte(object parseValue) { return(AlwaysConvert.ToByte(parseValue, 0)); }
protected void AddButton_Click(object sender, EventArgs e) { if (Page.IsValid) { if (!DigitalGoodNameExists(Name.Text)) { string fileName = Path.GetFileName(ServerFileName.Text); DigitalGood dg = new DigitalGood(); dg.ServerFileName = _RelativeDigitalGoodPath + fileName; dg.Name = Name.Text; dg.FileSize = new FileInfo(Path.Combine(_DigitalGoodPath, fileName)).Length; dg.FileName = string.IsNullOrEmpty(DownloadName.Text) ? fileName : DownloadName.Text; dg.ActivationModeId = AlwaysConvert.ToByte(ActivationMode.SelectedValue); dg.MaxDownloads = AlwaysConvert.ToByte(MaxDownloads.Text); int tempDays = AlwaysConvert.ToInt(ActivationTimeoutDays.Text); int tempHours = AlwaysConvert.ToInt(ActivationTimeoutHours.Text); int tempMinutes = AlwaysConvert.ToInt(ActivationTimeoutMinutes.Text); if ((tempDays > 0) || (tempHours > 0) || (tempMinutes > 0)) { dg.ActivationTimeout = string.Format("{0},{1},{2}", tempDays, tempHours, tempMinutes); } else { dg.ActivationTimeout = string.Empty; } tempDays = AlwaysConvert.ToInt(DownloadTimeoutDays.Text); tempHours = AlwaysConvert.ToInt(DownloadTimeoutHours.Text); tempMinutes = AlwaysConvert.ToInt(DownloadTimeoutMinutes.Text); if ((tempDays > 0) || (tempHours > 0) || (tempMinutes > 0)) { dg.DownloadTimeout = string.Format("{0},{1},{2}", tempDays, tempHours, tempMinutes); } else { dg.DownloadTimeout = string.Empty; } dg.Save(); // SEE WHETHER WE ARE SUPPOSED TO EDIT AFTER SAVING if (((WebControl)sender).ID == "AddAndEditButton") { // REDIRECT TO THE EDIT PAGE Response.Redirect("~/Admin/DigitalGoods/EditDigitalGood.aspx?DigitalGoodId=" + dg.Id); } // UPDATE THE FILE LIST int index = IndexOfFile(fileName); if (index > -1) { FileDigitalGood fdg = _FileList[index]; if (fdg.DigitalGoods == null) { fdg.DigitalGoods = new List <DigitalGood>(); } fdg.DigitalGoods.Add(dg); } // REBIND THE FILE GRID BindFileGrid(); } else { CustomValidator uniqueName = new CustomValidator(); uniqueName.IsValid = false; uniqueName.ControlToValidate = "Name"; uniqueName.ErrorMessage = "The specified name already exists. You must use an alternate name."; uniqueName.Text = "*"; uniqueName.ValidationGroup = "Add"; phUniqueName.Controls.Add(uniqueName); AddPopup.Show(); } } else { AddPopup.Show(); } }
protected void AddButton_Click(object sender, EventArgs e) { if (Page.IsValid) { if (!DigitalGoodNameExists(Name.Text)) { // SET THE DIGITAL GOOD PATH string digitalGoodPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "App_Data\\DigitalGoods"); // SAVE THE BINARY FILE DATA HttpPostedFile file = null; if (Request.Files.Count > 0) { file = Request.Files[0]; } bool fileUploaded = ((file != null) && (file.ContentLength > 0)); if (fileUploaded) { string fileName = string.IsNullOrEmpty(UploadFileName.Text) ? Path.GetFileName(file.FileName) : UploadFileName.Text; string filePath = Path.Combine(digitalGoodPath, fileName); if (FileHelper.IsExtensionValid(fileName, AbleContext.Current.Store.Settings.FileExt_DigitalGoods)) { if (!File.Exists(filePath) || UploadOverwrite.Checked) { int fileLength = file.ContentLength; Byte[] buffer = new byte[fileLength]; file.InputStream.Read(buffer, 0, fileLength); File.WriteAllBytes(filePath, buffer); // RECORD THE DIGITAL GOOD DigitalGood dg = new DigitalGood(); dg.ServerFileName = fileName; dg.Name = Name.Text; dg.FileSize = fileLength; dg.FileName = fileName; dg.ActivationModeId = AlwaysConvert.ToByte(ActivationMode.SelectedValue); dg.MaxDownloads = AlwaysConvert.ToByte(MaxDownloads.Text); int tempDays = AlwaysConvert.ToInt(ActivationTimeoutDays.Text); int tempHours = AlwaysConvert.ToInt(ActivationTimeoutHours.Text); int tempMinutes = AlwaysConvert.ToInt(ActivationTimeoutMinutes.Text); if ((tempDays > 0) || (tempHours > 0) || (tempMinutes > 0)) { dg.ActivationTimeout = string.Format("{0},{1},{2}", tempDays, tempHours, tempMinutes); } else { dg.ActivationTimeout = string.Empty; } tempDays = AlwaysConvert.ToInt(DownloadTimeoutDays.Text); tempHours = AlwaysConvert.ToInt(DownloadTimeoutHours.Text); tempMinutes = AlwaysConvert.ToInt(DownloadTimeoutMinutes.Text); if ((tempDays > 0) || (tempHours > 0) || (tempMinutes > 0)) { dg.DownloadTimeout = string.Format("{0},{1},{2}", tempDays, tempHours, tempMinutes); } else { dg.DownloadTimeout = string.Empty; } dg.Save(); // SEE WHETHER WE ARE SUPPOSED TO EDIT AFTER SAVING if (((WebControl)sender).ID == "AddAndEditButton") { // REDIRECT TO THE EDIT PAGE Response.Redirect("~/Admin/DigitalGoods/EditDigitalGood.aspx?DigitalGoodId=" + dg.Id); } else { // REDIRECT BACK TO THIS PAGE TO PREVENT REFRESH ISSUES WITH FILE UPLOAD Response.Redirect(Request.ServerVariables["SCRIPT_NAME"]); } } else { CustomValidator overwrite = new CustomValidator(); overwrite.IsValid = false; overwrite.ControlToValidate = "UploadFileName"; overwrite.ErrorMessage = "The target file '" + fileName + "' already exists. Either allow overwrite or use an alternate file name."; overwrite.Text = "*"; overwrite.ValidationGroup = "Add"; phUploadOverwrite.Controls.Add(overwrite); AddPopup.Show(); } } else { CustomValidator filetype = new CustomValidator(); filetype.IsValid = false; filetype.ControlToValidate = "UploadFileName"; filetype.ErrorMessage = "The target file '" + fileName + "' does not have a valid file extension."; filetype.Text = "*"; filetype.ValidationGroup = "Add"; phUploadFileTypes.Controls.Add(filetype); AddPopup.Show(); } } UploadFileName.Text = string.Empty; UploadOverwrite.Checked = false; } else { CustomValidator uniqueName = new CustomValidator(); uniqueName.IsValid = false; uniqueName.ControlToValidate = "Name"; uniqueName.ErrorMessage = "The specified display name already exists. You must use an alternate name."; uniqueName.Text = "*"; uniqueName.ValidationGroup = "Add"; phUniqueName.Controls.Add(uniqueName); AddPopup.Show(); } } else { AddPopup.Show(); } }
private bool Save() { if (!Page.IsValid) { return(false); } _DigitalGood.Name = Name.Text; _DigitalGood.FileName = FileName.Text; _DigitalGood.MediaKey = MediaKey.Text; _DigitalGood.ActivationModeId = AlwaysConvert.ToByte(ActivationMode.SelectedValue); _DigitalGood.MaxDownloads = AlwaysConvert.ToByte(MaxDownloads.Text); int tempDays = AlwaysConvert.ToInt(ActivationTimeoutDays.Text); int tempHours = AlwaysConvert.ToInt(ActivationTimeoutHours.Text); int tempMinutes = AlwaysConvert.ToInt(ActivationTimeoutMinutes.Text); if ((tempDays > 0) || (tempHours > 0) || (tempMinutes > 0)) { _DigitalGood.ActivationTimeout = string.Format("{0},{1},{2}", tempDays, tempHours, tempMinutes); } else { _DigitalGood.ActivationTimeout = string.Empty; } tempDays = AlwaysConvert.ToInt(DownloadTimeoutDays.Text); tempHours = AlwaysConvert.ToInt(DownloadTimeoutHours.Text); tempMinutes = AlwaysConvert.ToInt(DownloadTimeoutMinutes.Text); if ((tempDays > 0) || (tempHours > 0) || (tempMinutes > 0)) { _DigitalGood.DownloadTimeout = string.Format("{0},{1},{2}", tempDays, tempHours, tempMinutes); } else { _DigitalGood.DownloadTimeout = string.Empty; } //VALIDATE THE FILE SIE if (System.IO.File.Exists(_DigitalGood.AbsoluteFilePath)) { //READ THE EXISTING FILE SIZE System.IO.FileInfo fi = new System.IO.FileInfo(_DigitalGood.AbsoluteFilePath); _DigitalGood.FileSize = fi.Length; } //CHECK THE README TEXT _DigitalGood.LicenseAgreementId = AlwaysConvert.ToInt(LicenseAgreement.SelectedValue); _DigitalGood.LicenseAgreementModeId = AlwaysConvert.ToByte(LicenseAgreementMode.SelectedValue); _DigitalGood.ReadmeId = AlwaysConvert.ToInt(Readme.SelectedValue); _DigitalGood.EnableSerialKeys = EnableSerialKeys.Checked; //Check serial key provider if (string.IsNullOrEmpty(KeySource.SelectedValue) || KeySource.SelectedValue.Equals("0")) { _DigitalGood.SerialKeyProviderId = null; } else { _DigitalGood.SerialKeyProviderId = KeySource.SelectedValue; } //Check fulfillment mode if (FulfillmentMode.SelectedValue.Equals("0")) { _DigitalGood.FulfillmentMode = CommerceBuilder.DigitalDelivery.FulfillmentMode.Manual; } else if (FulfillmentMode.SelectedValue.Equals("1")) { _DigitalGood.FulfillmentMode = CommerceBuilder.DigitalDelivery.FulfillmentMode.OnOrder; } else { _DigitalGood.FulfillmentMode = CommerceBuilder.DigitalDelivery.FulfillmentMode.OnPaidOrder; } //Check Activation Email if (string.IsNullOrEmpty(ActivationEmailTemplateList.SelectedValue) || ActivationEmailTemplateList.SelectedValue.Equals("0")) { _DigitalGood.ActivationEmailId = 0; } else { _DigitalGood.ActivationEmailId = AlwaysConvert.ToInt(ActivationEmailTemplateList.SelectedValue); } //Check Fulfillment Email if (string.IsNullOrEmpty(FulfillmentEmailTemplateList.SelectedValue) || FulfillmentEmailTemplateList.SelectedValue.Equals("0")) { _DigitalGood.FulfillmentEmailId = 0; } else { _DigitalGood.FulfillmentEmailId = AlwaysConvert.ToInt(FulfillmentEmailTemplateList.SelectedValue); } _DigitalGood.DigitalGoodGroups.DeleteAll(); foreach (ListItem item in Groups.Items) { if (item.Selected) { int groupId = AlwaysConvert.ToInt(item.Value); DigitalGoodGroup dgg = new DigitalGoodGroup(_DigitalGood, GroupDataSource.Load(groupId)); _DigitalGood.DigitalGoodGroups.Add(dgg); } } _DigitalGood.Save(); ToggleConfigureProvider(); return(true); }
private void SaveShipMethodMatrix() { //UPDATE NAME _ShipMethod.Name = Name.Text; //UPDATE SHIP RATE UpdateRanges(); //UPDATE SURCHARGE _ShipMethod.Surcharge = AlwaysConvert.ToDecimal(Surcharge.Text); if (_ShipMethod.Surcharge < 0) { _ShipMethod.Surcharge = 0; } if (_ShipMethod.Surcharge > 0) { _ShipMethod.SurchargeMode = (SurchargeMode)AlwaysConvert.ToByte(SurchargeMode.SelectedValue); _ShipMethod.SurchargeIsVisible = (SurchargeIsVisible.SelectedIndex > 0); } else { _ShipMethod.SurchargeMode = 0; _ShipMethod.SurchargeIsVisible = false; } if (_ShipMethod.SurchargeIsVisible) { _ShipMethod.SurchargeTaxCodeId = AlwaysConvert.ToInt(SurchargeTaxCode.SelectedValue); } else { _ShipMethod.SurchargeTaxCodeId = 0; } //UPDATE WAREHOUSES _ShipMethod.Warehouses.Clear(); _ShipMethod.Save(); if (UseWarehouseRestriction.SelectedIndex > 0) { foreach (ListItem item in WarehouseList.Items) { Warehouse warehouse = WarehouseDataSource.Load(AlwaysConvert.ToInt(item.Value)); if (item.Selected) { _ShipMethod.Warehouses.Add(warehouse); } } } //UPDATE ZONES _ShipMethod.ShipZones.Clear(); _ShipMethod.Save(); if (UseZoneRestriction.SelectedIndex > 0) { foreach (ListItem item in ZoneList.Items) { ShipZone shipZone = ShipZoneDataSource.Load(AlwaysConvert.ToInt(item.Value)); if (item.Selected) { _ShipMethod.ShipZones.Add(shipZone); } } } //UPDATE ROLES _ShipMethod.Groups.Clear(); _ShipMethod.Save(); if (UseGroupRestriction.SelectedIndex > 0) { foreach (ListItem item in GroupList.Items) { CommerceBuilder.Users.Group group = GroupDataSource.Load(AlwaysConvert.ToInt(item.Value)); if (item.Selected) { _ShipMethod.Groups.Add(group); } } } //UPDATE MIN PURCHASE _ShipMethod.MinPurchase = AlwaysConvert.ToDecimal(MinPurchase.Text); //UPDATE MAX PURCHASE _ShipMethod.MaxPurchase = AlwaysConvert.ToDecimal(MaxPurchase.Text); //UPDATE TAX CODES _ShipMethod.TaxCode = TaxCodeDataSource.Load(AlwaysConvert.ToInt(TaxCode.SelectedValue)); //SAVE METHOD AND REDIRECT TO LIST _ShipMethod.Save(); }
protected void FinishButton_Click(object sender, EventArgs e) { foreach (RepeaterItem ri in SelectedProductRepeater.Items) { HiddenField pid = (HiddenField)ri.FindControl("PID"); int productId = AlwaysConvert.ToInt(pid.Value); Product product = ProductDataSource.Load(productId); if (product == null) { return; } if (!AllProductOptionsSelected(product, ri)) { return; } TextBox KitQuantity = (TextBox)ri.FindControl("KitQuantity"); short quantity = AlwaysConvert.ToInt16(KitQuantity.Text); if (quantity > 0) { ProductVariant productVariant = null; string optionList = string.Empty; if (product.ProductOptions.Count > 0) { Dictionary <int, int> selectedOptions = GetSelectedOptions(ri.ItemIndex); productVariant = ProductVariantDataSource.LoadForOptionList(productId, selectedOptions); optionList = ProductVariantDataSource.GetOptionList(productId, selectedOptions, true); } TextBox NameFormat = (TextBox)ri.FindControl("NameFormat"); DropDownList PriceMode = (DropDownList)ri.FindControl("PriceMode"); TextBox Price = (TextBox)ri.FindControl("Price"); DropDownList WeightMode = (DropDownList)ri.FindControl("WeightMode"); TextBox Weight = (TextBox)ri.FindControl("Weight"); CheckBox IsSelected = (CheckBox)ri.FindControl("IsSelected"); KitProduct kitProduct = new KitProduct(); kitProduct.ProductId = productId; kitProduct.KitComponent = _KitComponent; if (productVariant != null) { kitProduct.OptionList = productVariant.OptionList; } kitProduct.Name = NameFormat.Text; kitProduct.Quantity = quantity; ProductCalculator pcalc = ProductCalculator.LoadForProduct(productId, 1, optionList, string.Empty); kitProduct.PriceModeId = AlwaysConvert.ToByte(PriceMode.SelectedIndex); if (kitProduct.PriceMode == InheritanceMode.Inherit) { kitProduct.Price = pcalc.Price; } else { kitProduct.Price = AlwaysConvert.ToDecimal(Price.Text); } kitProduct.WeightModeId = AlwaysConvert.ToByte(WeightMode.SelectedIndex); if (kitProduct.WeightMode == InheritanceMode.Inherit) { kitProduct.Weight = pcalc.Weight; } else { kitProduct.Weight = AlwaysConvert.ToDecimal(Weight.Text); } kitProduct.IsSelected = IsSelected.Checked; kitProduct.Save(); } } Response.Redirect(string.Format("EditKit.aspx?CategoryId={0}&ProductId={1}", _CategoryId, _ProductId)); }
protected void VariantGrid_ItemCreated(object sender, RepeaterItemEventArgs e) { // GET THE ICON PATH if (string.IsNullOrEmpty(_IconPath)) { _IconPath = AbleCommerce.Code.PageHelper.GetAdminThemeIconPath(this.Page); } if (e.Item.ItemType == ListItemType.Header) { PlaceHolder phVariantHeader = e.Item.FindControl("phVariantHeader") as PlaceHolder; if (phVariantHeader != null) { StringBuilder headerBuilder = new StringBuilder(); if (names.Contains("SKU")) { headerBuilder.Append("<th>SKU</th>"); } if (names.Contains("GTIN")) { headerBuilder.Append("<th>GTIN</th>"); } if (names.Contains("Price")) { headerBuilder.Append("<th>Price</th>"); } if (names.Contains("Retail")) { headerBuilder.Append("<th>Retail</th>"); } if (names.Contains("Model")) { headerBuilder.Append("<th>Model #</th>"); } if (names.Contains("Dimensions")) { headerBuilder.Append("<th>Dimensions</th>"); } if (names.Contains("HandlingCharges")) { headerBuilder.Append("<th>Special Handling Charges</th>"); } if (names.Contains("Weight")) { headerBuilder.Append("<th>Weight</th>"); } if (names.Contains("COGS")) { headerBuilder.Append("<th>COGS</th>"); } if (names.Contains("Available")) { headerBuilder.Append("<th>Available</th>"); } if (_ShowInventory) { if (names.Contains("InStock")) { headerBuilder.Append("<th>In Stock</th>"); } if (names.Contains("Availability")) { headerBuilder.Append("<th>Availability Date</th>"); } if (names.Contains("LowStock")) { headerBuilder.Append("<th>Low Stock</th>"); } } if (names.Contains("Image")) { headerBuilder.Append("<th>Image</th>"); } if (names.Contains("Thumbnail")) { headerBuilder.Append("<th>Thumbnail</th>"); } if (names.Contains("Icon")) { headerBuilder.Append("<th>Icon</th>"); } phVariantHeader.Controls.Add(new LiteralControl(headerBuilder.ToString())); } } if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem) { PlaceHolder phVariantRow = e.Item.FindControl("phVariantRow") as PlaceHolder; if (phVariantRow != null) { ProductVariant variant = (ProductVariant)e.Item.DataItem; int variantIndex = _VariantManager.IndexOf(variant); StringBuilder rowBuilder = new StringBuilder(); string skuKey = "V_" + variantIndex.ToString() + "S"; string gtinKey = "V_" + variantIndex.ToString() + "G"; string priceKey = "V_" + variantIndex.ToString() + "P"; string retailKey = "V_" + variantIndex.ToString() + "RT"; string modelKey = "V_" + variantIndex.ToString() + "M"; string lengthKey = "V_" + variantIndex.ToString() + "L"; string widthKey = "V_" + variantIndex.ToString() + "WI"; string heightKey = "V_" + variantIndex.ToString() + "H"; string handlingChargesKey = "V_" + variantIndex.ToString() + "SH"; string priceModKey = "V_" + variantIndex.ToString() + "PM"; string weightKey = "V_" + variantIndex.ToString() + "W"; string weightModKey = "V_" + variantIndex.ToString() + "WM"; string cogsKey = "V_" + variantIndex.ToString() + "C"; string availKey = "V_" + variantIndex.ToString() + "A"; string instockKey = "V_" + variantIndex.ToString() + "I"; string availDateKey = "V_" + variantIndex.ToString() + "AD"; string restockKey = "V_" + variantIndex.ToString() + "R"; string imageKey = "V_" + variantIndex.ToString() + "IMG"; string thumbKey = "V_" + variantIndex.ToString() + "THU"; string iconKey = "V_" + variantIndex.ToString() + "ICO"; //CHECK IF THIS VARIANT IS IN FORM POST if (_FormValues.Any(v => v.Key.StartsWith("V_" + variantIndex.ToString()))) { //UPDATE THE VALUES BASED ON THE FORM POST if (_FormValues.ContainsKey(skuKey)) { variant.Sku = SafeTryGetValue(_FormValues, skuKey); } if (_FormValues.ContainsKey(gtinKey)) { variant.GTIN = SafeTryGetValue(_FormValues, gtinKey); } if (_FormValues.ContainsKey(priceKey)) { variant.Price = AlwaysConvert.ToDecimal(SafeTryGetValue(_FormValues, priceKey)); } if (_FormValues.ContainsKey(retailKey)) { variant.MSRP = AlwaysConvert.ToDecimal(SafeTryGetValue(_FormValues, retailKey)); } if (_FormValues.ContainsKey(priceModKey)) { variant.PriceModeId = AlwaysConvert.ToByte(SafeTryGetValue(_FormValues, priceModKey)); } if (_FormValues.ContainsKey(modelKey)) { variant.ModelNumber = SafeTryGetValue(_FormValues, modelKey); } if (_FormValues.ContainsKey(lengthKey)) { variant.Length = AlwaysConvert.ToDecimal(SafeTryGetValue(_FormValues, lengthKey)); } if (_FormValues.ContainsKey(widthKey)) { variant.Width = AlwaysConvert.ToDecimal(SafeTryGetValue(_FormValues, widthKey)); } if (_FormValues.ContainsKey(heightKey)) { variant.Height = AlwaysConvert.ToDecimal(SafeTryGetValue(_FormValues, heightKey)); } if (_FormValues.ContainsKey(handlingChargesKey)) { variant.HandlingCharges = AlwaysConvert.ToDecimal(SafeTryGetValue(_FormValues, handlingChargesKey)); } if (_FormValues.ContainsKey(weightKey)) { variant.Weight = AlwaysConvert.ToDecimal(SafeTryGetValue(_FormValues, weightKey)); } if (_FormValues.ContainsKey(weightModKey)) { variant.WeightModeId = AlwaysConvert.ToByte(SafeTryGetValue(_FormValues, weightModKey)); } if (_FormValues.ContainsKey(cogsKey)) { variant.CostOfGoods = AlwaysConvert.ToDecimal(SafeTryGetValue(_FormValues, cogsKey)); } if (_FormValues.ContainsKey(availKey)) { variant.Available = (SafeTryGetValue(_FormValues, availKey) == "1,0"); } if (_FormValues.ContainsKey(imageKey)) { variant.ImageUrl = SafeTryGetValue(_FormValues, imageKey); } if (_FormValues.ContainsKey(thumbKey)) { variant.ThumbnailUrl = SafeTryGetValue(_FormValues, thumbKey); } if (_FormValues.ContainsKey(iconKey)) { variant.IconUrl = SafeTryGetValue(_FormValues, iconKey); } if (_ShowInventory) { if (_FormValues.ContainsKey(instockKey)) { variant.InStock = AlwaysConvert.ToInt(SafeTryGetValue(_FormValues, instockKey)); } if (_FormValues.ContainsKey(availDateKey)) { variant.AvailabilityDate = AlwaysConvert.ToDateTime(SafeTryGetValue(_FormValues, availDateKey), DateTime.MinValue); } if (_FormValues.ContainsKey(restockKey)) { variant.InStockWarningLevel = AlwaysConvert.ToInt(SafeTryGetValue(_FormValues, restockKey)); } } } //DRAW THE DATA ROW string rowClass = (e.Item.ItemType == ListItemType.Item) ? "oddRow" : "evenRow"; string autoExpand = selectedCount > 9 ? "noExpand" : "expandColumns"; string smallExpands = selectedCount > 9 ? "nosmallExpand" : "expandSmallColumns"; string overrideSelected = string.Empty; rowBuilder.Append("<tr class=\"" + rowClass + "\">\r\n"); rowBuilder.Append("<td>" + (variantIndex + 1) + "</td>\r\n"); rowBuilder.Append("<td>" + variant.VariantName + "</td>\r\n"); if (names.Contains("SKU")) { rowBuilder.Append("<td align=\"center\"><input name=\"" + skuKey + "\" type=\"text\" value=\"" + variant.Sku + "\" class= \"" + autoExpand + "\" /></td>\r\n"); } if (names.Contains("GTIN")) { rowBuilder.Append("<td align=\"center\"><input name=\"" + gtinKey + "\" type=\"text\" value=\"" + variant.GTIN + "\" class= \"" + autoExpand + "\" /></td>\r\n"); } if (names.Contains("Price")) { rowBuilder.Append("<td align=\"center\"><input name=\"" + priceKey + "\" type=\"text\" value=\"" + variant.Price.LSCurrencyFormat("F2") + "\" class= \"" + smallExpands + "\" />"); overrideSelected = (variant.PriceMode == ModifierMode.Modify) ? string.Empty : " selected"; rowBuilder.Append("<select name=\"" + priceModKey + "\"><option value=\"0\">Modify</option><option value=\"1\"" + overrideSelected + ">Override</option></select></td>\r\n"); } if (names.Contains("Retail")) { rowBuilder.Append("<td align=\"center\"><input name=\"" + retailKey + "\" type=\"text\" value=\"" + variant.MSRP.LSCurrencyFormat("F2") + "\" class= \"" + smallExpands + "\" />"); } if (names.Contains("Model")) { rowBuilder.Append("<td align=\"center\"><input name=\"" + modelKey + "\" type=\"text\" value=\"" + variant.ModelNumber + "\" class= \"" + autoExpand + "\" />"); } if (names.Contains("Dimensions")) { rowBuilder.Append("<td align=\"center\">L <input name=\"" + lengthKey + "\" type=\"text\" value=\"" + variant.Length.LSCurrencyFormat("F2") + "\" style=\"width:46px;\" />"); rowBuilder.Append("W <input name=\"" + widthKey + "\" type=\"text\" value=\"" + variant.Width.LSCurrencyFormat("F2") + "\" style=\"width:46px;\" />"); rowBuilder.Append("H <input name=\"" + heightKey + "\" type=\"text\" value=\"" + variant.Height.LSCurrencyFormat("F2") + "\" style=\"width:46px;\" />"); } if (names.Contains("HandlingCharges")) { rowBuilder.Append("<td align=\"center\"><input name=\"" + handlingChargesKey + "\" type=\"text\" value=\"" + variant.HandlingCharges.LSCurrencyFormat("F2") + "\" class= \"" + smallExpands + "\" />"); } if (names.Contains("Weight")) { rowBuilder.Append("<td align=\"center\"><input name=\"" + weightKey + "\" type=\"text\" value=\"" + variant.Weight.LSCurrencyFormat("F2") + "\" class= \"" + smallExpands + "\" />"); overrideSelected = (variant.WeightMode == ModifierMode.Modify) ? string.Empty : " selected"; rowBuilder.Append("<select name=\"" + weightModKey + "\"><option value=\"0\">Modify</option><option value=\"1\"" + overrideSelected + ">Override</option></select></td>\r\n"); } if (names.Contains("COGS")) { rowBuilder.Append("<td align=\"center\"><input name=\"" + cogsKey + "\" type=\"text\" value=\"" + variant.CostOfGoods.LSCurrencyFormat("F2") + "\" class= \"" + smallExpands + "\" /></td>\r\n"); } string checkedAttribute = string.Empty; if (names.Contains("Available")) { if (variant.Available) { checkedAttribute = " checked=\"true\""; } rowBuilder.Append("<td align=\"center\"><input name=\"" + availKey + "\" type=\"checkbox\"" + checkedAttribute + " value=\"1\" /><input name=\"" + availKey + "\" type=\"hidden\"" + checkedAttribute + " value=\"0\" /></td>"); } if (_ShowInventory) { if (names.Contains("InStock")) { rowBuilder.Append("<td align=\"center\"><input name=\"" + instockKey + "\" type=\"text\" value=\"" + variant.InStock.ToString("F0") + "\" class= \"" + smallExpands + "\" /></td>\r\n"); } if (names.Contains("Availability")) { rowBuilder.Append("<td align=\"center\"><input name=\"" + availDateKey + "\" type=\"text\" value=\"" + ((variant.AvailabilityDate.HasValue && variant.AvailabilityDate != DateTime.MinValue) ? variant.AvailabilityDate.Value.ToShortDateString() : string.Empty) + "\" style=\"width:90px;\" class=\"pickerAndCalendar\" /></td>\r\n"); } if (names.Contains("LowStock")) { rowBuilder.Append("<td align=\"center\"><input name=\"" + restockKey + "\" type=\"text\" value=\"" + variant.InStockWarningLevel.ToString("F0") + "\" class= \"" + smallExpands + "\" /></td>\r\n"); } } if (names.Contains("Image")) { rowBuilder.Append("<td align=\"center\"><input name=\"" + imageKey + "\" type=\"text\" value=\"" + variant.ImageUrl + "\" class= \"" + autoExpand + "\" /><input name=\"" + imageKey + "B\" alt=\"Browse\" onclick=\"return PickImage('" + imageKey + "');\" type=\"image\" align=\"absmiddle\" src=\"" + _IconPath + "find.gif\" /></td>\r\n"); } if (names.Contains("Thumbnail")) { rowBuilder.Append("<td align=\"center\"><input name=\"" + thumbKey + "\" type=\"text\" value=\"" + variant.ThumbnailUrl + "\" class= \"" + autoExpand + "\" /><input name=\"" + thumbKey + "B\" alt=\"Browse\" onclick=\"return PickImage('" + thumbKey + "');\" type=\"image\" align=\"absmiddle\" src=\"" + _IconPath + "find.gif\" /></td>\r\n"); } if (names.Contains("Icon")) { rowBuilder.Append("<td align=\"center\"><input name=\"" + iconKey + "\" type=\"text\" value=\"" + variant.IconUrl + "\" class= \"" + autoExpand + "\" /><input name=\"" + iconKey + "B\" alt=\"Browse\" onclick=\"return PickImage('" + iconKey + "');\" type=\"image\" align=\"absmiddle\" src=\"" + _IconPath + "find.gif\" /></td>\r\n"); } rowBuilder.Append("</tr>\r\n"); phVariantRow.Controls.Add(new LiteralControl(rowBuilder.ToString())); } } }