예제 #1
0
        public void RoleAddIdList(HttpContext context)
        {
            int RoleId = 0;

            if (!string.IsNullOrEmpty(GetParam("RoleId	", context).ToString()))
            {
                RoleId = Convert.ToInt32(GetParam("RoleId	", context).ToString());
            }
            string objOrder = GetParam("RoleModel", context);
            Role   roleobj  = JsonConvert.DeserializeObject <Role>(objOrder);

            roleobj.RoleType   = 1;
            roleobj.RoleStatus = 1;
            roleobj.IsDeleted  = 0;
            RoleBLL rolebll = new RoleBLL();
            int     result  = 0;

            if (roleobj.RoleName != "")
            {
                if (roleobj.RoleId > 0)
                {
                    //编辑
                    result = rolebll.Update(roleobj) ? 1 : 0;
                }
                else
                {
                    result = rolebll.Add(roleobj);
                }
            }
            context.Response.Write(result);
        }
예제 #2
0
        public async Task <ActionResult> proc()
        {
            var json = new StreamReader(Request.Body).ReadToEnd();
            var item = JsonConvert.DeserializeObject <JGN_Roles>(json);

            item = await RoleBLL.Add(_context, item);

            return(Ok(new { status = "success", record = item, message = SiteConfig.generalLocalizer["_records_processed"].Value }));
        }
 public string Add(RoleView obj)
 {
     try
     {
         RoleBLL.Add(obj);
     }
     catch (Exception ex)
     {
         Result.Code    = 500;
         Result.Message = ex.Message;
     }
     return(JsonHelper.Instance.Serialize(Result));
 }
예제 #4
0
    private void Save()
    {
        AjaxResult result = new AjaxResult();

        result.IsSuccess = false;
        result.Msg       = "保存失败!";
        int?id = null;

        if (!string.IsNullOrEmpty(Request.Form["id"]))
        {
            id = Convert.ToInt32(Request.Form["id"]);
        }
        Role model = null;

        if (!id.HasValue)//新增
        {
            model = new Role()
            {
                RoleName    = Request.Form["RoleName"],
                Description = Request.Form["Description"],
                IsAdmin     = (Request.Form["IsAdmin"].ToString() == "1") ? true : false,
                CreateTime  = DateTime.Now
            };
            if (bll.Add(model))
            {
                result.IsSuccess = true;
                result.Msg       = "增加成功!";
            }
        }
        else//编辑
        {
            model = bll.Get(id.Value);
            if (model != null)
            {
                model.RoleName    = Request.Form["RoleName"];
                model.Description = Request.Form["Description"];
                model.IsAdmin     = (Request.Form["IsAdmin"].ToString() == "1") ? true : false;

                if (bll.Update(model))
                {
                    result.IsSuccess = true;
                    result.Msg       = "更新成功!";
                }
            }
        }
        Response.Clear();
        Response.Write(result.ToJsonString());
        Response.ContentType = "application/json";
        Response.End();
    }
예제 #5
0
        private void button1_Click(object sender, EventArgs e)
        {
            //string name = txtrolename.Text;
            //string description = rtbdescription.Text;
            //role.Name = name;
            //role.Description = description;

            roleBLL.Add(new Role()
            {
                Name = txtrolename.Text, Description = rtbdescription.Text
            });
            txtrolename.Text    = "";
            rtbdescription.Text = "";
            RoleBLL role = new RoleBLL();

            dgvroleadd.DataSource = roleBLL.GetALl();
        }
예제 #6
0
        private void Add_Click(object sender, EventArgs e)
        {
            string name = Role_Name.Text;

            if (Role_Name.Text.Length != 0)
            {
                if (Roles.Where(r => r.Role_Name == name).ToList().Count <= 0)
                {
                    RoleBLL.Add(name);
                    MessageBox.Show("Role Added Successfully");
                    Role_Name.Text = " ";
                }
                else
                {
                    MessageBox.Show("Role already exist ");
                }
            }
        }
