예제 #1
0
 /// <summary>
 /// 删除用户
 /// </summary>
 /// <param name="id"></param>
 /// <returns></returns>
 public ActionResult Delete(int id)
 {
     AjaxModel ajaxModel = new AjaxModel();
     try
     {
         IUserBLL bll = OperationContext.GetBLLSessionFactory().GetBLLSession().GetUserBLL;
         int result = bll.DelBy(u => u.ID == id);
         if (result > 0)
         {
             ajaxModel.Statu = "ok";
             ajaxModel.Msg = "删除成功!";
         }
         else
         {
             ajaxModel.Statu = "err";
             ajaxModel.Msg = "删除失败!";
         }
     }
     catch
     {
         ajaxModel.Statu = "err";
         ajaxModel.Msg = "删除失败!";
     }
     return Json(ajaxModel);
 }
예제 #2
0
 /// <summary>
 /// 删除部门
 /// </summary>
 /// <param name="id"></param>
 /// <returns></returns>
 public ActionResult Delete(int id)
 {
     AjaxModel ajaxModel = new AjaxModel();
     try
     {
         IDepartmentBLL bll = OperationContext.GetBLLSessionFactory().GetBLLSession().GetDepartmentBLL;
         bll.DelBy(d => d.ID == id);
         ajaxModel.Statu = "ok";
         ajaxModel.Msg = "删除成功";
     }
     catch
     {
         ajaxModel.Statu = "err";
         ajaxModel.Msg = "删除失败";
     }
     return Json(ajaxModel);
 }
예제 #3
0
 /// <summary>
 /// 彻底删除权限
 /// </summary>
 /// <param name="id"></param>
 /// <returns></returns>
 public ActionResult CompleteDelete(int id)
 {
     AjaxModel ajaxModel = new AjaxModel();
     try
     {
         IRoleBLL bll = OperationContext.GetBLLSessionFactory().GetBLLSession().GetRoleBLL;
         bll.DelBy(r => r.ID == id);
         ajaxModel.Statu = "ok";
         ajaxModel.Msg = "删除成功!";
     }
     catch
     {
         ajaxModel.Statu = "err";
         ajaxModel.Msg = "删除失败!";
     }
     return Json(ajaxModel);
 }
예제 #4
0
 /// <summary>
 /// 彻底删除
 /// </summary>
 /// <param name="id"></param>
 /// <returns></returns>
 public ActionResult CompleteDelete(int id)
 {
     AjaxModel ajaxModle = new AjaxModel();
     Permission permission = new Permission();
     try
     {
         IPermissionBLL bll = OperationContext.GetBLLSessionFactory().GetBLLSession().GetPermissionBLL;
         bll.DelBy(p => p.ID == id);
         ajaxModle.Statu = "ok";
         ajaxModle.Msg = "删除成功";
     }
     catch
     {
         ajaxModle.Statu = "err";
         ajaxModle.Msg = "删除失败";
     }
     return Json(ajaxModle);
 }
예제 #5
0
        /// <summary>
        /// 执行部门增加
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public ActionResult DoAdd(Department model)
        {
            AjaxModel ajaxModel = new AjaxModel();

            try
            {
                IDepartmentBLL bll = OperationContext.GetBLLSessionFactory().GetBLLSession().GetDepartmentBLL;
                model.IsDelete = false;
                model.AddTime = DateTime.Now;
                bll.Add(model);
                ajaxModel.Statu = "ok";
                ajaxModel.Msg = "增加成功";
                ajaxModel.BackUrl = "/Admin/Department/Index";
            }
            catch
            {
                ajaxModel.Statu = "err";
                ajaxModel.Msg = "增加失败";
            }
            return Json(ajaxModel);
        }
예제 #6
0
        public ActionResult Delete(int id)
        {
            AjaxModel ajaxModel = new AjaxModel();
            try
            {
                IPermissionBLL bll = DI.SpringHelper.GetObject<IBLL.IBLLSessionFactory>("BLLSessionFactory").GetBLLSession().GetPermissionBLL;
                Permission permission = new Permission();
                permission = bll.GetListBy(p => p.ID == id).SingleOrDefault();
                permission.IsDelete = true;
                bll.Modify(permission, "IsDelete");

                ajaxModel.Statu = "ok";
                ajaxModel.Msg = "删除成功!";
            }
            catch
            {
                ajaxModel.Statu = "err";
                ajaxModel.Msg = "删除失败!";
            }
            return Json(ajaxModel);
        }
