Beispiel #1
0
        protected void btn_login_Click(object sender, EventArgs e)
        {
            AdminTableAdapter ta_admin = new AdminTableAdapter();
            DataTable         dt_admin = ta_admin.GetAdminByName(txt_name.Text);

            if (dt_admin.Rows.Count > 0)
            {
                Admin admin = new Admin();
                admin.id       = Convert.ToInt32(dt_admin.Rows[0]["id"]);
                admin.name     = (dt_admin.Rows[0]["name"]).ToString();
                admin.password = dt_admin.Rows[0]["password"].ToString();
                admin.type     = Convert.ToInt32(dt_admin.Rows[0]["type"]);
                if (admin.password.Equals(txt_psw.Text))
                {
                    Session["admin"] = admin;
                    Response.Redirect("adminlist.aspx");
                }
                else
                {
                    lab_tip.Text = "管理员账户名或密码错误";
                }
            }
            else
            {
                lab_tip.Text = "管理员账户名或密码错误";
            }
        }
Beispiel #2
0
        protected void btn_update_Click(object sender, EventArgs e)
        {
            AdminTableAdapter ta_admin = new AdminTableAdapter();
            DataTable         dt_admin = ta_admin.GetAdminByName(txt_name.Text);

            if (dt_admin.Rows.Count <= 0)
            {
                lab_tip.Text = "不存在的管理员帐户";
            }
            else
            {
                int id   = Convert.ToInt32(ta_admin.GetAdminByName(txt_name.Text).Rows[0]["id"]);
                int type = Convert.ToInt32(ta_admin.GetAdminByName(txt_name.Text).Rows[0]["type"]);
                ta_admin.UpdateAdmin(txt_name.Text, txt_psw.Text, type, id);
                lab_tip.Text = "修改密码成功<script>alert('修改密码成功');</script>";
            }
        }
Beispiel #3
0
        protected void btn_add_Click(object sender, EventArgs e)
        {
            AdminTableAdapter ta_admin = new AdminTableAdapter();
            DataTable         dt_user  = ta_admin.GetAdminByName(txt_name.Text);

            if (dt_user.Rows.Count != 0)
            {
                lab_tip.Text = "账户名已存在";
            }
            else
            {
                ta_admin.InsertAdmin(txt_name.Text, txt_psw.Text, 2);
                lab_tip.Text = "添加成功";
            }
        }