コード例 #1
0
        private static void AddProductMainImage(int ProductID, string CatePath, string ImageRelativeURL)
        {
            string   ImageFullURL = UrlPrefix + ImageRelativeURL;
            FileInfo ImageFile    = DownloadImage(ImageFullURL);

            if (!ImageFile.Directory.Exists)
            {
                Directory.CreateDirectory(ImageFile.Directory.FullName);
            }
            string[] MainImages;
            ProductMainImageRule.SaveProductMainImage(ProductID, CatePath, ImageFile, out MainImages);

            pbll.UpdateProductMainImage(ProductID, MainImages);
        }
コード例 #2
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            SuiteBll sbll    = new SuiteBll();
            int      suiteId = String.IsNullOrEmpty(lblSuiteId.Text) ? 0 : int.Parse(lblSuiteId.Text);

            SuiteModel smodel = sbll.GetModel(suiteId);

            if (smodel == null)
            {
                smodel          = new SuiteModel();
                smodel.Price    = 0m;
                smodel.Score    = 0;
                smodel.SuiteId  = NoName.NetShop.Common.CommDataHelper.GetNewSerialNum(AppType.Product);
                smodel.ScenceId = ScenceId;
            }
            decimal price;

            if (!decimal.TryParse(lblPrice.Text, out price))
            {
                price = 0m;
            }
            smodel.ProductFee = price;
            smodel.DerateFee  = decimal.Parse(txtDerate.Text);
            smodel.Price      = smodel.ProductFee - smodel.DerateFee;
            smodel.Remark     = txtRemark.Text.Trim();
            smodel.SuiteName  = txtSuiteName.Text.Trim();
            if (!String.IsNullOrEmpty(fulImage.FileName))
            {
                string[] MainImages;
                if (ProductMainImageRule.SaveProductMainImage(smodel.SuiteId, "suite/", fulImage.PostedFile, out MainImages))
                {
                    smodel.SmallImage  = MainImages[0];
                    smodel.MediumImage = MainImages[1];
                    smodel.LargeImage  = MainImages[2];
                }
            }
            sbll.Save(smodel);
            this.ShowInfo(smodel.SuiteId);
        }
コード例 #3
0
        protected void btnAdd_Click(object sender, EventArgs e)
        {
            string strErr = "";

            if (this.txtProductName.Text == "")
            {
                strErr += "ProductName不能为空!\\n";
            }
            if (!PageValidate.IsNumber(txtStock.Text))
            {
                strErr += "Stock不是数字!\\n";
            }
            if (this.txtKeywords.Text == "")
            {
                strErr += "Keywords不能为空!\\n";
            }
            if (this.txtBrief.Text == "")
            {
                strErr += "Brief不能为空!\\n";
            }

            if (!PageValidate.IsNumber(txtScore.Text))
            {
                strErr += "Score不是数字!\\n";
            }
            if (this.txtDecription.Text == "")
            {
                strErr += "Decription不能为空!\\n";
            }

            if (strErr != "")
            {
                MessageBox.Show(this, strErr);
                return;
            }
            int ProductId;

            if (!int.TryParse(this.litProductId.Text, out ProductId))
            {
                ProductId = 0;
            }
            string ProductName = this.txtProductName.Text;
            int    Stock       = int.Parse(this.txtStock.Text);
            string Keywords    = this.txtKeywords.Text;
            string Brief       = this.txtBrief.Text;
            int    Status      = int.Parse(this.rblStatus.SelectedValue);
            int    Score       = int.Parse(this.txtScore.Text);
            string Decription  = this.txtDecription.Text;

            NoName.NetShop.Product.Model.GiftModel model = new NoName.NetShop.Product.Model.GiftModel();
            model.ProductId = ProductId;
            if (ProductId == 0)
            {
                model.ProductId = NoName.NetShop.Common.CommDataHelper.GetNewSerialNum(AppType.Product);
            }
            model.ProductName = ProductName;
            model.Stock       = Stock;

            if (fulImage.HasFile)
            {
                string[] MainImages;
                if (ProductMainImageRule.SaveProductMainImage(model.ProductId, "gift/", fulImage.PostedFile, out MainImages))
                {
                    model.SmallImage  = MainImages[0];
                    model.MediumImage = MainImages[1];
                    model.LargeImage  = MainImages[2];
                }
            }
            model.Keywords   = Keywords;
            model.Brief      = Brief;
            model.Status     = Status;
            model.SortValue  = 0;
            model.Score      = Score;
            model.Decription = Decription;

            gbll.Save(model);
            Response.Redirect("GiftProductList.aspx");
        }
