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_radio_edit :BaseAdminUI
    {
        HaTeam.Dd.BLL.Dd_Video bll = new HaTeam.Dd.BLL.Dd_Video();
        HaTeam.Dd.Model.Dd_Video model = new HaTeam.Dd.Model.Dd_Video();
        public string video_address;//用户输入地址
        public string video_url;//视频播放地址
        public string video_image;//图片地址
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                if (Fetch.Get("action") != null && Fetch.Get("video_id") != null)
                {
                    if (Fetch.Get("action").ToString() == "edit")
                    {
                        ShowInfo(int.Parse(Request.QueryString["video_id"].ToString()));
                    }
                }
            }
        }
        public void ShowInfo(int id)
        {
            model = bll.GetModel(id);
            txtName.Text = Fetch.Get("user_name");
            video_address = model.Video_Address;
            video_url = model.Video_Radiourl;
            video_image = model.Video_Imageurl;
            txtContent.Text = model.Video_Description;
            txtTag.Text = model.Video_Tag;
            rbtdelete2.Checked = true;
            if (model.Video_Verify == 0)
            {
                rbtVerity2.Checked = true;
            }
            else { rbtVerity1.Checked = true; }
        }
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            int delete;
            int verify;
            if (this.txtContent.Text == "")
            {
                Jscript.Alert("内容不能为空！");
                this.txtContent.Focus();
            }
            else
            {
                string content = txtContent.Text;
                string tag = txtTag.Text;
                int textID = int.Parse(Fetch.Get("video_id"));
                if (rbtdelete1.Checked == true)
                {
                    delete = 1;
                }
                else { delete = 0; }
                if (rbtVerity2.Checked == true)
                {
                    verify = 0;

                }
                else { verify = 1; }
                string str = "update dd_video set video_description ='" + content + "',video_tag ='" + tag + "',video_delete=" + delete + ",video_verify =" + verify + "where video_id =" + textID;
                try
                {
                    DbHelperSQL.ExecuteSql(str);
                    Jscript.AlertAndRedirect("系统提示：修改成功！", "Admin_radio_manage.aspx");
                }
                catch (Exception ex)
                {
                    Response.Write(ex);
                }

            }
        }

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