918博天堂

Server : Microsoft-IIS/10.0
System : Windows NT EBS-6136 10.0 build 17763 (Windows Server 2016) i586
User : jxgj ( 0)
PHP Version : 7.0.33
Disable Function : passthru,exec,system,shell_exec,proc_open,popen,pcntl_exec,socket_bind,stream_socket_server
Directory :  D:/tmp_aspnet/root/04556082/ecc0c5af/
Upload File :
Current Directory [ Writeable ] Root Directory [ Writeable ]


Current File : D:/tmp_aspnet/root/04556082/ecc0c5af/App_Web_vweuldhz.1.cs
?#pragma checksum "d:\wwwroot\gzgunuo\wwwroot\qiao\Gong_jc.aspx.cs" "{406ea660-64cf-4c82-b6f0-42d48172a799}" "C2B3A3E331B613D4FB09616FDA8E46B0"

#line 1 "d:\wwwroot\gzgunuo\wwwroot\qiao\Gong_jc.aspx.cs"
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Model;
using System.IO;


public partial class Admin_Gong : System.Web.UI.Page
{
    private int Id { get { return Convert.ToInt32(Request.QueryString["Id"]); } }
    private string Name { get { return Convert.ToString(Request.QueryString["n"]); } }

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            if (this.Name == null || this.Name == "")
            {
                this.Button1.Enabled = false;
                return;
            }

            DataBinCF();
            
