コード例 #1
0
        private void btnOk_Click(object sender, EventArgs e)
        {
            //判断验证码
            if (skinCode1.CodeStr.ToLower() != txtCode.Text.ToLower())
            {
                SelfForm.Msbox.Show("验证码不正确");
                return;
            }
            //建立Role对象
            Role model = new Role();

            model.Name         = txtName.Text.Trim();
            model.Submitter_id = frmMain.current_user.Id;
            model.Remark       = txtRemark.Text;
            //根据反射设置role的权限
            Type type = model.GetType();

            foreach (var permission in cklbPermission.CheckedItems)
            {
                type.GetProperty(permission.ToString()).SetValue(model, 1, null);
            }
            RoleBLL bll = new RoleBLL();

            SelfForm.Msbox.Show(bll.AddRole(model) ? "添加成功" : "添加失败请重试");
        }
コード例 #2
0
        protected void btAdd_Click(object sender, EventArgs e)
        {
            RoleBLL _RoleBLL = new RoleBLL();
            Role    _Role    = new Role();

            _Role.RoleName = this.txtRole.Text.Trim();

            if (_RoleBLL.AddRole(_Role))
            {
                Response.Write("<script language='javascript'>");
                Response.Write("alert('添加成功');");
                Response.Write("document.location.href='RoleList.aspx';");
                Response.Write("</script>");
            }
        }
コード例 #3
0
ファイル: RoleApi.cs プロジェクト: franknew/RiskMgr
        public string AddRole(AddRoleServiceForm form)
        {
            UserBLL userbll = new UserBLL();
            var     user    = userbll.GetCurrentUser();

            form.Creator = user.User.ID;
            string weixinid = "20";

            if (!string.IsNullOrEmpty(ConfigurationManager.AppSettings["WeiXinDepartmentID"]))
            {
                weixinid = ConfigurationManager.AppSettings["WeiXinDepartmentID"];
            }
            form.WeiXinID = weixinid;
            return(bll.AddRole(form));
        }
コード例 #4
0
        private void btn_saveRole_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(this.tb_roleName.Text.Trim()))
            {
                this.SetError(tb_username, "角色名不能为空!");
                tb_username.Focus();
                return;
            }


            Roles role;

            if (isRoleModify)
            {
                role = new Roles(int.Parse(this.lb_roleId.Text), tb_roleName.Text.Trim(), GetRoleValue(), int.Parse(cb_adminFlag.CheckValue.ToString()));

                if (roleBll.UpdateRole(role))
                {
                    MessageBoxEx.Show("修改成功!", "修改角色");
                    this.DisableRoleForm();
                    InitRoleDropdownList();
                    InitRolenameList();
                }
                else
                {
                    MessageBoxEx.Show("修改失败!", "修改角色");
                }
            }
            else
            {
                role = new Roles(tb_roleName.Text.Trim(), GetRoleValue(), int.Parse(cb_adminFlag.CheckValue.ToString()));
                if (roleBll.Check(role.RoleName))
                {
                    if (roleBll.AddRole(role))
                    {
                        MessageBoxEx.Show("添加成功!", "添加角色");
                        this.DisableRoleForm();
                        this.ClearForm();
                        InitRolenameList();
                        InitRoleDropdownList();
                    }
                    else
                    {
                        MessageBoxEx.Show("添加失败!", "添加角色");
                    }
                }
            }
        }
コード例 #5
0
ファイル: RoleController.cs プロジェクト: dylanpeng/Admin
 public ActionResult Add(RoleEntity role)
 {
     //var role = new RoleEntity() { RoleName = roleName };
     //验证
     if (ModelState.IsValid)
     {
         var result = RoleBLL.AddRole(role);
         if (result > 0)
         {
             return(RedirectToAction("Index", "Role"));
         }
         ViewBag.ErrorMsg = "添加失败,请确认ID是否重复";
     }
     // 如果我们进行到这一步时某个地方出错,则重新显示表单
     return(View(role));
 }
