using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Text;
using TopWinCMS.BLL;
using TopWinCMS.Common;
using TopWinCMS.Model;
namespace TopWinCMS.WebUI.Admin.UDT
{
    public partial class UDT_JS : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                LB_Path.Text = "<a href='UDT_Manage.aspx'>标签管理</a> → 静态JS标签";
                if (Request["ID"] != null)
                {
                    RightsCheck.CheckWorkPower("L_3");
                    //“修改”界面
                    Edit_Load();


                }
                else
                {
                    RightsCheck.CheckWorkPower("L_1");
                }
            }

        }
        #region 加载
        private void Edit_Load()
        {
            UDTInfo model = new UDTManage().EditLoad(Request["ID"]);
            if (model != null)
            {
                TB_Name.Text = model.Name;
                TB_Remark.Text = model.Remark;
                TB_Tag.Text = model.Tag;
                TB_JsPath.Text = model.JsPath;

                this.Title = "修改" + model.Name;

                 
            }
            else
            {
                //转向错误页面
                ErrClass.Redirect("数据不存在。");
            }
        }
        #endregion

        protected void BT_OK_Click(object sender, EventArgs e)
        {
            MyStringBuilder strErrMsg = new MyStringBuilder();

            string strErr = null;
            UDTInfo model = new UDTInfo();

            model.Name = TB_Name.Text.Trim();
            model.DataType = "";
            model.DataSource = "";
            model.SqlScript = "";
            model.Type = "3";
            model.JsPath = TB_JsPath.Text.Trim();
            model.URLType = "4";

            model.ShortTitle = "";
            model.Length = "0";
            model.ItemTemplet = "";
            model.EmptyTemplet = "";
            model.Remark = TB_Remark.Text.Trim();

            model.Tag = TB_Tag.Text.Trim();
            if (Request["ID"] == null)
            {
                model.ID = "0";
            }
            else
            {
                model.ID = Request["ID"];
            }
            new UDTManage().Add(model, ref strErr);

            if (string.IsNullOrEmpty(strErr) != true)
            {
                MsgBox.Alert(strErrMsg.ToString(), UpdatePanel1);
                return;
            }
            else
            {
                MsgBox.Alert("录入成功！", UpdatePanel1);
            }

        }
    }
}
