/// <summary>
 /// 上传商品相册图
 /// </summary>
 /// <param name="albumthumbnail"></param>
 /// <param name="ImagesThumbnailsWidth"></param>
 /// <param name="ImagesThumbnailsHeight"></param>
 /// <param name="WhetherWater"></param>
 /// <param name="ImageWatermarkTransparent"></param>
 /// <param name="TextWatermarkTransparent"></param>
 /// <param name="WatermarkPosition"></param>
 /// <param name="WatermarkImage"></param>
 /// <param name="WatermarkText"></param>
 /// <param name="TextOrImagesWatermark"></param>
 protected string Album(int ImagesThumbnailsWidth, int ImagesThumbnailsHeight, bool IsModfiy, int ProductId)
 {
     ShowShop.Common.SysParameter sp = new ShowShop.Common.SysParameter();
     string gomessage = "";
     int proId = 0;
     ShowShop.BLL.Product.ProductInfo bll = new ShowShop.BLL.Product.ProductInfo();
     if (IsModfiy)
     {
         proId = ProductId;
     }
     else
     {
         //if (bll.GetMax() == 0)
         //{
         //    return gomessage = "相册上传失败";
         //}
         //else
         //{
         //    proId = bll.GetMax() + 1;
         //}
     }
     System.Web.HttpFileCollection files = System.Web.HttpContext.Current.Request.Files;
     ShowShop.BLL.Product.ProductAlbum pabll = new ShowShop.BLL.Product.ProductAlbum();
     ShowShop.Model.Product.ProductAlbum pamodel = new ShowShop.Model.Product.ProductAlbum();
     string[] rd = null;
     string des = ChangeHope.WebPage.PageRequest.GetFormString("description");
     if (!string.IsNullOrEmpty(des))
     {
         rd = des.Split(',');//获得图片描述的文本框字符串数组,为对应的图片的描述
     }
     if (files.Count > 1)//说明图片大小和格式都没问题
     {
         ShowShop.BLL.Product.ProductAlbum PGBLL = new ShowShop.BLL.Product.ProductAlbum();
         ShowShop.Model.Product.ProductAlbum PGModel = new ShowShop.Model.Product.ProductAlbum();
         int autouFile = files.Count;
         ChangeHope.Common.UploadProcesedImages wm = new ChangeHope.Common.UploadProcesedImages();
         ChangeHope.Common.UploadFile uf = new ChangeHope.Common.UploadFile();
         string AlbumOriginalSave = "/imageFile/product/album";
         string AlbumThumbnail = string.Empty;
         string AlbumOriginal = string.Empty;
         string Message = string.Empty;
         uf.ExtensionLim = ".gif,.jpg,.jpeg,.bmp";
         uf.FileLengthLim = sp.ImageSize;
         for (int i = 1; i < files.Count; i++)
         {
             uf.MyFile = files[i];
             uf.SavePath = AlbumOriginalSave;
             if (uf.HTMLUpLoad())
             {
                 if (uf.HaveLoad)
                 {
                     AlbumOriginal = uf.FilePath;
                     //原图缩略图
                     wm.SourceImagePath = AlbumOriginal;
                     wm.ThumbnailImagePath = AlbumOriginalSave;
                     wm.ThumbnailImageWidth = ImagesThumbnailsWidth;
                     wm.ThumbnailImageHeight = ImagesThumbnailsHeight;
                     if (wm.ToThumbnailImage())
                     {
                         AlbumThumbnail = wm.FilePath;
                     }
                     else
                     {
                         gomessage += "<br>" + wm.Message;
                     }
                 }
                 else
                 {
                     gomessage += "<br>" + uf.Message;
                 }
             }
             pamodel.Productid = proId;
             pamodel.OriginalAddress = AlbumOriginal;
             pamodel.ThumbnailAddress = AlbumThumbnail;
             pamodel.Description = "";
             if (AlbumThumbnail != string.Empty)
             {
                 pabll.Add(pamodel);
             }
         }
     }
     return gomessage;
 }
        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>");
                }
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            // ShowShop.Common.PromptInfo.Popedom("001008001");

            if (!IsPostBack)
            {
                this.litProductBrand.Text = this.BrandList(string.Empty);
                this.bindUnit(string.Empty);
                this.InitWebControl();
                //int productId =;// ChangeHope.WebPage.PageRequest.GetInt("id");
                if (Request["productNo"] != null)
                {
                    this.BindInfo(Convert.ToInt32(Request["productNo"]));
                }
                else
                {
                    ShowShop.BLL.Product.ProductInfo bll = new ShowShop.BLL.Product.ProductInfo();
                    string pro_No = bll.GetMax();
                    lb_ProductNo.Text = (Convert.ToInt32(pro_No) + 1).ToString("000000");
                }
            }
        }
 protected void BindInfo(int ProductId)
 {
     ShowShop.BLL.Product.ProductInfo bll = new ShowShop.BLL.Product.ProductInfo();
     ShowShop.Model.Product.ProductInfo model = bll.GetModel(ProductId);
     this.hfcid.Value = model.ClassID.ToString();  //商品id
     #region 商品类别名称
     Productclass proClass = new Productclass();
     ShowShop.Model.Product.Productclass modelClass = proClass.GetModelID(model.ClassID);
     this.txtProductClass.Text = modelClass.Name;
     #endregion
     lb_ProductNo.Text = model.ProductNo;//商品编号
     this.txtProductName.Text = model.ProductName;//商品名称
     this.txtProductAttachName.Text = model.ProductAttachName;//商品附加名称
     this.litProductBrand.Text = this.BrandList(model.BrandID.ToString());//商品品牌
     this.bindUnit(model.Unit);//商品单位
     this.rblIsShelves.SelectedValue = model.IsAuto.ToString();//是否上下架(0下架1上架)
     this.txtFilingTime.Text = model.AutoUp.ToString();//上架时间
     this.txtDownTime.Text = model.AutoDown.ToString();//下架时间
     this.txtMarketPrice.Text = Convert.ToDouble(model.MarketPrice).ToString("f2");//市场价格
     this.txtCostPrice.Text = Convert.ToDouble(model.ShopPrice).ToString("f2");//商城价格
     ViewState["pro_Thumbnail"] = model.Thumbnail;//缩略图
     this.txtDescription.Text = model.Synopsis;//商品简介
     this.txtContent.Value = model.ProductContent;//商品明细
     this.litaAlbum.Text = this.bindAlbum(ProductId);
     ViewState["ID"] = model.ProductID;//商品ID
 }