예제 #7
0
        public JsonResult RoleEdit(Role model)
        {
            var json = new JsonModel();

            var roleBLL = new RoleBLL();

            model.ResourceID = Request.Form["RESOURCESID"];

            if (model.ID > 0)
            {
                model.UpdateDate   = DateTime.Now;
                model.UpdateUserID = model.UpdateLoginID = LoginUser.ID;

                if (roleBLL.Update(model, "Name", "ResourceID", "UpdateDate", "UpdateUserID", "UpdateLoginID") > 0)
                {
                    json.Status  = "success";
                    json.Message = "修改成功!";
                }
                else
                {
                    json.Message = "抱歉,修改失败,请稍后重试!";
                }
            }
            else
            {
                model.CreateDate   = DateTime.Now;
                model.CreateUserID = model.CreateLoginID = LoginUser.ID;

                if (roleBLL.Add(model) > 0)
                {
                    json.Status  = "success";
                    json.Message = "添加成功!";
                }
                else
                {
                    json.Message = "抱歉,添加失败,请稍后重试!";
                }
            }

            return(Json(json));
        }
        /// <summary>
        /// GridView的InsertCommand事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void GridRole_InsertCommand(object sender, Telerik.Web.UI.GridCommandEventArgs e)
        {
            GridEditableItem edittedItem = e.Item.OwnerTableView.GetInsertItem();
            //获取控件
            RadTextBox  textRoleName = edittedItem.FindControl("txtRoleName") as RadTextBox;
            RadTextBox  textRoleCode = edittedItem.FindControl("textRoleCode") as RadTextBox;
            RadTextBox  textDesc     = edittedItem.FindControl("textDesc") as RadTextBox;
            RadComboBox ComBoxState  = edittedItem.FindControl("ComBoxState") as RadComboBox;

            //实例化Entity实体
            tblRole roleObj = new tblRole();

            roleObj.RoleName = textRoleName.Text;
            roleObj.RoleCode = textRoleCode.Text;
            roleObj.Desc     = textDesc.Text;
            roleObj.State    = Convert.ToDecimal(ComBoxState.SelectedItem.Value);
            RoleBLL RoleBLLs = new RoleBLL();

            RoleBLLs.Add(roleObj);
            this.GridViewData();
        }
예제 #9
0
        protected void BtnSaveRole_Click(object sender, EventArgs e)
        {
            Rdto.RoleName = txtRolename.Text.ToString();

            Rdto.CreateDate = System.DateTime.Now;
            Rdto.CreateBy   = HttpContext.Current.User.Identity.Name;
            if (btnSave.Text == "Save")
            {
                RBLL.Add(Rdto);
            }
            else
            {
                Rdto.RoleId     = Convert.ToInt32(HFRoleId.Value);
                Rdto.UpdateDate = System.DateTime.Now;
                Rdto.UpdateBy   = HttpContext.Current.User.Identity.Name;
                RBLL.Edit(Rdto);
                btnSave.Text = "Save";
            }
            pagingLoal();
            clearCntrol_role();
        }
예제 #10
0
    private string AddRole(string name, int organID)
    {
        if (name == string.Empty || name == "无")
        {
            return("");
        }
        RoleBLL pBLL = new RoleBLL();
        bool    _re  = pBLL.Exists(name, organID);

        if (!_re)
        {
            Role p = new Role();
            p.RoleName = name;

            p.OrganID = organID;
            p.InputBy = Session["UserID"].ToString();

            int re = pBLL.Add(p);
        }

        string _Code = pBLL.GetRoleCode(name, organID);

        return(_Code);
    }
예제 #11
0
        public void ProcessRequest(HttpContext context)
        {
            try
            {
                LoginUser loginUser = new LoginUser(context, "Role");
                if (!loginUser.Pass)//权限验证
                {
                    return;
                }

                //加载DataGrid
                if (context.Request["action"] == "gridLoad")
                {
                    RoleBLL bll  = new RoleBLL(context, loginUser);
                    int     page = int.Parse(context.Request["page"]);
                    int     rows = int.Parse(context.Request["rows"]);
                    bll.LoadGrid(page, rows);
                    return;
                }

                //加载信息
                if (context.Request["action"] == "load")
                {
                    RoleBLL bll    = new RoleBLL(context, loginUser);
                    string  roleId = context.Request["roleId"];//角色编号
                    bll.Load(roleId);
                    return;
                }

                //增加
                if (context.Request["action"] == "add")
                {
                    RoleBLL bll    = new RoleBLL(context, loginUser);
                    TSRole  tsRole = new TSRole();
                    //tsRole.roleId = context.Request["roleId"];//角色编号
                    tsRole.roleName = context.Request["roleName"]; //角色名称
                    tsRole.status   = context.Request["status"];   //使用状态
                    bll.Add(tsRole);
                    return;
                }

                //修改
                if (context.Request["action"] == "edit")
                {
                    RoleBLL bll    = new RoleBLL(context, loginUser);
                    TSRole  tsRole = new TSRole();
                    tsRole.roleId   = context.Request["roleId"];   //角色编号
                    tsRole.roleName = context.Request["roleName"]; //角色名称
                    tsRole.status   = context.Request["status"];   //使用状态
                    bll.Edit(tsRole);
                    return;
                }

                //删除
                if (context.Request["action"] == "delete")
                {
                    RoleBLL bll    = new RoleBLL(context, loginUser);
                    string  roleId = context.Request["roleId"];//角色编号
                    bll.Delete(roleId);
                    return;
                }
            }
            catch (Exception e)
            {
                Message.error(context, e.Message);
            }
        }
