Esempio n. 1
0
        public override bool GetShoppingProductInfo(int productId, string skuId, out ProductSaleStatus saleStatus, out int stock, out int totalQuantity)
        {
            saleStatus    = ProductSaleStatus.Delete;
            stock         = 0;
            totalQuantity = 0;
            bool      flag             = false;
            DbCommand sqlStringCommand = this.database.GetSqlStringCommand("SELECT Stock,SaleStatus,AlertStock FROM Hishop_Skus s INNER JOIN Hishop_Products p ON s.ProductId=p.ProductId WHERE s.ProductId=@ProductId AND s.SkuId=@SkuId");

            this.database.AddInParameter(sqlStringCommand, "ProductId", DbType.Int32, productId);
            this.database.AddInParameter(sqlStringCommand, "SkuId", DbType.String, skuId);
            using (IDataReader reader = this.database.ExecuteReader(sqlStringCommand))
            {
                if (reader.Read())
                {
                    saleStatus = (ProductSaleStatus)((int)reader["SaleStatus"]);
                    stock      = (int)reader["Stock"];
                    int num = (int)reader["AlertStock"];
                    if (stock <= num)
                    {
                        saleStatus = ProductSaleStatus.UnSale;
                    }
                    flag = true;
                }
                totalQuantity = this.GetShoppingProductQuantity(skuId, productId);
            }
            return(flag);
        }
Esempio n. 2
0
        public int UpdateProductApproveStatus(int num_iid, string approve_status)
        {
            ProductSaleStatus productSaleStatus = ProductSaleStatus.OnStock;

            if (approve_status.Equals("On_Sale", StringComparison.OrdinalIgnoreCase))
            {
                productSaleStatus = ProductSaleStatus.OnSale;
                goto IL_0046;
            }
            if (approve_status.Equals("Un_Sale", StringComparison.OrdinalIgnoreCase))
            {
                productSaleStatus = ProductSaleStatus.UnSale;
                goto IL_0046;
            }
            if (approve_status.Equals("In_Stock", StringComparison.OrdinalIgnoreCase))
            {
                productSaleStatus = ProductSaleStatus.OnStock;
                goto IL_0046;
            }
            return(0);

IL_0046:
            DbCommand sqlStringCommand = base.database.GetSqlStringCommand("UPDATE Hishop_Products SET SaleStatus = @SaleStatus  WHERE ProductId = @ProductId ");

            base.database.AddInParameter(sqlStringCommand, "SaleStatus", DbType.Int32, (int)productSaleStatus);
            base.database.AddInParameter(sqlStringCommand, "ProductId", DbType.Int32, num_iid);
            return(base.database.ExecuteNonQuery(sqlStringCommand));
        }
Esempio n. 3
0
 protected ProductOnStock() : base("m02", "spp03")
 {
     this.saleStatus = ProductSaleStatus.OnStock;
     this.LocalUrl   = string.Empty;
     this.myNotifier = new StatisticNotifier();
     this.myEvent    = new UpdateStatistics();
 }
 protected ProductSendsIntegral() : base("m02", "spp02")
 {
     this.saleStatus = ProductSaleStatus.OnSale;
     this.LocalUrl   = string.Empty;
     this.myNotifier = new StatisticNotifier();
     this.myEvent    = new UpdateStatistics();
 }
Esempio n. 5
0
 protected ProductZero() : base("m02", "spp10")
 {
     this.saleStatus = ProductSaleStatus.All;
     this.LocalUrl   = string.Empty;
     this.myNotifier = new StatisticNotifier();
     this.myEvent    = new UpdateStatistics();
 }
Esempio n. 6
0
        public string GetSoldProducts(DateTime?start_modified, DateTime?end_modified, string approve_status, string q, string order_by, int page_no, int page_size)
        {
            string       format = "{{\"products_get_response\":{{\"total_results\":\"{0}\",\"items\":{1}}}}}";
            ProductQuery query  = new ProductQuery
            {
                SortBy     = "DisplaySequence",
                SortOrder  = SortAction.Asc,
                PageIndex  = 1,
                PageSize   = 40,
                SaleStatus = ProductSaleStatus.All
            };

            if (start_modified.HasValue)
            {
                query.StartDate = start_modified;
            }
            if (end_modified.HasValue)
            {
                query.EndDate = end_modified;
            }
            if (!string.IsNullOrEmpty(q))
            {
                query.Keywords = DataHelper.CleanSearchString(q);
            }
            if (!string.IsNullOrEmpty(approve_status))
            {
                ProductSaleStatus all = ProductSaleStatus.All;
                EnumDescription.GetEnumValue <ProductSaleStatus>(approve_status, ref all);
                query.SaleStatus = all;
            }
            DbQueryResult productsForApi = ProductHelper.GetProductsForApi(query);

            return(string.Format(format, productsForApi.TotalRecords, this.ConvertProductSold((DataTable)productsForApi.Data)));
        }
Esempio n. 7
0
 private void LoadParameters()
 {
     if (!string.IsNullOrEmpty(this.Page.Request.QueryString["SaleStatus"]))
     {
         this.saleStatus = (ProductSaleStatus)System.Enum.Parse(typeof(ProductSaleStatus), this.Page.Request.QueryString["SaleStatus"]);
     }
 }
        private void btnImport_Click(object sender, System.EventArgs e)
        {
            if (!this.CheckItems())
            {
                return;
            }
            string            text          = this.dropFiles.SelectedValue;
            string            text2         = System.IO.Path.Combine(this._dataPath, System.IO.Path.GetFileNameWithoutExtension(text));
            ImportAdapter     importer      = TransferHelper.GetImporter(this.dropImportVersions.SelectedValue, new object[0]);
            int               value         = this.dropCategories.SelectedValue.Value;
            int               value2        = this.dropProductLines.SelectedValue.Value;
            int?              selectedValue = this.dropBrandList.SelectedValue;
            ProductSaleStatus saleStatus    = ProductSaleStatus.OnStock;

            text = System.IO.Path.Combine(this._dataPath, text);
            if (!System.IO.File.Exists(text))
            {
                this.ShowMsg("选择的数据包文件有问题!", false);
                return;
            }
            importer.PrepareDataFiles(new object[]
            {
                text
            });
            text2 = text2.ToLower().Replace("cpage\\supplier\\" + Hidistro.Membership.Context.HiContext.Current.User.UserId, "data");
            object[] array = importer.ParseProductData(new object[]
            {
                text2
            });
            Methods.Supplier_PtImportProducts((System.Data.DataTable)array[0], value, value2, selectedValue, saleStatus, false);
            System.IO.File.Delete(text);
            System.IO.Directory.Delete(text2, true);
            this.BindFiles();
            this.ShowMsg("此次商品批量导入操作已成功!", true);
        }
Esempio n. 9
0
        private void LoadParameters()
        {
            if (!string.IsNullOrEmpty(this.Page.Request.QueryString["productName"]))
            {
                this.productName = Globals.UrlDecode(this.Page.Request.QueryString["productName"]);
            }
            if (!string.IsNullOrEmpty(this.Page.Request.QueryString["productCode"]))
            {
                this.productCode = Globals.UrlDecode(this.Page.Request.QueryString["productCode"]);
            }
            int value = 0;

            if (int.TryParse(this.Page.Request.QueryString["categoryId"], out value))
            {
                this.categoryId = new int?(value);
            }
            int value2 = 0;

            if (int.TryParse(this.Page.Request.QueryString["brandId"], out value2))
            {
                this.dropBrandList.SelectedValue = new int?(value2);
            }
            int value4 = 0;

            if (int.TryParse(this.Page.Request.QueryString["typeId"], out value4))
            {
                this.typeId = new int?(value4);
            }
            if (!string.IsNullOrEmpty(this.Page.Request.QueryString["SaleStatus"]))
            {
                this.saleStatus = (ProductSaleStatus)System.Enum.Parse(typeof(ProductSaleStatus), this.Page.Request.QueryString["SaleStatus"]);
            }
            int iSourceId = 0;

            if (int.TryParse(this.Page.Request.QueryString["importSourceId"], out iSourceId))
            {
                this.importSourceId = new int?(iSourceId);
            }

            int iSupplier = 0;

            if (int.TryParse(this.Page.Request.QueryString["supplierId"], out iSupplier))
            {
                this.supplierId = new int?(iSupplier);
            }

            this.txtSearchText.Text = this.productName;
            this.txtSKU.Text        = this.productCode;
            this.dropCategories.DataBind();
            this.dropCategories.SelectedValue = this.categoryId;

            this.ddlImportSourceType.DataBind();
            this.ddlImportSourceType.SelectedValue = this.importSourceId;

            this.ddlSupplier.DataBind();
            this.ddlSupplier.SelectedValue = this.supplierId;

            this.dropType.SelectedValue = this.typeId;
        }
Esempio n. 10
0
        private void LoadParameters()
        {
            if (!string.IsNullOrEmpty(this.Page.Request.QueryString["productName"]))
            {
                this.productName = Globals.UrlDecode(this.Page.Request.QueryString["productName"]);
            }
            if (!string.IsNullOrEmpty(this.Page.Request.QueryString["productCode"]))
            {
                this.productCode = Globals.UrlDecode(this.Page.Request.QueryString["productCode"]);
            }
            int result = 0;

            if (int.TryParse(this.Page.Request.QueryString["categoryId"], out result))
            {
                this.categoryId = new int?(result);
            }
            int num2 = 0;

            if (int.TryParse(this.Page.Request.QueryString["brandId"], out num2))
            {
                this.dropBrandList.SelectedValue = new int?(num2);
            }
            int num3 = 0;

            if (int.TryParse(this.Page.Request.QueryString["tagId"], out num3))
            {
                this.tagId = new int?(num3);
            }
            int num4 = 0;

            if (int.TryParse(this.Page.Request.QueryString["typeId"], out num4))
            {
                this.typeId = new int?(num4);
            }
            if (!string.IsNullOrEmpty(this.Page.Request.QueryString["SaleStatus"]))
            {
                this.saleStatus = (ProductSaleStatus)System.Enum.Parse(typeof(ProductSaleStatus), this.Page.Request.QueryString["SaleStatus"]);
            }
            if (!string.IsNullOrEmpty(this.Page.Request.QueryString["startDate"]))
            {
                this.startDate = new System.DateTime?(System.DateTime.Parse(this.Page.Request.QueryString["startDate"]));
            }
            if (!string.IsNullOrEmpty(this.Page.Request.QueryString["endDate"]))
            {
                this.endDate = new System.DateTime?(System.DateTime.Parse(this.Page.Request.QueryString["endDate"]));
            }
            this.txtSearchText.Text = this.productName;
            this.txtSKU.Text        = this.productCode;
            this.dropCategories.DataBind();
            this.dropCategories.SelectedValue = this.categoryId;
            this.dropTagList.DataBind();
            this.dropTagList.SelectedValue      = this.tagId;
            this.calendarStartDate.SelectedDate = this.startDate;
            this.calendarEndDate.SelectedDate   = this.endDate;
            this.dropType.SelectedValue         = this.typeId;
            this.dropSaleStatus.SelectedValue   = this.saleStatus;
        }
Esempio n. 11
0
 protected void btnImport_Click(object sender, EventArgs e)
 {
     //try
     //{
     if (CheckItems())
     {
         string        selectedValue = dropFiles.SelectedValue;
         string        path          = Path.Combine(_dataPath, Path.GetFileNameWithoutExtension(selectedValue));
         ImportAdapter importer      = TransferHelper.GetImporter(dropImportVersions.SelectedValue, new object[0]);
         DataSet       mappingSet    = null;
         if (txtMappedTypes.Text.Length > 0)
         {
             XmlDocument document = new XmlDocument();
             document.LoadXml(txtMappedTypes.Text);
             mappingSet = importer.CreateMapping(new object[] { document, path })[0] as DataSet;
             ProductHelper.EnsureMapping(mappingSet);
         }
         bool includeCostPrice    = chkIncludeCostPrice.Checked;
         bool includeStock        = chkIncludeStock.Checked;
         bool includeImages       = chkIncludeImages.Checked;
         int  categoryId          = dropCategories.SelectedValue.Value;
         int  lineId              = dropProductLines.SelectedValue.Value;
         int? bandId              = dropBrandList.SelectedValue;
         ProductSaleStatus delete = ProductSaleStatus.Delete;
         if (radInStock.Checked)
         {
             delete = ProductSaleStatus.OnStock;
         }
         if (radUnSales.Checked)
         {
             delete = ProductSaleStatus.UnSale;
         }
         if (radOnSales.Checked)
         {
             delete = ProductSaleStatus.OnSale;
         }
         ProductHelper.ImportProducts((DataSet)importer.ParseProductData(new object[] { mappingSet, path, includeCostPrice, includeStock, includeImages })[0], categoryId, lineId, bandId, delete, includeCostPrice, includeStock, includeImages);
         if (chkDeleteFiles.Checked)
         {
             File.Delete(Path.Combine(_dataPath, selectedValue));
             Directory.Delete(path, true);
         }
         chkFlag.Checked        = false;
         txtMappedTypes.Text    = string.Empty;
         txtProductTypeXml.Text = string.Empty;
         txtPTXml.Text          = string.Empty;
         OutputProductTypes();
         BindFiles();
         ShowMsg("此次商品批量导入操作已成功!", true);
     }
     //}
     //catch (Exception ex)
     //{
     //    ShowMsg("导入失败,请检查数据包格式是否正确",false);
     // }
 }
Esempio n. 12
0
 private void btnImport_Click(object sender, System.EventArgs e)
 {
     if (this.CheckItems())
     {
         string              selectedValue = this.dropFiles.SelectedValue;
         string              path          = System.IO.Path.Combine(this._dataPath, System.IO.Path.GetFileNameWithoutExtension(selectedValue));
         ImportAdapter       importer      = TransferHelper.GetImporter(this.dropImportVersions.SelectedValue, new object[0]);
         System.Data.DataSet mappingSet    = null;
         if (this.txtMappedTypes.Text.Length > 0)
         {
             XmlDocument document = new XmlDocument();
             document.LoadXml(this.txtMappedTypes.Text);
             mappingSet = (importer.CreateMapping(new object[]
             {
                 document,
                 path
             })[0] as System.Data.DataSet);
             ProductHelper.EnsureMapping(mappingSet);
         }
         bool includeCostPrice    = this.chkIncludeCostPrice.Checked;
         bool includeStock        = this.chkIncludeStock.Checked;
         bool includeImages       = this.chkIncludeImages.Checked;
         int  categoryId          = this.dropCategories.SelectedValue.Value;
         int? bandId              = this.dropBrandList.SelectedValue;
         ProductSaleStatus delete = ProductSaleStatus.Delete;
         if (this.radInStock.Checked)
         {
             delete = ProductSaleStatus.OnStock;
         }
         if (this.radUnSales.Checked)
         {
             delete = ProductSaleStatus.UnSale;
         }
         if (this.radOnSales.Checked)
         {
             delete = ProductSaleStatus.OnSale;
         }
         ProductHelper.ImportProducts((System.Data.DataSet)importer.ParseProductData(new object[]
         {
             mappingSet,
             path,
             includeCostPrice,
             includeStock,
             includeImages
         })[0], categoryId, 0, bandId, delete, includeCostPrice, includeStock, includeImages);
         System.IO.File.Delete(System.IO.Path.Combine(this._dataPath, selectedValue));
         System.IO.Directory.Delete(path, true);
         this.chkFlag.Checked        = false;
         this.txtMappedTypes.Text    = string.Empty;
         this.txtProductTypeXml.Text = string.Empty;
         this.txtPTXml.Text          = string.Empty;
         this.OutputProductTypes();
         this.BindFiles();
         this.ShowMsg("此次商品批量导入操作已成功!", true);
     }
 }
