Esempio n. 1
0
 /// <summary>
 /// Handles the Load event of the Page control.
 /// </summary>
 /// <param name="sender">The source of the event.</param>
 /// <param name="e">The <see cref="T:System.EventArgs"/> instance containing the event data.</param>
 protected void Page_Load(object sender, EventArgs e)
 {
     try {
     productId = Utility.GetIntParameter("productId");
     view = Utility.GetParameter("view");
     if (productId > 0) {
       product = new Product(productId);
       lblProductEdit.Text = LocalizationUtility.GetText("lblProductEdit") + " >> " + product.Name;
       if(!product.IsEnabled) {
     lblProductEdit.Text += " " + LocalizationUtility.GetText("lblProductNotEnabled");
       }
       productNavigation.Visible = true;
     }
     else {
       lblProductEdit.Text = LocalizationUtility.GetText("lblProductAdd");
     }
     switch (view) {
       case "g":
     generalInformation.Visible = true;
     break;
       case "d":
     descriptors.Visible = true;
     break;
       case "c":
     categories.Visible = true;
     break;
       case "a":
     attributes.Visible = true;
     break;
       case "i":
     images.Visible = true;
     break;
       case "s":
     skus.Visible = true;
     break;
       case "cs":
     crossSells.Visible = true;
     break;
       case "r":
     reviews.Visible = true;
     break;
       case "n":
     notes.Visible = true;
     break;
       case "dl":
     downloads.Visible = true;
     break;
       default:
     generalInformation.Visible = true;
     break;
     }
       }
       catch (Exception ex) {
     Logger.Error(typeof(productedit).Name + ".Page_Load", ex);
     Master.MessageCenter.DisplayCriticalMessage(ex.Message);
       }
 }
Esempio n. 2
0
        /// <summary>
        /// Handles the Click event of the btnPostSimilar control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="T:System.EventArgs"/> instance containing the event data.</param>
        protected void btnCopy_Click(object sender, EventArgs e)
        {
            this.btnSave_Click(null, EventArgs.Empty); //Save any changes first

              Product newProduct = new Product();
              newProduct.ProductGuid = Guid.NewGuid();
              newProduct.BaseSku = string.Empty;
              newProduct.Name = product.Name = txtName.Text.Trim() + " - Copy";
              newProduct.ShortDescription = product.ShortDescription;
              newProduct.OurPrice = product.OurPrice;
              newProduct.RetailPrice = product.RetailPrice;
              newProduct.ManufacturerId = product.ManufacturerId;
              newProduct.ProductStatusDescriptorId = product.ProductStatusDescriptorId;
              newProduct.ProductTypeId = product.ProductTypeId;
              newProduct.TaxRateId = product.TaxRateId;
              newProduct.ShippingEstimateId = product.ShippingEstimateId;
              newProduct.Weight = product.Weight;
              newProduct.Length = product.Length;
              newProduct.Height = product.Height;
              newProduct.Width = product.Width;
              newProduct.TotalRatingVotes = product.TotalRatingVotes;
              newProduct.RatingSum = product.RatingSum;
              newProduct.Save(WebUtility.GetUserName());

              if (newProduct.ProductId > 0) {
            foreach (Category cat in product.GetCategoryCollection()) {
              ProductCategoryMap map = new ProductCategoryMap();
              map.CategoryId = cat.CategoryId;
              map.ProductId = newProduct.ProductId;
              map.Save(WebUtility.GetUserName());
              Store.Caching.ProductCache.RemoveProductsByCategoryIdFromCache(cat.CategoryId);
            }

            AssociatedAttributeCollection productAttributes = Store.Caching.ProductCache.GetAssociatedAttributeCollectionByProduct(product.ProductId);
            foreach (AssociatedAttribute at in productAttributes) {
              int sortOrder = 0;
              ProductAttributeMap map = new ProductAttributeMap();
              map.AttributeId = at.AttributeId;
              map.ProductId = newProduct.ProductId;
              map.SortOrder = sortOrder++;
              map.IsRequired = at.IsRequired;
              map.Save(WebUtility.GetUserName());
            }
            Response.Redirect(string.Format("~/admin/productedit.aspx?view=g&productId={0}", newProduct.ProductId.ToString()), false);
              }
              else {
            base.MasterPage.MessageCenter.DisplayFailureMessage(LocalizationUtility.GetText("lblProductNotSaved"));
              }
        }
