Beispiel #1
0
        public ActionResult GetRoleView()
        {
            int id = int.Parse(Request.Form["id"]);

            var viewModel = new Model.ViewModel.Role();

            if (id == -1)
            {
                viewModel.DepID    = 1;
                viewModel.IsActive = true;
                viewModel.SN       = 255;
                return(PartialView("RoleForm", viewModel));
            }
            else
            {
                var tempModel = new P_RoleBLL().GetListBy(p => p.ID == id).FirstOrDefault();

                if (tempModel != null)
                {
                    viewModel.ID       = tempModel.ID;
                    viewModel.IsActive = tempModel.IsActive;
                    viewModel.Name     = tempModel.Name;
                    viewModel.DepID    = tempModel.DepID;
                    viewModel.Remark   = tempModel.Remark;
                    viewModel.SN       = tempModel.SN;
                }
                return(PartialView("RoleForm", viewModel));
            }
        }
Beispiel #2
0
 public ActionResult SaveRole(Model.ViewModel.Role model)
 {
     //先查角色是否存在  如果没有新增 反正修改
     if (new P_RoleBLL().GetModelWithOutTrace(d => d.ID == model.ID) != null)
     {
         int res = new P_RoleBLL().Modify(model.ToPOCO(), "Name", "ID", "IsActive", "Remark", "SN", "DepID");
         if (res > 0)
         {
             return(this.JsonResult(Utility.E_JsonResult.OK, "修改成功!", null, null));
         }
         else
         {
             return(this.JsonResult(Utility.E_JsonResult.Error, "修改失败!", null, null));
         }
     }
     else
     {
         //model.DepID = 1;
         int res = new P_RoleBLL().Add(model.ToPOCO());
         if (res > 0)
         {
             return(this.JsonResult(Utility.E_JsonResult.OK, "新增成功!", null, null));
         }
         else
         {
             return(this.JsonResult(Utility.E_JsonResult.Error, "新增失败!", null, null));
         }
     }
 }
Beispiel #3
0
        /// <summary>
        /// 角色修改
        /// </summary>
        /// <returns></returns>
        public ActionResult EditRole(Model.P_Role model)
        {
            int res = new P_RoleBLL().Modify(model, "DepID", "Name", "Remark", "IsActive", "SN");

            if (res > 0)
            {
                return(this.JsonResult(Utility.E_JsonResult.OK, "编辑权限成功!", null, null));
            }
            else
            {
                return(this.JsonResult(Utility.E_JsonResult.Error, "编辑权限失败~!", null, null));
            }
        }
Beispiel #4
0
        /// <summary>
        /// 新增角色
        /// </summary>
        /// <returns></returns>
        public ActionResult AddRole(Model.P_Role model)
        {
            model.IsActive = true;

            int res = new P_RoleBLL().Add(model);

            if (res > 0)
            {
                return(this.JsonResult(Utility.E_JsonResult.OK, "新增权限成功!", null, null));
            }
            else
            {
                return(this.JsonResult(Utility.E_JsonResult.Error, "新增权限失败~!", null, null));
            }
        }
Beispiel #5
0
        public ActionResult Index(FormCollection form)
        {
            //0.接收参数 page=1&rows=5
            int pageIndex = int.Parse(form["page"]);
            int pageSize  = int.Parse(form["rows"]);

            //1.读取数据
            var rowCount = 0;
            var list     = new P_RoleBLL().GetDynamicPagedList(pageIndex, pageSize, ref rowCount, r => r.IsActive == true, r => r.ID, r => new { r.IsActive, r.ID, r.DepID, DepartmentName = r.P_Department.Name, r.Name, r.Remark });

            //2.将list转成 json 字符串发回浏览器
            return(Json(new Model.EasyUIModel.DataGridModel()
            {
                rows = list, total = rowCount
            }));
        }
Beispiel #6
0
        public ActionResult GetRoleByDepId()
        {
            var list = new P_RoleBLL().GetListBy(r => r.IsActive == true).Select(r => r.ToPOCO());

            return(Json(list, JsonRequestBehavior.AllowGet));
        }