コード例 #4
0
        private void SaveData()
        {
            string strErr = "";

            if (this.txtProductName.Text == "")
            {
                strErr += "产品名称不能为空!\\n";
            }
            if (!PageValidate.IsDecimal(txtTradePrice.Text))
            {
                strErr += "市场价输入有误!\\n";
            }
            if (!PageValidate.IsDecimal(txtMerchantPrice.Text))
            {
                strErr += "销售价输入有误!\\n";
            }
            if (!PageValidate.IsDecimal(txtReducePrice.Text))
            {
                strErr += "直降价输入有误!\\n";
            }
            if (!PageValidate.IsNumber(txtScore.Text))
            {
                strErr += "商品积分输入有误!\\n";
            }
            if (!PageValidate.IsDecimal(txtWeight.Text))
            {
                strErr += "商品重量输入有误!\\n";
            }
            if (this.txtKeywords.Text == "")
            {
                strErr += "关键词不能为空!\\n";
            }
            if (this.TextBox_Brief.Text == "")
            {
                strErr += "商品简介不能为空!\\n";
            }
            if (!PageValidate.IsNumber(drpStatus.SelectedValue))
            {
                strErr += "商品状态选择有误!\\n";
            }
            int TempNewsID = 0;

            if (!String.IsNullOrEmpty(txtNewsID.Text) && !int.TryParse(txtNewsID.Text, out TempNewsID))
            {
                strErr += "关联资讯ID输入有误";
            }

            if (strErr != "")
            {
                MessageBox.Show(this, strErr);
                return;
            }

            ProductModel product = bll.GetModel(ProductID);

            product.ProductName   = txtProductName.Text;
            product.ProductCode   = txtProductCode.Text;
            product.CateId        = Convert.ToInt32(txtCategoryID.Value);
            product.TradePrice    = Convert.ToDecimal(txtTradePrice.Text);
            product.MerchantPrice = Convert.ToDecimal(txtMerchantPrice.Text);
            product.ReducePrice   = Convert.ToDecimal(txtReducePrice.Text);
            product.Status        = Convert.ToInt32(drpStatus.SelectedValue);
            product.Keywords      = txtKeywords.Text;
            product.Brief         = TextBox_Brief.Text;
            product.BrandID       = Convert.ToInt32(DropDown_Brand.SelectedValue);

            product.Specifications   = TextBox_Specification.Text;
            product.OfferSet         = TextBox_OfferSet.Text;
            product.PackingList      = TextBox_Packing.Text;
            product.AfterSaleService = TextBox_Service.Text;

            product.Weight = Convert.ToDecimal(txtWeight.Text);

            product.StockTip       = GetStockTip();
            product.RelateProducts = txtRelateProduct.Text.Replace(",", ",");

            product.ChangeTime = DateTime.Now;

            if (fulImage.FileName != String.Empty)
            {
                string[] MainImages;
                ProductMainImageRule.SaveProductMainImage(ProductID, product.CatePath, fulImage.PostedFile, out MainImages);
                product.SmallImage  = MainImages[0];
                product.MediumImage = MainImages[1];
                product.LargeImage  = MainImages[2];
            }

            //更新检索属性
            foreach (GridViewRow row in GridView_Parameter.Rows)
            {
                RadioButtonList ParameterValueList = ((RadioButtonList)row.Cells[0].FindControl("RadioList_ParameterValue"));
                if (!String.IsNullOrEmpty(ParameterValueList.SelectedValue))
                {
                    int              ParameterID    = Convert.ToInt32(((HiddenField)row.Cells[0].FindControl("Hidden_ParameterID")).Value);
                    string           ParameterValue = Convert.ToString(ParameterValueList.SelectedItem.Text);
                    ProductParaModel para           = new ProductParaModel();

                    para.ParaId    = ParameterID;
                    para.ProductId = product.ProductId;
                    para.ParaValue = ParameterValue;

                    pvBll.Save(para);
                }
            }
            //更新基本属性
            foreach (GridViewRow row in GridView_Specification.Rows)
            {
                RadioButtonList ParameterValueList = ((RadioButtonList)row.Cells[0].FindControl("RadioList_SpecificationValue"));
                if (!String.IsNullOrEmpty(ParameterValueList.SelectedValue))
                {
                    int              ParameterID    = Convert.ToInt32(((HiddenField)row.Cells[0].FindControl("Hidden_SpecificationID")).Value);
                    string           ParameterValue = Convert.ToString(ParameterValueList.SelectedItem.Text);
                    ProductParaModel para           = new ProductParaModel();

                    para.ParaId    = ParameterID;
                    para.ProductId = product.ProductId;
                    para.ParaValue = ParameterValue;

                    pvBll.Save(para);
                }
            }
            //添加商品多图
            foreach (string s in Request.Files.AllKeys)
            {
                if (s.StartsWith("multiImageUpload") && Request.Files[s].ContentLength > 0)
                {
                    string[] FileNames;
                    ProductMultiImageRule.SaveProductMultiImage(ProductID, product.CatePath, Request.Files[s], out FileNames);

                    if (FileNames != null)
                    {
                        ProductImageModel model = new ProductImageModel();
                        model.ImageId     = CommDataHelper.GetNewSerialNum("pd");
                        model.ProductId   = ProductID;
                        model.LargeImage  = FileNames[1];
                        model.OriginImage = FileNames[2];
                        model.SmallImage  = FileNames[0];
                        model.Title       = String.Empty;

                        new ProductImageModelBll().Add(model);
                    }
                }
            }

            //更新关联资讯ID
            new ProductNewsBll().Save(new ProductNewsModel()
            {
                ProdutID = product.ProductId, NewsID = TempNewsID
            });

            bll.Update(product);


            //重建索引
            try
            {
                DataIndexerProduct SearchIndexer = new DataIndexerProduct(Config.Searches["product"]);
                SearchIndexer.DeleteSingleIndex(product.ProductId);
                SearchIndexer.CreateSingleIndex(new Search.Entities.ProductModel()
                {
                    EntityIdentity = product.ProductId,
                    CategoryID     = product.CateId,
                    CategoryPath   = product.CatePath,
                    CreateTime     = product.InsertTime,
                    Description    = product.Brief,
                    Keywords       = product.Keywords,
                    Price          = product.MerchantPrice,
                    ProcessType    = NoName.NetShop.Search.Entities.EntityProcessType.insert,
                    ProductImage   = product.MediumImage,
                    ProductName    = product.ProductName,
                    UpdateTime     = product.ChangeTime
                });
            }
            catch { }
        }