Esempio n. 3
0
 /// <summary>
 /// Handles the Load event of the Page control.
 /// </summary>
 /// <param name="sender">The source of the event.</param>
 /// <param name="e">The <see cref="T:System.EventArgs"/> instance containing the event data.</param>
 protected void Page_Load(object sender, EventArgs e)
 {
     productId = Utility.GetIntParameter("pid");
       if (productId > 0) {
     SetReviewProperties();
     _product = new Product(productId);
     if (!ReviewController.UserReviewedProduct(_product.ProductId, WebUtility.GetUserName())) {
       lblName.Text = _product.Name;
     }
     else {
       pnlReview.Visible = false;
       lblAlreadyReviewed.Visible = true;
     }
     Page.Title = string.Format(LocalizationUtility.GetText("titleReview"), _product.Name.PadRight(30).Substring(0, 30).Trim());
       }
 }
Esempio n. 4
0
 /// <summary>
 /// Handles the Click event of the btnSave control.
 /// </summary>
 /// <param name="sender">The source of the event.</param>
 /// <param name="e">The <see cref="T:System.EventArgs"/> instance containing the event data.</param>
 protected void btnSave_Click(object sender, EventArgs e)
 {
     try {
     int reviewId = 0;
     int.TryParse(lblReviewId.Text, out reviewId);
     if (reviewId > 0) {
       Review review = new Review(reviewId);
       review.IsApproved = chkIsApproved.Checked;
       review.Save(WebUtility.GetUserName());
       Product product = new Product(productId);
       product.RatingSum = product.RatingSum + review.Rating;
       product.TotalRatingVotes = product.TotalRatingVotes + 1;
       product.Save(WebUtility.GetUserName());
       Store.Caching.ProductCache.RemoveReviewCollectionFromCache(productId);
       LoadReviews();
       Reset();
       base.MasterPage.MessageCenter.DisplaySuccessMessage(LocalizationUtility.GetText("lblReviewSaved"));
     }
       }
       catch (Exception ex) {
     Logger.Error(typeof(reviews).Name + ".btnSave_Click", ex);
     base.MasterPage.MessageCenter.DisplayCriticalMessage(ex.Message);
       }
 }
Esempio n. 5
0
 /// <summary>
 /// Loads the product.
 /// </summary>
 private void LoadProduct()
 {
     _product = Store.Caching.ProductCache.GetProductByProductID(productId);
       productAttributes.Product = _product;
       lblProductName.Text = _product.Name;
       lblOurPriceAmount.Text = StoreUtility.GetFormattedAmount(_product.DisplayPrice, true);
       if(Master.SiteSettings.AddTaxToPrice && TaxService.GetDefaultTaxProvider().IsProductLevelTaxProvider) {
     lblTaxApplied.Visible = true;
       }
       ajaxRating.CurrentRating = _product.Rating;
       ajaxRating.Visible = SiteSettings.DisplayRatings;
       lblShortDescription.Text = HttpUtility.HtmlDecode(_product.ShortDescription);
       if (_product.RetailPrice != 0 && Master.SiteSettings.DisplayRetailPrice) {
     lblRetailPriceAmount.Text = StoreUtility.GetFormattedAmount(_product.RetailPrice, true);
     pnlRetailPrice.Visible = true;
     pnlYouSave.Visible = true;
     lblYouSaveAmount.Text = string.Format("{0}&nbsp;({1})", StoreUtility.GetFormattedAmount(_product.YouSaveAmount, true), _product.YouSavePercentage.ToString("p"));
       }
       if (!IsPostBack) {
     SkuCollection productSkus = _product.SkuRecords(); //TODO: Cache this?
     if (productSkus.Count > 0) {
       if (productSkus.Count == 1) {//there is only 1 Sku, so load the inventory
     productAttributes.GetInventory(productSkus[0].SkuX);
       }
       else {
     ddlQuantity.Enabled = false;
     btnAddToCart.Enabled = false;
       }
     }
       }
       if (_product.AllowNegativeInventories) {
     ddlQuantity.Visible = false;
     txtQuantity.Visible = true;
     rfvQuantity.Visible = true;
       }
 }
