Ejemplo n.º 1
0
        //用户管理页面删除
        public ActionResult UserManagementDelete(int id)
        {
            //查询出要删除用户的真实姓名是否和登陆进来的姓名相同  AsNoTracking
            var list = iud.SelectWhere(e => e.UserID == id);

            foreach (var item in list)
            {
                if (item.UserRealName == Session["UserRealName"].ToString())
                {
                    return(Content("<script>alert('用户正在使用中不能被删除');window.location.href='/Systems/UserManagementSelect'</script>"));
                }
            }
            info_User user = new info_User
            {
                UserID = id
            };

            //不相同,则删除
            if (iud.Delete(user) > 0)
            {
                return(Content("<script>alert('删除成功');window.location.href='/Systems/UserManagementSelect'</script>"));
            }
            else
            {
                return(Content("<script>alert('删除失败');window.location.href='/Systems/UserManagementSelect'</script>"));
            }
        }
        public ActionResult DeleteConfirmed(int id)
        {
            User user = _userBll.Get(id);

            _userBll.Delete(user);
            return(RedirectToAction("Index"));
        }
 public void Delete(int id)
 {
     _userBll.Delete(id);
 }