using Mesnac.Codd.Session; using System; using System.Collections.Generic; using System.Data; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Mesnac.Action.Default.Purview.BasUser { public class UserHelper { #region 获取所有用户信息 /// /// 获取所有用户信息 /// /// /// public static DataTable GetUserListForSelect() { try { DbHelper dbHelper = Mesnac.Basic.DataSourceFactory.Instance.GetDbHelper(Mesnac.Basic.DataSourceFactory.MCDbType.Local); if (dbHelper == null) { throw new Exception(Mesnac.Basic.LanguageHelper.DataBaseConnectError); } dbHelper.ClearParameter(); dbHelper.CommandType = CommandType.Text; string strSql = "SELECT TA.*,TB.RoleName FROM BasUser TA LEFT JOIN BasRole TB ON TA.RoleGUID=TB.GUID ORDER BY TA.SeqIndex"; dbHelper.CommandText = strSql; DataTable table = dbHelper.ToDataTable(); if (table != null && table.Rows.Count > 0) { return table; } return null; } catch (Exception) { return null; } } public static void UpdateUser(BasUserModel user) { try { DbHelper dbHelper = Mesnac.Basic.DataSourceFactory.Instance.GetDbHelper(Mesnac.Basic.DataSourceFactory.MCDbType.Local); if (dbHelper == null) { throw new Exception(Mesnac.Basic.LanguageHelper.DataBaseConnectError); } dbHelper.ClearParameter(); dbHelper.CommandType = CommandType.Text; string strSql = "UPDATE BasUser SET UserName=@UName, UserPWD=@UPwd, RealName=@URoleName,RoleGUID=@URoleID WHERE GUID=@UID"; dbHelper.CommandText = strSql; dbHelper.AddParameter("@UName", user.UserName); dbHelper.AddParameter("@UPwd", user.UserPWD); dbHelper.AddParameter("@URoleName", user.RealName); dbHelper.AddParameter("@URoleID", user.RoleGUID); dbHelper.AddParameter("@UID", user.UID); dbHelper.ExecuteNonQuery(); } catch (Exception ex) { ICSharpCode.Core.LoggingService.Error("修改用户信息异常:" + ex.Message, ex); } } #endregion } }