/// <summary>
 /// 新增用户角色
 /// </summary>
 /// <param name="loginId">登录ID</param>
 /// <param name="userRoleEntity"></param>
 /// <returns></returns>
 public EntityBase AddUserRole(string loginId, UserRoleEntity userRoleEntity)
 {
     TradeUser TdUser = new TradeUser();
     if (ComFunction.ExistUserLoginID(loginId, ref TdUser) == false)
     {
         return entityBase;
     }
     UserLogEntity userLogEntity = new UserLogEntity();
     userLogEntity.Account = TdUser.Account;
     userLogEntity.DESC = string.Format(@"后台新增用户角色;{0}", TdUser.Account);
     userLogEntity.UserType = (int)TdUser.UType;
     YicelTransaction tran = new YicelTransaction();
     try
     {
         string ipmac = string.Empty;
         if (!string.IsNullOrEmpty(TdUser.Ip))
         {
             ipmac += string.Format("IP={0},", TdUser.Ip);
         }
         if (!string.IsNullOrEmpty(TdUser.Mac))
         {
             ipmac += string.Format("MAC={0},", TdUser.Mac);
         }
         tran.BeginTransaction();
         ComFunction.AddUserRole(userRoleEntity, tran);
         ComFunction.CreateLogEx(userLogEntity,ipmac, tran);
         tran.Commit();
         entityBase.Result = true;
         entityBase.Desc = "用户角色新增成功";
     }
     catch (Exception ex)
     {
         tran.Rollback();
         SetException("用户角色新增失败,原因:", ex);
     }
     return entityBase;
 }
 /// <summary>
 /// 修改用户角色
 /// </summary>
 /// <param name="roleEntity"></param>
 /// <param name="tran"></param>
 /// <returns></returns>
 public static int UpdateUserRole(UserRoleEntity roleEntity, YicelTransaction tran)
 {
     SqlParameter[] parms = new SqlParameter[] {
         new SqlParameter("@userId",roleEntity.UserId),
         new SqlParameter("@RoleID",roleEntity.RoleID)
     };
     StringBuilder strSql = new StringBuilder();
     strSql.AppendFormat(@"UPDATE  Base_UserRole SET  RoleID = @RoleID  WHERE   userId = @userId", Fields.UserRole_FIELD_List);
     object obj = DbHelper.ExecuteNonQuery(strSql.ToString(), parms, tran.Transaction);
     return obj == null || obj == DBNull.Value ? 0 : Convert.ToInt32(obj);
 }
 /// <summary>
 /// 读取用户角色
 /// </summary>
 /// <param name="loginId"></param>
 /// <param name="account"></param>
 /// <returns></returns>
 public UserRoleEntity ReadUserRole(string loginId, string account)
 {
     UserRoleEntity userRoleEntity = new UserRoleEntity();
     if (ComFunction.ExistUserLoginID(loginId) == false)
     {
         userRoleEntity.Result = false;
         userRoleEntity.Desc = ResCode.UL003Desc;
         return userRoleEntity;
     }
     try
     {
         DataTable dt = ComFunction.ReadUserRole(account);
         foreach (DataRow dr in dt.Rows)
         {
             userRoleEntity.UserId = dr["UserID"].ToString();
             userRoleEntity.RoleID = dr["RoleID"].ToString();
         }
         userRoleEntity.Desc = "获取用户角色成功!";
         userRoleEntity.Result = true;
     }
     catch (Exception ex)
     {
         userRoleEntity.Result = false;
         userRoleEntity.Desc = "获取用户角色记录出错,原因:" + ex.ToString();
         ManagerLog.WriteErr(ex);
     }
     return userRoleEntity;
 }
 /// <summary>
 /// 新增用户角色
 /// </summary>
 /// <param name="roleEntity"></param>
 /// <param name="tran"></param>
 /// <returns></returns>
 public static int AddUserRole(UserRoleEntity roleEntity, YicelTransaction tran)
 {
     SqlParameter[] parms = new SqlParameter[] {
         new SqlParameter("@userId",roleEntity.UserId),
         new SqlParameter("@RoleID",roleEntity.RoleID)
     };
     StringBuilder strSql = new StringBuilder();
     strSql.AppendFormat("insert into Base_UserRole({0})", Fields.UserRole_FIELD_List);
     strSql.AppendFormat(" values ({0})", "@" + Fields.UserRole_FIELD_List.Replace(",", ",@"));
     object obj = DbHelper.ExecuteNonQuery(strSql.ToString(), parms, tran.Transaction);
     return obj == null || obj == DBNull.Value ? 0 : Convert.ToInt32(obj);
 }