Пример #1
0
 /// <summary>
 /// 获取角色信息
 /// </summary>
 /// <param name="UserInfo"></param>
 /// <returns></returns>
 public JsonResult AuthorityList(Cu_User UserInfo)
 {
     using (BuyunSiteEntities db = new BuyunSiteEntities())
     {
         var Authority = db.Cu_UserAuthority;
         return(Json(new { data = Authority.ToList() }));
     }
 }
Пример #2
0
        /// <summary>
        /// 获取角色信息
        /// </summary>
        /// <param name="UserInfo"></param>
        /// <returns></returns>
        public JsonResult AdminByUserIdList(Cu_User UserInfo)
        {
            int UserId = Convert.ToInt32(Request["UserId"]);

            using (BuyunSiteEntities db = new BuyunSiteEntities())
            {
                var Authority = from a in db.Cu_User where a.UserId == UserId select a;
                return(Json(new { data = Authority.ToList() }));
            }
        }
Пример #3
0
 /// <summary>
 /// 删除管理员
 /// </summary>
 /// <param name="userInfo"></param>
 /// <returns></returns>
 public JsonResult DelAdmin(Cu_User UserInfo)
 {
     using (BuyunSiteEntities db = new BuyunSiteEntities())
     {
         Cu_User user = db.Cu_User.First(o => o.UserId == UserInfo.UserId);
         db.Cu_User.Remove(user);
         db.SaveChanges();
         return(Json(new { data = "success" }));
     }
 }
Пример #4
0
 /// <summary>
 /// 禁用启用
 /// </summary>
 /// <param name="userInfo"></param>
 /// <returns></returns>
 public JsonResult EditStatus(Cu_User UserInfo)
 {
     using (BuyunSiteEntities db = new BuyunSiteEntities())
     {
         Cu_User user = db.Cu_User.First(o => o.UserId == UserInfo.UserId);
         user.Status = UserInfo.Status;
         db.SaveChanges();
         return(Json(new { data = "success" }));
     }
 }
Пример #5
0
 /// <summary>
 /// 增加管理员
 /// </summary>
 /// <param name="UserInfo"></param>
 /// <returns></returns>
 public JsonResult AddAdmin(Cu_User UserInfo)
 {
     using (BuyunSiteEntities db = new BuyunSiteEntities())
     {
         var chkUserCode = from a in db.Cu_User where a.UserCode == UserInfo.UserCode select a;
         if (chkUserCode.Count() > 0)
         {
             return(Json(new { data = "fail", content = "管理员编码重复!" }));
         }
         UserInfo.UserPassword = BasePage.Md5Hash(UserInfo.UserPassword);
         UserInfo.AddTime      = DateTime.Now;
         UserInfo.AddUser      = BasePage.GetCookie("UserNameCookie");
         UserInfo.Status       = 1;
         UserInfo.IsAdmin      = false;
         db.Cu_User.Add(UserInfo);
         db.SaveChanges();
     }
     return(Json(new { data = "success", content = "新增管理员成功!" }));
 }
Пример #6
0
 /// <summary>
 /// 处理登录的信息
 /// </summary>
 /// <param name="userInfo"></param>
 /// <returns></returns>
 public JsonResult CheckUserLogin(Cu_User userInfo)
 {
     using (BuyunSiteEntities db = new BuyunSiteEntities())
     {
         //linq查询
         userInfo.UserPassword = BasePage.Md5Hash(userInfo.UserPassword);
         var users = from p in db.Cu_User
                     where p.UserCode == userInfo.UserCode && p.UserPassword == userInfo.UserPassword
                     select p;
         if (users.Count() > 0)
         {
             string strUser = DynamicJsonConverter.GetJson <Cu_User>(users.FirstOrDefault());
             BasePage.WriteCookie("UserNameCookie", users.FirstOrDefault().UserName, 0);
             BasePage.WriteCookie("UserInfoCookie", strUser, 0);
             return(Json(new { result = "success", content = "" }));
         }
         else
         {
             return(Json(new { result = "error", content = "用户名密码错误,请您检查" }));
         }
     }
 }
Пример #7
0
 /// <summary>
 /// 修改管理员
 /// </summary>
 /// <param name="UserInfo"></param>
 /// <returns></returns>
 public JsonResult EditAdmin(Cu_User UserInfo)
 {
     using (BuyunSiteEntities db = new BuyunSiteEntities())
     {
         var chkUserCode = from a in db.Cu_User where a.UserCode == UserInfo.UserCode && a.UserId != UserInfo.UserId select a;
         if (chkUserCode.Count() > 0)
         {
             return(Json(new { data = "fail", content = "管理员编码重复!" }));
         }
         var User = from a in db.Cu_User where a.UserId == UserInfo.UserId select a;
         if (!string.IsNullOrEmpty(UserInfo.UserPassword))
         {
             User.FirstOrDefault().UserPassword = BasePage.Md5Hash(UserInfo.UserPassword);
         }
         User.FirstOrDefault().UserName    = UserInfo.UserName;
         User.FirstOrDefault().UserCode    = UserInfo.UserCode;
         User.FirstOrDefault().UserPhone   = UserInfo.UserPhone;
         User.FirstOrDefault().AuthorityId = UserInfo.AuthorityId;
         User.FirstOrDefault().UpdateTime  = DateTime.Now;
         User.FirstOrDefault().UpdateUser  = BasePage.GetCookie("UserNameCookie");
         db.SaveChanges();
     }
     return(Json(new { data = "success", content = "修改管理员成功!" }));
 }