using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;


public partial class userManage : System.Web.UI.Page
{
    DataBaseLayer db = new DataBaseLayer();
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            if (Session["UserID"] == null && Session["UserName"] != "shuanghan")
            {
                Response.Write("<script>alert(\"请管理员登录!\")</script>");
                Response.Write("<meta http-equiv='refresh' content='1;url=mp4.aspx'>");
            }
            else
            {
                BindAllMp4User();
            }
        }
    }
    protected void selectMp4User_DeleteCommand(object source, DataGridCommandEventArgs e)
    {
        
            SqlParameter[] prams ={
                db.ParamBuilder("@UserID",Convert.ToInt32(((Label)e.Item.FindControl("UserID")).Text),SqlDbType.Int)
            };
            //执行存储过程
            try
            {
                db.ExecuteNonQuery("Pr_Mp4_DeleteMp4User",prams);
                Response.Write("<script>alert(\"删除成功!\")</script>");
                //selectmp4.EditItemIndex = -1;
            }
        catch (Exception ex)
        {
            Response.Write("<script>alert(\"删除失败!\")</script>");
            //throw new Exception(ex.Message, ex);
        }
    }
    protected void selectMp4User_ItemDataBound(object sender, DataGridItemEventArgs e)
    {
        LinkButton delete = (LinkButton)e.Item.FindControl("LinkButton4");
        if (delete != null)
        {
            delete.Attributes.Add("onclick", "return confirm('你确定要删除此用户数据吗?')");
        }
    }
    protected void selectMp4User_PageIndexChanged(object source, DataGridPageChangedEventArgs e)
    {
        selectMp4User.CurrentPageIndex = e.NewPageIndex;
        BindAllMp4User();
    }
    public void BindAllMp4User()
    {
        DataSet ds = db.DataSetFactory("Pr_Mp4_GetAllMp4User");
        selectMp4User.DataSource = ds;
        selectMp4User.DataBind();
        ds.Dispose();
    }
}
