using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
using System.Xml;
using System.IO;
using picmark;

namespace PanRoor
{
    public partial class WTOSYSadmin_Products_Products : XMLX
    {
        //图片上传
        string picmm="";
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["WtoRightName"] == null)
            {
                Response.Redirect("~/SYSADMIN/main/error.aspx?err=非法登陆!或系统超时，请刷新后重新登录");
            }
            if (!IsPostBack)
            {
                switch (Request.QueryString["do"])
                {
                    case "del":
                        Doadmin.Exec("delete from Comments where pid=" + Request.QueryString["id"].Trim());  
                        Doadmin.Exec("delete from ProductInfo where id=" + Request.QueryString["id"].Trim());
                        Response.Redirect("ProductsList2.aspx");
                        Response.End();
                        break;

                    case "edit":
                        #region 修改初始化值
                        //第一标签复值
                        string Products, ProductsNo, ISPublished, ISpf, Brandf, Description, Unit, Unitweight, Stockvolume, StockWarning, IsNew, IsHot, IsRecommended, IsSpecials, Nature, Content;
                        string id;
                        id = Request.QueryString["id"].ToString().Trim();
                        SqlConnection connfz = CDatabase.wtoconn();
                        connfz.Open();
                        SqlCommand scd = new SqlCommand("select * from ProductInfo where id=" + id, connfz);
                        SqlDataReader sdr = scd.ExecuteReader();
                        sdr.Read();
                        Products = sdr.GetString(3).ToString().Trim();
                        this.Products.Text = Products;
                        ProductsNo = sdr.GetString(4).ToString().Trim();
                        this.ProductsNo.Text = ProductsNo;
                        ISPublished = sdr.GetString(5).ToString().Trim();
                        if (ISPublished == "y")
                        {
                            this.open.Checked = true;
                        }
                        else
                        {
                            this.close.Checked = true;
                        }
                        //加入修改值
                        Doadmin.ddldatabind(Brand, "select * from Brand", "BrandName", "id");
                        Brandf = sdr.GetString(7).ToString().Trim();
                        this.Brand.SelectedValue = Brandf;
                        Doadmin.ddldatabind(BigProduct, "select * from BigProductCategory order by Sort", "BigCategory", "id");
                        this.BigProduct.SelectedValue = (Convert.ToString(sdr.GetInt32(1))).Trim();
                        Description = sdr.GetString(8).ToString().Trim();
                        this.Description.Text = Description;
                        this.Unit.Text = sdr.GetString(9).ToString().Trim();
                        this.Unitweight.Text = sdr.GetString(10).ToString().Trim();
                      
                        Nature = sdr.GetString(17).ToString().Trim();
                        switch (Nature)
                        {
                            case "1":
                                this.isS.Checked = true;
                                break;
                            case "2":
                                this.isK.Checked = true;
                                break;
                            case "3":
                                this.isX.Checked = true;
                                break;

                        }
                        this.Content.Text = Server.HtmlDecode(sdr.GetString(33).ToString().Trim());
                        //第二个标签
                        string SmallProductId = (Convert.ToString(sdr.GetInt32(2))).ToString().Trim();
                        string bigid = (Convert.ToString(sdr.GetInt32(1))).Trim();
                        this.SmallProductId.Text = Convert.ToString(sdr.GetInt32(2)).Trim();
                        
                        this.piclable.Text = sdr.GetString(26);
                        this.Slab.Text = sdr.GetString(25);
                        if (sdr.GetString(28).Trim() == "nopic.jpg")
                        {
                            this.RemotePicURLt.Text = "";
                        }
                        else
                        {
                            this.RemotePicURLt.Text = sdr.GetString(28).Trim();
                        }
                        if (sdr.GetString(29).Trim() == "nopic.jpg")
                        {
                            this.RemotePicURLc.Text = "";
                        }
                        else
                        {
                            this.RemotePicURLc.Text = sdr.GetString(29).Trim();
                        }
                        //第四标签
                        this.PageTitle.Text = sdr.GetString(30).Trim();
                        this.META_KEYWORDS.Text = sdr.GetString(31).Trim();
                        this.META_DESCRIPTION.Text = sdr.GetString(32).Trim();
                        string lx2 = sdr.GetString(35).Trim();//属性类别
                        //this.strall.Text = lx2;
                        picmm = sdr.GetString(34);
                        this.picMORE.Value = picmm;
                        string[] xxG = lx2.Split('$');

                        sdr.Close();
                        SqlCommand sdm2 = new SqlCommand("select * from SmallProductCategory  where BigCategoryId=" + bigid, connfz);
                        SqlDataReader sdr2 = sdm2.ExecuteReader();
                        string erli = "";

                        while (sdr2.Read())
                        {
                            erli += Convert.ToString(sdr2.GetInt32(0)) + "+";
                            erli += Convert.ToString(sdr2.GetString(2)).Trim() + "-";
                        }
                        RegisterStartupScript("", "<script>goscript('" + erli + "','" + lx2 + "');<" + "/script>");
                        erli = "";
                        connfz.Close();
                        #endregion
                        break;
                }



            }

        }

        //保存
        protected void LinkButton2_Click(object sender, EventArgs e)
        {
            //取值------------------------------------------------------------------------------------------------------------------
            //第一标签[基本信息] Products|产品名称$　ProductsNo|货号 ISPublished|open/close|是否发布 ISpf|批发 Brand|品牌 Description|简单描述
            //Unit|计量单位 Unitweight|单位重量 Stockvolume|库存量 StockWarning|isy/isns|库存警告 IsNew|最新 IsHot|最热 IsRecommended|推荐 IsSpecials|特价
            //Nature|商品属性 Content|详细信息

            #region 第一标签取值
            string Products, ProductsNo, ISPublished, ISpf, Brand, Description, Unit, Unitweight, Stockvolume, StockWarning, IsNew, IsHot, IsRecommended, IsSpecials, Nature, Content;
            Products = Request["Products"].ToString().Trim();
            ProductsNo = Request["ProductsNo"].ToString().Trim();

            if (this.open.Checked)
            {
                ISPublished = "y";
            }
            else
            {
                ISPublished = "n";
            }

            ISpf ="0";
            Brand = this.Brand.SelectedItem.Value;
            Description = Request["Description"].ToString().Trim();
            Unit = Request["Unit"].ToString().Trim();
            Unitweight = Request["Unitweight"].ToString().Trim();
            Stockvolume ="0";
         
                StockWarning = "y";
                IsNew = "y";
                IsHot = "y";
                IsRecommended = "y";
                IsSpecials = "y";
            if (this.isS.Checked)
            {
                Nature = "1";
            }
            else
            {
                if (this.isK.Checked)
                {
                    Nature = "2";
                }
                else
                {
                    Nature = "3";
                }
            }


            Content = Server.HtmlEncode(this.Content.Text.Replace("'", "''"));
            #endregion

            //第二标签取值开始
            //BigProduct|商品大类 SmlProduct|小类   
            //商品属性值确认表 ddlFL|属性列表大类 小类数组值
            //sale|销售价 CountALL|确认销售价  Sprice|市场价 CostPrice|成本价 CjVipPrice|初级会员价 MiddleVIPPrice|中级会员价 HiVipPrice|高级会员价
            //VIPPrice|VIP会员价
            #region 第二标签取值开始
            string BigProductID, SmallProductId, SalePrice, Marketprice, CostPrice, CjVipPrice, MiddleVIPPrice, HiVipPrice, VIPPrice,strall;
            BigProductID = this.BigProduct.SelectedValue.ToString().Trim();
            SmallProductId = Request["SmallProductId"].ToString().Trim();
            SalePrice = "0";
            Marketprice = "0";
            CostPrice = "0";
            CjVipPrice = "0";
            MiddleVIPPrice = "0";
            HiVipPrice = "0";
            VIPPrice = "0";
            strall="0";
            //以上是商品表中内容.属性表还未填
            #endregion

            #region 第三标签取值开始------------------------------------------------------------------------------------------------------------------
            //  isslpic|开启本地上传缩略图 ThumbnailsPic|本地上传缩略图 fup_img|清晰图 RemotePicURLt|缩略图远程链接地址 RemotePicURLc|清晰图远程链接地址
            //更多图片:存放在商品图片更多表中[取数组值]
            //OriginalPic|原始图
            string fpath, ftype, fname, dot="";
            string ThumbnailsPic, ClearPic, OriginalPic, RemotePicURLt, RemotePicURLc="";
            string isSL = "";


                //取缩略图片
                string picPath = Server.MapPath("~/upfile");
                HttpPostedFile file = this.ThumbnailsPic.PostedFile;
                
                string hz = this.ThumbnailsPic.PostedFile.FileName;
                if (hz != "")
                {
                    string S_hz = (hz.Substring(hz.LastIndexOf(".") + 1)).ToLower().Trim();
                    string stpt = "";
                    string stfilename = "";
                    if (S_hz == "jpg" || S_hz == "gif")
                    {
                        stfilename = DateTime.Now.ToString("yyyyMMddHHmmssffffMM");
                        stpt = Server.MapPath("~/upfile/") + stfilename + "." + S_hz;
                        file.SaveAs(stpt);

                    }
                    else
                    {
                        Response.Write("<script>alert('文件格式错误！');</script>");
                        Response.End();
                    }

                    ThumbnailsPic = stfilename + "." + S_hz;
                    isSL = "Y";
                }
                else
                {
                    ThumbnailsPic = this.Slab.Text;
                }

            #region 图片上传
            fname = this.fup_imgb.FileName;
            fpath = this.fup_imgb.PostedFile.FileName;
            ftype = this.fup_imgb.PostedFile.ContentType;
            string[] type = ftype.Split('/');
            string[] fn = fname.Split('.');
            string S_hC = (fpath.Substring(fpath.LastIndexOf(".") + 1)).ToLower().Trim();

            if (S_hC != "jpg" & S_hC!="" & S_hC!="gif" &S_hC!="bmp"&S_hC!="png")
            {
                Response.Write("<script>alert('文件格式错误！');window.location.href('ProductsEdit.aspx?id=" + Request.QueryString["id"].Trim() + "')</script>");
            }
            else
            {
                if (fpath != "")
                {
                    dot = "." + fn[1].ToString();
                    string filename = DateTime.Now.ToString("yyyyMMddHHmmssffff");
                    string pt = Server.MapPath("~/upfile/") + filename + dot;
                    fup_imgb.SaveAs(pt);
                    fup_imgb.Dispose();
                    if (XMLRead("NoAndOff") == "true")
                    {
                        picmark.ImageModification wm = new ImageModification();
                        wm.DrawedImagePath = Server.MapPath("~/upfile/Watermark/logo_cn.gif"); //水印图片
                        wm.ModifyImagePath = pt;    //图片的路径
                        wm.RightSpace = Convert.ToInt32(XMLRead("RightSpace"));          //水印位置 宽 相对图片右下角
                        wm.BottoamSpace = Convert.ToInt32(XMLRead("BottoamSpace"));       //水印位置 高
                        wm.LucencyPercent = Convert.ToInt32(XMLRead("LucencyPercent"));      //透明度
                        wm.OutPath = Server.MapPath("~/upfile/") + filename + "_new" + dot;
                        wm.DrawImage();

                        if (File.Exists(pt))
                        {
                            File.Delete(pt);
                        }

                        ClearPic = filename + "_new" + dot;
                    }
                    else
                    {
                        ClearPic = filename+ dot;
                    }


                    OriginalPic = filename + dot;
                    if (isSL == "N")
                    {
                        ThumbnailsPic = filename + dot;
                    }
                }
                else
                {
                    ClearPic = this.piclable.Text;
                    OriginalPic = ClearPic.Substring(0,18).ToString().Trim()+ ".jpg";
                }
            #endregion
                //接着取值
                RemotePicURLt = Request["RemotePicURLt"].ToString().Trim();
                RemotePicURLc = Request["RemotePicURLc"].ToString().Trim();
                if (RemotePicURLt == "")
                {
                    RemotePicURLt = "nopic.jpg";
                }
                if (RemotePicURLc == "")
                {
                    RemotePicURLc = "nopic.jpg";

                }
//暂定为无图，如果有保留原始图，则为filename直接加上.jpg就OK了
                //更多图片上传取值开始
            
                string picstrSZ="";
                if (Request["picMORE"].Trim() != "")
                {
                    picstrSZ = Request["picMORE"].Trim();
                }
               #region 第一个图上传
                string fpath1, ftype1, fname1, dot1, filename1, pt1;
                fname1 = this.Mpic1.FileName;
                fpath1 = this.Mpic1.PostedFile.FileName;
                string S_hC1 = (fpath1.Substring(fpath1.LastIndexOf(".") + 1)).ToLower().Trim();
                if (fpath1 != "")
                {
                    ftype1 = this.Mpic1.PostedFile.ContentType;
                    string[] type1 = ftype1.Split('/');
                    string[] fn1 = fname.Split('.');

                    if (S_hC1 != "jpg" & S_hC1 != "gif" & S_hC1 != "bmp" & S_hC1 != "png")
                    {
                   Response.Write("<script>alert('文件格式错误！1');window.location.href('ProductsEdit.aspx?id=" + Request.QueryString["id"].Trim() + "')</script>");

                    }
                    else
                    {
                        dot1 = "." + S_hC1;
                        filename1 = DateTime.Now.ToString("yyyyMMddHHmmssffff");
                        pt1 = Server.MapPath("~/upfile/") + filename1 + dot1;
                        Mpic1.SaveAs(pt1);
                        Mpic1.Dispose();
                        if (XMLRead("NoAndOff") == "true")
                        {
                            picmark.ImageModification wm1 = new ImageModification();
                            wm1.DrawedImagePath = Server.MapPath("~/upfile/Watermark/logo_cn.gif"); //水印图片
                            wm1.ModifyImagePath = pt1;    //图片的路径
                            wm1.RightSpace = Convert.ToInt32(XMLRead("RightSpace"));          //水印位置 宽 相对图片右下角
                            wm1.BottoamSpace = Convert.ToInt32(XMLRead("BottoamSpace"));       //水印位置 高
                            wm1.LucencyPercent = Convert.ToInt32(XMLRead("LucencyPercent"));      //透明度
                            wm1.OutPath = Server.MapPath("~/upfile/") + filename1 + "_new" + dot1;
                            wm1.DrawImage();
                            if (File.Exists(pt1))
                            {
                                File.Delete(pt1);
                            }

                           
                            picstrSZ += filename1 + "_new.jpg$";
                        }
                        else
                        { 
                         picstrSZ += filename1 + ".jpg$";
                        }


                    }
                }


               #endregion
               #region 第二个图上传
                string fpath2, ftype2,fname2, dot2, filename2, pt2;
                    fname2 = this.Mpic2.FileName;
                    fpath2 = this.Mpic2.PostedFile.FileName;
                    string S_hC2 = (fpath2.Substring(fpath2.LastIndexOf(".") + 1)).ToLower().Trim();
                    if (fpath2 != "")
                    {
                        ftype2 = this.Mpic2.PostedFile.ContentType;
                        string[] type2 = ftype2.Split('/');
                        string[] fn2 = fname.Split('.');
                        if (S_hC2 != "jpg" & S_hC2 != "gif" & S_hC2 != "bmp" & S_hC2 != "png")
                        {
                            Response.Write("<script>alert('文件格式错误！1');window.location.href('ProductsEdit.aspx?id=" + Request.QueryString["id"].Trim() + "')</script>");

                        }
                        else
                        {
                            dot2 = "." + S_hC2;
                            filename2 = DateTime.Now.ToString("yyyyMMddHHmmssffff");
                            pt2 = Server.MapPath("~/upfile/") + filename2 + dot2;
                            Mpic2.SaveAs(pt2);
                            Mpic2.Dispose();


                            if (XMLRead("NoAndOff") == "true")
                            {
                                picmark.ImageModification wm2 = new ImageModification();
                                wm2.DrawedImagePath = Server.MapPath("~/upfile/Watermark/logo_cn.gif"); //水印图片
                                wm2.ModifyImagePath = pt2;    //图片的路径
                                wm2.RightSpace = Convert.ToInt32(XMLRead("RightSpace"));          //水印位置 宽 相对图片右下角
                                wm2.BottoamSpace = Convert.ToInt32(XMLRead("BottoamSpace"));       //水印位置 高
                                wm2.LucencyPercent = Convert.ToInt32(XMLRead("LucencyPercent"));      //透明度
                                wm2.OutPath = Server.MapPath("~/upfile/") + filename2 + "_new" + dot2;
                                wm2.DrawImage();
                                if (File.Exists(pt2))
                                {
                                    File.Delete(pt2);
                                }
                                
                                picstrSZ += filename2 + "_new.jpg$";
                            }
                            else
                            { 
                            picstrSZ += filename2 + ".jpg$";
                            }
                        }
                    }


                    #endregion
               #region 第三个图上传
                        string fpath3,ftype3, fname3, dot3, filename3, pt3;
                        fname3 = this.Mpic3.FileName;
                        fpath3 = this.Mpic3.PostedFile.FileName;
                        string S_hC3 = (fpath3.Substring(fpath3.LastIndexOf(".") + 1)).ToLower().Trim();
                        if (fpath3 != "")
                        {
                            ftype3 = this.Mpic3.PostedFile.ContentType;
                            string[] type3 = ftype3.Split('/');
                            string[] fn3 = fname.Split('.');
                            if (S_hC3 != "jpg" & S_hC3 != "gif" & S_hC3 != "bmp" & S_hC3 != "png")
                            {
                                Response.Write("<script>alert('文件格式错误！');window.location.href('ProductsEdit.aspx?id=" + Request.QueryString["id"].Trim() + "')</script>");

                            }
                            else
                            {
                                dot3 = "." + S_hC3;
                                filename3 = DateTime.Now.ToString("yyyyMMddHHmmssffff");
                                pt3 = Server.MapPath("~/upfile/") + filename3 + dot3;
                                Mpic3.SaveAs(pt3);
                                Mpic3.Dispose();
                                if (XMLRead("NoAndOff") == "true")
                                {
                                    picmark.ImageModification wm3 = new ImageModification();
                                    wm3.DrawedImagePath = Server.MapPath("~/upfile/Watermark/logo_cn.gif"); //水印图片
                                    wm3.ModifyImagePath = pt3;    //图片的路径
                                    wm3.RightSpace = Convert.ToInt32(XMLRead("RightSpace"));          //水印位置 宽 相对图片右下角
                                    wm3.BottoamSpace = Convert.ToInt32(XMLRead("BottoamSpace"));       //水印位置 高
                                    wm3.LucencyPercent = Convert.ToInt32(XMLRead("LucencyPercent"));      //透明度
                                    wm3.OutPath = Server.MapPath("~/upfile/") + filename3 + "_new" + dot3;
                                    wm3.DrawImage();
                                    if (File.Exists(pt3))
                                    {
                                        File.Delete(pt3);
                                    }
                                   
                                    picstrSZ += filename3 + "_new.jpg$";
                                }
                                else
                                { 
                                    picstrSZ += filename3 + ".jpg$";
                                }


                            }
                        }

                        #endregion
               #region 第四个图上传
                            string fpath4,ftype4,fname4, dot4, filename4, pt4;
                            fname4 = this.Mpic4.FileName;
                            fpath4 = this.Mpic4.PostedFile.FileName;
                            string S_hC4 = (fpath4.Substring(fpath4.LastIndexOf(".") + 1)).ToLower().Trim();
                            if (fpath4 != "")
                            {
                                ftype4 = this.Mpic4.PostedFile.ContentType;
                                string[] type4 = ftype4.Split('/');
                                string[] fn4 = fname.Split('.');
                                if (S_hC4 != "jpg" & S_hC4 != "gif" & S_hC4 != "bmp" & S_hC4 != "png")
                                {
                                    Response.Write("<script>alert('文件格式错误！');window.location.href('ProductsEdit.aspx?id=" + Request.QueryString["id"].Trim() + "')</script>");

                                }
                                else
                                {
                                    dot4 = "." + S_hC4;
                                    filename4 = DateTime.Now.ToString("yyyyMMddHHmmssffff");
                                    pt4 = Server.MapPath("~/upfile/") + filename4 + dot4;
                                    Mpic4.SaveAs(pt4);
                                    Mpic4.Dispose();
                                    if (XMLRead("NoAndOff") == "true")
                                    {
                                        picmark.ImageModification wm4 = new ImageModification();
                                        wm4.DrawedImagePath = Server.MapPath("~/upfile/Watermark/logo_cn.gif"); //水印图片
                                        wm4.ModifyImagePath = pt4;    //图片的路径
                                        wm4.RightSpace = Convert.ToInt32(XMLRead("RightSpace"));          //水印位置 宽 相对图片右下角
                                        wm4.BottoamSpace = Convert.ToInt32(XMLRead("BottoamSpace"));       //水印位置 高
                                        wm4.LucencyPercent = Convert.ToInt32(XMLRead("LucencyPercent"));      //透明度
                                        wm4.OutPath = Server.MapPath("~/upfile/") + filename4 + "_new" + dot4;
                                        wm4.DrawImage();
                                        if (File.Exists(pt4))
                                        {
                                            File.Delete(pt4);
                                        }
                                        
                                        picstrSZ += filename4 + "_new.jpg$";
                                    }
                                    else
                                    { 
                                        picstrSZ += filename4 + ".jpg$";
                                    }
                                }
                            }
                            #endregion
               #region 第五个图上传
                            string fpath5, ftype5,fname5, dot5, filename5, pt5;
                                fname5 = this.Mpic5.FileName;
                                fpath5 = this.Mpic5.PostedFile.FileName;
                                string S_hC5 = (fpath5.Substring(fpath5.LastIndexOf(".") + 1)).ToLower().Trim();
                                if (fpath5 != "")
                                {
                                    ftype5 = this.Mpic5.PostedFile.ContentType;
                                    string[] type5 = ftype5.Split('/');
                                    string[] fn5 = fname.Split('.');
                                    if (S_hC5 != "jpg" & S_hC5 != "gif" & S_hC5 != "bmp" & S_hC4 != "png")
                                    {
                                        Response.Write("<script>alert('文件格式错误！');window.location.href('ProductsEdit.aspx?id=" + Request.QueryString["id"].Trim() + "')</script>");

                                    }
                                    else
                                    {
                                        dot5 = "." + S_hC5;
                                        filename5 = DateTime.Now.ToString("yyyyMMddHHmmssffff");
                                        pt5 = Server.MapPath("~/upfile/") + filename5 + dot5;
                                        Mpic5.SaveAs(pt5);
                                        Mpic5.Dispose();
                                        if (XMLRead("NoAndOff") == "true")
                                        {
                                            picmark.ImageModification wm5 = new ImageModification();
                                            wm5.DrawedImagePath = Server.MapPath("~/upfile/Watermark/logo_cn.gif"); //水印图片
                                            wm5.ModifyImagePath = pt5;    //图片的路径
                                            wm5.RightSpace = Convert.ToInt32(XMLRead("RightSpace"));          //水印位置 宽 相对图片右下角
                                            wm5.BottoamSpace = Convert.ToInt32(XMLRead("BottoamSpace"));       //水印位置 高
                                            wm5.LucencyPercent = Convert.ToInt32(XMLRead("LucencyPercent"));      //透明度
                                            wm5.OutPath = Server.MapPath("~/upfile/") + filename5 + "_new" + dot5;
                                            wm5.DrawImage();
                                            if (File.Exists(pt5))
                                            {
                                                File.Delete(pt5);
                                            }
                                            
                                            picstrSZ += filename5 + "_new.jpg$";
                                        }
                                        else
                                        { 
                                        picstrSZ += filename5 + ".jpg$";
                                        }
                                    }
                                }
                                #endregion
               #region 第六个图上传
                                    string fpath6,ftype6,fname6, dot6, filename6, pt6;
                                    fname6 = this.Mpic6.FileName;
                                    fpath6 = this.Mpic6.PostedFile.FileName;
                                    string S_hC6 = (fpath6.Substring(fpath6.LastIndexOf(".") + 1)).ToLower().Trim();
                                    if (fpath6 != "")
                                    {
                                        ftype6 = this.Mpic6.PostedFile.ContentType;
                                        string[] type6 = ftype6.Split('/');
                                        string[] fn6 = fname.Split('.');
                                        if (S_hC6 != "jpg" & S_hC6 != "gif" & S_hC6 != "bmp" & S_hC6 != "png")
                                        {
                                            Response.Write("<script>alert('文件格式错误！');window.location.href('ProductsEdit.aspx?id=" + Request.QueryString["id"].Trim() + "')</script>");

                                        }
                                        else
                                        {
                                            dot6 = "." + S_hC6;
                                            filename6 = DateTime.Now.ToString("yyyyMMddHHmmssffff");
                                            pt6 = Server.MapPath("~/upfile/") + filename6 + dot6;
                                            Mpic6.SaveAs(pt6);
                                            Mpic6.Dispose();
                                            if (XMLRead("NoAndOff") == "true")
                                            {
                                                picmark.ImageModification wm6 = new ImageModification();
                                                wm6.DrawedImagePath = Server.MapPath("~/upfile/Watermark/logo_cn.gif"); //水印图片
                                                wm6.ModifyImagePath = pt6;    //图片的路径
                                                wm6.RightSpace = Convert.ToInt32(XMLRead("RightSpace"));          //水印位置 宽 相对图片右下角
                                                wm6.BottoamSpace = Convert.ToInt32(XMLRead("BottoamSpace"));       //水印位置 高
                                                wm6.LucencyPercent = Convert.ToInt32(XMLRead("LucencyPercent"));      //透明度
                                                wm6.OutPath = Server.MapPath("~/upfile/") + filename6 + "_new" + dot6;
                                                wm6.DrawImage();
                                                if (File.Exists(pt6))
                                                {
                                                    File.Delete(pt6);
                                                }
                                             
                                                picstrSZ += filename6 + "_new.jpg$";
                                            }
                                            else
                                            { 
                                               picstrSZ += filename6 + ".jpg$";
                                            }
                                        }
                                    }
                                    #endregion
               #region 第七个图上传
                                        string fpath7,ftype7,fname7, dot7, filename7, pt7;
                                        fname7 = this.Mpic7.FileName;
                                        fpath7 = this.Mpic7.PostedFile.FileName;
                                        string S_hC7 = (fpath7.Substring(fpath7.LastIndexOf(".") + 1)).ToLower().Trim();
                                        if (fpath7 != "")
                                        {
                                            ftype7 = this.Mpic7.PostedFile.ContentType;
                                            string[] type7 = ftype7.Split('/');
                                            string[] fn7 = fname.Split('.');
                                            if (S_hC7 != "jpg" & S_hC7 != "gif" & S_hC7 != "bmp" & S_hC7 != "png")
                                            {
                                                Response.Write("<script>alert('文件格式错误！');window.location.href('ProductsEdit.aspx?id=" + Request.QueryString["id"].Trim() + "')</script>");

                                            }
                                            else
                                            {
                                                dot7 = "." + S_hC7;
                                                filename7 = DateTime.Now.ToString("yyyyMMddHHmmssffff");
                                                pt7 = Server.MapPath("~/upfile/") + filename7 + dot7;
                                                Mpic7.SaveAs(pt7);
                                                Mpic7.Dispose();
                                                if (XMLRead("NoAndOff") == "true")
                                                {
                                                    picmark.ImageModification wm7 = new ImageModification();
                                                    wm7.DrawedImagePath = Server.MapPath("~/upfile/Watermark/logo_cn.gif"); //水印图片
                                                    wm7.ModifyImagePath = pt7;    //图片的路径
                                                    wm7.RightSpace = Convert.ToInt32(XMLRead("RightSpace"));          //水印位置 宽 相对图片右下角
                                                    wm7.BottoamSpace = Convert.ToInt32(XMLRead("BottoamSpace"));       //水印位置 高
                                                    wm7.LucencyPercent = Convert.ToInt32(XMLRead("LucencyPercent"));      //透明度
                                                    wm7.OutPath = Server.MapPath("~/upfile/") + filename7 + "_new" + dot7;
                                                    wm7.DrawImage();
                                                    if (File.Exists(pt7))
                                                    {
                                                        File.Delete(pt7);
                                                    }
                                                   
                                                    picstrSZ += filename7 + "_new.jpg$";
                                                }
                                                else
                                                { 
                                                    picstrSZ += filename7 + ".jpg$";
                                                }

                                            }
                                        }


                                        #endregion
               #region 第八个图上传
                                            string fpath8,ftype8, fname8, dot8, filename8, pt8;
                                            fname8 = this.Mpic8.FileName;
                                            fpath8 = this.Mpic8.PostedFile.FileName;
                                            string S_hC8 = (fpath8.Substring(fpath8.LastIndexOf(".") + 1)).ToLower().Trim();
                                            if (fpath8 != "")
                                            {
                                                ftype8 = this.Mpic8.PostedFile.ContentType;
                                                string[] type8 = ftype8.Split('/');
                                                string[] fn8 = fname.Split('.');
                                                if (S_hC8 != "jpg" & S_hC8 != "gif" & S_hC8 != "bmp" & S_hC8 != "png")
                                                {
                                                    Response.Write("<script>alert('文件格式错误！');window.location.href('ProductsEdit.aspx?id=" + Request.QueryString["id"].Trim() + "')</script>");

                                                }
                                                else
                                                {
                                                    dot8 = "." + S_hC8;
                                                    filename8 = DateTime.Now.ToString("yyyyMMddHHmmssffff");
                                                    pt8 = Server.MapPath("~/upfile/") + filename8 + dot8;
                                                    Mpic8.SaveAs(pt8);
                                                    Mpic8.Dispose();

                                                    if (XMLRead("NoAndOff") == "true")
                                                    {

                                                        picmark.ImageModification wm8 = new ImageModification();
                                                        wm8.DrawedImagePath = Server.MapPath("~/upfile/Watermark/logo_cn.gif"); //水印图片
                                                        wm8.ModifyImagePath = pt8;    //图片的路径
                                                        wm8.RightSpace = Convert.ToInt32(XMLRead("RightSpace"));          //水印位置 宽 相对图片右下角
                                                        wm8.BottoamSpace = Convert.ToInt32(XMLRead("BottoamSpace"));       //水印位置 高
                                                        wm8.LucencyPercent = Convert.ToInt32(XMLRead("LucencyPercent"));      //透明度
                                                        wm8.OutPath = Server.MapPath("~/upfile/") + filename8 + "_new" + dot8;
                                                        wm8.DrawImage();
                                                        if (File.Exists(pt8))
                                                        {
                                                            File.Delete(pt8);
                                                        }
                                                        
                                                        picstrSZ += filename8 + "_new.jpg$";
                                                    }
                                                    else
                                                    { 
                                                    picstrSZ += filename8 + ".jpg$";
                                                    }
                                                }
                                            }


                                            #endregion
               #region 第九个图上传
                                                string fpath9,ftype9, fname9, dot9, filename9, pt9;
                                                fname9 = this.Mpic9.FileName;
                                                fpath9 = this.Mpic9.PostedFile.FileName;
                                                string S_hC9 = (fpath9.Substring(fpath9.LastIndexOf(".") + 1)).ToLower().Trim();
                                                if (fpath9 != "")
                                                {
                                                    ftype9 = this.Mpic9.PostedFile.ContentType;
                                                    string[] type9 = ftype9.Split('/');
                                                    string[] fn9 = fname.Split('.');
                                                    if (S_hC9 != "jpg" & S_hC9 != "gif" & S_hC9 != "bmp" & S_hC9 != "png")
                                                    {
                                                        Response.Write("<script>alert('文件格式错误！');window.location.href('ProductsEdit.aspx?id=" + Request.QueryString["id"].Trim() + "')</script>");

                                                    }
                                                    else
                                                    {
                                                        dot9 = "." + S_hC9;
                                                        filename9 = DateTime.Now.ToString("yyyyMMddHHmmssffff");
                                                        pt9 = Server.MapPath("~/upfile/") + filename9 + dot9;
                                                        Mpic9.SaveAs(pt9);
                                                        Mpic9.Dispose();
                                                        if (XMLRead("NoAndOff") == "true")
                                                        {
                                                            picmark.ImageModification wm9 = new ImageModification();
                                                            wm9.DrawedImagePath = Server.MapPath("~/upfile/Watermark/logo_cn.gif"); //水印图片
                                                            wm9.ModifyImagePath = pt9;    //图片的路径
                                                            wm9.RightSpace = Convert.ToInt32(XMLRead("RightSpace"));          //水印位置 宽 相对图片右下角
                                                            wm9.BottoamSpace = Convert.ToInt32(XMLRead("BottoamSpace"));       //水印位置 高
                                                            wm9.LucencyPercent = Convert.ToInt32(XMLRead("LucencyPercent"));      //透明度
                                                            wm9.OutPath = Server.MapPath("~/upfile/") + filename9 + "_new" + dot9;
                                                            wm9.DrawImage();
                                                            if (File.Exists(pt9))
                                                            {
                                                                File.Delete(pt9);
                                                            }
                                                            
                                                            picstrSZ += filename9 + "_new.jpg$";
                                                        }
                                                        else
                                                        { 
                                                            picstrSZ += filename9 + ".jpg$";
                                                        }

                                                    }
                                                }

                                                #endregion
               #region 第十个图上传
                                                    string fpath10, ftype10,fname10, dot10, filename10, pt10;
                                                    fname10 = this.Mpic10.FileName;
                                                    fpath10 = this.Mpic10.PostedFile.FileName;
                                                    string S_hC10 = (fpath10.Substring(fpath10.LastIndexOf(".") + 1)).ToLower().Trim();
                                                    if (fpath10 != "")
                                                    {
                                                        ftype10 = this.Mpic10.PostedFile.ContentType;
                                                        string[] type10 = ftype10.Split('/');
                                                        string[] fn10 = fname.Split('.');
                                                        if (S_hC10 != "jpg" & S_hC10 != "gif" & S_hC10 != "bmp" & S_hC10 != "png")
                                                        {
                                                            Response.Write("<script>alert('文件格式错误！');window.location.href('ProductsEdit.aspx?id=" + Request.QueryString["id"].Trim() + "')</script>");

                                                        }
                                                        else
                                                        {
                                                            dot10 = "." + S_hC10;
                                                            filename10 = DateTime.Now.ToString("yyyyMMddHHmmssffff");
                                                            pt10 = Server.MapPath("~/upfile/") + filename10 + dot10;
                                                            Mpic10.SaveAs(pt10);
                                                            Mpic10.Dispose();
                                                            if (XMLRead("NoAndOff") == "true")
                                                            {
                                                                picmark.ImageModification wm10 = new ImageModification();
                                                                wm10.DrawedImagePath = Server.MapPath("~/upfile/Watermark/logo_cn.gif"); //水印图片
                                                                wm10.ModifyImagePath = pt10;    //图片的路径
                                                                wm10.RightSpace = Convert.ToInt32(XMLRead("RightSpace"));          //水印位置 宽 相对图片右下角
                                                                wm10.BottoamSpace = Convert.ToInt32(XMLRead("BottoamSpace"));       //水印位置 高
                                                                wm10.LucencyPercent = Convert.ToInt32(XMLRead("LucencyPercent"));      //透明度
                                                                wm10.OutPath = Server.MapPath("~/upfile/") + filename10 + "_new" + dot10;
                                                                wm10.DrawImage();
                                                                if (File.Exists(pt10))
                                                                {
                                                                    File.Delete(pt10);
                                                                }
                                                                
                                                                picstrSZ += filename10 + "_new.jpg$";
                                                            }
                                                            else
                                                            { 
                                                                picstrSZ += filename10 + ".jpg$";
                                                            }

                                                        }
                                                    }
                                                    #endregion


                                                    if (fpath1 == "" || fpath2 == "")
                                                    { 
                                                    
                                                    }
                                                        //图片上传完成

    
              #endregion
                                                    //第四标签[暂留]---------------------------------------------------------------------------------------------------------              

               #region 第五标签---------------------------------------------------------------------------------------------------------------
                                                        string PageTitle, META_KEYWORDS, META_DESCRIPTION;
                                                        PageTitle = Request["PageTitle"].ToString();
                                                        META_KEYWORDS = Request["META_KEYWORDS"].ToString();
                                                        META_DESCRIPTION = Request["META_DESCRIPTION"].ToString();
                                                        #endregion

               #region 整合上传
                                                        string sqlstrWTO;
                                                        sqlstrWTO = "update ProductInfo set BigProductID=" + BigProductID + ",SmallProductId=" + SmallProductId + ",Products='" + Products + "',ProductsNo='" + ProductsNo + "',ISPublished='" + ISPublished + "',ISpf='" + ISpf + "',Brand='" + Brand + "',Description='" + Description + "',Unit='" + Unit + "',Unitweight='" + Unitweight + "',Stockvolume=" + Stockvolume + ",StockWarning='" + StockWarning + "',IsNew='" + IsNew + "',IsHot='" + IsHot + "',IsRecommended='" + IsRecommended + "',IsSpecials='" + IsSpecials + "',Nature='" + Nature + "',Marketprice=" + Convert.ToDecimal(Marketprice) + ",SalePrice=" + Convert.ToDecimal(SalePrice) + ",CostPrice=" + Convert.ToDecimal(CostPrice) + ",CjVipPrice=" + Convert.ToDecimal(CjVipPrice) + ",MiddleVIPPrice=" + Convert.ToDecimal(MiddleVIPPrice) + ",HiVipPrice=" + Convert.ToDecimal(HiVipPrice);
                                                        sqlstrWTO += ",VIPPrice=" + Convert.ToDecimal(VIPPrice) + ",ThumbnailsPic='" + ThumbnailsPic + "',ClearPic='" + ClearPic + "',OriginalPic='" + OriginalPic + "',RemotePicURLt='" + RemotePicURLt + "',RemotePicURLc='" + RemotePicURLc + "',PageTitle='" + PageTitle + "',META_KEYWORDS='" + META_KEYWORDS + "',META_DESCRIPTION='" + META_DESCRIPTION + "',Content='" + Content + "',Picmore='" + picstrSZ + "',XX='" + strall + "',AddDate='" + System.DateTime.Now.ToString() + "',Language='china',ljprice="+Convert.ToDecimal(Request["sale"])+" where id=" +Request.QueryString["id"].Trim();
                                                         
                                                        
                                                        if (Doadmin.Exec(sqlstrWTO))
                                                        {
                                                            Response.Write("<script>alert('修改成功');location.href('ProductsList2.aspx')</script>");
                                                        }
                                                        else
                                                        {
                                                            Response.Write("<script>alert('修改失败')</script>");
                                                        }
                                                        #endregion



                 }
                        
              }
      }
 }