Esempio n. 13
0
        private void LoadParameters()
        {
            if (!string.IsNullOrEmpty(this.Page.Request.QueryString["productName"]))
            {
                this.Keywords = Globals.UrlDecode(this.Page.Request.QueryString["productName"]);
            }
            if (!string.IsNullOrEmpty(this.Page.Request.QueryString["productCode"]))
            {
                this.ProductCode = Globals.UrlDecode(this.Page.Request.QueryString["productCode"]);
            }
            int value = 0;

            if (int.TryParse(this.Page.Request.QueryString["categoryId"], out value))
            {
                this.CategoryId = value;
                this.dropCategories.SelectedValue = this.CategoryId;
            }
            int value2 = 0;

            if (int.TryParse(this.Page.Request.QueryString["brandId"], out value2))
            {
                this.BrandId = value2;
                this.dropBrandList.SelectedValue = value2;
            }
            int value3 = 0;

            if (int.TryParse(this.Page.Request.QueryString["tagId"], out value3))
            {
                this.TagId = value3;
            }
            int value4 = 0;

            if (int.TryParse(this.Page.Request.QueryString["typeId"], out value4))
            {
                this.TypeId = value4;
            }
            if (!string.IsNullOrEmpty(this.Page.Request.QueryString["SaleStatus"]))
            {
                this.SaleStatus = (ProductSaleStatus)Enum.Parse(typeof(ProductSaleStatus), this.Page.Request.QueryString["SaleStatus"]);
            }
            if (!string.IsNullOrEmpty(this.Page.Request.QueryString["startDate"]))
            {
                this.StartDate = DateTime.Parse(this.Page.Request.QueryString["startDate"]);
            }
            if (!string.IsNullOrEmpty(this.Page.Request.QueryString["endDate"]))
            {
                this.EndDate = DateTime.Parse(this.Page.Request.QueryString["endDate"]);
            }
            if (!string.IsNullOrEmpty(this.Page.Request.QueryString["isWarningStock"]))
            {
                this.IsWarningStock = (this.Page.Request.QueryString["isWarningStock"] == "1" && true);
            }
            this.dropCategories.DataBind();
            this.dropCategories.SelectedValue = this.CategoryId;
        }
Esempio n. 14
0
        public void ChangeSaleStatus(HttpContext context)
        {
            string text     = context.Request["ids"];
            int?   intParam = base.GetIntParam(context, "status", true);

            if (!intParam.HasValue)
            {
                throw new HidistroAshxException("错误的状态参数");
            }
            ProductSaleStatus value = (ProductSaleStatus)intParam.Value;

            if (string.IsNullOrWhiteSpace(text))
            {
                throw new HidistroAshxException("请选择要操作的商品");
            }
            string[] source = text.Split(',');
            int      num    = source.Count();
            bool     flag   = false;
            int      num2   = 0;

            switch (value)
            {
            case ProductSaleStatus.OnSale:
                num2 = ProductHelper.UpShelf(text);
                break;

            case ProductSaleStatus.UnSale:
                text = ProductHelper.RemoveEffectiveActivityProductId(text);
                if (string.IsNullOrWhiteSpace(text))
                {
                    throw new HidistroAshxException("选中的商品都在参加活动不能被下架");
                }
                num2 = ProductHelper.OffShelf(text);
                break;

            case ProductSaleStatus.OnStock:
                text = ProductHelper.RemoveEffectiveActivityProductId(text);
                if (string.IsNullOrWhiteSpace(text))
                {
                    throw new HidistroAshxException("选中的商品都在参加活动不能被入库");
                }
                num2 = ProductHelper.InStock(text);
                break;

            default:
                throw new HidistroAshxException("错误的状态参数");
            }
            if (num2 > 0)
            {
                base.ReturnSuccessResult(context, "操作商品成功", 0, true);
                return;
            }
            throw new HidistroAshxException("操作商品失败");
        }
Esempio n. 15
0
 private void LoadParameters()
 {
     if (!this.Page.IsPostBack)
     {
         if (!string.IsNullOrEmpty(this.Page.Request.QueryString["productName"]))
         {
             this.productName = Globals.UrlDecode(this.Page.Request.QueryString["productName"]);
         }
         if (!string.IsNullOrEmpty(this.Page.Request.QueryString["productCode"]))
         {
             this.productCode = Globals.UrlDecode(this.Page.Request.QueryString["productCode"]);
         }
         if (!string.IsNullOrEmpty(this.Page.Request.QueryString["categoryId"]))
         {
             int result = 0;
             if (int.TryParse(this.Page.Request.QueryString["categoryId"], out result))
             {
                 this.categoryId = new int?(result);
             }
         }
         if (!string.IsNullOrEmpty(this.Page.Request.QueryString["tagId"]))
         {
             int num2 = 0;
             if (int.TryParse(this.Page.Request.QueryString["tagId"], out num2))
             {
                 this.tagId = new int?(num2);
             }
         }
         if (!string.IsNullOrEmpty(this.Page.Request.QueryString["SaleStatus"]))
         {
             this.saleStatus = (ProductSaleStatus)Enum.Parse(typeof(ProductSaleStatus), this.Page.Request.QueryString["SaleStatus"]);
         }
         bool.TryParse(this.Page.Request.QueryString["isAlert"], out this.isAlert);
         this.txtSearchText.Text = this.productName;
         this.txtSKU.Text        = this.productCode;
         this.dropCategories.DataBind();
         this.dropCategories.SelectedValue = this.categoryId;
         this.dropTagList.DataBind();
         this.dropTagList.SelectedValue    = this.tagId;
         this.chkIsAlert.Checked           = this.isAlert;
         this.dropSaleStatus.SelectedValue = this.saleStatus;
     }
     else
     {
         this.productName = this.txtSearchText.Text;
         this.productCode = this.txtSKU.Text;
         this.categoryId  = this.dropCategories.SelectedValue;
         this.tagId       = this.dropTagList.SelectedValue;
         this.saleStatus  = this.dropSaleStatus.SelectedValue;
         this.isAlert     = this.chkIsAlert.Checked;
     }
 }
Esempio n. 16
0
 private void LoadParameters()
 {
     if (!string.IsNullOrEmpty(this.Page.Request.QueryString["SaleStatus"]))
     {
         this.saleStatus      = (ProductSaleStatus)Enum.Parse(typeof(ProductSaleStatus), this.Page.Request.QueryString["SaleStatus"]);
         this.hidFilter.Value = ((int)this.saleStatus).ToNullString();
     }
     if (!string.IsNullOrEmpty(this.Page.Request.QueryString["isWarningStock"]))
     {
         this.isWarningStock = (this.Page.Request.QueryString["isWarningStock"] == "1" && true);
     }
     this.chkIsWarningStock.Checked = this.isWarningStock;
 }
Esempio n. 17
0
        private void btnImport_Click(object sender, System.EventArgs e)
        {
            if (!this.CheckItems())
            {
                return;
            }
            string            text          = this.dropFiles.SelectedValue;
            string            text2         = System.IO.Path.Combine(this._dataPath, System.IO.Path.GetFileNameWithoutExtension(text));
            ImportAdapter     importer      = TransferHelper.GetImporter(this.dropImportVersions.SelectedValue, new object[0]);
            int               value         = this.dropCategories.SelectedValue.Value;
            int?              selectedValue = this.dropBrandList.SelectedValue;
            ProductSaleStatus saleStatus    = ProductSaleStatus.Delete;

            if (this.radInStock.Checked)
            {
                saleStatus = ProductSaleStatus.OnStock;
            }
            if (this.radUnSales.Checked)
            {
                saleStatus = ProductSaleStatus.UnSale;
            }
            if (this.radOnSales.Checked)
            {
                saleStatus = ProductSaleStatus.OnSale;
            }
            text = System.IO.Path.Combine(this._dataPath, text);
            if (!System.IO.File.Exists(text))
            {
                this.ShowMsg("选择的数据包文件有问题!", false);
                return;
            }
            this.PrepareDataFiles(text2, text);
            try
            {
                object[] array = importer.ParseProductData(new object[]
                {
                    text2
                });
                ProductHelper.ImportProducts((System.Data.DataTable)array[0], value, 0, selectedValue, saleStatus, true);
                System.IO.File.Delete(text);
                System.IO.Directory.Delete(text2, true);
                this.BindFiles();
                this.ShowMsg("此次商品批量导入操作已成功!", true);
            }
            catch (System.Exception)
            {
                this.ShowMsg("选择的数据包文件有问题!", false);
            }
        }
Esempio n. 18
0
 private void btnImport_Click(object sender, System.EventArgs e)
 {
     if (this.CheckItems())
     {
         string            selectedValue = this.dropFiles.SelectedValue;
         string            path          = System.IO.Path.Combine(this._dataPath, System.IO.Path.GetFileNameWithoutExtension(selectedValue));
         ImportAdapter     importer      = TransferHelper.GetImporter(this.dropImportVersions.SelectedValue, new object[0]);
         int               categoryId    = this.dropCategories.SelectedValue.Value;
         int?              brandId       = this.dropBrandList.SelectedValue;
         ProductSaleStatus delete        = ProductSaleStatus.Delete;
         if (this.radInStock.Checked)
         {
             delete = ProductSaleStatus.OnStock;
         }
         if (this.radUnSales.Checked)
         {
             delete = ProductSaleStatus.UnSale;
         }
         if (this.radOnSales.Checked)
         {
             delete = ProductSaleStatus.OnSale;
         }
         selectedValue = System.IO.Path.Combine(this._dataPath, selectedValue);
         if (!System.IO.File.Exists(selectedValue))
         {
             this.ShowMsg("选择的数据包文件有问题!", false);
         }
         else
         {
             importer.PrepareDataFiles(new object[] { selectedValue });
             try
             {
                 ProductHelper.ImportProducts((System.Data.DataTable)importer.ParseProductData(new object[] { path })[0], categoryId, 0, brandId, delete, false);
                 System.IO.File.Delete(selectedValue);
                 System.IO.Directory.Delete(path, true);
                 this.BindFiles();
                 this.ShowMsg("此次商品批量导入操作已成功!", true);
             }
             catch
             {
                 System.IO.File.Delete(selectedValue);
                 System.IO.Directory.Delete(path, true);
                 this.ShowMsg("选择的数据包文件有问题!", false);
             }
         }
     }
 }
Esempio n. 19
0
        private void LoadParameters()
        {
            if (!string.IsNullOrEmpty(this.Page.Request.QueryString["SaleStatus"]))
            {
                this.saleStatus = (ProductSaleStatus)Enum.Parse(typeof(ProductSaleStatus), this.Page.Request.QueryString["SaleStatus"]);
            }
            if (!string.IsNullOrEmpty(this.Page.Request.QueryString["isWarningStock"]))
            {
                this.isWarningStock = (this.Page.Request.QueryString["isWarningStock"] == "1" && true);
            }
            int num = this.Page.Request["SupplierId"].ToInt(0);

            if (num > 0)
            {
                this.dropSuplier.SelectedValue = num.ToString();
            }
        }
Esempio n. 20
0
        private void BindProducts()
        {
            this.LoadParameters();
            ProductSaleStatus all    = ProductSaleStatus.All;
            ProductQuery      entity = new ProductQuery {
                Keywords   = this.productName,
                PageSize   = this.pager.PageSize,
                PageIndex  = this.pager.PageIndex,
                SaleStatus = all
            };

            this.txtSearchText.Text = entity.Keywords;
            Globals.EntityCoding(entity, true);
            DbQueryResult products = ProductHelper.GetProducts(entity);

            this.grdProducts.DataSource = products.Data;
            this.grdProducts.DataBind();
            this.pager.TotalRecords = products.TotalRecords;
        }
Esempio n. 21
0
 private void btnImport_Click(object sender, EventArgs e)
 {
     if (CheckItems())
     {
         string            selectedValue = dropFiles.SelectedValue;
         string            path          = Path.Combine(_dataPath, Path.GetFileNameWithoutExtension(selectedValue));
         ImportAdapter     importer      = TransferHelper.GetImporter(dropImportVersions.SelectedValue, new object[0]);
         int               categoryId    = dropCategories.SelectedValue.Value;
         int               lineId        = dropProductLines.SelectedValue.Value;
         int?              brandId       = dropBrandList.SelectedValue;
         ProductSaleStatus delete        = ProductSaleStatus.Delete;
         if (radInStock.Checked)
         {
             delete = ProductSaleStatus.OnStock;
         }
         if (radUnSales.Checked)
         {
             delete = ProductSaleStatus.UnSale;
         }
         if (radOnSales.Checked)
         {
             delete = ProductSaleStatus.OnSale;
         }
         selectedValue = Path.Combine(_dataPath, selectedValue);
         if (!File.Exists(selectedValue))
         {
             ShowMsg("选择的数据包文件有问题!", false);
         }
         else
         {
             importer.PrepareDataFiles(new object[] { selectedValue });
             ProductHelper.ImportProducts((DataTable)importer.ParseProductData(new object[] { path })[0], categoryId, lineId, brandId, delete);
             if (chkDeleteFiles.Checked)
             {
                 File.Delete(selectedValue);
                 Directory.Delete(path, true);
             }
             BindFiles();
             ShowMsg("此次商品批量导入操作已成功!", true);
         }
     }
 }
Esempio n. 22
0
        public override int UpdateProductSaleStatus(string productIds, ProductSaleStatus saleStatus)
        {
            DbCommand sqlStringCommand;

            if (saleStatus == ProductSaleStatus.OnSale)
            {
                sqlStringCommand =
                    this.database.GetSqlStringCommand(
                        string.Format(
                            "UPDATE a SET a.SaleStatus = {0} from HiFlat_Products  a inner join vw_HiFlat_BrowseProductList b on b.ProductId=a.ProductId " +
                            " WHERE a.ProductId IN ({1}) and b.Stock>0 and  b.Weight>0",
                            (int)saleStatus, productIds));
            }
            else
            {
                sqlStringCommand =
                    this.database.GetSqlStringCommand(
                        string.Format("UPDATE HiFlat_Products SET SaleStatus = {0} WHERE ProductId IN ({1})",
                                      (int)saleStatus, productIds));
            }
            return(this.database.ExecuteNonQuery(sqlStringCommand));
        }
