Beispiel #1
0
 /// <summary>
 /// Handles the Click event of the lbAdd control.
 /// </summary>
 /// <param name="sender">The source of the event.</param>
 /// <param name="e">The <see cref="T:System.Web.UI.WebControls.CommandEventArgs"/> instance containing the event data.</param>
 protected void lbAdd_Click(object sender, CommandEventArgs e)
 {
     try {
         int attributeId = 0;
         int.TryParse(e.CommandArgument.ToString(), out attributeId);
         if (attributeId > 0)
         {
             Where where          = new Where();
             where.ColumnName     = ProductAttributeMap.Columns.ProductId;
             where.DbType         = DbType.Int32;
             where.ParameterValue = productId;
             Query  query        = new Query(ProductAttributeMap.Schema);
             object strSortOrder = query.GetMax(ProductAttributeMap.Columns.SortOrder, where);
             int    maxSortOrder = 0;
             int.TryParse(strSortOrder.ToString(), out maxSortOrder);
             ProductAttributeMap map = new ProductAttributeMap();
             map.AttributeId = attributeId;
             map.ProductId   = productId;
             map.SortOrder   = maxSortOrder + 1;
             map.Save(WebUtility.GetUserName());
             Store.Caching.ProductCache.RemoveAssociatedAttributeCollectionFromCache(productId);
             LoadAvailableAttributes();
             LoadAssociatedAttributes();
         }
     }
     catch (Exception ex) {
         Logger.Error(typeof(attributes).Name + ".lbAdd_Click", ex);
         base.MasterPage.MessageCenter.DisplayCriticalMessage(ex.Message);
     }
 }
Beispiel #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"));
            }
        }
 /// <summary>
 /// Handles the Click event of the lbAdd control.
 /// </summary>
 /// <param name="sender">The source of the event.</param>
 /// <param name="e">The <see cref="T:System.Web.UI.WebControls.CommandEventArgs"/> instance containing the event data.</param>
 protected void lbAdd_Click(object sender, CommandEventArgs e)
 {
     try {
     int attributeId = 0;
     int.TryParse(e.CommandArgument.ToString(), out attributeId);
     if(attributeId > 0) {
       Where where = new Where();
       where.ColumnName = ProductAttributeMap.Columns.ProductId;
       where.DbType = DbType.Int32;
       where.ParameterValue = productId;
       Query query = new Query(ProductAttributeMap.Schema);
       object strSortOrder = query.GetMax(ProductAttributeMap.Columns.SortOrder, where);
       int maxSortOrder = 0;
       int.TryParse(strSortOrder.ToString(), out maxSortOrder);
       ProductAttributeMap map = new ProductAttributeMap();
       map.AttributeId = attributeId;
       map.ProductId = productId;
       map.SortOrder = maxSortOrder + 1;
       map.Save(WebUtility.GetUserName());
       Store.Caching.ProductCache.RemoveAssociatedAttributeCollectionFromCache(productId);
       LoadAvailableAttributes();
       LoadAssociatedAttributes();
     }
       }
       catch(Exception ex) {
     Logger.Error(typeof(attributes).Name + ".lbAdd_Click", ex);
     base.MasterPage.MessageCenter.DisplayCriticalMessage(ex.Message);
       }
 }
        /// <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"));
              }
        }
        public void Update(int AttributeId,int ProductId,int SortOrder,bool IsRequired)
        {
            ProductAttributeMap item = new ProductAttributeMap();

                item.AttributeId = AttributeId;

                item.ProductId = ProductId;

                item.SortOrder = SortOrder;

                item.IsRequired = IsRequired;

            item.MarkOld();
            item.Save(UserName);
        }