コード例 #6
0
        /// <summary>
        /// To save details to database
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btn_Save_Click(object sender, EventArgs e)
        {
            RoleBO  objRole    = new RoleBO();
            RoleBLL objroleBLL = new RoleBLL();

            objRole.RoleID          = Convert.ToInt32(ViewState["ROLEID"]);
            objRole.RoleName        = txtRoleName.Text.Trim();
            objRole.RoleDescription = txtDescription.Text.Trim();

            if (objRole.RoleDescription.Length >= 200)
            {
                objRole.RoleDescription = objRole.RoleDescription.Substring(0, 198);
            }

            string AlertMessage = string.Empty;
            string message      = string.Empty;

            AlertMessage = "alert('" + message + "');";

            if (objRole.RoleID == 0)
            {
                objRole.CreatedBy = Convert.ToInt32(Session["USER_ID"]);
                message           = objroleBLL.AddRole(objRole);
                if (string.IsNullOrEmpty(message) || message == "" || message == "null")
                {
                    message = "Data saved successfully";
                    ClearDetails();
                }
            }
            else
            {
                objRole.UpdatedBy = Convert.ToInt32(Session["USER_ID"]);
                message           = objroleBLL.UpdateRole(objRole);
                if (string.IsNullOrEmpty(message) || message == "" || message == "null")
                {
                    message = "Data updated successfully";
                    ClearDetails();
                    SetUpdateMode(false);
                }
            }

            BindGrid(true, false);

            AlertMessage = "alert('" + message + "');";
            ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "Added", AlertMessage, true);
        }
コード例 #7
0
        /// <summary>
        /// 添加角色
        /// </summary>
        /// <param name="u"></param>
        public void _AddRole(DT_Role r)
        {
            DT_Role ro = new DT_Role();

            ro.Id     = r.Id;
            ro.Name   = r.Name;
            ro.Remark = r.Remark;

            int count = rbll.AddRole(r);

            if (count > 0)
            {
                Response.Write("1");
            }
            else
            {
                Response.Write("0");
            }
            Response.End();
        }
コード例 #8
0
ファイル: FrmRole.cs プロジェクト: Gwj-ui/HRM
 private void btnSave_Click(object sender, EventArgs e)
 {
     if (ValidateInput())
     {
         string     rolename = txtRoleName.Text.Trim();
         List <int> ids      = new List <int>();
         TreeNode   root     = tvwMenu.Nodes[0];
         foreach (TreeNode node in root.Nodes)
         {
             if (node.Checked)
             {
                 ids.Add((int)node.Tag);
                 foreach (TreeNode childNode in node.Nodes)
                 {
                     if (childNode.Checked)
                     {
                         ids.Add((int)childNode.Tag);
                     }
                 }
             }
         }
         if (op == Operator.Add)
         {
             if (ids.Count > 0)
             {
                 try
                 {
                     int count = rbll.AddRole(rolename, ids.ToArray());
                     if (count > 0)
                     {
                         MessageBox.Show("添加成功");
                         txtRoleName.Text = "";
                         LoadAllRoles();
                         tvwMenu.Enabled = false;
                         op = Operator.Other;
                     }
                 }
                 catch (Exception ex)
                 {
                     MessageBox.Show(ex.Message);
                 }
             }
             else
             {
                 MessageBox.Show("请选择要添加的菜单权限");
             }
         }
         else if (op == Operator.Edit)
         {
             int roleid = (int)tvwRole.SelectedNode.Tag;
             if (ids.Count > 0)
             {
                 try
                 {
                     int count = rbll.EditRole(roleid, rolename, ids.ToArray());
                     if (count > 0)
                     {
                         MessageBox.Show("修改成功");
                         txtRoleName.Text = "";
                         LoadAllRoles();
                         tvwMenu.Enabled = false;
                         op = Operator.Other;
                     }
                 }
                 catch (Exception ex)
                 {
                     MessageBox.Show(ex.Message);
                 }
             }
             else
             {
                 MessageBox.Show("请选择要修改的菜单权限");
             }
         }
     }
 }
コード例 #9
0
 public HttpResponseMessage AddRole([FromBody] Role role)
 {
     return(new HttpResponseMessage {
         Content = new StringContent(roleBLL.AddRole(role), Encoding.GetEncoding("UTF-8"), "text/json")
     });
 }