Esempio n. 23
0
 private void btnImport_Click(object sender, EventArgs e)
 {
     if (this.CheckItems())
     {
         string            selectedValue  = this.dropFiles.SelectedValue;
         string            text           = Path.Combine(this._dataPath, Path.GetFileNameWithoutExtension(selectedValue));
         ImportAdapter     importer       = TransferHelper.GetImporter(this.dropImportVersions.SelectedValue);
         int               value          = this.dropCategories.SelectedValue.Value;
         int?              selectedValue2 = this.dropBrandList.SelectedValue;
         ProductSaleStatus saleStatus     = ProductSaleStatus.Delete;
         if (this.radInStock.Checked)
         {
             saleStatus = ProductSaleStatus.OnStock;
         }
         if (this.radUnSales.Checked)
         {
             saleStatus = ProductSaleStatus.UnSale;
         }
         if (this.radOnSales.Checked)
         {
             saleStatus = ProductSaleStatus.OnSale;
         }
         selectedValue = Path.Combine(this._dataPath, selectedValue);
         if (!File.Exists(selectedValue))
         {
             this.ShowMsg("选择的数据包文件有问题!", false);
         }
         else
         {
             this.PrepareDataFiles(text, selectedValue);
             object[] array = importer.ParseProductData(text);
             ProductHelper.ImportProducts((DataTable)array[0], value, selectedValue2, saleStatus, true);
             File.Delete(selectedValue);
             Directory.Delete(text, true);
             this.BindFiles();
             this.ShowMsg("此次商品批量导入操作已成功!", true);
         }
     }
 }
Esempio n. 24
0
 public override int UpdateProductSaleStatus(string productIds, ProductSaleStatus saleStatus)
 {
     DbCommand sqlStringCommand = database.GetSqlStringCommand(string.Format("UPDATE distro_Products SET SaleStatus = {0} WHERE DistributorUserId = {1} AND ProductId IN ({2})", (int)saleStatus, HiContext.Current.User.UserId, productIds));
     return database.ExecuteNonQuery(sqlStringCommand);
 }
Esempio n. 25
0
 public abstract bool GetShoppingProductInfo(Member member, int productId, string skuId, out ProductSaleStatus saleStatus, out int stock, out int totalQuantity);
Esempio n. 26
0
 public abstract ShoppingCartItemInfo GetCartItemInfo(Member member, int productId, string skuId, string skuContent, int quantity, out ProductSaleStatus saleStatus, out string sku, out int stock, out int totalQuantity);
Esempio n. 27
0
 public override bool GetShoppingProductInfo(Hidistro.Membership.Context.Member member, int productId, string skuId, out ProductSaleStatus saleStatus, out int stock, out int totalQuantity)
 {
     saleStatus = ProductSaleStatus.Delete;
     stock = 0;
     totalQuantity = 0;
     bool flag = false;
     DbCommand sqlStringCommand = database.GetSqlStringCommand("SELECT Stock,SaleStatus,AlertStock FROM Hishop_Skus s INNER JOIN Hishop_Products p ON s.ProductId=p.ProductId WHERE s.ProductId=@ProductId AND s.SkuId=@SkuId;SELECT Quantity FROM Hishop_ShoppingCarts sc WHERE sc.ProductId=@ProductId AND sc.SkuId=@SkuId AND sc.UserId=@UserId");
     database.AddInParameter(sqlStringCommand, "ProductId", DbType.Int32, productId);
     database.AddInParameter(sqlStringCommand, "UserId", DbType.Int32, member.UserId);
     database.AddInParameter(sqlStringCommand, "SkuId", DbType.String, skuId);
     using (IDataReader reader = database.ExecuteReader(sqlStringCommand))
     {
         if (reader.Read())
         {
             saleStatus = (ProductSaleStatus)((int)reader["SaleStatus"]);
             stock = (int)reader["Stock"];
             flag = true;
         }
         if (reader.NextResult() && reader.Read())
         {
             totalQuantity = (int)reader["Quantity"];
         }
     }
     return flag;
 }
Esempio n. 28
0
 private void LoadParameters()
 {
     if (!string.IsNullOrEmpty(this.Page.Request.QueryString["productName"]))
     {
         this.productName = Globals.UrlDecode(this.Page.Request.QueryString["productName"]);
     }
     if (!string.IsNullOrEmpty(this.Page.Request.QueryString["productCode"]))
     {
         this.productCode = Globals.UrlDecode(this.Page.Request.QueryString["productCode"]);
     }
     int result = 0;
     if (int.TryParse(this.Page.Request.QueryString["categoryId"], out result))
     {
         this.categoryId = new int?(result);
     }
     int num2 = 0;
     if (int.TryParse(this.Page.Request.QueryString["brandId"], out num2))
     {
         this.dropBrandList.SelectedValue = new int?(num2);
     }
     int num3 = 0;
     if (int.TryParse(this.Page.Request.QueryString["tagId"], out num3))
     {
         this.tagId = new int?(num3);
     }
     int num4 = 0;
     if (int.TryParse(this.Page.Request.QueryString["typeId"], out num4))
     {
         this.typeId = new int?(num4);
     }
     if (!string.IsNullOrEmpty(this.Page.Request.QueryString["SaleStatus"]))
     {
         this.saleStatus = (ProductSaleStatus) Enum.Parse(typeof(ProductSaleStatus), this.Page.Request.QueryString["SaleStatus"]);
     }
     if (!string.IsNullOrEmpty(this.Page.Request.QueryString["startDate"]))
     {
         this.startDate = new DateTime?(DateTime.Parse(this.Page.Request.QueryString["startDate"]));
     }
     if (!string.IsNullOrEmpty(this.Page.Request.QueryString["endDate"]))
     {
         this.endDate = new DateTime?(DateTime.Parse(this.Page.Request.QueryString["endDate"]));
     }
     this.txtSearchText.Text = this.productName;
     this.txtSKU.Text = this.productCode;
     this.dropCategories.DataBind();
     this.dropCategories.SelectedValue = this.categoryId;
     this.dropTagList.DataBind();
     this.dropTagList.SelectedValue = this.tagId;
     this.calendarStartDate.SelectedDate = this.startDate;
     this.calendarEndDate.SelectedDate = this.endDate;
     this.dropType.SelectedValue = this.typeId;
     this.dropSaleStatus.SelectedValue = this.saleStatus;
 }
Esempio n. 29
0
 public abstract int UpdateProductSaleStatus(string productIds, ProductSaleStatus saleStatus);
Esempio n. 30
0
 public override bool GetShoppingProductInfo(Member member, int productId, string skuId, out ProductSaleStatus saleStatus, out int stock, out int totalQuantity)
 {
     saleStatus = ProductSaleStatus.Delete;
     stock = 0;
     totalQuantity = 0;
     bool flag = false;
     DbCommand sqlStringCommand = this.database.GetSqlStringCommand("SELECT Stock,SaleStatus,AlertStock FROM Hishop_Skus s INNER JOIN distro_Products p ON s.ProductId=p.ProductId WHERE s.ProductId=@ProductId AND s.SkuId=@SkuId AND p.DistributorUserId=@DistributorUserId;SELECT Quantity FROM distro_ShoppingCarts sc WHERE sc.ProductId=@ProductId AND sc.SkuId=@SkuId AND sc.UserId=@UserId AND sc.DistributorUserId=@DistributorUserId");
     this.database.AddInParameter(sqlStringCommand, "ProductId", DbType.Int32, productId);
     this.database.AddInParameter(sqlStringCommand, "UserId", DbType.Int32, member.UserId);
     this.database.AddInParameter(sqlStringCommand, "SkuId", DbType.String, skuId);
     this.database.AddInParameter(sqlStringCommand, "DistributorUserId", DbType.Int32, HiContext.Current.SiteSettings.UserId.Value);
     using (IDataReader reader = this.database.ExecuteReader(sqlStringCommand))
     {
         if (reader.Read())
         {
             saleStatus = (ProductSaleStatus) ((int) reader["SaleStatus"]);
             stock = (int) reader["Stock"];
             int num = (int) reader["AlertStock"];
             if (stock <= num)
             {
                 saleStatus = ProductSaleStatus.UnSale;
             }
             flag = true;
         }
         if (reader.NextResult() && reader.Read())
         {
             totalQuantity = (int) reader["Quantity"];
         }
     }
     return flag;
 }
Esempio n. 31
0
 public int UpdateProductSaleStatus(string productIds, ProductSaleStatus saleStatus)
 {
     DbCommand sqlStringCommand = this.database.GetSqlStringCommand(string.Format("UPDATE Hishop_Products SET SaleStatus = {0} WHERE ProductId IN ({1})", (int) saleStatus, productIds));
     return this.database.ExecuteNonQuery(sqlStringCommand);
 }
Esempio n. 32
0
 public static int UpdateProductSaleStatus(string productIds, ProductSaleStatus saleStatus)
 {
     return SubsiteProductProvider.Instance().UpdateProductSaleStatus(productIds, saleStatus);
 }
Esempio n. 33
0
 public override ShoppingCartItemInfo GetCartItemInfo(Member member, int productId, string skuId, string skuContent, int quantity, out ProductSaleStatus saleStatus, out string sku, out int stock, out int totalQuantity)
 {
     saleStatus = ProductSaleStatus.Delete;
     sku = string.Empty;
     stock = 0;
     totalQuantity = quantity;
     ShoppingCartItemInfo info = null;
     DbCommand storedProcCommand = this.database.GetStoredProcCommand("ss_distro_ShoppingCart_GetItemInfo");
     this.database.AddInParameter(storedProcCommand, "ProductId", DbType.Int32, productId);
     this.database.AddInParameter(storedProcCommand, "Quantity", DbType.Int32, quantity);
     this.database.AddInParameter(storedProcCommand, "UserId", DbType.Int32, (member != null) ? member.UserId : 0);
     this.database.AddInParameter(storedProcCommand, "SkuId", DbType.String, skuId);
     this.database.AddInParameter(storedProcCommand, "GradeId", DbType.Int32, (member != null) ? member.GradeId : 0);
     this.database.AddInParameter(storedProcCommand, "DistributorUserId", DbType.Int32, HiContext.Current.SiteSettings.UserId.Value);
     using (IDataReader reader = this.database.ExecuteReader(storedProcCommand))
     {
         if (!reader.Read())
         {
             return info;
         }
         saleStatus = (ProductSaleStatus) ((int) reader["SaleStatus"]);
         if (reader["SKU"] != DBNull.Value)
         {
             sku = (string) reader["SKU"];
         }
         stock = (int) reader["Stock"];
         int num = (int) reader["AlertStock"];
         if (stock <= num)
         {
             saleStatus = ProductSaleStatus.UnSale;
         }
         if (reader["TotalQuantity"].ToString() != "")
         {
             totalQuantity = (int) reader["TotalQuantity"];
         }
         string name = reader["ProductName"].ToString();
         int categoryId = 0;
         if (DBNull.Value != reader["CategoryId"])
         {
             categoryId = (int) reader["CategoryId"];
         }
         int weight = 0;
         if (DBNull.Value != reader["Weight"])
         {
             weight = (int) reader["Weight"];
         }
         decimal memberPrice = (decimal) reader["SalePrice"];
         string str2 = string.Empty;
         if (DBNull.Value != reader["ThumbnailUrl40"])
         {
             str2 = reader["ThumbnailUrl40"].ToString();
         }
         string str3 = string.Empty;
         if (DBNull.Value != reader["ThumbnailUrl60"])
         {
             str3 = reader["ThumbnailUrl60"].ToString();
         }
         string str4 = string.Empty;
         if (DBNull.Value != reader["ThumbnailUrl100"])
         {
             str4 = reader["ThumbnailUrl100"].ToString();
         }
         int purchaseGiftId = 0;
         int giveQuantity = 0;
         int wholesaleDiscountId = 0;
         string purchaseGiftName = null;
         string wholesaleDiscountName = null;
         decimal? discountRate = null;
         if (member != null)
         {
             if (reader.NextResult() && reader.Read())
             {
                 if (DBNull.Value != reader["ActivityId"])
                 {
                     purchaseGiftId = (int) reader["ActivityId"];
                 }
                 if (DBNull.Value != reader["Name"])
                 {
                     purchaseGiftName = reader["Name"].ToString();
                 }
                 if ((DBNull.Value != reader["BuyQuantity"]) && (DBNull.Value != reader["GiveQuantity"]))
                 {
                     giveQuantity = (totalQuantity / ((int) reader["BuyQuantity"])) * ((int) reader["GiveQuantity"]);
                 }
             }
             if (reader.NextResult() && reader.Read())
             {
                 if (DBNull.Value != reader["ActivityId"])
                 {
                     wholesaleDiscountId = (int) reader["ActivityId"];
                 }
                 if (DBNull.Value != reader["Name"])
                 {
                     wholesaleDiscountName = reader["Name"].ToString();
                 }
                 if (DBNull.Value != reader["DiscountValue"])
                 {
                     discountRate = new decimal?(Convert.ToDecimal(reader["DiscountValue"]));
                 }
             }
         }
         return new ShoppingCartItemInfo(skuId, productId, sku, name, memberPrice, skuContent, totalQuantity, weight, purchaseGiftId, purchaseGiftName, giveQuantity, wholesaleDiscountId, wholesaleDiscountName, discountRate, categoryId, str2, str3, str4);
     }
 }