Esempio n. 6
0
        /// <summary>
        /// Handles the Load event of the Page control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="T:System.EventArgs"/> instance containing the event data.</param>
        protected void Page_Load(object sender, EventArgs e)
        {
            productId = Utility.GetIntParameter("pid");
              _product = new Product(productId);
              if (string.IsNullOrEmpty(_product.BaseSku) || _product.ProductStatusDescriptorId == 99) {
            throw new InvalidOperationException(string.Format("Invalid product. Product Id of {0} is not valid.", productId));
            //We should display alternative products.
              }

              SetProductProperties();
              LogProductBrowse();
              LoadProduct();
              LoadPageTitle();
              LoadProductImages();
              LoadDownloads();
              LoadDescriptors();
              LoadReviews();
              LoadCrossSells();
              SetSeoInformation();
              LoadBreadCrumbs();
              if (User.Identity.IsAuthenticated) {
            //only allow them to review if they haven't reviewed before (select even the non-approved reviews)
            pnlReview.Visible = SiteSettings.DisplayRatings && !ReviewController.UserReviewedProduct(_product.ProductId, WebUtility.GetUserName());
              }
        }
        public void Insert(int ManufacturerId,int ProductStatusDescriptorId,int ProductTypeId,int ShippingEstimateId,string BaseSku,Guid ProductGuid,string Name,string ShortDescription,decimal OurPrice,decimal RetailPrice,int TaxRateId,decimal Weight,decimal Length,decimal Height,decimal Width,int SortOrder,int RatingSum,int TotalRatingVotes,bool AllowNegativeInventories,bool IsEnabled,string CreatedBy,DateTime CreatedOn,string ModifiedBy,DateTime ModifiedOn,bool IsDeleted)
        {
            Product item = new Product();

            item.ManufacturerId = ManufacturerId;

            item.ProductStatusDescriptorId = ProductStatusDescriptorId;

            item.ProductTypeId = ProductTypeId;

            item.ShippingEstimateId = ShippingEstimateId;

            item.BaseSku = BaseSku;

            item.ProductGuid = ProductGuid;

            item.Name = Name;

            item.ShortDescription = ShortDescription;

            item.OurPrice = OurPrice;

            item.RetailPrice = RetailPrice;

            item.TaxRateId = TaxRateId;

            item.Weight = Weight;

            item.Length = Length;

            item.Height = Height;

            item.Width = Width;

            item.SortOrder = SortOrder;

            item.RatingSum = RatingSum;

            item.TotalRatingVotes = TotalRatingVotes;

            item.AllowNegativeInventories = AllowNegativeInventories;

            item.IsEnabled = IsEnabled;

            item.CreatedBy = CreatedBy;

            item.CreatedOn = CreatedOn;

            item.ModifiedBy = ModifiedBy;

            item.ModifiedOn = ModifiedOn;

            item.IsDeleted = IsDeleted;

            item.Save(UserName);
        }
 /// <summary>
 /// Handles the ItemDataBound event of the rptrCart control.
 /// </summary>
 /// <param name="sender">The source of the event.</param>
 /// <param name="e">The <see cref="T:System.Web.UI.WebControls.RepeaterItemEventArgs"/> instance containing the event data.</param>
 void rptrCart_ItemDataBound(object sender, RepeaterItemEventArgs e)
 {
     OrderItem orderItem = e.Item.DataItem as OrderItem;
       Product product = new Product(orderItem.ProductId);
       TextBox quantityTextBox = e.Item.FindControl("txtQuantity") as TextBox;
       DropDownList quantityDropDownList = e.Item.FindControl("ddlQuantity") as DropDownList;
       FilteredTextBoxExtender filteredTextBoxExtender = e.Item.FindControl("ftbeQuantity") as FilteredTextBoxExtender;
       if (quantityTextBox != null) {
     if(this.IsEditable) {
       if(product.AllowNegativeInventories) {
     quantityDropDownList.Visible = false;
     quantityTextBox.Text = orderItem.Quantity.ToString();
       }
       else {
     quantityTextBox.Visible = false;
     filteredTextBoxExtender.Enabled = false;
     Sku sku = new Sku("Sku", orderItem.Sku);
     for(int i = 1;i <= sku.Inventory;i++) {
       quantityDropDownList.Items.Add(new ListItem(i.ToString(), i.ToString()));
     }
     //Inventory may have changed, so try to set it, but we may have to reset it
     if(quantityDropDownList.Items.FindByValue(orderItem.Quantity.ToString()) != null) {
       quantityDropDownList.SelectedValue = orderItem.Quantity.ToString();
     }
     else {
       quantityDropDownList.SelectedIndex = 0;
     }
       }
     }
     else {
       quantityDropDownList.Visible = false;
       quantityTextBox.Text = orderItem.Quantity.ToString();
       quantityTextBox.CssClass = "readOnly";
       quantityTextBox.ReadOnly = true;
     }
       }
 }
