コード例 #1
0
        protected void lvAdminList_ItemDeleting(object sender, ListViewDeleteEventArgs e)
        {
            //int id = Convert.ToInt32(e.Keys["id"]);
            //string name = e.Values["UserName"].ToString();
            //if (Session["userName"].ToString()==name/*Convert.ToInt32(admin.DeleteAdmin(id)) == 1*/)
            //{
            //    JSHelper.Alert("不能删除当前账号");
            //    return;
            //}
            string name   = Session["UserName"].ToString();
            string id     = e.Keys["id"].ToString();
            string Slevel = Session["Level"].ToString();

            //string level =e.Values["Level"].ToString();
            if (id == admin.SelectAdmin("-1", name).Rows[0]["id"].ToString())
            {
                JSHelper.Alert("当前账号正在使用,不能删除");
                return;
            }
            //if (level == "1")
            //{
            //    JSHelper.Alert("不能删除超级管理员");
            //    return;
            //}
            if (Slevel == "2")
            {
                JSHelper.Alert("权限不足,不能删除该账号");
                return;
            }

            if (admin.DeleteAdmin(id) == 1)
            {
                JSHelper.Alert("删除成功");
                BindAdmin();
                return;
            }
            else
            {
                JSHelper.Alert("删除失败");
            }
        }