Esempio n. 34
0
 private static ProductInfo ConverToProduct(DataRow productRow, int categoryId, int lineId, int? bandId, ProductSaleStatus saleStatus, bool includeImages)
 {
     ProductInfo info = new ProductInfo {
         CategoryId = categoryId,
         TypeId = new int?((int) productRow["SelectedTypeId"]),
         ProductName = (string) productRow["ProductName"],
         ProductCode = (string) productRow["ProductCode"],
         BrandId = bandId,
         Unit = (string) productRow["Unit"],
         ShortDescription = (string) productRow["ShortDescription"],
         Description = (string) productRow["Description"],
         AddedDate = DateTime.Now,
         SaleStatus = saleStatus,
         HasSKU = (bool) productRow["HasSKU"],
         MainCategoryPath = CatalogHelper.GetCategory(categoryId).Path + "|",
         ImageUrl1 = (string) productRow["ImageUrl1"],
         ImageUrl2 = (string) productRow["ImageUrl2"],
         ImageUrl3 = (string) productRow["ImageUrl3"],
         ImageUrl4 = (string) productRow["ImageUrl4"],
         ImageUrl5 = (string) productRow["ImageUrl5"]
     };
     if (productRow["MarketPrice"] != DBNull.Value)
     {
         info.MarketPrice = new decimal?((decimal) productRow["MarketPrice"]);
     }
     if (includeImages)
     {
         string[] strArray;
         HttpContext current = HttpContext.Current;
         if (!(string.IsNullOrEmpty(info.ImageUrl1) || (info.ImageUrl1.Length <= 0)))
         {
             strArray = ProcessImages(current, info.ImageUrl1);
             info.ThumbnailUrl40 = strArray[0];
             info.ThumbnailUrl60 = strArray[1];
             info.ThumbnailUrl100 = strArray[2];
             info.ThumbnailUrl160 = strArray[3];
             info.ThumbnailUrl180 = strArray[4];
             info.ThumbnailUrl220 = strArray[5];
             info.ThumbnailUrl310 = strArray[6];
             info.ThumbnailUrl410 = strArray[7];
         }
         if (!(string.IsNullOrEmpty(info.ImageUrl2) || (info.ImageUrl2.Length <= 0)))
         {
             strArray = ProcessImages(current, info.ImageUrl2);
         }
         if (!(string.IsNullOrEmpty(info.ImageUrl3) || (info.ImageUrl3.Length <= 0)))
         {
             strArray = ProcessImages(current, info.ImageUrl3);
         }
         if (!(string.IsNullOrEmpty(info.ImageUrl4) || (info.ImageUrl4.Length <= 0)))
         {
             strArray = ProcessImages(current, info.ImageUrl4);
         }
         if (!(string.IsNullOrEmpty(info.ImageUrl5) || (info.ImageUrl5.Length <= 0)))
         {
             strArray = ProcessImages(current, info.ImageUrl5);
         }
     }
     return info;
 }
Esempio n. 35
0
 protected AddProductToCoupon_stock() : base("m08", "yxp01")
 {
     this.status = ProductSaleStatus.OnStock;
 }
Esempio n. 36
0
 public static void ImportProducts(DataTable productData, int categoryId, int lineId, int? brandId, ProductSaleStatus saleStatus, bool isImportFromTaobao)
 {
     if ((productData != null) && (productData.Rows.Count > 0))
     {
         foreach (DataRow row in productData.Rows)
         {
             string[] strArray;
             ProductInfo product = new ProductInfo {
                 CategoryId = categoryId,
                 MainCategoryPath = CatalogHelper.GetCategory(categoryId).Path + "|",
                 ProductName = (string) row["ProductName"],
                 ProductCode = (string) row["SKU"],
                 BrandId = brandId
             };
             if (row["Description"] != DBNull.Value)
             {
                 product.Description = (string) row["Description"];
             }
             product.AddedDate = DateTime.Now;
             product.SaleStatus = saleStatus;
             product.HasSKU = false;
             HttpContext current = HttpContext.Current;
             if (row["ImageUrl1"] != DBNull.Value)
             {
                 product.ImageUrl1 = (string) row["ImageUrl1"];
             }
             if (!(string.IsNullOrEmpty(product.ImageUrl1) || (product.ImageUrl1.Length <= 0)))
             {
                 strArray = ProcessImages(current, product.ImageUrl1);
                 product.ThumbnailUrl40 = strArray[0];
                 product.ThumbnailUrl60 = strArray[1];
                 product.ThumbnailUrl100 = strArray[2];
                 product.ThumbnailUrl160 = strArray[3];
                 product.ThumbnailUrl180 = strArray[4];
                 product.ThumbnailUrl220 = strArray[5];
                 product.ThumbnailUrl310 = strArray[6];
                 product.ThumbnailUrl410 = strArray[7];
             }
             if (row["ImageUrl2"] != DBNull.Value)
             {
                 product.ImageUrl2 = (string) row["ImageUrl2"];
             }
             if (!(string.IsNullOrEmpty(product.ImageUrl2) || (product.ImageUrl2.Length <= 0)))
             {
                 strArray = ProcessImages(current, product.ImageUrl2);
             }
             if (row["ImageUrl3"] != DBNull.Value)
             {
                 product.ImageUrl3 = (string) row["ImageUrl3"];
             }
             if (!(string.IsNullOrEmpty(product.ImageUrl3) || (product.ImageUrl3.Length <= 0)))
             {
                 strArray = ProcessImages(current, product.ImageUrl3);
             }
             if (row["ImageUrl4"] != DBNull.Value)
             {
                 product.ImageUrl4 = (string) row["ImageUrl4"];
             }
             if (!(string.IsNullOrEmpty(product.ImageUrl4) || (product.ImageUrl4.Length <= 0)))
             {
                 strArray = ProcessImages(current, product.ImageUrl4);
             }
             if (row["ImageUrl5"] != DBNull.Value)
             {
                 product.ImageUrl5 = (string) row["ImageUrl5"];
             }
             if (!(string.IsNullOrEmpty(product.ImageUrl5) || (product.ImageUrl5.Length <= 0)))
             {
                 strArray = ProcessImages(current, product.ImageUrl5);
             }
             SKUItem item = new SKUItem {
                 SkuId = "0",
                 SKU = (string) row["SKU"]
             };
             if (row["Stock"] != DBNull.Value)
             {
                 item.Stock = (int) row["Stock"];
             }
             if (row["Weight"] != DBNull.Value)
             {
                 item.Weight = (decimal) row["Weight"];
             }
             item.SalePrice = (decimal) row["SalePrice"];
             Dictionary<string, SKUItem> skus = new Dictionary<string, SKUItem>();
             skus.Add(item.SkuId, item);
             ProductActionStatus status = AddProduct(product, skus, null, null);
             if (isImportFromTaobao && (status == ProductActionStatus.Success))
             {
                 TaobaoProductInfo taobaoProduct = new TaobaoProductInfo {
                     ProductId = product.ProductId,
                     ProTitle = product.ProductName,
                     Cid = (long) row["Cid"]
                 };
                 if (row["StuffStatus"] != DBNull.Value)
                 {
                     taobaoProduct.StuffStatus = (string) row["StuffStatus"];
                 }
                 taobaoProduct.Num = (long) row["Num"];
                 taobaoProduct.LocationState = (string) row["LocationState"];
                 taobaoProduct.LocationCity = (string) row["LocationCity"];
                 taobaoProduct.FreightPayer = (string) row["FreightPayer"];
                 if (row["PostFee"] != DBNull.Value)
                 {
                     taobaoProduct.PostFee = (decimal) row["PostFee"];
                 }
                 if (row["ExpressFee"] != DBNull.Value)
                 {
                     taobaoProduct.ExpressFee = (decimal) row["ExpressFee"];
                 }
                 if (row["EMSFee"] != DBNull.Value)
                 {
                     taobaoProduct.EMSFee = (decimal) row["EMSFee"];
                 }
                 taobaoProduct.HasInvoice = (bool) row["HasInvoice"];
                 taobaoProduct.HasWarranty = (bool) row["HasWarranty"];
                 taobaoProduct.HasDiscount = (bool) row["HasDiscount"];
                 taobaoProduct.ValidThru = (long) row["ValidThru"];
                 if (row["ListTime"] != DBNull.Value)
                 {
                     taobaoProduct.ListTime = (DateTime) row["ListTime"];
                 }
                 else
                 {
                     taobaoProduct.ListTime = DateTime.Now;
                 }
                 if (row["PropertyAlias"] != DBNull.Value)
                 {
                     taobaoProduct.PropertyAlias = (string) row["PropertyAlias"];
                 }
                 if (row["InputPids"] != DBNull.Value)
                 {
                     taobaoProduct.InputPids = (string) row["InputPids"];
                 }
                 if (row["InputStr"] != DBNull.Value)
                 {
                     taobaoProduct.InputStr = (string) row["InputStr"];
                 }
                 if (row["SkuProperties"] != DBNull.Value)
                 {
                     taobaoProduct.SkuProperties = (string) row["SkuProperties"];
                 }
                 if (row["SkuQuantities"] != DBNull.Value)
                 {
                     taobaoProduct.SkuQuantities = (string) row["SkuQuantities"];
                 }
                 if (row["SkuPrices"] != DBNull.Value)
                 {
                     taobaoProduct.SkuPrices = (string) row["SkuPrices"];
                 }
                 if (row["SkuOuterIds"] != DBNull.Value)
                 {
                     taobaoProduct.SkuOuterIds = (string) row["SkuOuterIds"];
                 }
                 UpdateToaobProduct(taobaoProduct);
             }
         }
     }
 }
        private void btnSave_Click(object sender, EventArgs e)
        {
            int     num;
            int     num2;
            int     num3;
            decimal num4;
            decimal num5;
            decimal num6;
            decimal?nullable;
            decimal?nullable2;
            decimal?nullable3;

            if (this.categoryId == 0)
            {
                this.categoryId = (int)this.ViewState["ProductCategoryId"];
            }
            if (this.ValidateConverts(this.chkSkuEnabled.Checked, out num, out num4, out num5, out num6, out nullable, out nullable2, out num2, out num3, out nullable3))
            {
                if (!this.chkSkuEnabled.Checked)
                {
                    if (num6 <= 0M)
                    {
                        this.ShowMsg("商品一口价必须大于0", false);
                        return;
                    }
                    if (nullable.HasValue && (nullable.Value >= num6))
                    {
                        this.ShowMsg("商品成本价必须小于商品一口价", false);
                        return;
                    }
                    if (num4 > num5)
                    {
                        this.ShowMsg("分销商采购价必须要小于等于其最低零售价", false);
                        return;
                    }
                }
                string text = this.fckDescription.Text;
                if (this.ckbIsDownPic.Checked)
                {
                    text = base.DownRemotePic(text);
                }
                ProductInfo info3 = new ProductInfo();
                info3.ProductId         = this.productId;
                info3.CategoryId        = this.categoryId;
                info3.TypeId            = this.dropProductTypes.SelectedValue;
                info3.ProductName       = this.txtProductName.Text;
                info3.ProductCode       = this.txtProductCode.Text;
                info3.DisplaySequence   = num;
                info3.LineId            = this.dropProductLines.SelectedValue.Value;
                info3.LowestSalePrice   = num5;
                info3.MarketPrice       = nullable2;
                info3.Unit              = this.txtUnit.Text;
                info3.ImageUrl1         = this.uploader1.UploadedImageUrl;
                info3.ImageUrl2         = this.uploader2.UploadedImageUrl;
                info3.ImageUrl3         = this.uploader3.UploadedImageUrl;
                info3.ImageUrl4         = this.uploader4.UploadedImageUrl;
                info3.ImageUrl5         = this.uploader5.UploadedImageUrl;
                info3.ThumbnailUrl40    = this.uploader1.ThumbnailUrl40;
                info3.ThumbnailUrl60    = this.uploader1.ThumbnailUrl60;
                info3.ThumbnailUrl100   = this.uploader1.ThumbnailUrl100;
                info3.ThumbnailUrl160   = this.uploader1.ThumbnailUrl160;
                info3.ThumbnailUrl180   = this.uploader1.ThumbnailUrl180;
                info3.ThumbnailUrl220   = this.uploader1.ThumbnailUrl220;
                info3.ThumbnailUrl310   = this.uploader1.ThumbnailUrl310;
                info3.ThumbnailUrl410   = this.uploader1.ThumbnailUrl410;
                info3.ShortDescription  = this.txtShortDescription.Text;
                info3.Description       = (!string.IsNullOrEmpty(text) && (text.Length > 0)) ? text : null;
                info3.PenetrationStatus = this.chkPenetration.Checked ? PenetrationStatus.Already : PenetrationStatus.Notyet;
                info3.Title             = this.txtTitle.Text;
                info3.MetaDescription   = this.txtMetaDescription.Text;
                info3.MetaKeywords      = this.txtMetaKeywords.Text;
                info3.AddedDate         = DateTime.Now;
                info3.BrandId           = this.dropBrandCategories.SelectedValue;
                ProductInfo       target = info3;
                ProductSaleStatus onSale = ProductSaleStatus.OnSale;
                if (this.radInStock.Checked)
                {
                    onSale = ProductSaleStatus.OnStock;
                }
                if (this.radUnSales.Checked)
                {
                    onSale = ProductSaleStatus.UnSale;
                }
                if (this.radOnSales.Checked)
                {
                    onSale = ProductSaleStatus.OnSale;
                }
                target.SaleStatus = onSale;
                CategoryInfo category = CatalogHelper.GetCategory(this.categoryId);
                if (category != null)
                {
                    target.MainCategoryPath = category.Path + "|";
                }
                Dictionary <string, SKUItem>   skus  = null;
                Dictionary <int, IList <int> > attrs = null;
                if (this.chkSkuEnabled.Checked)
                {
                    target.HasSKU = true;
                    skus          = base.GetSkus(this.txtSkus.Text);
                }
                else
                {
                    Dictionary <string, SKUItem> dictionary3 = new Dictionary <string, SKUItem>();
                    SKUItem item = new SKUItem();
                    item.SkuId         = "0";
                    item.SKU           = this.txtSku.Text;
                    item.SalePrice     = num6;
                    item.CostPrice     = nullable.HasValue ? nullable.Value : 0M;
                    item.PurchasePrice = num4;
                    item.Stock         = num2;
                    item.AlertStock    = num3;
                    item.Weight        = nullable3.HasValue ? nullable3.Value : 0M;
                    dictionary3.Add("0", item);
                    skus = dictionary3;
                    if (this.txtMemberPrices.Text.Length > 0)
                    {
                        base.GetMemberPrices(skus["0"], this.txtMemberPrices.Text);
                    }
                    if (this.txtDistributorPrices.Text.Length > 0)
                    {
                        base.GetDistributorPrices(skus["0"], this.txtDistributorPrices.Text);
                    }
                }
                if (!string.IsNullOrEmpty(this.txtAttributes.Text) && (this.txtAttributes.Text.Length > 0))
                {
                    attrs = base.GetAttributes(this.txtAttributes.Text);
                }
                ValidationResults validateResults = Hishop.Components.Validation.Validation.Validate <ProductInfo>(target);
                if (!validateResults.IsValid)
                {
                    this.ShowMsg(validateResults);
                }
                else
                {
                    if (this.ViewState["distributorUserIds"] == null)
                    {
                        this.ViewState["distributorUserIds"] = new List <int>();
                    }
                    int type = 0;
                    if (((target.LineId > 0) && (int.Parse(this.hdlineId.Value) > 0)) && (target.LineId != int.Parse(this.hdlineId.Value)))
                    {
                        type = 6;
                    }
                    if (!this.chkPenetration.Checked)
                    {
                        type = 5;
                    }
                    if (type == 5)
                    {
                        SendMessageHelper.SendMessageToDistributors(target.ProductId.ToString(), type);
                        ProductHelper.CanclePenetrationProducts(this.productId.ToString());
                    }
                    else if (type == 6)
                    {
                        this.toline = this.dropProductLines.SelectedItem.Text;
                        SendMessageHelper.SendMessageToDistributors(this.hdlineId.Value + "|" + this.toline, type);
                    }
                    IList <int> tagIds = new List <int>();
                    if (!string.IsNullOrEmpty(this.txtProductTag.Text.Trim()))
                    {
                        string   str2     = this.txtProductTag.Text.Trim();
                        string[] strArray = null;
                        if (str2.Contains(","))
                        {
                            strArray = str2.Split(new char[] { ',' });
                        }
                        else
                        {
                            strArray = new string[] { str2 };
                        }
                        foreach (string str3 in strArray)
                        {
                            tagIds.Add(Convert.ToInt32(str3));
                        }
                    }
                    switch (ProductHelper.UpdateProduct(target, skus, attrs, (IList <int>) this.ViewState["distributorUserIds"], tagIds))
                    {
                    case ProductActionStatus.Success:
                        this.litralProductTag.SelectedValue = tagIds;
                        this.ShowMsg("修改商品成功", true);
                        return;

                    case ProductActionStatus.AttributeError:
                        this.ShowMsg("修改商品失败,保存商品属性时出错", false);
                        return;

                    case ProductActionStatus.DuplicateName:
                        this.ShowMsg("修改商品失败,商品名称不能重复", false);
                        return;

                    case ProductActionStatus.DuplicateSKU:
                        this.ShowMsg("修改商品失败,商家编码不能重复", false);
                        return;

                    case ProductActionStatus.SKUError:
                        this.ShowMsg("修改商品失败,商家编码不能重复", false);
                        return;

                    case ProductActionStatus.OffShelfError:
                        this.ShowMsg("修改商品失败, 子站没在零售价范围内的商品无法下架", false);
                        return;

                    case ProductActionStatus.ProductTagEroor:
                        this.ShowMsg("修改商品失败,保存商品标签时出错", false);
                        return;
                    }
                    this.ShowMsg("修改商品失败,未知错误", false);
                }
            }
        }
