using System;
using System.Web;
using System.Web.UI;
using System.Linq;
using Models;


    public partial class TagAdd : AdminBase
    {
        public int _Id=0;

        protected void Page_Load(object sender, EventArgs e)
        {

            Response.CacheControl = "no-cache";
            if (!string.IsNullOrEmpty(Request.Params["ID"]))
            {
                _Id = int.Parse(HttpContext.Current.Request.QueryString["ID"]);

            }

            if (!Page.IsPostBack)
            {
               
                if (_Id != 0)
                {
                    ShowInfo(_Id);
                }

            }
               
           
        }

        //保存
        protected void btnSave_Click(object sender, EventArgs e)
        {
         
       

            // bll.Add(model);
            //保存日志
            //SaveLogs("[资讯模块]添加文章：" + model.Title);
            //JscriptPrint("文章发布成功啦！", "Add.aspx?classId=" + ddlClassId.SelectedValue, "Success");
        }

        private void ShowInfo(int _id)
        {

            Entities mydb = new Entities();
            {

             L_Tags _lt = mydb.L_Tags.First(p => p.TID == _id);    
             txtName.Text = _lt.TName;
             txtTag.Text = _lt.TContent;
        
         
          }
        }


    protected void Button1_Click(object sender, EventArgs e)
    {
        Entities mydb = new Entities();
        {
            L_Tags Lt = new L_Tags();
            if (_Id != 0)
                Lt = mydb.L_Tags.First(p => p.TID == _Id);

            Lt.TName = txtName.Text.Trim();
            Lt.TContent = this.txtTag.Text;
            Lt.TNotice = "";


            if (_Id == 0)
            {
                mydb.L_Tags.Add(Lt);
                mydb.SaveChanges();
                Response.Write("<script> var Close=1;</script>");
              // JscriptPrint("自定义标签添加成功啦！", "list.aspx", "Success");
            }
            else
            {
                mydb.SaveChanges();
                Response.Write("<script> var Close=1;</script>");

               // JscriptPrint("自定义标签修改成功啦！", "list.aspx", "Success");
            }
        }
    }
}