예제 #12
0
        protected void RoleInfoSave()
        {
            RoleBLL roleBLL = new RoleBLL();

            RoleNameChild = this.txtRoleNameChild.Value.Trim();
            RoleName      = this.txtRoleName.Value.ToString();
            int RoleStatus = 1;

            try
            {
                ParentID = int.Parse(this.txtRoleId.Value);
            }
            catch
            { }
            if (RoleNameChild.Length > 50)
            {
                Response.Write(CommonHelper.JumpBack("角色名称输入过长,请重新输入!"));
                Response.End();
            }
            if (this.txtRoleNameChild.Value.ToString() == "")
            {
                Response.Write(CommonHelper.JumpBack("请填写角色名称!"));
                Response.End();
            }
            if ((ParentID == RoleId) && ParentID != 0 && RoleId != 0)
            {
                Response.Write(IFrameLayerClosetwo("父级选择错误,请重新选择!"));
                Response.End();
            }
            DataSet ds = new DataSet();

            ds = roleBLL.GetParentNameList("r.RoleId<>" + RoleId + " and r.RoleName='" + RoleNameChild + "'  and r.IsDeleted=0 ");
            if (ds.Tables[0].Rows.Count > 0)
            {
                Response.Write(IFrameLayerClosetwo("角色名称重复,重新填写!"));
                Response.End();
            }

            bool bFlag = false;

            if (this.btnSave.Text == "修改角色")
            {
                Role model = new Role();
                model.RoleId     = Request.QueryString["RoleID"].ToString().ToInt();
                model.RoleStatus = RoleStatus;
                model.RoleName   = RoleNameChild;
                model.ParentId   = ParentID;
                model.IsDeleted  = 0;
                model.Remark     = this.txtRemark.Value.ToString();
                model.EditDate   = DateTime.Now;
                model.EditId     = LoginUserID;
                if (this.yes.Checked == true)
                {
                    model.IsManager = true;
                }
                else
                {
                    model.IsManager = false;
                }
                bFlag = roleBLL.Update(model);
                if (bFlag)
                {
                    Response.Write(IFrameLayerClosetwo("修改角色成功!"));
                    Response.End();
                }
                else
                {
                    Response.Write(IFrameLayerClosetwo("修改角色失败"));
                    Response.End();
                }
            }
            else
            {
                Role model = new Role();
                model.RoleId     = RoleId;
                model.RoleName   = RoleNameChild;
                model.ParentId   = ParentID;
                model.RoleStatus = RoleStatus;
                model.IsDeleted  = 0;
                model.EditDate   = DateTime.Now;
                model.CreateId   = LoginUserID;
                model.EditId     = LoginUserID;
                model.Remark     = this.txtRemark.Value.ToString();
                model.CreateDate = DateTime.Now;
                if (this.yes.Checked == true)
                {
                    model.IsManager = true;
                }
                else
                {
                    model.IsManager = false;
                }
                int RoleIdNew = 0;

                RoleIdNew = roleBLL.Add(model);
                if (RoleIdNew > 0)
                {
                    Response.Write(IFrameLayerClosetwo("添加角色成功!"));
                    Response.End();
                }
                else
                {
                    Response.Write(IFrameLayerClosetwo("添加角色失败,继续添加!"));
                    Response.End();
                }
            }
        }
예제 #13
0
 static public int Add(string role_name)
 {
     return(RoleBLL.Add(role_name));
 }