Esempio n. 38
0
        private void btnAdd_Click(object sender, System.EventArgs e)
        {
            int     displaySequence;
            decimal salePrice;
            decimal?costPrice;
            decimal?marketPrice;
            int     stock;
            int     factstock;
            decimal?num4;
            decimal?referralDeduct;
            decimal?subMemberDeduct;
            decimal?subReferralDeduct;
            decimal?deductFee;
            int     buyCardinality;
            decimal?grossweight;

            //销售类型
            int saletype = string.IsNullOrWhiteSpace(this.dropSaleType.SelectedValue) ? 1 : Convert.ToInt32(this.dropSaleType.SelectedValue);

            if (!this.ValidateConverts(this.chkSkuEnabled.Checked, out displaySequence, out salePrice, out costPrice, out marketPrice, out stock, out factstock, out num4, out referralDeduct, out subMemberDeduct, out subReferralDeduct, out deductFee, out buyCardinality, out grossweight))
            {
                return;
            }

            if (saletype != 2)
            {
                if (this.ddlImportSourceType.SelectedValue == null || this.ddlImportSourceType.SelectedValue == 0)
                {
                    this.ShowMsg("请选择原产地", false);
                    return;
                }
            }

            if (saletype != 2)
            {
                if (this.ddlSupplier.SelectedValue == null || this.ddlSupplier.SelectedValue == 0)
                {
                    this.ShowMsg("请选择供货商", false);
                    return;
                }
            }

            if (this.ddlUnit.SelectedValue == null || this.ddlUnit.SelectedValue == "")
            {
                this.ShowMsg("请选择计量单位", false);
                return;
            }
            if (this.ddlShipping.SelectedValue == null || this.ddlShipping.SelectedValue == 0)
            {
                this.ShowMsg("请选择运费模版", false);
                return;
            }
            int ConversionRelation;

            if (!int.TryParse(this.txtConversionRelation.Text, out ConversionRelation))
            {
                this.ShowMsg("输入换算关系不正确", false);
                return;
            }

            if (!this.chkSkuEnabled.Checked)
            {
                if (salePrice <= 0m)
                {
                    this.ShowMsg("商品一口价必须大于0", false);
                    return;
                }
                if (costPrice.HasValue && (costPrice.Value > salePrice || costPrice.Value < 0m))
                {
                    this.ShowMsg("商品成本价必须大于0且小于商品一口价", false);
                    return;
                }
                if (!costPrice.HasValue)              //|| !deductFee.HasValue
                {
                    this.ShowMsg("商品成本价不能为空", false); //与扣点
                    return;
                }
                if (string.IsNullOrEmpty(txtProductStandard.Text))
                {
                    this.ShowMsg("未开启多规格时,商品规格必填", false);
                    return;
                }
            }

            string text = Globals.StripScriptTags(this.txtProductName.Text.Trim());

            text = Globals.StripHtmlXmlTags(text).Replace("\\", "").Replace("'", "");
            if (string.IsNullOrEmpty(text) || text == "")
            {
                this.ShowMsg("商品名称不能为空,且不能包含脚本标签、HTML标签、XML标签、反斜杠(\\)、单引号(')!", false);
                return;
            }
            //判断是否存在广告关键字
            Dictionary <string, string> msg;

            if (!ValidateKeyWordHelper.ValidateKeyWord(new Dictionary <string, string>()
            {
                { "商品名称", this.txtProductName.Text }, { "商品简介", this.txtShortDescription.Text }
            }, out msg))
            {
                System.Text.StringBuilder showMsg = new System.Text.StringBuilder();
                foreach (string k in msg.Keys)
                {
                    showMsg.Append(k + "中不能包含广告词:" + msg[k] + ";");
                }
                this.ShowMsg(showMsg.ToString(), false);
                return;
            }
            string text2 = this.editDescription.Text;
            string text3 = this.editmobbileDescription.Text;

            if (this.ckbIsDownPic.Checked)
            {
                text2 = base.DownRemotePic(text2);
                text3 = base.DownRemotePic(text3);
            }

            System.Text.RegularExpressions.Regex regex = new System.Text.RegularExpressions.Regex("<script[^>]*?>.*?</script>", System.Text.RegularExpressions.RegexOptions.IgnoreCase);
            ProductInfo productInfo = new ProductInfo
            {
                CategoryId         = this.categoryId,
                TypeId             = this.dropProductTypes.SelectedValue,
                ProductName        = text,
                EnglishName        = this.txtEnglishName.Text,
                SysProductName     = this.txtsysProductName.Text.Trim(),
                ProductCode        = this.txtProductCode.Text,
                MarketPrice        = marketPrice,
                Unit               = this.ddlUnit.SelectedItem.Text,
                ImageUrl1          = this.uploader1.UploadedImageUrl,
                ImageUrl2          = this.uploader2.UploadedImageUrl,
                ImageUrl3          = this.uploader3.UploadedImageUrl,
                ImageUrl4          = this.uploader4.UploadedImageUrl,
                ImageUrl5          = this.uploader5.UploadedImageUrl,
                ThumbnailUrl40     = this.uploader1.ThumbnailUrl40,
                ThumbnailUrl60     = this.uploader1.ThumbnailUrl60,
                ThumbnailUrl100    = this.uploader1.ThumbnailUrl100,
                ThumbnailUrl160    = this.uploader1.ThumbnailUrl160,
                ThumbnailUrl180    = this.uploader1.ThumbnailUrl180,
                ThumbnailUrl220    = this.uploader1.ThumbnailUrl220,
                ThumbnailUrl310    = this.uploader1.ThumbnailUrl310,
                ThumbnailUrl410    = this.uploader1.ThumbnailUrl410,
                ShortDescription   = this.txtShortDescription.Text,
                IsCustomsClearance = this.ChkisCustomsClearance.Checked,
                Description        = (!string.IsNullOrEmpty(text2) && text2.Length > 0) ? regex.Replace(text2, "") : null,
                MobblieDescription = (!string.IsNullOrEmpty(text3) && text3.Length > 0) ? regex.Replace(text3, "") : null,
                Title              = this.txtTitle.Text,
                MetaDescription    = this.txtMetaDescription.Text,
                MetaKeywords       = this.txtMetaKeywords.Text,
                AddedDate          = System.DateTime.Now,
                BrandId            = this.dropBrandCategories.SelectedValue,
                MainCategoryPath   = CatalogHelper.GetCategory(this.categoryId).Path + "|",
                IsfreeShipping     = this.ChkisfreeShipping.Checked,
                ReferralDeduct     = referralDeduct,
                SubMemberDeduct    = subMemberDeduct,
                SubReferralDeduct  = subReferralDeduct,
                TaxRateId          = this.dropTaxRate.SelectedValue,
                TemplateId         = this.ddlShipping.SelectedValue,
                SupplierId         = this.ddlSupplier.SelectedValue,
                ImportSourceId     = this.ddlImportSourceType.SelectedValue,
                IsApproved         = true,
                BuyCardinality     = buyCardinality,
                UnitCode           = this.ddlUnit.SelectedValue,
                Manufacturer       = txtManufacturer.Text,
                ItemNo             = txtItemNo.Text,
                BarCode            = txtBarCode.Text,
                Ingredient         = txtIngredient.Text,
                ProductStandard    = txtProductStandard.Text,
                ConversionRelation = ConversionRelation,
                ProductTitle       = this.txtProductTitle.Text,
                SaleType           = saletype,
                IsPromotion        = this.ChkisPromotion.Checked,
                IsDisplayDiscount  = this.ChkisDisplayDiscount.Checked,
                Purchase           = int.Parse(this.Rd_Purchase.SelectedValue),
                SectionDay         = int.Parse(this.txtSectionDay.Text),
                PurchaseMaxNum     = int.Parse(this.txtMaxCount.Text.ToString())
            };
            ProductSaleStatus saleStatus = ProductSaleStatus.OnSale;

            if (this.radInStock.Checked)
            {
                saleStatus = ProductSaleStatus.OnStock;
            }
            if (this.radUnSales.Checked)
            {
                saleStatus = ProductSaleStatus.UnSale;
            }
            if (this.radOnSales.Checked)
            {
                saleStatus = ProductSaleStatus.OnSale;

                if (productInfo.SaleType != 2)
                {
                    this.ShowMsg("商品还未完成归类操作,不能出售", false);
                    return;
                }
            }

            productInfo.SaleStatus = saleStatus;


            //如果是组合商品,默认已审价
            if (productInfo.SaleType == 2)
            {
                productInfo.IsApprovedPrice = 1;
            }

            else
            {
                productInfo.IsApprovedPrice = 0;
            }
            System.Collections.Generic.Dictionary <int, System.Collections.Generic.IList <int> > attrs = null;
            System.Collections.Generic.Dictionary <string, SKUItem> dictionary;
            if (this.chkSkuEnabled.Checked)
            {
                productInfo.HasSKU = true;
                dictionary         = base.GetSkus(this.txtSkus.Text);
            }
            else
            {
                AutoCalcCostPriceAndDeductFee(salePrice, ref costPrice, ref deductFee);
                dictionary = new System.Collections.Generic.Dictionary <string, SKUItem>
                {
                    {
                        "0",
                        new SKUItem
                        {
                            SkuId       = "0",
                            SKU         = Globals.HtmlEncode(Globals.StripScriptTags(this.txtSku.Text.Trim()).Replace("\\", "")),
                            SalePrice   = salePrice,
                            CostPrice   = costPrice.HasValue ? costPrice.Value : 0m,
                            Stock       = stock,
                            FactStock   = factstock,
                            Weight      = num4.HasValue ? num4.Value : 0m,
                            DeductFee   = deductFee.HasValue ? deductFee.Value :0m,
                            GrossWeight = grossweight.HasValue?grossweight.Value:0m
                        }
                    }
                };
                if (this.txtMemberPrices.Text.Length > 0)
                {
                    base.GetMemberPrices(dictionary["0"], this.txtMemberPrices.Text);
                }
            }
            if (!string.IsNullOrEmpty(this.txtAttributes.Text) && this.txtAttributes.Text.Length > 0)
            {
                attrs = base.GetAttributes(this.txtAttributes.Text);
            }
            ValidationResults validationResults = Validation.Validate <ProductInfo>(productInfo, new string[]
            {
                "AddProduct"
            });

            if (!validationResults.IsValid)
            {
                this.ShowMsg(validationResults);
                return;
            }
            System.Collections.Generic.IList <int> list = new System.Collections.Generic.List <int>();
            if (!string.IsNullOrEmpty(this.txtProductTag.Text.Trim()))
            {
                string   text4 = this.txtProductTag.Text.Trim();
                string[] array;
                if (text4.Contains(","))
                {
                    array = text4.Split(new char[]
                    {
                        ','
                    });
                }
                else
                {
                    array = new string[]
                    {
                        text4
                    };
                }
                string[] array2 = array;
                for (int i = 0; i < array2.Length; i++)
                {
                    string value = array2[i];
                    list.Add(System.Convert.ToInt32(value));
                }
            }
            #region   ==组合商品
            List <ProductsCombination> combinations = new List <ProductsCombination>();
            string   combinationInfos = base.Request.Form["selectProductsinfo"];
            string[] curCom           = combinationInfos.Split(new char[]
            {
                ','
            });
            string[] curCom2 = curCom;
            for (int i = 0; i < curCom2.Length; i++)
            {
                string combinationInfo     = curCom2[i];
                ProductsCombination com    = new ProductsCombination();
                string[]            array3 = combinationInfo.Split(new char[]
                {
                    '|'
                });
                if (array3.Length == 10)
                {
                    com.SkuId         = array3[0];
                    com.ProductId     = array3[1] == "" ? 0 : Convert.ToInt32(array3[1]);
                    com.ProductName   = array3[2];
                    com.ThumbnailsUrl = array3[3];
                    decimal tempweight;
                    if (decimal.TryParse(array3[4], out tempweight))
                    {
                        com.Weight = tempweight;
                    }
                    com.SKU        = array3[5];
                    com.SKUContent = array3[6];
                    com.Quantity   = array3[8] == "" ? 0 : Convert.ToInt32(array3[8]);
                    decimal tempprice;
                    if (decimal.TryParse(array3[9], out tempprice))
                    {
                        com.Price = tempprice;
                    }
                    combinations.Add(com);
                }
            }
            productInfo.CombinationItemInfos = combinations;
            #endregion

            if (productInfo.SaleType == 2)
            {
                decimal CombinationTotalPrice = 0M;
                foreach (var item in productInfo.CombinationItemInfos)
                {
                    CombinationTotalPrice += item.Price * item.Quantity;
                }

                if (Math.Round(CombinationTotalPrice, 2) != Math.Round(salePrice, 2))
                {
                    this.ShowMsg("添加商品失败,组合商品一口价和组合商品明细总价不一致", false);
                    return;
                }
            }


            ProductActionStatus productActionStatus = ProductHelper.AddProduct(productInfo, dictionary, attrs, list, combinations);
            if (productActionStatus == ProductActionStatus.Success)
            {
                this.ShowMsg("添加商品成功", true);
                base.Response.Redirect(Globals.GetAdminAbsolutePath(string.Format("/product/AddProductComplete.aspx?categoryId={0}&productId={1}", this.categoryId, productInfo.ProductId)), true);
                return;
            }
            if (productActionStatus == ProductActionStatus.AttributeError)
            {
                this.ShowMsg("添加商品失败,保存商品属性时出错", false);
                return;
            }
            if (productActionStatus == ProductActionStatus.DuplicateName)
            {
                this.ShowMsg("添加商品失败,商品名称不能重复", false);
                return;
            }
            if (productActionStatus == ProductActionStatus.DuplicateSKU)
            {
                this.ShowMsg("添加商品失败,商家编码不能重复", false);
                return;
            }
            if (productActionStatus == ProductActionStatus.SKUError)
            {
                this.ShowMsg("添加商品失败,商品规格错误", false);
                return;
            }
            if (productActionStatus == ProductActionStatus.ProductTagEroor)
            {
                this.ShowMsg("添加商品失败,保存商品标签时出错", false);
                return;
            }
            this.ShowMsg("添加商品失败,未知错误", false);
        }