Esempio n. 9
0
 /// <summary>
 /// Handles the Load event of the Page control.
 /// </summary>
 /// <param name="sender">The source of the event.</param>
 /// <param name="e">The <see cref="T:System.EventArgs"/> instance containing the event data.</param>
 protected void Page_Load(object sender, EventArgs e)
 {
     try {
     productId = Utility.GetIntParameter("productId");
     view = Utility.GetParameter("view");
     if (view.Equals("s")) {
       SetSkuProperties();
       product = new Product(productId);
       associatedAttributeCollection = new ProductController().FetchAssociatedAttributesByProductId(productId);
       if(!Page.IsPostBack) {
     chkAllowNegativeInventories.Checked = product.AllowNegativeInventories;
     SkuCollection skuCollection = LoadSkuCollection(productId);
     if (skuCollection.Count > 0) {
       pnlSkuList.Visible = false;
     }
     else {
       pnlSkuInventory.Visible = false;
       string tempSku = product.BaseSku;
       if (associatedAttributeCollection.Count > 0) {
         CreateSkus(associatedAttributeCollection[0], 0, tempSku);
         lblTotalSkuCount.Text = skus.Count.ToString();
       }
       else {
         skus.Add(tempSku);
         lblTotalSkuCount.Text = skus.Count.ToString();
       }
       skus.TrimExcess();
       dlSkus.DataSource = skus;
       dlSkus.DataBind();
     }
       }
     }
       }
       catch (Exception ex) {
     Logger.Error(typeof(sku).Name + ".Page_Load", ex);
     base.MasterPage.MessageCenter.DisplayCriticalMessage(ex.Message);
       }
 }
Esempio n. 10
0
 /// <summary>
 /// Handles the Load event of the Page control.
 /// </summary>
 /// <param name="sender">The source of the event.</param>
 /// <param name="e">The <see cref="T:System.EventArgs"/> instance containing the event data.</param>
 protected void Page_Load(object sender, EventArgs e)
 {
     try {
     productId = Utility.GetIntParameter("productId");
     view = Utility.GetParameter("view");
     if(view == "a") {
       SetAttributesProperties();
       product = new Product(productId);
       if(!Page.IsPostBack) {
     if(!product.IsEnabled) {
       LoadAssociatedAttributes();
       LoadAvailableAttributes();
     }
     else {
       attributeTable.Visible = false;
       pnlAttributesLocked.Visible = true;
       LoadAttributesLocked();
     }
       }
     }
       }
       catch(Exception ex) {
     Logger.Error(typeof(attributes).Name + ".Page_Load", ex);
     base.MasterPage.MessageCenter.DisplayCriticalMessage(ex.Message);
       }
 }
Esempio n. 11
0
        /// <summary>
        /// Handles the Load event of the Page control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="T:System.EventArgs"/> instance containing the event data.</param>
        protected void Page_Load(object sender, EventArgs e)
        {
            try {
            productId = Utility.GetIntParameter("productId");
            view = Utility.GetParameter("view");
            if (view == "g") {
              SetGeneralProperties();
              SiteSettings siteSettings = SiteSettingCache.GetSiteSettings();
              if (productId > 0) {
            product = new Product(productId);
              }
              else {
            product = new Product();
              }

              if (!Page.IsPostBack) {
            LoadManufacturer();
            LoadProductStatus();
            LoadProductType();
            LoadShippingEstimate();
            LoadTaxRates();
            txtBaseSku.Text = product.BaseSku;
            txtName.Text = product.Name;
            txtShortDescription.Value = HttpUtility.HtmlDecode(product.ShortDescription);
            txtOurPrice.Text = StoreUtility.GetFormattedAmount(product.OurPrice, false);
            txtRetailPrice.Text = StoreUtility.GetFormattedAmount(product.RetailPrice, false);
            ddlManufacturer.SelectedValue = product.ManufacturerId.ToString();
            ddlStatus.SelectedValue = product.ProductStatusDescriptorId.ToString();
            ddlTaxRate.SelectedValue = product.TaxRateId.ToString();
            ddlProductType.SelectedValue = product.ProductTypeId.ToString();
            ddlShippingEstimate.SelectedValue = product.ShippingEstimateId.ToString();
            txtWeight.Text = product.Weight.ToString();
            txtLength.Text = product.Length.ToString();
            txtHeight.Text = product.Height.ToString();
            txtWidth.Text = product.Width.ToString();
              }
              lblOurPriceCurrencySymbol.Text = siteSettings.CurrencySymbol;
              lblRetailPriceCurrencySymbol.Text = siteSettings.CurrencySymbol;
            }
              }
              catch (Exception ex) {
            Logger.Error(typeof(general).Name + ".Page_Load", ex);
            base.MasterPage.MessageCenter.DisplayCriticalMessage(ex.Message);
              }
        }