Example #1
0
 protected void butUpFile_Click(object sender, EventArgs e)
 {
     ChangeHope.Common.UploadFile uf = new ChangeHope.Common.UploadFile();
     uf.ExtensionLim = ".jpe|.jpeg|.jpg|.gif|.png|.tif|.tiff|.bmp";
     uf.FileLengthLim = 4000;
     uf.PostedFile = this.fufile;
     uf.SavePath = this.path.Value;
     uf.FileSaveMethod = "d";
     if (uf.Upload())
     {
         if (uf.HaveLoad)
         {
             this.ltlMsg.Text = "操作成功,上传文件以保存.";
             this.pnlMsg.Visible = true;
             this.pnlMsg.CssClass = "actionOk";
         }
     }
     else
     {
         this.ltlMsg.Text = "操作失败," + uf.Message + "";
         this.pnlMsg.Visible = true;
         this.pnlMsg.CssClass = "actionOk";
         return;
     }
 }
        protected void butSave_Click(object sender, EventArgs e)
        {
            ShowShop.BLL.Product.ProductInfo bll = new ShowShop.BLL.Product.ProductInfo();
            ShowShop.Model.Product.ProductInfo model = new ShowShop.Model.Product.ProductInfo();
            #region 数据准备
            model.ProductNo = lb_ProductNo.Text.Trim();//商品编号
            model.ProductName = this.txtProductName.Text;//商品名称
            model.ProductAttachName = txtProductAttachName.Text.Trim();//附加名称
            model.ClassID = this.hfcid.Value != "" ? int.Parse(this.hfcid.Value) : 0;//商品类别Id
            model.BrandID = Convert.ToInt32(ChangeHope.WebPage.PageRequest.GetFormString("selBrand"));//品牌
            model.Unit = ChangeHope.WebPage.PageRequest.GetFormString("selUnit") == "0" ? "" : ChangeHope.WebPage.PageRequest.GetFormString("selUnit");//商品单位
            model.MarketPrice = this.txtMarketPrice.Text.Trim() != "" ? Convert.ToDecimal(this.txtMarketPrice.Text.Trim()) : 0;//市场价格
            model.ShopPrice = this.txtCostPrice.Text.Trim() != "" ? Convert.ToDecimal(this.txtCostPrice.Text.Trim()) : 0;//商城价格
            model.Synopsis = this.txtDescription.Text;//商品简介
            model.ProductContent = this.txtContent.Value;//商品明细
            model.AutoUp = this.txtFilingTime.Text.Trim() != "" ? Convert.ToDateTime(this.txtFilingTime.Text.Trim()) : System.DateTime.Now;//上架时间
            model.AutoDown = this.txtDownTime.Text.Trim() != "" ? Convert.ToDateTime(this.txtDownTime.Text.Trim()) : Convert.ToDateTime("2020-01-01");//下架时间
            model.UpdateTime = System.DateTime.Now;//更新时间
            model.IsAuto = Convert.ToInt32(rblIsShelves.SelectedValue);//是否上架

            #endregion
            #region 图片
            string thumbnailPath = System.Configuration.ConfigurationManager.AppSettings["ImgThumbnailPath"].ToString();
            string SavePath = "/imageFile/product/thumbnail";
            string thumbnail = string.Empty;
            if (fuPic.HasFile)
            {
                //原图
                ChangeHope.Common.UploadFile uf = new ChangeHope.Common.UploadFile();
                uf.ExtensionLim = ".gif,.jpg,.jpeg,.bmp";
                uf.FileLengthLim = 1024;
                uf.PostedFile = this.fuPic;
                uf.SavePath = SavePath;
                if (uf.Upload())
                {
                    thumbnail = uf.FilePath;
                }
                else
                {
                    this.ltlMsg.Text = "操作失败," + uf.Message + "";
                    this.pnlMsg.Visible = true;
                    this.pnlMsg.CssClass = "actionOk";
                    return;
                }
            }
            model.Thumbnail = thumbnail;//缩略图地址
            #endregion
            if (ViewState["ID"] != null)
            {
                ShowShop.Common.PromptInfo.Popedom("001008004", "对不起,您没有编辑权限");
                model.ProductID = Convert.ToInt32(ViewState["ID"].ToString());
                //相册
                string AlbumInfo = Album(100, 100, true, Convert.ToInt32(ViewState["ID"].ToString()));
                string reStr = string.Empty;
                ChangeHope.WebPage.BasePage.PageRight("操作成功,您的已修改该商品信息。", "product_list.aspx?q_PutoutType=", "<li>" + reStr + "</li>");
            }
            else
            {
                ShowShop.Common.PromptInfo.Popedom("001008002", "对不起,您没有新增权限");
                //相册

                int productId = bll.Add(model);
                string AlbumInfo = Album(100, 100, false, productId);
                string reStr = string.Empty;
                if (productId > 0)
                {
                    ChangeHope.WebPage.BasePage.PageRight("操作成功,您的添加的商品信息已保存。", "product_info_edit.aspx?putoutType=", "<li>" + reStr + "</li>");
                }
                else
                {
                    ChangeHope.WebPage.BasePage.PageError("操作失败,您的添加的商品信息保存失败。", "product_info_edit.aspx?putoutType=", "<li>" + reStr + "</li>");
                }
            }
        }