Esempio n. 39
0
        private void LoadParameters()
        {
            if (Page.IsPostBack)
            {
                productName = txtSearchText.Text;
                productCode = txtSKU.Text;
                categoryId = dropCategories.SelectedValue;
                if (dropproductsale.SelectedValue.HasValue)
                {
                    switch (dropproductsale.SelectedValue.Value)
                    {
                        case 1:
                            productstatus = ProductSaleStatus.OnSale;
                            return;

                        case 2:
                            productstatus = ProductSaleStatus.UnSale;
                            return;
                    }
                    productstatus = ProductSaleStatus.OnStock;
                }
            }
            else
            {
                if (!string.IsNullOrEmpty(Page.Request.QueryString["productName"]))
                {
                    productName = Globals.UrlDecode(Page.Request.QueryString["productName"]);
                }
                if (!string.IsNullOrEmpty(Page.Request.QueryString["productCode"]))
                {
                    productCode = Globals.UrlDecode(Page.Request.QueryString["productCode"]);
                }
                if (!string.IsNullOrEmpty(Page.Request.QueryString["categoryId"]))
                {
                    int result = 0;
                    if (int.TryParse(Page.Request.QueryString["categoryId"], out result))
                    {
                        categoryId = new int?(result);
                    }
                }
                dropproductsale.DataBind();
                if (!string.IsNullOrEmpty(Page.Request.QueryString["productStatus"]))
                {
                    int num2 = 0;
                    if (int.TryParse(Page.Request.QueryString["productStatus"], out num2))
                    {
                        switch (num2)
                        {
                            case 1:
                                productstatus = ProductSaleStatus.OnSale;
                                break;

                            case 2:
                                productstatus = ProductSaleStatus.UnSale;
                                break;

                            default:
                                productstatus = ProductSaleStatus.OnStock;
                                break;
                        }
                        dropproductsale.SelectedValue = new int?(num2);
                    }
                }
                txtSearchText.Text = productName;
                txtSKU.Text = productCode;
                dropCategories.DataBind();
                dropCategories.SelectedValue = categoryId;
            }
        }
Esempio n. 40
0
 public override bool GetShoppingProductInfo(int productId, string skuId, out ProductSaleStatus saleStatus, out int stock, out int totalQuantity)
 {
     saleStatus = ProductSaleStatus.Delete;
     stock = 0;
     totalQuantity = 0;
     bool flag = false;
     DbCommand sqlStringCommand = this.database.GetSqlStringCommand("SELECT Stock,SaleStatus,AlertStock FROM Hishop_Skus s INNER JOIN Hishop_Products p ON s.ProductId=p.ProductId WHERE s.ProductId=@ProductId AND s.SkuId=@SkuId");
     this.database.AddInParameter(sqlStringCommand, "ProductId", DbType.Int32, productId);
     this.database.AddInParameter(sqlStringCommand, "SkuId", DbType.String, skuId);
     using (IDataReader reader = this.database.ExecuteReader(sqlStringCommand))
     {
         if (reader.Read())
         {
             saleStatus = (ProductSaleStatus) ((int) reader["SaleStatus"]);
             stock = (int) reader["Stock"];
             int num = (int) reader["AlertStock"];
             if (stock <= num)
             {
                 saleStatus = ProductSaleStatus.UnSale;
             }
             flag = true;
         }
         totalQuantity = this.GetShoppingProductQuantity(skuId, productId);
     }
     return flag;
 }
Esempio n. 41
0
 public abstract int UpdateProductSaleStatus(string productIds, ProductSaleStatus saleStatus);
Esempio n. 42
0
 public static void ImportProducts(DataTable productData, int categoryId, int lineId, int? brandId, ProductSaleStatus saleStatus)
 {
     if ((productData != null) && (productData.Rows.Count > 0))
     {
         foreach (DataRow row in productData.Rows)
         {
             string[] strArray;
             ProductInfo product = new ProductInfo();
             product.CategoryId = categoryId;
             product.MainCategoryPath = CatalogHelper.GetCategory(categoryId).Path + "|";
             product.ProductName = (string)row["ProductName"];
             product.ProductCode = (string)row["SKU"];
             product.LineId = lineId;
             product.BrandId = brandId;
             if (row["Description"] != DBNull.Value)
             {
                 product.Description = (string)row["Description"];
             }
             product.PenetrationStatus = PenetrationStatus.Notyet;
             product.AddedDate = DateTime.Now;
             product.SaleStatus = saleStatus;
             product.HasSKU = false;
             HttpContext current = HttpContext.Current;
             if (row["ImageUrl1"] != DBNull.Value)
             {
                 product.ImageUrl1 = (string)row["ImageUrl1"];
             }
             if (!(string.IsNullOrEmpty(product.ImageUrl1) || (product.ImageUrl1.Length <= 0)))
             {
                 strArray = ProcessImages(current, product.ImageUrl1);
                 product.ThumbnailUrl40 = strArray[0];
                 product.ThumbnailUrl60 = strArray[1];
                 product.ThumbnailUrl100 = strArray[2];
                 product.ThumbnailUrl160 = strArray[3];
                 product.ThumbnailUrl180 = strArray[4];
                 product.ThumbnailUrl220 = strArray[5];
                 product.ThumbnailUrl310 = strArray[6];
                 product.ThumbnailUrl410 = strArray[7];
             }
             if (row["ImageUrl2"] != DBNull.Value)
             {
                 product.ImageUrl2 = (string)row["ImageUrl2"];
             }
             if (!(string.IsNullOrEmpty(product.ImageUrl2) || (product.ImageUrl2.Length <= 0)))
             {
                 strArray = ProcessImages(current, product.ImageUrl2);
             }
             if (row["ImageUrl3"] != DBNull.Value)
             {
                 product.ImageUrl3 = (string)row["ImageUrl3"];
             }
             if (!(string.IsNullOrEmpty(product.ImageUrl3) || (product.ImageUrl3.Length <= 0)))
             {
                 strArray = ProcessImages(current, product.ImageUrl3);
             }
             if (row["ImageUrl4"] != DBNull.Value)
             {
                 product.ImageUrl4 = (string)row["ImageUrl4"];
             }
             if (!(string.IsNullOrEmpty(product.ImageUrl4) || (product.ImageUrl4.Length <= 0)))
             {
                 strArray = ProcessImages(current, product.ImageUrl4);
             }
             if (row["ImageUrl5"] != DBNull.Value)
             {
                 product.ImageUrl5 = (string)row["ImageUrl5"];
             }
             if (!(string.IsNullOrEmpty(product.ImageUrl5) || (product.ImageUrl5.Length <= 0)))
             {
                 strArray = ProcessImages(current, product.ImageUrl5);
             }
             SKUItem item = new SKUItem();
             item.SkuId = "_0";
             item.SKU = (string)row["SKU"];
             product.LowestSalePrice = item.PurchasePrice = item.SalePrice = (decimal)row["SalePrice"];
             if (row["Stock"] != DBNull.Value)
             {
                 item.Stock = (int)row["Stock"];
             }
             if (row["Weight"] != DBNull.Value)
             {
                 item.Weight = (int)row["Weight"];
             }
             Dictionary<string, SKUItem> skus = new Dictionary<string, SKUItem>();
             skus.Add(item.SkuId, item);
             AddProduct(product, skus, null);
         }
     }
 }