예제 #14
0
        public IHttpActionResult Post([FromBody] Request <ExtRole> request)
        {
            try
            {
                IList <RoleFunction> roleFuns = request.Data.RoleFuns;
                string roleId         = request.Data.RoleID;
                string roleName       = request.Data.RoleName;
                int    systemCategory = (int)request.Data.SystemCategory;
                string remark         = request.Data.Remark;

                MetaDataBLL     metaBLL   = new MetaDataBLL();
                List <MetaData> metaDatas = metaBLL.GetList(string.Empty);

                RoleFunctionBLL rfBLL = new RoleFunctionBLL();
                Role            mode  = new Role();
                if (string.IsNullOrEmpty(roleId))
                {
                    mode.RoleName       = roleName;
                    mode.SystemCategory = systemCategory;
                    mode.Remark         = remark;
                    mode.CreateDateTime = DateTime.Now;

                    roleId = bll.Add(mode);
                    if (string.IsNullOrEmpty(roleId))
                    {
                        return(BadRequest("异常"));
                    }

                    foreach (RoleFunction fun in roleFuns)
                    {
                        fun.RoleID         = roleId;
                        fun.CreateDateTime = DateTime.Now;

                        StringBuilder sb = new StringBuilder();
                        sb.AppendFormat("<?xml version=\"1.0\" encoding=\"utf-8\"?>");
                        sb.AppendFormat("<data version=\"2.0\">");

                        string[] _arr1 = fun.DataRange.Split(',');
                        foreach (string str in _arr1)
                        {
                            string[] _arr2 = str.Split('#');
                            if (_arr2.Length != 5)
                            {
                                continue;
                            }
                            int    _id = int.Parse(_arr2[1]);
                            string col = GetValue(metaDatas, _id);
                            sb.AppendFormat("<item>");
                            sb.AppendFormat("<relationship>{0}</relationship>", _arr2[3]);
                            sb.AppendFormat("<nameID>{0}</nameID>", _arr2[1]);
                            sb.AppendFormat("<name>{0}</name>", _arr2[0]);
                            sb.AppendFormat("<operation>{0}</operation>", _arr2[2]);
                            sb.AppendFormat("<value>{0}</value>", _arr2[4]);
                            sb.AppendFormat("<column>{0}</column>", col);
                            sb.AppendFormat("</item>");
                        }
                        sb.AppendFormat("</data>");

                        rfBLL.Add(fun);
                    }
                }
                else
                {
                    mode = bll.Get(roleId);
                    if (mode == null)
                    {
                        return(BadRequest("该记录不存在!"));
                    }
                    mode.RoleName       = roleName;
                    mode.SystemCategory = systemCategory;
                    mode.Remark         = remark;
                    mode.EditTime       = DateTime.Now;

                    bll.Edit(mode);
                    List <RoleFunction> hasRF = rfBLL.GetList(p => p.ROLEID.Equals(roleId) && p.ISDELETED == false);
                    foreach (RoleFunction fun in hasRF)
                    {
                        rfBLL.Delete(fun.RoleFunctionID);
                    }

                    foreach (RoleFunction fun in roleFuns)
                    {
                        fun.RoleID         = roleId;
                        fun.CreateDateTime = DateTime.Now;

                        StringBuilder sb = new StringBuilder();
                        sb.AppendFormat("<?xml version=\"1.0\" encoding=\"utf-8\"?>");
                        sb.AppendFormat("<data version=\"2.0\">");

                        string[] _arr1 = fun.DataRange.Split(',');
                        foreach (string str in _arr1)
                        {
                            string[] _arr2 = str.Split('#');
                            if (_arr2.Length != 5)
                            {
                                continue;
                            }
                            int    _id = int.Parse(_arr2[1]);
                            string col = GetValue(metaDatas, _id);
                            sb.AppendFormat("<item>");
                            sb.AppendFormat("<relationship>{0}</relationship>", _arr2[3]);
                            sb.AppendFormat("<nameID>{0}</nameID>", _arr2[1]);
                            sb.AppendFormat("<name>{0}</name>", _arr2[0]);
                            sb.AppendFormat("<operation>{0}</operation>", _arr2[2]);
                            sb.AppendFormat("<value>{0}</value>", _arr2[4]);
                            sb.AppendFormat("<column>{0}</column>", col);
                            sb.AppendFormat("</item>");
                        }
                        sb.AppendFormat("</data>");
                        fun.DataRange = sb.ToString();

                        rfBLL.Add(fun);
                    }
                }

                return(Ok("ok"));
            }
            catch (Exception ex)
            {
                LogHelper.WriteInfo(ex.ToString());
                return(BadRequest("异常!"));
            }
        }
 protected override CommandResult  AddItem(object item)
 {
     return(bll.Add((Role)item));
 }
예제 #16
0
 public JsonResult Add(RoleEditParam p)
 {
     return(Json(bll.Add(p)));
 }
예제 #17
0
        public JsonResult Add(Role model)
        {
            var result = bll.Add(model);

            return(Json(result));
        }