Example #1
0
    protected void Button1_Click(object sender, EventArgs e)
    {
        admin admin1 = new admin();
        admin1.name = txt_name.Text;
        admin1.pwd = txt_pwd.Text;
        admin1.role = Convert.ToInt32(DropDownList1.SelectedValue);
        BLLadmin blladmin = new BLLadmin();
        MySqlDataReader sdr = blladmin._login(admin1);
        if (sdr.Read())
        {
            HttpCookie mycookie = new HttpCookie("login");
            mycookie.Values.Add("_name", txt_name.Text);
            mycookie.Values.Add("_role", DropDownList1.SelectedValue);

            TimeSpan ts = new TimeSpan(3, 0, 30, 0);

            DateTime dt = DateTime.Now;

           mycookie.Expires = dt.Add(ts);

            Response.AppendCookie(mycookie);
            sdr.Close();

            Response.Redirect("Default.aspx");

        }
        else
        {

            Common.MessageAlert.Alert(Page, "用户名或密码有误");
        }
    }
Example #2
0
    protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        if (Convert.ToInt32(Request.Cookies["login"].Values["_role"]) == 1)
        {

            if (e.CommandName == "Delete")
            {
                admin admin1 = new admin();
                admin1.id = Convert.ToInt32(e.CommandArgument);
                BLLadmin blladmin1 = new BLLadmin();
                int result = blladmin1.deleteAdmin(admin1);
                if (result > 0)
                {
                    Common.MessageAlert.AlertLocation(Page, "alert('删除成功');location.href='adminList.aspx'");

                }
                else
                {
                    Common.MessageAlert.Alert(Page, "删除失败");
                }
            }
        }
        else
        {
            Response.Write("<script>alert('对不起您没有这个权限');</script>");
        }
    }
Example #3
0
    public void binddata()
    {
        BLLadmin blladmin = new BLLadmin();
        DataSet ds = blladmin.adminlist(AspNetPager1.PageSize * (AspNetPager1.CurrentPageIndex - 1), AspNetPager1.PageSize, "info");

        GridView1.DataSource = ds;
        GridView1.DataBind();
    }
Example #4
0
    public void binddata()
    {
        string name=Request.QueryString["_name"];
        BLLadmin blladmin = new BLLadmin();
        DataSet ds = blladmin.S_admin(AspNetPager1.PageSize * (AspNetPager1.CurrentPageIndex - 1), AspNetPager1.PageSize, "info",name);

        GridView1.DataSource = ds;
        GridView1.DataBind();
    }
Example #5
0
 protected void Page_Load(object sender, EventArgs e)
 {
     AspNetPager1.PageSize = 5;
     if (!IsPostBack)
     {
         string name=Request.QueryString["_name"];
         BLLadmin blladmin = new BLLadmin();
         int result = blladmin.s_admin(name);
         AspNetPager1.RecordCount = result;
         binddata();
     }
 }
Example #6
0
    protected void Page_Load(object sender, EventArgs e)
    {
        AspNetPager1.PageSize = 4;
        if (!IsPostBack)
        {
            BLLadmin blladmin = new BLLadmin();
            int result = blladmin.admin();

            AspNetPager1.RecordCount = result;

            binddata();
        }
    }
Example #7
0
    protected void Button1_Click(object sender, EventArgs e)
    {
        admin admin2 = new admin();
        admin2.id = Convert.ToInt32(Label1.Text);
        admin2.name = txt_name.Text;
        admin2.pwd =Common.DESEncrypt.Encrypt(txt_pwd.Text);

        BLLadmin blladmin = new BLLadmin();
        int result = blladmin.updateAdmin(admin2);
        if (result > 0)
        {
            Common.MessageAlert.AlertLocation(Page, "alert('更新成功');location.href='adminList.aspx'");
        }
        else
        {
            Common.MessageAlert.Alert(Page, "更新失败");
        }
    }
Example #8
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {

            admin admin1 = new admin();
            admin1.id = Convert.ToInt32(Request.QueryString["id"]);

            BLLadmin blladmin = new BLLadmin();
            MySqlDataReader sdr = blladmin.readAdmin(admin1);
            if (sdr.Read())
            {
                int i = Convert.ToInt32(sdr["_id"].ToString());
                Label1.Text = i.ToString();
                txt_name.Text = sdr["_name"].ToString();
                txt_pwd.Text = Common.DESEncrypt.Decrypt(sdr["_pwd"].ToString());

            }
        }
    }
Example #9
0
    protected void Button1_Click(object sender, EventArgs e)
    {
        if (Convert.ToInt32(Request.Cookies["login"].Values["_role"])==1)
        {
            admin admin1 = new admin();
            admin1.name = txt_name.Text;

            BLLadmin blladmin1 = new BLLadmin();
            MySqlDataReader sdr = blladmin1.checkAdmin(admin1);
            if (sdr.Read())
            {
                Common.MessageAlert.Alert(Page, "该管理员已存在");
                txt_name.Text = "";
                txt_pwd.Text = "";
                sdr.Close();
            }
            else
            {
                admin admin2 = new admin();
                admin2.name = txt_name.Text;
                admin2.pwd =Common.DESEncrypt.Encrypt(txt_pwd.Text);
                admin2.role =Convert.ToInt32(dl_select.SelectedValue);

                BLLadmin blladmin2 = new BLLadmin();
                int result = blladmin2.insertAdmin(admin2);
                if (result > 0)
                {
                    Common.MessageAlert.AlertLocation(Page, "alert('添加管理员成功');location.href='adminList.aspx'");
                }
            }
        }
        else
        {
            Common.MessageAlert.Alert(Page,"对不起您不能执行此操作");
            txt_name.Text = "";
            txt_pwd.Text = "";
        }
    }