Beispiel #1
0
 private bool AddProduct(Item item)
 {
     string path = "";
     string imgname = this.CreateIDCode() + ".jpg";
     using (System.Net.WebClient client = new System.Net.WebClient())
     {
         path = this.savePath + imgname;
         client.DownloadFile(item.PicUrl, base.Server.MapPath(path));
     }
     string json = string.Concat(new object[] { "{ 'SKU':'", item.NumIid, "', 'SalePrice': '", item.Price, "','CostPrice':'", item.Price, "','Stock':'", item.Num, "','AlertStock':'0','Weight':'0','Upselling':'1','SKUItems':[]}" });
     string thumbImagePath = "";
     this.MakeThumbnail(imgname, out thumbImagePath);
     Maticsoft.Model.Shop.Products.ProductInfo productInfo = new Maticsoft.Model.Shop.Products.ProductInfo {
         HasSKU = false,
         ImageUrl = path,
         ThumbnailUrl1 = thumbImagePath,
         LowestSalePrice = Globals.SafeDecimal(item.Price, (decimal) 0M),
         MarketPrice = new decimal?(Globals.SafeDecimal(item.Price, (decimal) 0M)),
         SaleStatus = 1,
         AddedDate = DateTime.Now,
         ProductName = item.Title,
         ProductCode = item.NumIid.ToString(),
         CategoryId = -1
     };
     List<Maticsoft.Model.Shop.Products.SKUInfo> list = this.GetSKUInfo4Json(JsonMapper.ToObject(json));
     productInfo.SkuInfos = list;
     productInfo.SupplierId = -1;
     productInfo.Product_Categories = new string[0];
     long productId = 0L;
     return ProductManage.AddProduct(productInfo, out productId);
 }
 public void BindData()
 {
     if (!base.UserPrincipal.HasPermissionID(base.GetPermidByActID(this.Act_UpdateData)) && (base.GetPermidByActID(this.Act_UpdateData) != -1))
     {
         this.gridView.Columns[5].Visible = false;
     }
     Maticsoft.Model.Shop.Products.ProductInfo model = new Maticsoft.Model.Shop.Products.ProductInfo {
         SaleStatus = 2,
         CategoryId = -1
     };
     if (!string.IsNullOrWhiteSpace(this.txtKeyword.Text.Trim()))
     {
         model.ProductName = this.txtKeyword.Text.Trim();
     }
     this.gridView.DataSetSource = this.bll.GetListByCategoryIdSaleStatus(model);
     this.BindDropList();
 }
        public void BindData()
        {
            if (!base.UserPrincipal.HasPermissionID(base.GetPermidByActID(this.Act_UpdateData)) && (base.GetPermidByActID(this.Act_UpdateData) != -1))
            {
                this.gridView.Columns[8].Visible = false;
            }
            switch (this.SaleStatus)
            {
                case -1:
                    this.btnCheck.Visible = true;
                    this.strTitle = "您可以对未审核中的商品进行编辑、删除和审核操作";
                    this.btnInverseApprove.Visible = false;
                    this.btnInverseApprove2.Visible = false;
                    break;

                case 0:
                    this.strTitle = "您可以对仓库中的商品进行删除和上架功能";
                    this.btnInverseApprove.Text = "批量上架";
                    this.btnInverseApprove2.Text = "批量上架";
                    break;

                case 1:
                    this.strTitle = "您可以对出售中的商品进行编辑、删除和下架操作";
                    break;
            }
            Maticsoft.Model.Shop.Products.ProductInfo model = new Maticsoft.Model.Shop.Products.ProductInfo {
                SaleStatus = this.SaleStatus
            };
            if (!string.IsNullOrWhiteSpace(this.txtKeyword.Text.TrimEnd(new char[0])))
            {
                model.ProductName = InjectionFilter.SqlFilter(this.txtKeyword.Text);
            }
            if (!string.IsNullOrWhiteSpace(this.drpProductCategory.SelectedValue))
            {
                model.CategoryId = Globals.SafeInt(this.drpProductCategory.SelectedValue, 0);
            }
            if (!string.IsNullOrWhiteSpace(this.txtProductNum.Text))
            {
                model.ProductCode = InjectionFilter.SqlFilter(this.txtProductNum.Text);
            }
            this.gridView.DataSetSource = this.bll.GetProductInfo(model);
        }