예제 #7
0
        public ActionResult DoLogin(string username, string password, string code, bool remember)
        {
            User user = new User();
            AjaxModel ajaxModel = new AjaxModel();

            if (code != Session["validateCode"].ToString())
            {
                ajaxModel.Statu = "err";
                ajaxModel.Msg = "验证码输入错";
                return Json(ajaxModel);
            }

            IUserBLL bll = SpringHelper.GetObject<IBLLSessionFactory>("BLLSessionFactory").GetBLLSession().GetUserBLL;

            user = bll.GetListBy(u => u.Username == username.Trim()).SingleOrDefault();
            if (user == null)
            {
                ajaxModel.Statu = "err";
                ajaxModel.Msg = "不存在该用户";
                return Json(ajaxModel);
            }
            password = Common.Encryt.GetMD5(password);
            user = bll.GetListBy(u => u.Username == username && u.Password == password).SingleOrDefault();
            if (user == null)
            {
                ajaxModel.Statu = "err";
                ajaxModel.Msg = "密码错误";
                return Json(ajaxModel);
            }

            Session["user"] = user;
            FormsAuthentication.SetAuthCookie(username, remember);  ///设置
            ajaxModel.Statu = "ok";
            ajaxModel.Msg = "登陆成功";
            ajaxModel.BackUrl = "/Admin/Home/Index";
            return Json(ajaxModel);
        }
예제 #8
0
 /// <summary>
 /// 角色授权
 /// </summary>
 /// <param name="authorties"></param>
 /// <param name="rid"></param>
 /// <returns></returns>
 public ActionResult Authorize(string authorties, int rid)
 {
     AjaxModel ajaxModel = new AjaxModel();
     authorties = authorties.Substring(0, authorties.Length - 1);
     List<RolePermission> rps = new List<RolePermission>();
     try
     {
         IRolePermissionBLL rpbll = OperationContext.GetBLLSessionFactory().GetBLLSession().GetRolePermissionBLL;
         rpbll.DelBy(rp => rp.RoleID == rid);
         string[] authorizeIDString = authorties.Split(',');
         foreach (var id in authorizeIDString)
         {
             rpbll.Add(new RolePermission { PermissionID = int.Parse(id), RoleID = rid, IsDelete = false, AddTime = DateTime.Now, });
         }
         ajaxModel.Statu = "ok";
         ajaxModel.Msg = "授权成功";
     }
     catch
     {
         ajaxModel.Statu = "err";
         ajaxModel.Msg = "授权失败";
     }
     return Json(ajaxModel);
 }
예제 #9
0
        public ActionResult DoAdd(Permission model)
        {
            AjaxModel ajaxModel = new AjaxModel();

            try
            {
                IPermissionBLL bll = DI.SpringHelper.GetObject<IBLL.IBLLSessionFactory>("BLLSessionFactory").GetBLLSession().GetPermissionBLL;
                model.AddTime = DateTime.Now;
                model.IsDelete = false;
                bll.Add(model);
                ajaxModel.Statu = "ok";
                ajaxModel.Msg = "添加成功!";
                ajaxModel.BackUrl = "/Admin/Permission/Index";
            }
            catch
            {
                ajaxModel.Statu = "err";
                ajaxModel.Msg = "添加失败!";
            }
            return Json(ajaxModel);
        }
예제 #10
0
 /// <summary>
 /// 删除角色
 /// </summary>
 /// <param name="rid"></param>
 /// <param name="uid"></param>
 /// <returns></returns>
 public ActionResult RevokeRole(int rid, int uid)
 {
     AjaxModel ajaxModle = new AjaxModel();
     try
     {
         IUserRoleBLL urbll = OperationContext.GetBLLSessionFactory().GetBLLSession().GetUserRoleBLL;
         int result = urbll.DelBy(ur => ur.UserID == uid && ur.RoleID == rid);
         if (result > 0)
         {
             ajaxModle.Statu = "ok";
             ajaxModle.Msg = "删除成功!";
         }
         else
         {
             ajaxModle.Statu = "err";
             ajaxModle.Msg = "删除失败!";
         }
     }
     catch
     {
         ajaxModle.Statu = "err";
         ajaxModle.Msg = "删除失败!";
     }
     return Json(ajaxModle);
 }
