Пример #1
0
 public JsonResult Delete(string id)
 {
     if (!string.IsNullOrWhiteSpace(id))
     {
         string   usid = LoginUser.User.UserName;
         EAP_Role m    = new EAP_Role()
         {
             ID = int.Parse(id)
         };
         CommandResult r = DeleteObj <EAP_Role>(m);
         // if (m_BLL.Delete(ref errors, id))
         if (r.IntResult > 0)
         {
             LogHandler.WriteServiceLog(usid, "Id:" + id, "成功", "删除", "SysRole");
             return(Json(JsonHandler.CreateMessage(1, Suggestion.DeleteSucceed)));
         }
         else
         {
             string ErrorCol = r.Message;
             LogHandler.WriteServiceLog(usid, "Id" + id + "," + ErrorCol, "失败", "删除", "SysRole");
             return(Json(JsonHandler.CreateMessage(0, Suggestion.DeleteFail + ErrorCol)));
         }
     }
     else
     {
         return(Json(JsonHandler.CreateMessage(0, Suggestion.DeleteFail)));
     }
 }
Пример #2
0
        public CommandResult UpdateRole(EAP_Role role)
        {
            CommandResult result = new CommandResult();

            /*
             * string sSql = "UPDATE EAP_Role SET ";
             * role.Items.ForEach(e =>
             * {
             *  if (e.S == EntityStatus.Modified && !string.IsNullOrEmpty(e.K))
             *  {
             *      sSql += string.Format("[{0}]='{1}',", e.K, e.V);
             *  }
             * });
             *
             * sSql = sSql.Trim().TrimEnd(',');
             * sSql += " WHERE ID='" + role.ID.ToString() + "'";
             *
             * int iRows = DataProvider.ExecuteNonQuery(sSql);
             */
            int iRows = DataProvider.DoUpdate(role, "EAP_Role", "ID", null);

            result.Result  = iRows > 0 ? true : false;
            result.Message = iRows > 0 ? "更新成功。" : "更新失败。";

            return(result);
        }
Пример #3
0
        public ActionResult Details(string id)
        {
            ViewBag.Perm = GetPermission();
            EAP_Role entity = GetObjByID <EAP_Role>(id);

            return(View(entity));
        }
Пример #4
0
        public ActionResult Create()
        {
            ViewBag.Perm = GetPermission();
            EAP_Role m = new EAP_Role();

            return(View(m));
        }
Пример #5
0
        public ActionResult Edit(string id)
        {
            ViewBag.Perm = GetPermission();
            EAP_Role entity = GetObjByID <EAP_Role>(id);

            //SysRoleModel entity = m_BLL.GetById(id);
            return(View("Create", entity));
        }
Пример #6
0
        public JsonResult Create(EAP_Role model)
        {
            if (model != null && ModelState.IsValid)
            {
                LoginInfo     _login = LoginUser;
                CommandResult r      = SaveObj <EAP_Role>(model);
                if (r.IntResult > 0)
                {
                    LogHandler.WriteServiceLog(_login.User.UserID.ToString(), "Id:" + model.ID + ",Name:" + model.RoleName, "成功", "保存", "组织结构");
                    return(Json(JsonHandler.CreateMessage(1, Suggestion.Save), JsonRequestBehavior.AllowGet));
                }
                else
                {
                    string ErrorCol = r.Message;
                    LogHandler.WriteServiceLog(_login.User.UserID.ToString(), "Id:" + model.ID + ",Name:" + model.RoleName + "," + ErrorCol, "失败", "保存", "组织结构");
                    return(Json(JsonHandler.CreateMessage(0, Suggestion.SaveFail + ErrorCol), JsonRequestBehavior.AllowGet));
                }
            }
            else
            {
                return(Json(JsonHandler.CreateMessage(0, Suggestion.SaveFail), JsonRequestBehavior.AllowGet));
            }

            /*
             * model.Id = ResultHelper.NewId;
             * model.CreateTime = ResultHelper.NowTime;
             * model.CreatePerson = GetUserId();
             * if (model != null && ModelState.IsValid)
             * {
             *
             *  if (m_BLL.Create(ref errors, model))
             *  {
             *      LogHandler.WriteServiceLog(GetUserId(), "Id" + model.Id + ",Name" + model.Name, "成功", "创建", "SysRole");
             *      return Json(JsonHandler.CreateMessage(1, Suggestion.InsertSucceed));
             *  }
             *  else
             *  {
             *      string ErrorCol = errors.Error;
             *      LogHandler.WriteServiceLog(GetUserId(), "Id" + model.Id + ",Name" + model.Name + "," + ErrorCol, "失败", "创建", "SysRole");
             *      return Json(JsonHandler.CreateMessage(0, Suggestion.InsertFail + ErrorCol));
             *  }
             * }
             * else
             * {
             *  return Json(JsonHandler.CreateMessage(0, Suggestion.InsertFail));
             * }
             */
        }
Пример #7
0
        public void UpdateRole(DataRequest request, DataResponse result, DataProvider datasource)
        {
            EAP_Role role = TJson.Parse <EAP_Role>(request["P0"]);

            result.Value = ToJson(new AccountOP(request.LogIn).UpdateRole(role));
        }
Пример #8
0
        public CommandResult AddRole(EAP_Role role)
        {
            CommandResult result = new CommandResult();

            result.Result = false;

            string sFields = "";
            string sValues = "";

            if (role.Items.Count <= 0)
            {
                return(result);
            }

            /*
             * role.Items.ForEach(e =>
             * {
             *  if (!string.IsNullOrEmpty(e.K) && e.S == EntityStatus.New)
             *  {
             *      sFields += string.Format("[{0}],", e.K);
             *      sValues += string.Format("'{0}',", e.V);
             *  }
             * });
             * */
            string sql = string.Format("select count(*) from EAP_Role where RoleName='{0}'", role.RoleName);

            /*
             * string sSql = string.Format(
             *  "INSERT INTO EAP_Role({0}) VALUES({1});SELECT CAST(scope_identity() AS int);",
             *  sFields.Trim().TrimEnd(','),
             *  sValues.Trim().TrimEnd(','));
             * int count = DataProvider.ExecuteScalar<int>(sql);
             */
            int count = (int)DataProvider.ExecuteScalar <decimal>(sql);

            if (count <= 0)
            {
                // int iPID = DataProvider.ExecuteScalar<int>(sSql);
                int iPID = DataProvider.DoInsert(role, "EAP_Role", true, null);
                if (iPID > 0)
                {
                    result.Result = true;
                    result.ReturnValue.Add(new LookupDataItem()
                    {
                        K = "ID", V = iPID.ToString()
                    });
                    result.Message = "新增成功。";
                }
                else
                {
                    result.Result  = false;
                    result.Message = "新增失败。";
                }
            }
            else
            {
                result.Result    = false;
                result.IntResult = 1;
                result.Message   = "该角色已经存在。";
            }
            return(result);
        }