Ejemplo n.º 1
0
 /// <summary>
 /// 创建一个组织机构_角色
 /// </summary>
 /// <param name="validationErrors">返回的错误信息</param>
 /// <param name="db">数据库上下文</param>
 /// <param name="entity">一个组织机构_角色</param>
 /// <returns></returns>
 public bool Create(ref ValidationErrors validationErrors, ORG_Role entity)
 {
     try
     {
         repository.Create(entity);
         return(true);
     }
     catch (Exception ex)
     {
         validationErrors.Add(ex.Message);
         ExceptionsHander.WriteExceptions(ex);
     }
     return(false);
 }
Ejemplo n.º 2
0
        public ActionResult Edit(int id)
        {
            ORG_Role menu = m_BLL.GetById(id);

            return(View(menu));
        }
Ejemplo n.º 3
0
        public ActionResult Create(FormCollection form)
        {
            try
            {
                int total = 0;

                ORG_Role role = new ORG_Role()
                {
                    RoleCode = form["txtCode"].ToString(),
                    RoleName = form["txtRoleName"].ToString(),
                    Des      = form["txtDes"].ToString(),
                    XYBZ     = "Y"
                };
                Dictionary <string, object> par = new Dictionary <string, object>();
                par.Add("@code", role.RoleCode);
                par.Add("@roleName", role.RoleName);

                #region 添加前进行判断
                //编码不为空时,需要对编码唯一性进行判断
                if (!string.IsNullOrEmpty(role.RoleCode.Trim()))
                {
                    StringBuilder sqlWhere = new StringBuilder();
                    sqlWhere.Append("XYBZDDL_String&Y");
                    if (!string.IsNullOrEmpty(role.RoleCode))
                    {
                        sqlWhere.Append("^RoleCode&" + role.RoleCode);
                    }

                    List <ORG_Role> queryData = m_BLL.GetByParam(null, 0, 100, "Desc", "ID", sqlWhere.ToString(), ref total);



                    if (queryData.Count > 0)
                    {
                        return(Json(new { Code = "error", Message = "此编码已被使用" }));
                    }
                }
                //角色名称不为空时,需要进行判断
                if (!string.IsNullOrEmpty(role.RoleName.Trim()))
                {
                    StringBuilder sqlWhere = new StringBuilder();
                    sqlWhere.Append("XYBZDDL_String&Y");

                    if (!string.IsNullOrEmpty(role.RoleName.Trim()))
                    {
                        sqlWhere.Append("^RoleName&" + role.RoleName.Trim());
                    }

                    List <ORG_Role> queryData = m_BLL.GetByParam(null, 0, 100, "Desc", "ID", sqlWhere.ToString(), ref total);



                    if (queryData.Count > 0)
                    {
                        return(Json(new { Code = "error", Message = "此角色名称已被使用" }));
                    }
                }
                #endregion
                m_BLL.Create(ref validationErrors, role);

                return(Json(new { Code = "ok", Message = "操作成功" }));
            }
            catch
            {
                return(Json(new { Code = "error", Message = "操作失败:服务器错误" }));
            }
        }
Ejemplo n.º 4
0
        public ActionResult Edit(FormCollection form)
        {
            try
            {
                int      total = 0;
                ORG_Role role  = m_BLL.GetById(Convert.ToInt32(form["hidID"].ToString()));
                role.ID       = Convert.ToInt32(form["hidID"].ToString());
                role.RoleCode = form["txtCode"].ToString();
                role.RoleName = form["txtRoleName"].ToString();
                role.Des      = form["txtDes"].ToString();


                Dictionary <string, object> par = new Dictionary <string, object>();
                par.Add("@rolecode", role.RoleCode);
                par.Add("@roleName", role.RoleName);

                #region 添加前进行判断
                //编码不为空时,需要对编码唯一性进行判断
                if (!string.IsNullOrEmpty(role.RoleCode.Trim()))
                {
                    StringBuilder sqlWhere = new StringBuilder();
                    sqlWhere.Append("XYBZDDL_String&Y");


                    if (!string.IsNullOrEmpty(role.RoleCode))
                    {
                        sqlWhere.Append("^RoleCode&" + role.RoleCode);
                    }

                    List <ORG_Role> queryData = m_BLL.GetByParam(null, 0, 100, "Desc", "ID", sqlWhere.ToString(), ref total);

                    var f = queryData.Find(x => x.ID != role.ID);



                    if (f != null)
                    {
                        return(Json(new { Code = "error", Message = "此编码已被使用" }));
                    }
                }
                //角色名称不为空时,需要进行判断
                if (!string.IsNullOrEmpty(role.RoleName.Trim()))
                {
                    StringBuilder sqlWhere = new StringBuilder();
                    sqlWhere.Append("XYBZDDL_String&Y");

                    if (!string.IsNullOrEmpty(role.RoleName.Trim()))
                    {
                        sqlWhere.Append("^RoleName&" + role.RoleName.Trim());
                    }

                    List <ORG_Role> queryData = m_BLL.GetByParam(null, 0, 100, "Desc", "ID", sqlWhere.ToString(), ref total);


                    var f = queryData.Find(x => x.RoleName != role.RoleName);


                    if (f != null)
                    {
                        return(Json(new { Code = "error", Message = "此角色名称已被使用" }));
                    }
                }
                #endregion

                m_BLL.Edit(ref validationErrors, role);
                return(Json(new { Code = "ok", Message = "操作成功" }));
            }
            catch
            {
                return(Json(new { Code = "error", Message = "操作失败:服务器错误" }));
            }
        }