            if (this.Id > 0)
            {
                this.Label1.Text = "建 改 信 息 ";
                this.Button1.Text = " 建 改 ";
                DataBinGong();
                DataBinImages();
            }
        }
    }

    public void DataBinGong()
    {
        Gong g = SqlManager.GetGong(this.Id);

        if (g == null)
            this.Response.Redirect("GongList_jc.aspx?n=" + this.Name);

        this.textTitle.Text = g.Title;
        this.DropDownList1.SelectedValue = g.CID.ToString();
        this.textAlt.Text = g.Alt;

        //其他参数
        this.RepeaterQT.DataSource = SqlManager.GetPropertyList(g.tableName, g.Id, 0);
        this.RepeaterQT.DataBind();
    }

    public void DataBinImages()
    {
        this.Repeater1.DataSource = SqlManager.GetImagesList(this.Name, this.Id);
        this.Repeater1.DataBind();
    }

    #region 加载分类

    public void DataBinCF()
    {
        //起头迭代加载
        MakeTr(0, 0);

        if (this.DropDownList1.Items.Count <= 0)
            Response.Write(string.Format("<script>alert('请先增长分类');location.href='Classification.aspx?n={0}';</script>", this.Name));
    }

    /// <summary>
    /// 装配每一行
    /// </summary>
    /// <param name="id">上级ID</param>
    /// <param name="count">迭代次数</param>
    private void MakeTr(int id, int count)
    {
        foreach (Classification cf in SqlManager.GetCFList(this.Name, id))
        {
            //形成下拉列表
            ListItem li = new ListItem(StringHelper.MakeFelgefu(count) + cf.Name, cf.Id.ToString());
            DropDownList1.Items.Add(li);

            //再次遍历
            MakeTr(cf.Id, count + 1);
        }
    }

    #endregion

    protected void Button1_Click(object sender, EventArgs e)
    {
        Gong g = new Gong();
        g.Id = this.Id;
        g.tableName = this.Name;
        g.Title = this.textTitle.Text.Trim();
        g.Content = "";
        g.Alt = this.textAlt.Text.Trim() == "请输入图片的描述(alt):" ? "" : this.textAlt.Text.Trim();
        g.keywords = "";
        g.description = "";
        g.CID = Convert.ToInt32(DropDownList1.SelectedValue);
        g.CkCount = 0;
        g.Order = 0;
        g.Time = DateTime.Now;


        int Id2 = this.Id;
        if (this.Id > 0)
        {
            if (SqlManager.UpdateGong(g))
                Response.Write(string.Format("<script>alert('批改成功!');location.href='Gong_jc.aspx?n={0}&Id={1}';</script>", this.Name, this.Id));
            else
                Response.Write(string.Format("<script>alert('批改失败!');location.href='Gong_jc.aspx?n={0}&Id={1}';</script>", this.Name, this.Id));
        }
        else
        {
            Id2 = SqlManager.AddGong(g);
            if (Id2 > 0)
                Response.Write(string.Format("<script>alert('增长成功!');location.href='Gong_jc.aspx?n={0}';</script>", this.Name));
            else
                Response.Write(string.Format("<script>alert('增长失败!');location.href='Gong_jc.aspx?n={0}';</script>", this.Name));
        }
        addImage(Id2);//增长图片

        SqlManager.DelProperty(g.tableName, Id2, 0);
        if (this.HF_Id.Value.Trim() != "")
        {
            foreach (string pid in this.HF_Id.Value.Split(','))
            {
                Property p = new Property();
                p.tableName = this.Name;
                p.TID = Id2;
                p.Type = 0;
                p.PTitle = Request.Form["text_" + pid].Trim();
                p.PContent = Request.Form[pid].Trim();
                p.Order = Request.Form["Order_" + pid].Trim() != null && Request.Form["Order_" + pid].Trim() != "" ? Convert.ToInt32(Request.Form["Order_" + pid].Trim()) : 0;
                SqlManager.AddProperty(p);
            }
        }

        //for (int i = 1; i < 21; i++)
        //{
        //    Gong g = new Gong();
        //    g.Id = this.Id;
        //    g.tableName = this.Name;
        //    g.Title = i.ToString() + this.textTitle.Text.Trim();
        //    g.Content = this.textContent.Text;
        //    g.Alt = this.textAlt.Text.Trim() == "请输入图片的描述(alt):" ? "" : this.textAlt.Text.Trim();
        //    g.keywords = this.textKeywords.Text.Trim();
        //    g.description = this.TextDescription.Text.Trim();
        //    g.CID = Convert.ToInt32(DropDownList1.SelectedValue);
        //    g.CkCount = this.textCkCount.Text.Trim() == "" ? 0 : Convert.ToInt32(this.textCkCount.Text.Trim());
        //    g.Order = this.textOrder.Text.Trim() == "" ? 0 : Convert.ToInt32(this.textOrder.Text.Trim());
        //    g.Time = this.textTime.Value.Trim() == "" ? DateTime.Now : Convert.ToDateTime(this.textTime.Value);


        //    int Id2 = this.Id;
        //    Id2 = SqlManager.AddGong(g);
        //}
        //Response.Write(string.Format("<script>alert('增长成功!');location.href='Gong_jc.aspx?n={0}';</script>", this.Name));
    }

    #region 增长图片

    /// <summary>
    /// 增长图片
    /// </summary>
    public void addImage(int Id)
    {
        HttpFileCollection files = HttpContext.Current.Request.Files;
        for (int i = 0; i < files.Count; i++)
        {
            System.Web.HttpPostedFile filePicture = files[i];
            string FileType = System.IO.Path.GetExtension(filePicture.FileName).ToLower();// 上传文件类型(扩大名)

            if (FileType == ".jpg" || FileType == ".gif" || FileType == ".bmp" || FileType == ".png")
            {
                string path = Server.MapPath("~/Images/" + this.Name);

                //文件夹是否存在,不存在则创建
                if (Directory.Exists(path) == false)
                    Directory.CreateDirectory(path);

                string fileName = DateTime.Now.ToFileTimeUtc().ToString();      //获取系统功夫作为文件名字
                string path1 = path + @"\" + fileName + FileType;
                filePicture.SaveAs(path1);//保留图片


                List<Images> list;
                if (StringHelper.GetImgList().ContainsKey(this.Name))
                    list = StringHelper.GetImgList()[this.Name];
                else
                    list = StringHelper.GetImgList()["Default"];
                foreach (Images item in list)
                {
                    if (item.tableName == "z_")
                    {
                        System.Drawing.Image images = System.Drawing.Image.FromFile(path1);
                        if (images.Width > 500)
                        {
                            if (item.Id == 1)
                                Thumbnail.MkThumbnail(path1, path + @"\" + item.tableName + fileName + FileType, item.Width, item.Height);
                            else if (item.Id == 2)
                                Thumbnail.UpLoadImage(path1, path + @"\" + item.tableName + fileName + FileType, item.Width, item.Height);
                            else
                                Thumbnail.MakeThumNail4(path1, path + @"\" + item.tableName + fileName + FileType, item.Width, item.Height, "Cut");
                        }
                        else
                        {
                            File.Copy(path1, path + @"\" + item.tableName + fileName + FileType);
                        }
                        images.Dispose();
                    }
                    else
                    {
                        if (item.Id == 1)
                            Thumbnail.MkThumbnail(path1, path + @"\" + item.tableName + fileName + FileType, item.Width, item.Height);
                        else if (item.Id == 2)
                            Thumbnail.UpLoadImage(path1, path + @"\" + item.tableName + fileName + FileType, item.Width, item.Height);
                        else
                            Thumbnail.MakeThumNail4(path1, path + @"\" + item.tableName + fileName + FileType, item.Width, item.Height, "Cut");
                    }

                    //System.Drawing.Image image = System.Drawing.Image.FromFile(Server.MapPath("~/Images/logo.png"));
                    //Thumbnail.CreateImageWaterMark(path1, image);


                    Images img = new Images();
                    img.tableName = this.Name;
                    img.TID = Id;
                    img.ImgUrl = fileName + FileType;
                    img.Order = 0;
                    img.Alt = this.textAlt.Text.Trim() == "请输入图片的描述(alt):" ? "" : this.textAlt.Text.Trim();
                    SqlManager.AddImages(img);
                    //string sFileName = Guid.NewGuid().ToString() + FileType;
                }
            }
        }
    }

    #endregion 

    protected void Repeater1_ItemCommand(object source, RepeaterCommandEventArgs e)
    {
        //删除
        if (e.CommandName == "Del")
        {

            Images img = SqlManager.GetImages(Convert.ToInt32(e.CommandArgument));
            //删除图片
            StringHelper.DelImgFile(Server.MapPath("~/Images/" + this.Name + @"\"), img.ImgUrl, this.Name);
            //删除数据库数据
            SqlManager.DelImages(Convert.ToInt32(e.CommandArgument));
        }
        //设置为封面图片
        if (e.CommandName == "FM")
        {
            Images img = SqlManager.GetImages(Convert.ToInt32(e.CommandArgument));
            SqlManager.UpdateImages(Convert.ToInt32(e.CommandArgument), img.tableName, img.TID, 1);
        }

        DataBinImages();
    }

}

#line default
#line hidden