using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
//必须引入命名空间
using DotNet.FrameWork.Utils;
using DotNet.FrameWork.Common.Web;
using DotNet.FrameWork.Page;
using DotNet.FrameWork.Data;
using GetCommand;

namespace HteamDd.Web.Admin
{
    public partial class Admin_link_editor :BaseAdminUI
    {
        HaTeam.Dd.BLL.Dd_Link bll = new HaTeam.Dd.BLL.Dd_Link();
        HaTeam.Dd.Model.Dd_Link model = new HaTeam.Dd.Model.Dd_Link();
        public string url;
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                if (Fetch.Get("action") != null && Fetch.Get("link_id") != null)
                {
                    if (Fetch.Get("action").ToString() == "edit")
                    {
                        ShowInfo(int.Parse(Request.QueryString["link_id"].ToString()));
                    }
                }

            }
        }
        public void ShowInfo(int id)
        {
            model = bll.GetModel(id);
            txtName.Text = Fetch.Get("user_name");
            txtTitle.Text = model.Link_Title;
            txtContent.Text = model.Link_Description;
            txtTag.Text = model.Link_Tag;
            url = model.Link_Address;
            //txtAddress.Text = model.Link_Address;
            rbtdelete2.Checked = true;
            if (model.Link_Verify == 0)
            {
                rbtVerity2.Checked = true;
            }
            else { rbtVerity1.Checked = true; }
        }

        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            int delete;
            int verify;
            int linkid = int.Parse(Fetch.Get("link_id"));
            string content = txtContent.Text;
            string tag = txtTag.Text;
            if (rbtdelete1.Checked == true)
            {
                delete = 1;
            }
            else { delete = 0; }
            if (rbtVerity2.Checked == true)
            {
                verify = 0;

            }
            else { verify = 1; }
            string str = "update dd_link set lini_description ='"+ content +"',link_tag ='"+ tag +"',link_delete ="+ delete +",link_verify ="+ verify +"where link_id ="+linkid;
            try {
                DbHelperSQL.ExecuteSql(str);
                Jscript.AlertAndRedirect("系统提示：更新成功！","Admin_link_manage.aspx");
            }
            catch(Exception ex){
                Response.Write(ex);
            }
        }

        protected void btnReset_Click(object sender, EventArgs e)
        {
            ShowInfo(int.Parse(Request.QueryString["link_id"].ToString()));
        }
    }
}