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_ckeltci6.1.cs
?#pragma checksum "d:\wwwroot\gzgunuo\wwwroot\qiao\Gong9.aspx.cs" "{406ea660-64cf-4c82-b6f0-42d48172a799}" "8B0DD1180F9073ED916B38CCB03B0B08"

#line 1 "d:\wwwroot\gzgunuo\wwwroot\qiao\Gong9.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;
using System.Drawing;
using System.Drawing.Drawing2D;

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();
            this.textTime.Value = DateTime.Now.ToString("yyyy-MM-dd");
            if (this.Id > 0)
            {
                this.Label1.Text = "建 改 信 息 ";
                this.Button1.Text = " 建 改 ";
                DataBinGong();
            }
        }
    }

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

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

        this.textTitle.Text = g.Title;
        this.textKeywords.Text = g.keywords;
        this.TextDescription.Text = g.description;
        this.textOrder.Text = g.Order.ToString();
        this.textTime.Value = g.Time.ToString("yyyy-MM-dd HH:mm:ss");
        this.DropDownList1.SelectedValue = g.CID.ToString();
        this.textContent.Text = g.Content;

        this.Image1.Visible = true;

        if (g.Alt.Trim() != "" && File.Exists(Server.MapPath("~/Images/" + g.tableName + "/" + g.Alt)))
        {
            this.Image1.ImageUrl = "~/Images/" + g.tableName + "/" + g.Alt;
            this.HF_Img.Value = g.Alt;
        }
        else
        {
            this.Image1.ImageUrl = "~/Images/zwtp.png";
        }
    }

    #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 = this.textContent.Text;
        g.Alt = "";
        g.keywords = this.textKeywords.Text.Trim();
        g.description = this.TextDescription.Text.Trim();
        g.CID = Convert.ToInt32(DropDownList1.SelectedValue);
        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);

        #region 增长图片
        if (this.FileUpload1.HasFile)
        {
            string FileType = System.IO.Path.GetExtension(this.FileUpload1.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;
                this.FileUpload1.SaveAs(path1);

                if (this.HF_Img.Value.Trim() != "")
                {
                    if (File.Exists(path + @"\" + this.HF_Img.Value))
                        File.Delete(path + @"\" + this.HF_Img.Value);
                }

                g.Alt = fileName + FileType;
            }
            else
            {
                g.Alt = this.HF_Img.Value.Trim();
            }
        }
        else
        {
            g.Alt = this.HF_Img.Value.Trim();
        }
        #endregion

        int Id2 = this.Id;
        if (this.Id > 0)
        {
            if (SqlManager.UpdateGong(g))
                Response.Write(string.Format("<script>alert('批改成功!');location.href='Gong9.aspx?n={0}&Id={1}';</script>", this.Name, this.Id));
            else
                Response.Write(string.Format("<script>alert('批改失败!');location.href='Gong9.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='Gong9.aspx?n={0}';</script>", this.Name));
            else
                Response.Write(string.Format("<script>alert('增长失败!');location.href='Gong9.aspx?n={0}';</script>", this.Name));
        }
    }
}

#line default
#line hidden