Esempio n. 43
0
        private void btnSave_Click(object sender, System.EventArgs e)
        {
            if (this.categoryId == 0)
            {
                this.categoryId = (int)this.ViewState["ProductCategoryId"];
            }
            int     num;
            decimal num2;
            decimal?nullable;
            decimal?nullable2;
            int     num3;
            decimal?nullable3;

            if (this.ValidateConverts(this.chkSkuEnabled.Checked, out num, out num2, out nullable, out nullable2, out num3, out nullable3))
            {
                if (!this.chkSkuEnabled.Checked)
                {
                    if (num2 <= 0m)
                    {
                        this.ShowMsg("商品一口价必须大于0", false);
                        return;
                    }
                    if (nullable.HasValue && nullable.Value >= num2)
                    {
                        this.ShowMsg("商品成本价必须小于商品一口价", false);
                        return;
                    }
                }
                string text = this.fckDescription.Text;
                if (this.ckbIsDownPic.Checked)
                {
                    text = base.DownRemotePic(text);
                }

                string str1 = this.ucFlashUpload1.Value.Trim();
                //this.ucFlashUpload1.Value = str1;
                string[] strArrays  = str1.Split(new char[] { ',' });
                string[] strArrays1 = new string[] { "", "", "", "", "" };
                string[] strArrays2 = strArrays1;
                for (int i = 0; i < (int)strArrays.Length && i < 5; i++)
                {
                    strArrays2[i] = strArrays[i];
                }
                string strChecks = "";
                for (int i = 0; i < this.BrandCategories.Items.Count; i++)
                {
                    bool a = this.BrandCategories.Items[i].Selected;
                    if (a)
                    {
                        strChecks += this.BrandCategories.Items[i].Value + ",";
                    }
                }
                ProductInfo target = ProductHelper.GetProductBaseInfo(this.productId);
                if (CustomConfigHelper.Instance.BrandShow)
                {
                    //修改一个商品
                    //1.从数据库获取填充到界面,有一个数据对象
                    //2.根据界面输入修改对象
                    target.ProductId        = this.productId;
                    target.CategoryId       = this.categoryId;
                    target.TypeId           = this.dropProductTypes.SelectedValue;
                    target.ProductName      = this.txtProductName.Text;
                    target.ProductCode      = this.txtProductCode.Text;
                    target.DisplaySequence  = num;
                    target.MarketPrice      = nullable2;
                    target.Unit             = this.txtUnit.Text;
                    target.Range            = Convert.ToInt32(this.DDLRange.SelectedValue);
                    target.ShowSaleCounts   = int.Parse(this.showCounts.Text);
                    target.ImageUrl1        = strArrays2[0];
                    target.ImageUrl2        = strArrays2[1];
                    target.ImageUrl3        = strArrays2[2];
                    target.ImageUrl4        = strArrays2[3];
                    target.ImageUrl5        = strArrays2[4];
                    target.ThumbnailUrl40   = strArrays2[0].Replace("/images/", "/thumbs40/40_");
                    target.ThumbnailUrl60   = strArrays2[0].Replace("/images/", "/thumbs60/60_");
                    target.ThumbnailUrl100  = strArrays2[0].Replace("/images/", "/thumbs100/100_");
                    target.ThumbnailUrl160  = strArrays2[0].Replace("/images/", "/thumbs160/160_");
                    target.ThumbnailUrl180  = strArrays2[0].Replace("/images/", "/thumbs180/180_");
                    target.ThumbnailUrl220  = strArrays2[0].Replace("/images/", "/thumbs220/220_");
                    target.ThumbnailUrl310  = strArrays2[0].Replace("/images/", "/thumbs310/310_");
                    target.ThumbnailUrl410  = strArrays2[0].Replace("/images/", "/thumbs410/410_");
                    target.ShortDescription = this.txtShortDescription.Text;
                    target.IsfreeShipping   = this.ChkisfreeShipping.Checked;
                    target.Description      = (!string.IsNullOrEmpty(text) && text.Length > 0) ? text : null;
                    target.AddedDate        = System.DateTime.Now;
                    target.BrandId          = strChecks.TrimEnd(',');
                }
                else
                {
                    //修改一个商品
                    //1.从数据库获取填充到界面,有一个数据对象
                    //2.根据界面输入修改对象
                    target.ProductId        = this.productId;
                    target.CategoryId       = this.categoryId;
                    target.TypeId           = this.dropProductTypes.SelectedValue;
                    target.ProductName      = this.txtProductName.Text;
                    target.ProductCode      = this.txtProductCode.Text;
                    target.DisplaySequence  = num;
                    target.MarketPrice      = nullable2;
                    target.Unit             = this.txtUnit.Text;
                    target.Range            = Convert.ToInt32(this.DDLRange.SelectedValue);
                    target.ShowSaleCounts   = int.Parse(this.showCounts.Text);
                    target.ImageUrl1        = strArrays2[0];
                    target.ImageUrl2        = strArrays2[1];
                    target.ImageUrl3        = strArrays2[2];
                    target.ImageUrl4        = strArrays2[3];
                    target.ImageUrl5        = strArrays2[4];
                    target.ThumbnailUrl40   = strArrays2[0].Replace("/images/", "/thumbs40/40_");
                    target.ThumbnailUrl60   = strArrays2[0].Replace("/images/", "/thumbs60/60_");
                    target.ThumbnailUrl100  = strArrays2[0].Replace("/images/", "/thumbs100/100_");
                    target.ThumbnailUrl160  = strArrays2[0].Replace("/images/", "/thumbs160/160_");
                    target.ThumbnailUrl180  = strArrays2[0].Replace("/images/", "/thumbs180/180_");
                    target.ThumbnailUrl220  = strArrays2[0].Replace("/images/", "/thumbs220/220_");
                    target.ThumbnailUrl310  = strArrays2[0].Replace("/images/", "/thumbs310/310_");
                    target.ThumbnailUrl410  = strArrays2[0].Replace("/images/", "/thumbs410/410_");
                    target.ShortDescription = this.txtShortDescription.Text;
                    target.IsfreeShipping   = this.ChkisfreeShipping.Checked;
                    target.Description      = (!string.IsNullOrEmpty(text) && text.Length > 0) ? text : null;
                    target.AddedDate        = System.DateTime.Now;
                    target.BrandId          = this.dropBrandCategories.SelectedValue.ToString();
                }

                /* 错误逻辑,不应该new,会容易漏掉新增的、已有的字段
                 * ProductInfo target = new ProductInfo
                 * {
                 *  ProductId = this.productId,
                 *  CategoryId = this.categoryId,
                 *  TypeId = this.dropProductTypes.SelectedValue,
                 *  ProductName = this.txtProductName.Text,
                 *  ProductCode = this.txtProductCode.Text,
                 *  DisplaySequence = num,
                 *  MarketPrice = nullable2,
                 *  Unit = this.txtUnit.Text,
                 *  ImageUrl1 = strArrays2[0],
                 *  ImageUrl2 = strArrays2[1],
                 *  ImageUrl3 = strArrays2[2],
                 *  ImageUrl4 = strArrays2[3],
                 *  ImageUrl5 = strArrays2[4],
                 *  ThumbnailUrl40 = strArrays2[0].Replace("/images/", "/thumbs40/40_"),
                 *  ThumbnailUrl60 = strArrays2[0].Replace("/images/", "/thumbs60/60_"),
                 *  ThumbnailUrl100 = strArrays2[0].Replace("/images/", "/thumbs100/100_"),
                 *  ThumbnailUrl160 = strArrays2[0].Replace("/images/", "/thumbs160/160_"),
                 *  ThumbnailUrl180 = strArrays2[0].Replace("/images/", "/thumbs180/180_"),
                 *  ThumbnailUrl220 = strArrays2[0].Replace("/images/", "/thumbs220/220_"),
                 *  ThumbnailUrl310 = strArrays2[0].Replace("/images/", "/thumbs310/310_"),
                 *  ThumbnailUrl410 = strArrays2[0].Replace("/images/", "/thumbs410/410_"),
                 *  ShortDescription = this.txtShortDescription.Text,
                 *  IsfreeShipping = this.ChkisfreeShipping.Checked,
                 *  Description = (!string.IsNullOrEmpty(text) && text.Length > 0) ? text : null,
                 *  AddedDate = System.DateTime.Now,
                 *  BrandId = this.dropBrandCategories.SelectedValue
                 * };
                 */
                ProductSaleStatus onSale = ProductSaleStatus.OnSale;
                if (this.radInStock.Checked)
                {
                    onSale = ProductSaleStatus.OnStock;
                }
                if (this.radUnSales.Checked)
                {
                    onSale = ProductSaleStatus.UnSale;
                }
                if (this.radOnSales.Checked)
                {
                    onSale = ProductSaleStatus.OnSale;
                }
                target.SaleStatus = onSale;
                CategoryInfo category = CatalogHelper.GetCategory(this.categoryId);
                if (category != null)
                {
                    target.MainCategoryPath = category.Path + "|";
                }
                System.Collections.Generic.Dictionary <int, System.Collections.Generic.IList <int> > attrs = null;
                System.Collections.Generic.Dictionary <string, SKUItem> skus;
                if (this.chkSkuEnabled.Checked)
                {
                    target.HasSKU = true;
                    skus          = base.GetSkus(this.txtSkus.Text);
                }
                else
                {
                    System.Collections.Generic.Dictionary <string, SKUItem> dictionary3 = new System.Collections.Generic.Dictionary <string, SKUItem>();
                    SKUItem item = new SKUItem
                    {
                        SkuId     = "0",
                        SKU       = this.txtSku.Text,
                        SalePrice = num2,
                        CostPrice = nullable.HasValue ? nullable.Value : 0m,
                        Stock     = num3,
                        Weight    = nullable3.HasValue ? nullable3.Value : 0m
                    };
                    dictionary3.Add("0", item);
                    skus = dictionary3;
                    if (this.txtMemberPrices.Text.Length > 0)
                    {
                        base.GetMemberPrices(skus["0"], this.txtMemberPrices.Text);
                    }
                }
                if (!string.IsNullOrEmpty(this.txtAttributes.Text) && this.txtAttributes.Text.Length > 0)
                {
                    attrs = base.GetAttributes(this.txtAttributes.Text);
                }
                ValidationResults validateResults = Validation.Validate <ProductInfo>(target);
                if (!validateResults.IsValid)
                {
                    this.ShowMsg(validateResults);
                }
                else
                {
                    System.Collections.Generic.IList <int> tagIds = new System.Collections.Generic.List <int>();
                    if (!string.IsNullOrEmpty(this.txtProductTag.Text.Trim()))
                    {
                        string   str2 = this.txtProductTag.Text.Trim();
                        string[] strArray;
                        if (str2.Contains(","))
                        {
                            strArray = str2.Split(new char[]
                            {
                                ','
                            });
                        }
                        else
                        {
                            strArray = new string[]
                            {
                                str2
                            };
                        }
                        string[] array = strArray;
                        for (int i = 0; i < array.Length; i++)
                        {
                            string str3 = array[i];
                            tagIds.Add(System.Convert.ToInt32(str3));
                        }
                    }

                    //获取当前子账号门店,以判断子门店是否编辑过商品,若点击保存,商品直接被设置为待审核状态
                    ManagerInfo currentManager = ManagerHelper.GetCurrentManager();
                    int         storeId        = ManagerHelper.getClientUserIdBySenderId(currentManager.UserId);
                    //如果当前子门店编辑过,商品设置为待审核状态 爽爽挝啡2.0
                    if (storeId > 0 && CustomConfigHelper.Instance.AutoShipping && CustomConfigHelper.Instance.AnonymousOrder)
                    {
                        target.ReviewState = 1;//待审核
                    }
                    switch (ProductHelper.UpdateProduct(target, skus, attrs, tagIds))
                    {
                    case ProductActionStatus.Success:
                        this.litralProductTag.SelectedValue = tagIds;
                        if (base.Request.QueryString["reurl"] != null)
                        {
                            this.ReUrl = base.Request.QueryString["reurl"].ToString();
                        }
                        if (storeId > 0 && CustomConfigHelper.Instance.AutoShipping && CustomConfigHelper.Instance.AnonymousOrder)
                        {
                            this.ShowMsg("修改商品的价格成功,修改过的商品无法显示在店铺内,请尽快提交至总店审核!", true);
                        }
                        this.ShowMsgAndReUrl("修改商品成功", true, this.ReUrl);
                        this.ShowMsg("修改商品成功", true);
                        break;

                    case ProductActionStatus.DuplicateName:
                        this.ShowMsg("修改商品失败,商品名称不能重复", false);
                        break;

                    case ProductActionStatus.DuplicateSKU:
                        this.ShowMsg("修改商品失败,商家编码不能重复", false);
                        break;

                    case ProductActionStatus.SKUError:
                        this.ShowMsg("修改商品失败,商家编码不能重复", false);
                        break;

                    case ProductActionStatus.AttributeError:
                        this.ShowMsg("修改商品失败,保存商品属性时出错", false);
                        break;

                    case ProductActionStatus.OffShelfError:
                        this.ShowMsg("修改商品失败, 子站没在零售价范围内的商品无法下架", false);
                        break;

                    case ProductActionStatus.ProductTagEroor:
                        this.ShowMsg("修改商品失败,保存商品标签时出错", false);
                        break;

                    default:
                        this.ShowMsg("修改商品失败,未知错误", false);
                        break;
                    }
                }
            }
        }
Esempio n. 44
0
 public static void ImportProducts(DataSet productData, int categoryId, int lineId, int? bandId, ProductSaleStatus saleStatus, bool includeCostPrice, bool includeStock, bool includeImages)
 {
     foreach (DataRow row in productData.Tables["products"].Rows)
     {
         int mappedProductId = (int)row["ProductId"];
         ProductInfo product = ConverToProduct(row, categoryId, lineId, bandId, saleStatus, includeImages);
         Dictionary<string, SKUItem> skus = ConverToSkus(mappedProductId, productData, includeCostPrice, includeStock);
         Dictionary<int, IList<int>> attrs = ConvertToAttributes(mappedProductId, productData);
         ProductActionStatus status = AddProduct(product, skus, attrs);
     }
 }
Esempio n. 45
0
		private void btnSave_Click(object sender, System.EventArgs e)
		{
			if (this.categoryId == 0)
			{
				this.categoryId = (int)this.ViewState["ProductCategoryId"];
			}
			int displaySequence;
			decimal num;
			decimal num2;
			decimal num3;
			decimal? num4;
			decimal? marketPrice;
			int stock;
			int alertStock;
			decimal? num5;
			if (!this.ValidateConverts(this.chkSkuEnabled.Checked, out displaySequence, out num, out num2, out num3, out num4, out marketPrice, out stock, out alertStock, out num5))
			{
				return;
			}
			decimal d = 0m;
			decimal.TryParse(this.txtCostPrice.Text, out d);
			if (d == 0m)
			{
				this.ShowMsg("供货价必填", false);
				return;
			}
			if (!this.chkSkuEnabled.Checked)
			{
				if (num3 <= 0m)
				{
					this.ShowMsg("商品一口价必须大于0", false);
					return;
				}
				if (num4.HasValue && num4.Value >= num3)
				{
					this.ShowMsg("商品成本价必须小于商品一口价", false);
					return;
				}
				if (!(num <= num2))
				{
					this.ShowMsg("分销商采购价必须要小于等于其最低零售价", false);
					return;
				}
			}
			string text = this.fckDescription.Text;
			if (this.ckbIsDownPic.Checked)
			{
				text = base.DownRemotePic(text);
			}
			ProductInfo productInfo = new ProductInfo
			{
				ProductId = this.productId,
				CategoryId = this.categoryId,
				TypeId = this.dropProductTypes.SelectedValue,
				ProductName = this.txtProductName.Text,
				ProductCode = this.txtProductCode.Text,
				DisplaySequence = displaySequence,
				LineId = this.dropProductLines.SelectedValue.Value,
				LowestSalePrice = num2,
				MarketPrice = marketPrice,
				Unit = this.txtUnit.Text,
				ImageUrl1 = this.uploader1.UploadedImageUrl,
				ImageUrl2 = this.uploader2.UploadedImageUrl,
				ImageUrl3 = this.uploader3.UploadedImageUrl,
				ImageUrl4 = this.uploader4.UploadedImageUrl,
				ImageUrl5 = this.uploader5.UploadedImageUrl,
				ThumbnailUrl40 = this.uploader1.ThumbnailUrl40,
				ThumbnailUrl60 = this.uploader1.ThumbnailUrl60,
				ThumbnailUrl100 = this.uploader1.ThumbnailUrl100,
				ThumbnailUrl160 = this.uploader1.ThumbnailUrl160,
				ThumbnailUrl180 = this.uploader1.ThumbnailUrl180,
				ThumbnailUrl220 = this.uploader1.ThumbnailUrl220,
				ThumbnailUrl310 = this.uploader1.ThumbnailUrl310,
				ThumbnailUrl410 = this.uploader1.ThumbnailUrl410,
				ShortDescription = this.txtShortDescription.Text,
				Description = (string.IsNullOrEmpty(text) || text.Length <= 0) ? null : text,
				PenetrationStatus = this.chkPenetration.Checked ? PenetrationStatus.Already : PenetrationStatus.Notyet,
				Title = this.txtTitle.Text,
				MetaDescription = this.txtMetaDescription.Text,
				MetaKeywords = this.txtMetaKeywords.Text,
				AddedDate = System.DateTime.Now,
				BrandId = this.dropBrandCategories.SelectedValue
			};
			ProductSaleStatus saleStatus = ProductSaleStatus.OnSale;
			if (this.radInStock.Checked)
			{
				saleStatus = ProductSaleStatus.OnStock;
			}
			if (this.radUnSales.Checked)
			{
				saleStatus = ProductSaleStatus.UnSale;
			}
			if (this.radOnSales.Checked)
			{
				saleStatus = ProductSaleStatus.OnSale;
			}
			productInfo.SaleStatus = saleStatus;
			CategoryInfo category = CatalogHelper.GetCategory(this.categoryId);
			if (category != null)
			{
				productInfo.MainCategoryPath = category.Path + "|";
			}
			System.Collections.Generic.Dictionary<int, System.Collections.Generic.IList<int>> attrs = null;
			System.Collections.Generic.Dictionary<string, SKUItem> dictionary;
			if (this.chkSkuEnabled.Checked)
			{
				productInfo.HasSKU = true;
				dictionary = base.GetSkus(this.txtSkus.Text);
			}
			else
			{
				dictionary = new System.Collections.Generic.Dictionary<string, SKUItem>
				{

					{
						"0",
						new SKUItem
						{
							SkuId = "0",
							SKU = this.txtSku.Text,
							SalePrice = num3,
							CostPrice = num4.HasValue ? num4.Value : 0m,
							PurchasePrice = num,
							Stock = stock,
							AlertStock = alertStock,
							Weight = num5.HasValue ? num5.Value : 0m
						}
					}
				};
				if (this.txtMemberPrices.Text.Length > 0)
				{
					base.GetMemberPrices(dictionary["0"], this.txtMemberPrices.Text);
				}
				if (this.txtDistributorPrices.Text.Length > 0)
				{
					base.GetDistributorPrices(dictionary["0"], this.txtDistributorPrices.Text);
				}
			}
			if (!string.IsNullOrEmpty(this.txtAttributes.Text) && this.txtAttributes.Text.Length > 0)
			{
				attrs = base.GetAttributes(this.txtAttributes.Text);
			}
			ValidationResults validationResults = Validation.Validate<ProductInfo>(productInfo);
			if (!validationResults.IsValid)
			{
				this.ShowMsg(validationResults);
				return;
			}
			if (this.ViewState["distributorUserIds"] == null)
			{
				this.ViewState["distributorUserIds"] = new System.Collections.Generic.List<int>();
			}
			int num6 = 0;
			if (productInfo.LineId > 0 && int.Parse(this.hdlineId.Value) > 0 && productInfo.LineId != int.Parse(this.hdlineId.Value))
			{
				num6 = 6;
			}
			if (!this.chkPenetration.Checked)
			{
				num6 = 5;
			}
			if (num6 == 5)
			{
				SendMessageHelper.SendMessageToDistributors(productInfo.ProductId.ToString(), num6);
			}
			else
			{
				if (num6 == 6)
				{
					this.toline = this.dropProductLines.SelectedItem.Text;
					SendMessageHelper.SendMessageToDistributors(this.hdlineId.Value + "|" + this.toline, num6);
				}
			}
			System.Collections.Generic.IList<int> list = new System.Collections.Generic.List<int>();
			if (!string.IsNullOrEmpty(this.txtProductTag.Text.Trim()))
			{
				string text2 = this.txtProductTag.Text.Trim();
				string[] array;
				if (text2.Contains(","))
				{
					array = text2.Split(new char[]
					{
						','
					});
				}
				else
				{
					array = new string[]
					{
						text2
					};
				}
				string[] array2 = array;
				for (int i = 0; i < array2.Length; i++)
				{
					string value = array2[i];
					list.Add(System.Convert.ToInt32(value));
				}
			}
			ProductActionStatus productActionStatus = ProductHelper.UpdateProduct(productInfo, dictionary, attrs, (System.Collections.Generic.IList<int>)this.ViewState["distributorUserIds"], list);
			if (productActionStatus == ProductActionStatus.Success)
			{
				this.litralProductTag.SelectedValue = list;
				this.ShowMsg("修改商品成功", true);
				return;
			}
			if (productActionStatus == ProductActionStatus.AttributeError)
			{
				this.ShowMsg("修改商品失败,保存商品属性时出错", false);
				return;
			}
			if (productActionStatus == ProductActionStatus.DuplicateName)
			{
				this.ShowMsg("修改商品失败,商品名称不能重复", false);
				return;
			}
			if (productActionStatus == ProductActionStatus.DuplicateSKU)
			{
				this.ShowMsg("修改商品失败,商家编码不能重复", false);
				return;
			}
			if (productActionStatus == ProductActionStatus.SKUError)
			{
				this.ShowMsg("修改商品失败,商家编码不能重复", false);
				return;
			}
			if (productActionStatus == ProductActionStatus.OffShelfError)
			{
				this.ShowMsg("修改商品失败, 子站没在零售价范围内的商品无法下架", false);
				return;
			}
			if (productActionStatus == ProductActionStatus.ProductTagEroor)
			{
				this.ShowMsg("修改商品失败,保存商品标签时出错", false);
				return;
			}
			this.ShowMsg("修改商品失败,未知错误", false);
		}