예제 #11
0
 /// <summary>
 /// 给用户授权角色
 /// </summary>
 /// <param name="rid"></param>
 /// <param name="uid"></param>
 /// <returns></returns>
 public ActionResult InvokeRole(int rid, int uid)
 {
     AjaxModel ajaxModel = new AjaxModel();
     UserRole ur = new UserRole();
     try
     {
         IUserRoleBLL urbll = OperationContext.GetBLLSessionFactory().GetBLLSession().GetUserRoleBLL;
         UserRole temp = new UserRole();
         temp = urbll.GetListBy(userrole => userrole.RoleID == rid && userrole.UserID == uid).SingleOrDefault();
         if (temp == null)
         {
             ur.UserID = uid;
             ur.RoleID = rid;
             ur.AddTime = DateTime.Now;
             ur.IsDelete = false;
             urbll.Add(ur);
             ajaxModel.Statu = "ok";
             ajaxModel.Msg = "增加成功!";
         }
         else
         {
             ajaxModel.Statu = "err";
             ajaxModel.Msg = "该用户已经存在改角色!请选择别的角色!";
         }
     }
     catch
     {
         ajaxModel.Statu = "err";
         ajaxModel.Msg = "增加失败!";
     }
     return Json(ajaxModel);
 }
예제 #12
0
 /// <summary>
 /// 修改权限
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public ActionResult DoUpdate(Permission model)
 {
     AjaxModel ajaxModel = new AjaxModel();
     try
     {
         IPermissionBLL bll = OperationContext.GetBLLSessionFactory().GetBLLSession().GetPermissionBLL;
         bll.Modify(model, "PName", "PAreaName", "PControllerName", "PActionName", "PFormMethod", "PURL", "IsShow", "Remark");
         ajaxModel.Statu = "ok";
         ajaxModel.Msg = "增加成功!";
         ajaxModel.BackUrl = "/Admin/Permission/Index";
     }
     catch
     {
         ajaxModel.Statu = "err";
         ajaxModel.Msg = "增加失败!";
     }
     return Json(ajaxModel);
 }
예제 #13
0
 /// <summary>
 /// 将回收箱 的权限还原
 /// </summary>
 /// <param name="id"></param>
 /// <returns></returns>
 public ActionResult Return(int id)
 {
     AjaxModel ajaxModle = new AjaxModel();
     Permission permission = new Permission();
     try
     {
         IPermissionBLL bll = OperationContext.GetBLLSessionFactory().GetBLLSession().GetPermissionBLL;
         permission = bll.GetListBy(p => p.ID == id).SingleOrDefault();
         permission.IsDelete = false;
         bll.Modify(permission, "IsDelete");
         ajaxModle.Statu = "ok";
         ajaxModle.Msg = "还原成功";
     }
     catch
     {
         ajaxModle.Statu = "err";
         ajaxModle.Msg = "还原失败";
     }
     return Json(ajaxModle);
 }
예제 #14
0
 /// <summary>
 /// 执行增加
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public ActionResult DoAdd(User model)
 {
     AjaxModel ajaxModel = new AjaxModel();
     try
     {
         IUserBLL bll = OperationContext.GetBLLSessionFactory().GetBLLSession().GetUserBLL;
         model.AddTime = DateTime.Now;
         model.IsDelete = false;
         model.Password = Common.Encryt.GetMD5(model.Password);
         bll.Add(model);
         ajaxModel.Statu = "ok";
         ajaxModel.Msg = "增加成功!";
         ajaxModel.BackUrl = "/Admin/User/Index";
     }
     catch
     {
         ajaxModel.Statu = "err";
         ajaxModel.Msg = "增加失败!";
     }
     return Json(ajaxModel);
 }
예제 #15
0
        /// <summary>
        /// 执行修改
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public ActionResult DoUpdate(Department model)
        {
            Department department = new Department();
            AjaxModel ajaxModel = new AjaxModel();
            try
            {
                IDepartmentBLL bll = OperationContext.GetBLLSessionFactory().GetBLLSession().GetDepartmentBLL;
                department = bll.GetListBy(d => d.ID == model.ID).SingleOrDefault();
                department.DepartmentName = model.DepartmentName;
                department.Remark = model.Remark;
                bll.Modify(department, "DepartmentName", "Remark");
                ajaxModel.Statu = "ok";
                ajaxModel.Msg = "修改成功!";
                ajaxModel.BackUrl = "/Admin/Department/Index";
            }
            catch
            {
                ajaxModel.Statu = "err";
                ajaxModel.Msg = "修改失败!";
            }

            return Json(ajaxModel);
        }
예제 #16
0
        /// <summary>
        /// 修改角色
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public ActionResult DoUpdate(Role model)
        {
            AjaxModel ajaxModel = new AjaxModel();
            Role role = new Role();
            IRoleBLL bll = OperationContext.GetBLLSessionFactory().GetBLLSession().GetRoleBLL;
            try
            {
                role = bll.GetListBy(r => r.ID == model.ID).SingleOrDefault();
                role.RoleName = model.RoleName;
                role.Remark = model.Remark;
                role.DepartmentID = model.DepartmentID;
                role.IsShow = model.IsShow;
                bll.Modify(role, "RoleName", "Remark", "DepartmentID", "IsShow");
                ajaxModel.Statu = "ok";
                ajaxModel.Msg = "修改成功";
                ajaxModel.BackUrl = "/Admin/Role/Index";
            }
            catch
            {
                ajaxModel.Statu = "err";
                ajaxModel.Msg = "修改失败!";
            }

            return Json(ajaxModel);
        }