Beispiel #4
0
 private void SaveProductInfo()
 {
     if (string.IsNullOrWhiteSpace(this.Hidden_SelectValue.Value))
     {
         MessageBox.ShowFailTip(this, "请选择产品分类!");
     }
     else
     {
         string text = this.txtProductName.Text;
         int num = Globals.SafeInt(this.hfCurrentProductType.Value, -1);
         int num2 = Globals.SafeInt(this.hfCurrentProductBrand.Value, -1);
         int supplierId = base.SupplierId;
         int? nullable = new int?(Globals.SafeInt(this.ajaxRegion.SelectedValue, -1));
         string str2 = this.txtUnit.Text;
         decimal? nullable2 = new decimal?(Globals.SafeDecimal(this.txtMarketPrice.Text, (decimal) -1M));
         int num4 = Globals.SafeInt(this.txtDisplaySequence.Text, -1);
         string str3 = this.txtShortDescription.Text;
         string str4 = this.txtDescription.Text;
         string str5 = this.hfProductImages.Value;
         string str6 = this.hfCurrentAttributes.Value;
         string str7 = this.hfCurrentBaseProductSKUs.Value;
         string str8 = this.hfCurrentProductSKUs.Value;
         bool flag = false;
         string[] strArray = new string[0];
         if (!string.IsNullOrWhiteSpace(str3))
         {
             str3 = Globals.HtmlEncodeForSpaceWrap(str3);
         }
         if (!string.IsNullOrWhiteSpace(str5))
         {
             strArray = str5.Split(new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries);
         }
         if (string.IsNullOrWhiteSpace(str6))
         {
             MessageBox.Show(this, "属性信息不存在,请检查已填数据是否正确!");
         }
         else
         {
             List<Maticsoft.Model.Shop.Products.AttributeInfo> list = this.GetAttributeInfo4Json(JsonMapper.ToObject(str6));
             if (string.IsNullOrWhiteSpace(str7))
             {
                 MessageBox.Show(this, "基础SKU信息不存在,请检查已填数据是否正确!");
             }
             else
             {
                 List<Maticsoft.Model.Shop.Products.SKUInfo> list2 = null;
                 decimal? nullable3 = 0M;
                 flag = !string.IsNullOrWhiteSpace(str8);
                 if (flag)
                 {
                     list2 = this.GetSKUInfo4Json(JsonMapper.ToObject(str8));
                     if (this.salePriceList.Count > 0)
                     {
                         this.salePriceList.Sort();
                         nullable3 = new decimal?(Convert.ToDecimal(this.salePriceList[0]));
                     }
                 }
                 else
                 {
                     list2 = this.GetSKUInfo4Json(JsonMapper.ToObject(str7));
                     nullable3 = new decimal?(Globals.SafeDecimal(this.txtSalePrice.Text, (decimal) -1M));
                 }
                 Maticsoft.Model.Shop.Products.ProductInfo productInfo = new Maticsoft.Model.Shop.Products.ProductInfo();
                 string[] strArray2 = this.Hidden_SelectValue.Value.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
                 productInfo.Product_Categories = strArray2;
                 productInfo.ProductName = text;
                 productInfo.CategoryId = 0;
                 productInfo.TypeId = new int?(num);
                 productInfo.BrandId = num2;
                 if (supplierId > 0)
                 {
                     productInfo.SupplierId = supplierId;
                 }
                 else
                 {
                     productInfo.SupplierId = -1;
                 }
                 productInfo.RegionId = (nullable == -1) ? null : nullable;
                 productInfo.Unit = str2;
                 productInfo.MarketPrice = (nullable2 == -1M) ? 0 : nullable2;
                 productInfo.LowestSalePrice = nullable3.Value;
                 productInfo.DisplaySequence = num4;
                 productInfo.ProductCode = this.txtProductSKU.Text;
                 productInfo.AddedDate = DateTime.Now;
                 productInfo.SaleStatus = -1;
                 productInfo.ShortDescription = str3;
                 productInfo.Description = str4;
                 productInfo.Tags = "";
                 if (strArray.Length == 0)
                 {
                     productInfo.ImageUrl = productInfo.ThumbnailUrl1 = productInfo.ThumbnailUrl2 = "/Content/themes/base/Shop/images/none.png";
                 }
                 string newValue = string.Format("/Upload/Shop/Images/Product/{0}/", DateTime.Now.ToString("yyyyMMdd"));
                 string str10 = "/Upload/Shop/Images/ProductThumbs/" + DateTime.Now.ToString("yyyyMMdd") + "/";
                 ArrayList list3 = new ArrayList();
                 for (int i = 0; i < strArray.Length; i++)
                 {
                     if (i == 0)
                     {
                         string str11 = string.Format(strArray[i], "");
                         string str12 = strArray[i];
                         productInfo.ImageUrl = str11.Replace(this.tempFile, newValue);
                         productInfo.ThumbnailUrl1 = str12.Replace(this.tempFile, str10);
                         list3.Add(str11.Replace(this.tempFile, ""));
                         list3.Add(str12.Replace(this.tempFile, ""));
                     }
                     else
                     {
                         string str13 = string.Format(strArray[i], "");
                         string str14 = strArray[i];
                         Maticsoft.Model.Shop.Products.ProductImage item = new Maticsoft.Model.Shop.Products.ProductImage {
                             ImageUrl = str13.Replace(this.tempFile, newValue),
                             ThumbnailUrl1 = str14.Replace(this.tempFile, str10)
                         };
                         productInfo.ProductImages.Add(item);
                         list3.Add(str13.Replace(this.tempFile, ""));
                         list3.Add(str14.Replace(this.tempFile, ""));
                     }
                     Maticsoft.BLL.Shop.Products.ProductImage.MoveImage(strArray[i], newValue, str10);
                 }
                 productInfo.AttributeInfos = list;
                 productInfo.HasSKU = flag;
                 productInfo.SkuInfos = list2;
                 productInfo.isRec = this.chbRec.Checked;
                 productInfo.isNow = this.chbNew.Checked;
                 productInfo.isHot = this.chbHot.Checked;
                 productInfo.isLowPrice = this.chbLowPrice.Checked;
                 if (!string.IsNullOrEmpty(this.Hidden_SelectPackage.Value))
                 {
                     Maticsoft.BLL.Shop.Package.Package package = new Maticsoft.BLL.Shop.Package.Package();
                     List<int> list4 = new List<int>();
                     string[] strArray3 = this.Hidden_SelectPackage.Value.Split(new char[] { ',' });
                     int packageId = 0;
                     foreach (string str15 in strArray3)
                     {
                         packageId = Globals.SafeInt(str15, 0);
                         if (package.Exists(packageId))
                         {
                             list4.Add(packageId);
                         }
                     }
                     productInfo.PackageId = list4;
                 }
                 long productId = 0L;
                 if (ProductManage.AddProduct(productInfo, out productId))
                 {
                     if (this.skuImageList.Count > 0)
                     {
                         FileManage.MoveFile(base.Server.MapPath(this.tempFile), base.Server.MapPath(this.skuImageFile), this.skuImageList);
                     }
                     string str16 = "";
                     str16 = this.chkSina.Checked ? "3" : "";
                     if (this.chkQQ.Checked)
                     {
                         str16 = str16 + (string.IsNullOrWhiteSpace(str16) ? "13" : ",13");
                     }
                     UserBind bind = new UserBind();
                     string url = string.Concat(new object[] { "http://", Globals.DomainFullName, "/Product/Detail/", productId });
                     bind.SendWeiBo(-1, str16, productInfo.ProductName, url, productInfo.ImageUrl);
                     base.Response.Redirect(string.Format("InStock.aspx?SaleStatus=-1", new object[0]));
                 }
                 else
                 {
                     MessageBox.Show(this, "保存失败! 请重试.");
                 }
             }
         }
     }
 }
 protected void ButUpload_Click(object sender, EventArgs e)
 {
     try
     {
         if ((this.FileUploadProducts.PostedFile != null) && (this.FileUploadProducts.PostedFile.ContentLength > 0))
         {
             string str = Path.GetExtension(this.FileUploadProducts.PostedFile.FileName).ToLower();
             ".csv".IndexOf(str);
             if ((!this.CheckBox1.Checked && !this.CheckBox2.Checked) && (!this.CheckBox3.Checked && !this.CheckBox4.Checked))
             {
                 MessageBox.ShowFailTip(this, "请至少选择一种商品推荐方式!");
             }
             else
             {
                 int num = Convert.ToInt32((this.ProductsBatchUploadDropList.SelectedValue == this.dropItem0Value) ? "-1" : this.ProductsBatchUploadDropList.SelectedValue);
                 int num2 = Convert.ToInt32((this.dropProductTypes.SelectedValue == this.dropItem0Value) ? "-1" : this.dropProductTypes.SelectedValue);
                 int num3 = Convert.ToInt32((this.dropBrands.SelectedValue == this.dropItem0Value) ? "-1" : this.dropBrands.SelectedValue);
                 int num4 = Convert.ToInt32((this.dropEnterprise.SelectedValue == this.dropItem0Value) ? "-1" : this.dropEnterprise.SelectedValue);
                 string str2 = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=";
                 OleDbConnection selectConnection = new OleDbConnection(str2 + this.FileUploadProducts.PostedFile.FileName.Replace(this.FileUploadProducts.FileName, string.Empty) + ";Extended Properties=\"text;HDR=Yes;FMT=Delimited\"");
                 DataSet dataSet = new DataSet();
                 new OleDbDataAdapter("select * from " + this.FileUploadProducts.FileName, selectConnection).Fill(dataSet);
                 selectConnection.Close();
                 int num5 = 0;
                 Maticsoft.Model.Shop.Products.ProductInfo model = new Maticsoft.Model.Shop.Products.ProductInfo();
                 Maticsoft.BLL.Shop.Products.ProductInfo info2 = new Maticsoft.BLL.Shop.Products.ProductInfo();
                 for (int i = 0; i < dataSet.Tables[0].Rows.Count; i++)
                 {
                     model.CategoryId = num;
                     model.TypeId = new int?(num2);
                     model.BrandId = num3;
                     model.SupplierId = num4;
                     model.SaleStatus = this.CheckBoxSaleStatus.Checked ? 1 : 0;
                     model.ProductName = dataSet.Tables[0].Rows[i]["商品名称"].ToString();
                     model.Description = dataSet.Tables[0].Rows[i]["简单介绍"].ToString();
                     model.AddedDate = Convert.ToDateTime(dataSet.Tables[0].Rows[i]["添加时间"]);
                     model.ImageUrl = dataSet.Tables[0].Rows[i]["清晰图"].ToString();
                     model.MarketPrice = new decimal?(Convert.ToDecimal(dataSet.Tables[0].Rows[i]["市场价"].ToString()));
                     model.LineId = 1;
                     int num7 = Convert.ToInt32(info2.Add(model));
                     if (num7 != 0)
                     {
                         Maticsoft.Model.Shop.Products.ProductStationMode mode = new Maticsoft.Model.Shop.Products.ProductStationMode();
                         Maticsoft.BLL.Shop.Products.ProductStationMode mode2 = new Maticsoft.BLL.Shop.Products.ProductStationMode();
                         int num8 = 0;
                         for (int j = 1; j <= 4; j++)
                         {
                             CheckBox box = (CheckBox) this.divCheckBox.FindControl("CheckBox" + j);
                             if (box.Checked)
                             {
                                 mode.ProductId = num7;
                                 mode.DisplaySequence = mode2.GetRecordCount(" ProductId = " + num7) + 1;
                                 mode.Type = Convert.ToInt32(box.SkinID);
                                 if (mode2.Add(mode) != 0)
                                 {
                                     num8 = 1;
                                 }
                             }
                         }
                         if (num8 == 1)
                         {
                             num8 = 0;
                             num5++;
                         }
                     }
                 }
                 if (num5 > 0)
                 {
                     MessageBox.ShowAndBack(this, "已成功导入 " + num5.ToString() + " 个商品!");
                 }
                 else
                 {
                     MessageBox.ShowFailTip(this, "导入失败!");
                 }
             }
         }
         else
         {
             MessageBox.ShowFailTip(this, "请选择上传文件!");
         }
     }
     catch (Exception exception)
     {
         MessageBox.ShowFailTip(this, exception.Message);
     }
 }