Ejemplo n.º 1
0
        public IActionResult SubmitAdd(string obj)
        {
            MRole  obj_   = new MRole();
            string errMsg = Validate(obj, ref obj_);

            if (errMsg == "")
            {
                bool isExist = rlm.CheckIsExist(obj_.RoleID, ref errMsg);
                if (errMsg == "")
                {
                    errMsg = isExist ? "Data already exist" : "";
                }
                else
                {
                    logger_.ERROR(errMsg);
                    errMsg = "Internal Server Error";
                }
            }
            if (errMsg == "")
            {
                errMsg = rlm.Add(obj_);
                if (!string.IsNullOrEmpty(errMsg))
                {
                    logger_.ERROR(errMsg);
                    errMsg = "Internal Server Error";
                }
            }
            return(Z_Result.SetResult(errMsg));
        }
Ejemplo n.º 2
0
 private void btnSave_Click(object sender, EventArgs e)
 {
     try
     {
         if (txtRoleName.Text == "")
         {
             MessageBox.Show("You Must Enter Role Name");
             return;
         }
         role.Add(new Role()
         {
             Role_Code = int.Parse(txtRoleCode.Text), Role_Name = txtRoleName.Text
         });
         btnSave.Enabled   = false;
         btnAddNew.Enabled = btnModify.Enabled = true;
         txtRoleCode.Text  = txtRoleName.Text = "";
         MessageBox.Show("New Role Successfully Added");
         FRM_Role_Load(null, null);
         btnLast_Click(null, null);
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
Ejemplo n.º 3
0
        private void buttonSave_Click(object sender, EventArgs e)
        {
            RoleManager       rm = new RoleManager();
            PermissionManager pm = new PermissionManager();
            Role   role          = new Role();
            string percode       = BuildCode.ModuleCode("PE");
            string rolecode      = BuildCode.ModuleCode("RO");

            // 新增一个角色信息
            role.Role_Code    = rolecode;
            role.Role_Modules = "";
            role.Role_Name    = textBoxName.Text.Trim();
            int roleAddResult = 0;

            try
            {
                roleAddResult = rm.Add(role);
            }
            catch (Exception ex)
            {
                MessageBox.Show("增加角色失败,请检查服务器连接.错误信息:" + ex.Message);
            }

            if (roleAddResult == 0)
            {
                MessageBox.Show("未能成功新增角色数据,请重试");
                return;
            }

            try
            {
                List <Permission> permList = new List <Permission>();
                string[]          nameList =
                { "用户资料",      "权限分配", "仓库资料", "货品资料",
                  "供应商资料", "物料信息", "仓库系统", "销售系统",
                  "售后系统",  "采购系统", "财务系统", "考勤系统" };
                //填充权限实体列表
                initPermission(permList, rolecode, nameList);
                int result = pm.AddBatch(permList);
                if (result > 0)
                {
                    MessageBox.Show("新增用户角色成功,该角色所有模块默认不可读写.");
                }
                //触发事件新增节点
                refresh?.Invoke(textBoxName.Text, rolecode);
            }
            catch (Exception ex)
            {
                rm.Delete(roleAddResult);
                MessageBox.Show("分配角色权限,请检查服务器连接.错误信息:" + ex.Message);
            }
        }
Ejemplo n.º 4
0
 /// <summary>
 /// 初始化角色表
 /// </summary>
 private static void RoleInit()
 {
     roleManager.Add(new Role()
     {
         Name = "超级管理员", Description = "超级管理员"
     });
     roleManager.Add(new Role()
     {
         Name = "消防机构总队", Description = "消防机构总队"
     });
     roleManager.Add(new Role()
     {
         Name = "消防机构支队", Description = "消防机构支队"
     });
     roleManager.Add(new Role()
     {
         Name = "消防机构大队", Description = "消防机构大队"
     });
     roleManager.Add(new Role()
     {
         Name = "服务机构", Description = "服务机构"
     });
 }
Ejemplo n.º 5
0
        public ActionResult CreateEntity(Role model)
        {
            if (!ModelState.IsValid)
            {
                return(Json(
                           new OperateResult
                {
                    content = Model.Utility.GetModelStateErrors(ModelState),
                },
                           JsonRequestBehavior.AllowGet
                           ));
            }

            OperateResult or = RoleManager.Add(model);

            return(Json(or, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 6
0
 public ActionResult Add(Role role)
 {
     if (ModelState.IsValid)
     {
         if (roleManager.Add(role).Code == 1)
         {
             return(View("Prompt", new Prompt()
             {
                 Title = "添加角色成功", Message = "你已经成功添加了角色【" + role.Name + "】", Buttons = new List <string>()
                 {
                     "<a href=\"" + Url.Action("Index", "Role") + "\" class=\"btn btn-default\">角色管理</a>", "<a href=\"" + Url.Action("Add", "Role") + "\" class=\"btn btn-default\">继续添加</a>"
                 }
             }));
         }
     }
     return(View(role));
 }
 public ActionResult Add(Role role)
 {
     RoleManager.Add(role.Name);
     return(RedirectToAction("Index"));
 }
Ejemplo n.º 8
0
 public ActionResult Add(Role r)
 {
     r.CreateTime = DateTime.Now;
     return(Json(RoleManager.Add(r), JsonRequestBehavior.AllowGet));
 }