Esempio n. 46
0
 static ProductInfo ConverToProduct(DataRow productRow, int categoryId, int lineId, int? bandId, ProductSaleStatus saleStatus, bool includeImages)
 {
     ProductInfo info2 = new ProductInfo();
     info2.CategoryId = categoryId;
     info2.TypeId = new int?((int)productRow["SelectedTypeId"]);
     info2.ProductName = (string)productRow["ProductName"];
     info2.ProductCode = (string)productRow["ProductCode"];
     info2.LineId = lineId;
     info2.BrandId = bandId;
     info2.LowestSalePrice = (decimal)productRow["LowestSalePrice"];
     info2.Unit = (string)productRow["Unit"];
     info2.ShortDescription = (string)productRow["ShortDescription"];
     info2.Description = (string)productRow["Description"];
     info2.PenetrationStatus = PenetrationStatus.Notyet;
     info2.Title = (string)productRow["Title"];
     info2.MetaDescription = (string)productRow["Meta_Description"];
     info2.MetaKeywords = (string)productRow["Meta_Keywords"];
     info2.AddedDate = DateTime.Now;
     info2.SaleStatus = saleStatus;
     info2.HasSKU = (bool)productRow["HasSKU"];
     info2.MainCategoryPath = CatalogHelper.GetCategory(categoryId).Path + "|";
     info2.ImageUrl1 = (string)productRow["ImageUrl1"];
     info2.ImageUrl2 = (string)productRow["ImageUrl2"];
     info2.ImageUrl3 = (string)productRow["ImageUrl3"];
     info2.ImageUrl4 = (string)productRow["ImageUrl4"];
     info2.ImageUrl5 = (string)productRow["ImageUrl5"];
     ProductInfo info = info2;
     if (productRow["MarketPrice"] != DBNull.Value)
     {
         info.MarketPrice = new decimal?((decimal)productRow["MarketPrice"]);
     }
     if (includeImages)
     {
         string[] strArray;
         HttpContext current = HttpContext.Current;
         if (!(string.IsNullOrEmpty(info.ImageUrl1) || (info.ImageUrl1.Length <= 0)))
         {
             strArray = ProcessImages(current, info.ImageUrl1);
             info.ThumbnailUrl40 = strArray[0];
             info.ThumbnailUrl60 = strArray[1];
             info.ThumbnailUrl100 = strArray[2];
             info.ThumbnailUrl160 = strArray[3];
             info.ThumbnailUrl180 = strArray[4];
             info.ThumbnailUrl220 = strArray[5];
             info.ThumbnailUrl310 = strArray[6];
             info.ThumbnailUrl410 = strArray[7];
         }
         if (!(string.IsNullOrEmpty(info.ImageUrl2) || (info.ImageUrl2.Length <= 0)))
         {
             strArray = ProcessImages(current, info.ImageUrl2);
         }
         if (!(string.IsNullOrEmpty(info.ImageUrl3) || (info.ImageUrl3.Length <= 0)))
         {
             strArray = ProcessImages(current, info.ImageUrl3);
         }
         if (!(string.IsNullOrEmpty(info.ImageUrl4) || (info.ImageUrl4.Length <= 0)))
         {
             strArray = ProcessImages(current, info.ImageUrl4);
         }
         if (!(string.IsNullOrEmpty(info.ImageUrl5) || (info.ImageUrl5.Length <= 0)))
         {
             strArray = ProcessImages(current, info.ImageUrl5);
         }
     }
     return info;
 }
Esempio n. 47
0
        private void btnAdd_Click(object sender, System.EventArgs e)
        {
            decimal num;
            decimal num2;
            decimal num3;
            decimal?num4;
            decimal?marketPrice;
            int     stock;
            int     alertStock;
            decimal?num5;
            int     lineId;

            if (!this.ValidateConverts(this.chkSkuEnabled.Checked, out num, out num2, out num3, out num4, out marketPrice, out stock, out alertStock, out num5, out lineId))
            {
                return;
            }
            if (!this.chkSkuEnabled.Checked)
            {
                if (num3 <= 0m)
                {
                    this.ShowMsg("商品一口价必须大于0", false);
                    return;
                }
                if (num4.HasValue && num4.Value >= num3)
                {
                    this.ShowMsg("商品成本价必须小于商品一口价", false);
                    return;
                }
                if (!(num <= num2))
                {
                    this.ShowMsg("分销商采购价必须要小于其最低零售价", false);
                    return;
                }
            }
            string text = this.editDescription.Text;

            if (this.ckbIsDownPic.Checked)
            {
                text = base.DownRemotePic(text);
            }
            ProductInfo productInfo = new ProductInfo
            {
                CategoryId        = this.categoryId,
                TypeId            = this.dropProductTypes.SelectedValue,
                ProductName       = this.txtProductName.Text,
                ProductCode       = this.txtProductCode.Text,
                LineId            = lineId,
                LowestSalePrice   = num2,
                MarketPrice       = marketPrice,
                Unit              = this.txtUnit.Text,
                ImageUrl1         = this.uploader1.UploadedImageUrl,
                ImageUrl2         = this.uploader2.UploadedImageUrl,
                ImageUrl3         = this.uploader3.UploadedImageUrl,
                ImageUrl4         = this.uploader4.UploadedImageUrl,
                ImageUrl5         = this.uploader5.UploadedImageUrl,
                ThumbnailUrl40    = this.uploader1.ThumbnailUrl40,
                ThumbnailUrl60    = this.uploader1.ThumbnailUrl60,
                ThumbnailUrl100   = this.uploader1.ThumbnailUrl100,
                ThumbnailUrl160   = this.uploader1.ThumbnailUrl160,
                ThumbnailUrl180   = this.uploader1.ThumbnailUrl180,
                ThumbnailUrl220   = this.uploader1.ThumbnailUrl220,
                ThumbnailUrl310   = this.uploader1.ThumbnailUrl310,
                ThumbnailUrl410   = this.uploader1.ThumbnailUrl410,
                ShortDescription  = this.txtShortDescription.Text,
                Description       = (string.IsNullOrEmpty(text) || text.Length <= 0) ? null : text,
                PenetrationStatus = this.chkPenetration.Checked ? PenetrationStatus.Already : PenetrationStatus.Notyet,
                Title             = this.txtTitle.Text,
                MetaDescription   = this.txtMetaDescription.Text,
                MetaKeywords      = this.txtMetaKeywords.Text,
                AddedDate         = System.DateTime.Now,
                BrandId           = this.dropBrandCategories.SelectedValue,
                MainCategoryPath  = CatalogHelper.GetCategory(this.categoryId).Path + "|"
            };
            ProductSaleStatus saleStatus = ProductSaleStatus.OnSale;

            if (this.radInStock.Checked)
            {
                saleStatus = ProductSaleStatus.OnStock;
            }
            if (this.radUnSales.Checked)
            {
                saleStatus = ProductSaleStatus.UnSale;
            }
            if (this.radOnSales.Checked)
            {
                saleStatus = ProductSaleStatus.OnSale;
            }
            productInfo.SaleStatus = saleStatus;
            System.Collections.Generic.Dictionary <int, System.Collections.Generic.IList <int> > attrs = null;
            System.Collections.Generic.Dictionary <string, SKUItem> dictionary;
            if (this.chkSkuEnabled.Checked)
            {
                productInfo.HasSKU = true;
                dictionary         = base.GetSkus(this.txtSkus.Text);
            }
            else
            {
                dictionary = new System.Collections.Generic.Dictionary <string, SKUItem>
                {
                    {
                        "0",
                        new SKUItem
                        {
                            SkuId         = "0",
                            SKU           = this.txtSku.Text,
                            SalePrice     = num3,
                            CostPrice     = num4.HasValue ? num4.Value : 0m,
                            PurchasePrice = num,
                            Stock         = stock,
                            AlertStock    = alertStock,
                            Weight        = num5.HasValue ? num5.Value : 0m
                        }
                    }
                };
                if (this.txtMemberPrices.Text.Length > 0)
                {
                    base.GetMemberPrices(dictionary["0"], this.txtMemberPrices.Text);
                }
                if (this.txtDistributorPrices.Text.Length > 0)
                {
                    base.GetDistributorPrices(dictionary["0"], this.txtDistributorPrices.Text);
                }
            }
            if (!string.IsNullOrEmpty(this.txtAttributes.Text) && this.txtAttributes.Text.Length > 0)
            {
                attrs = base.GetAttributes(this.txtAttributes.Text);
            }
            ValidationResults validationResults = Validation.Validate <ProductInfo>(productInfo, new string[]
            {
                "AddProduct"
            });

            if (!validationResults.IsValid)
            {
                this.ShowMsg(validationResults);
                return;
            }
            System.Collections.Generic.IList <int> list = new System.Collections.Generic.List <int>();
            if (!string.IsNullOrEmpty(this.txtProductTag.Text.Trim()))
            {
                string   text2 = this.txtProductTag.Text.Trim();
                string[] array;
                if (text2.Contains(","))
                {
                    array = text2.Split(new char[]
                    {
                        ','
                    });
                }
                else
                {
                    array = new string[]
                    {
                        text2
                    };
                }
                string[] array2 = array;
                for (int i = 0; i < array2.Length; i++)
                {
                    string value = array2[i];
                    list.Add(System.Convert.ToInt32(value));
                }
            }
            ProductActionStatus productActionStatus = ProductHelper.AddProduct(productInfo, dictionary, attrs, list);

            if (productActionStatus == ProductActionStatus.Success)
            {
                this.ShowMsg("添加商品成功", true);
                base.Response.Redirect(Globals.GetAdminAbsolutePath(string.Format("/product/AddProductComplete.aspx?categoryId={0}&productId={1}", this.categoryId, productInfo.ProductId)), true);
                return;
            }
            if (productActionStatus == ProductActionStatus.AttributeError)
            {
                this.ShowMsg("添加商品失败,保存商品属性时出错", false);
                return;
            }
            if (productActionStatus == ProductActionStatus.DuplicateName)
            {
                this.ShowMsg("添加商品失败,商品名称不能重复", false);
                return;
            }
            if (productActionStatus == ProductActionStatus.DuplicateSKU)
            {
                this.ShowMsg("添加商品失败,商家编码不能重复", false);
                return;
            }
            if (productActionStatus == ProductActionStatus.SKUError)
            {
                this.ShowMsg("添加商品失败,商家编码不能重复", false);
                return;
            }
            if (productActionStatus == ProductActionStatus.ProductTagEroor)
            {
                this.ShowMsg("添加商品失败,保存商品标签时出错", false);
                return;
            }
            this.ShowMsg("添加商品失败,未知错误", false);
        }
Esempio n. 48
0
        private void LoadParameters()
        {
            int result = 0;
            if (int.TryParse(Page.Request.QueryString["categoryId"], out result))
            {
                categoryId = new int?(result);
            }
            int num2 = 0;
            if (int.TryParse(Page.Request.QueryString["brandId"], out num2))
            {
                brandId = new int?(num2);
            }
            salestaus = ProductSaleStatus.All;
            int num3 = 0;
            if (int.TryParse(Page.Request.QueryString["salesatus"], out num3))
            {
                switch (num3)
                {
                    case 1:
                        salestaus = ProductSaleStatus.OnSale;
                        goto Label_00D9;

                    case 2:
                        salestaus = ProductSaleStatus.UnSale;
                        goto Label_00D9;
                }
                salestaus = ProductSaleStatus.OnStock;
            }
            Label_00D9:
            if (!string.IsNullOrEmpty(Page.Request.QueryString["productCode"]))
            {
                productCode = Globals.UrlDecode(Page.Request.QueryString["productCode"]);
            }
            int num4 = 0;
            if (int.TryParse(Page.Request.QueryString["lineId"], out num4))
            {
                lineId = new int?(num4);
            }
            if (!string.IsNullOrEmpty(Page.Request.QueryString["searchKey"]))
            {
                searchkey = Globals.UrlDecode(Page.Request.QueryString["searchKey"]);
            }
            if (!string.IsNullOrEmpty(Page.Request.QueryString["startDate"]))
            {
                startDate = new DateTime?(DateTime.Parse(Page.Request.QueryString["startDate"]));
            }
            if (!string.IsNullOrEmpty(Page.Request.QueryString["endDate"]))
            {
                endDate = new DateTime?(DateTime.Parse(Page.Request.QueryString["endDate"]));
            }
            dropCategories.DataBind();
            dropCategories.SelectedValue = categoryId;
            dropLines.DataBind();
            dropLines.SelectedValue = lineId;
            dropBrandList.DataBind();
            dropBrandList.SelectedValue = brandId;
            dropproductsale.DataBind();
            if (salestaus != ProductSaleStatus.All)
            {
                dropproductsale.SelectedValue = new int?((int)salestaus);
            }
            txtSearchText.Text = searchkey;
            txtSKU.Text = productCode;
            calendarStartDate.SelectedDate = startDate;
            calendarEndDate.SelectedDate = endDate;
        }