예제 #1
0
 public ActionResult Edit(RoleInfo roleInfo)
 {
     if (roleInfo.RoleID == 0)
     {
         return Insert(roleInfo);
     }
     else
     {
         return Update(roleInfo);
     }
 }
예제 #2
0
 public ActionResult Insert(RoleInfo roleInfo)
 {
     try
     {
         roleInfo.CreatedDate = DateTime.Now;
         roleInfo.UpdatedDate = DateTime.Now;
         roleInfo.CreatedBy = CurrentUserInfo.UserCode;
         roleInfo.UpdatedBy = CurrentUserInfo.UserCode;
         IRoleService roleService = UnityHelper.UnityResolve<IRoleService>();
         var data = roleService.InsertRole(roleInfo);
         LogHelper.LogOperation(CurrentUserInfo.UserCode, string.Format("Insert RoleInfo {0},{1}", LogHelper.ChangeEntityToLog(roleInfo), data));
         if (data > 0)
         {
             return Content("OK");
         }
         else
         {
             return Content("Failed");
         }
     }
     catch (BusinessException bex)
     {
         return Content(bex.Message);
     }
     catch (Exception ex)
     {
         LogHelper.LogError(ex, "");
         return Content(ex.Message);
     }
 }
예제 #3
0
파일: RoleDA.cs 프로젝트: jerryxi/GXP
 /// <summary>
 /// 设置SQL参数表
 /// </summary>
 /// <param name="Role">Role对象</param>
 /// <returns>Role参数数组</returns>
 private SqlParameter[] Set_Role_Parameters(RoleInfo roleInfo)
 {
     SqlParameter[] paramArray = new SqlParameter[] {new SqlParameter("@RoleID",roleInfo.RoleID),
                                                         new SqlParameter("@RoleName",roleInfo.RoleName),
                                                         new SqlParameter("@CreatedBy",string.IsNullOrEmpty(roleInfo.CreatedBy)?"":roleInfo.CreatedBy),
                                                         new SqlParameter("@UpdatedBy",string.IsNullOrEmpty(roleInfo.UpdatedBy)?"":roleInfo.UpdatedBy)
                                                     };
     return paramArray;
 }
예제 #4
0
파일: RoleDA.cs 프로젝트: jerryxi/GXP
 /// <summary>
 /// 初始化RoleInfo
 /// </summary>
 private RoleInfo InitRoleInfoByDataReader(RoleInfo roleInfo, IDataReader reader)
 {
     roleInfo = new RoleInfo(reader["RoleID"].ToString() != "" ? Int32.Parse(reader["RoleID"].ToString()) : 0,
     reader["RoleName"].ToString(),
     reader["CreatedBy"].ToString(),
     reader["CreatedDate"].ToString() != "" ? DateTime.Parse(reader["CreatedDate"].ToString()) : new DateTime(),
     reader["UpdatedBy"].ToString(),
     reader["UpdatedDate"].ToString() != "" ? DateTime.Parse(reader["UpdatedDate"].ToString()) : new DateTime());
     return roleInfo;
 }
예제 #5
0
파일: RoleDA.cs 프로젝트: jerryxi/GXP
 /// <summary>
 /// 更新一条Role记录
 /// </summary>
 /// <param name="db">DataBase对象</param>
 /// <param name="tran">一个有效的DbTransaction</param>
 /// <param name="role">Role对象</param>
 /// <param name="whLoginID">要查询的仓库的前缀</param>
 /// <returns>执行更新对数据库影响的行数</returns>
 public int UpdateRole(Database db, DbTransaction tran, RoleInfo roleInfo)
 {
     int result = 0;
     SqlParameter[] paras = Set_Role_Parameters(roleInfo);
     if (paras != null)
     {
         result += DBHelper.ExecuteNonQuery(db, tran, CommandType.Text, SQL_UPDATE_ROLE, paras);
     }
     return result;
 }
예제 #6
0
파일: RoleDA.cs 프로젝트: jerryxi/GXP
 /// <summary>
 /// 新增一条Role记录
 /// </summary>
 /// <param name="role">Role对象</param>
 /// <param name="whLoginID">要查询的仓库的前缀</param>
 /// <returns>执行新增对数据库影响的行数</returns>
 public int InsertRole(RoleInfo roleInfo)
 {
     int result = 0;
     SqlParameter[] paras = Set_Role_Parameters(roleInfo);
     if (paras != null)
     {
         result = DBHelper.ExecuteNonQuery(CommandType.Text, SQL_INSERT_ROLE, paras);
     }
     return result;
 }
예제 #7
0
파일: RoleService.cs 프로젝트: jerryxi/GXP
 /// <summary>
 /// 更新一条Role记录
 /// </summary>
 /// <param name="role">Role对象</param>
 /// <param name="whLoginID">要查询的仓库的前缀</param>
 /// <returns>执行更新对数据库影响的行数</returns>
 public int UpdateRole(RoleInfo roleInfo)
 {
     return roleDA.UpdateRole(roleInfo);
 }
예제 #8
0
파일: RoleService.cs 프로젝트: jerryxi/GXP
 /// <summary>
 /// 新增一条Role记录
 /// </summary>
 /// <param name="role">Role对象</param>
 /// <param name="whLoginID">要查询的仓库的前缀</param>
 /// <returns>执行新增对数据库影响的行数</returns>
 public int InsertRole(RoleInfo roleInfo)
 {
     return roleDA.InsertRole(roleInfo);
 }