예제 #17
0
 /// <summary>
 /// 根据名称查找角色
 /// </summary>
 /// <param name="name"></param>
 /// <returns></returns>
 public ActionResult GetRoleByRoleName(string name)
 {
     AjaxModel ajaxModel = new AjaxModel();
     List<Role> roles = new List<Role>();
     string key = name.Trim().ToString();
     try
     {
         IRoleBLL bll = OperationContext.GetBLLSessionFactory().GetBLLSession().GetRoleBLL;
         if (string.IsNullOrEmpty(name))
         {
             roles = bll.GetListBy(r => r.IsDelete == false && r.IsShow == true);
         }
         else
         {
             roles = bll.GetListBy(r => r.IsDelete == false && r.IsShow == true && r.RoleName.Contains(key.Trim()));
         }
         ajaxModel.Data = roles;
         ajaxModel.Statu = "ok";
     }
     catch
     {
         ajaxModel.Data = roles;
         ajaxModel.Statu = "err";
     }
     return Json(ajaxModel, JsonRequestBehavior.AllowGet);
 }
예제 #18
0
 /// <summary>
 /// 执行修改
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public ActionResult DoUpdate(User model)
 {
     AjaxModel ajaxModel = new AjaxModel();
     User user = new User();
     try
     {
         IUserBLL bll = OperationContext.GetBLLSessionFactory().GetBLLSession().GetUserBLL;
         user = bll.GetListBy(u => u.ID == model.ID).SingleOrDefault();
         user.Username = model.Username;
         user.DepartmentID = model.DepartmentID;
         user.Gender = model.Gender;
         user.Remark = model.Remark;
         if (!string.IsNullOrEmpty(model.Password))
         {
             user.Password = Common.Encryt.GetMD5(model.Password);
         }
         bll.Modify(user, "Username", "DepartmentID", "Gender", "Remark", "Password");
         ajaxModel.Statu = "ok";
         ajaxModel.Msg = "修改成功!";
         ajaxModel.BackUrl = "/Admin/User/Index";
     }
     catch
     {
         ajaxModel.Statu = "err";
         ajaxModel.Msg = "修改失败!";
     }
     return Json(ajaxModel);
 }
예제 #19
0
        /// <summary>
        /// 还原角色
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public ActionResult Return(int id)
        {
            AjaxModel ajaxModel = new AjaxModel();
            Role role = new Role();
            try
            {
                IRoleBLL bll = OperationContext.GetBLLSessionFactory().GetBLLSession().GetRoleBLL;
                role = bll.GetListBy(r => r.ID == id).SingleOrDefault();
                role.IsDelete = false;
                bll.Modify(role, "IsDelete");
                ajaxModel.Statu = "ok";
                ajaxModel.Msg = "还原成功";
            }
            catch
            {
                ajaxModel.Statu = "ok";
                ajaxModel.Msg = "还原成功";
            }

            return Json(ajaxModel);
        }
예제 #20
0
 /// <summary>
 /// 根据和用户名称查找角色 
 /// </summary>
 /// <param name="name"></param>
 /// <returns></returns>
 public ActionResult GetRoleByRoleNameByUser(string name,int uid)
 {
     AjaxModel ajaxModel = new AjaxModel();
     List<Role> roles = new List<Role>();
     string key = name.Trim().ToString();
     User user = new User();
     try
     {
         IRoleBLL bll = OperationContext.GetBLLSessionFactory().GetBLLSession().GetRoleBLL;
         IUserBLL ubll = OperationContext.GetBLLSessionFactory().GetBLLSession().GetUserBLL;
         user = ubll.GetListBy(u => u.ID == uid).SingleOrDefault();
         if (string.IsNullOrEmpty(name))
         {
             roles = bll.GetListBy(r => r.IsDelete == false && r.IsShow == true && r.DepartmentID==user.DepartmentID);
         }
         else
         {
             roles = bll.GetListBy(r => r.IsDelete == false && r.IsShow == true && r.RoleName.Contains(key.Trim()) && r.DepartmentID==user.DepartmentID);
         }
         ajaxModel.Data = roles;
         ajaxModel.Statu = "ok";
     }
     catch
     {
         ajaxModel.Data = roles;
         ajaxModel.Statu = "err";
     }
     return Json(ajaxModel, JsonRequestBehavior.AllowGet);
 }