private static IList <RcUsers> LoadListFromReader(IDataReader reader) { IList <RcUsers> rcUsersList = new List <RcUsers>(); try { while (reader.Read()) { RcUsers rcUsers = new RcUsers(); rcUsers.Id = Convert.ToInt32(reader["Id"]); rcUsers.UserID = reader["UserID"].ToString(); rcUsers.Name = reader["Name"].ToString(); rcUsers.Password = reader["Password"].ToString(); rcUsers.Declaring = reader["Declaring"].ToString(); rcUsers.Status = Convert.ToInt32(reader["Status"]); rcUsers.GroupID = Convert.ToInt32(reader["GroupID"]); rcUsers.IsMale = Convert.ToBoolean(reader["IsMale"]); rcUsers.UserLevel = Convert.ToInt32(reader["UserLevel"]); rcUsers.Enabled = Convert.ToBoolean(reader["Enabled"]); rcUsers.RegisterTime = Convert.ToDateTime(reader["RegisterTime"]); rcUsers.LastLoginTime = Convert.ToDateTime(reader["LastLoginTime"]); rcUsersList.Add(rcUsers); } } finally { reader.Close(); } return(rcUsersList); }
/// <summary> /// Saves this instance of RcUsers. Returns true on success. /// </summary> /// <returns>bool</returns> public static bool Save(RcUsers rcUsers) { if (rcUsers.Id > 0) { return(Update(rcUsers)); } else { return(Create(rcUsers)); } }
//更改用户密码 public static string ChangePassword(string userId, string oldPassword, string newPassword) { RcUsers theUser = GetByUserID(userId); if (theUser.Password == oldPassword) { DBRcUsers.ChangePwd(userId, newPassword); return("success"); } else { return("修改密码不成功"); } }
/// <summary> /// Updates this instance of RcUsers. Returns true on success. /// </summary> /// <returns>bool</returns> private static bool Update(RcUsers rcUsers) { return(DBRcUsers.Update( rcUsers.Id, rcUsers.UserID, rcUsers.Name, rcUsers.Password, rcUsers.Declaring, rcUsers.Status, rcUsers.GroupID, rcUsers.IsMale, rcUsers.UserLevel, rcUsers.Enabled, rcUsers.RegisterTime, rcUsers.LastLoginTime)); }
/// <summary> /// Persists a new instance of RcUsers. Returns true on success. /// </summary> /// <returns></returns> private static bool Create(RcUsers rcUsers) { int newID = 0; newID = DBRcUsers.Create( rcUsers.UserID, rcUsers.Name, rcUsers.Password, rcUsers.Declaring, rcUsers.Status, rcUsers.GroupID, rcUsers.IsMale, rcUsers.UserLevel, rcUsers.Enabled, rcUsers.RegisterTime, rcUsers.LastLoginTime); rcUsers.Id = newID; return(newID > 0); }
private static RcUsers PopulateFromReader(IDataReader reader) { RcUsers rcUsers = new RcUsers(); if (reader.Read()) { rcUsers.Id = Convert.ToInt32(reader["Id"]); rcUsers.UserID = reader["UserID"].ToString(); rcUsers.Name = reader["Name"].ToString(); rcUsers.Password = reader["Password"].ToString(); rcUsers.Declaring = reader["Declaring"].ToString(); rcUsers.Status = Convert.ToInt32(reader["Status"]); rcUsers.GroupID = Convert.ToInt32(reader["GroupID"]); rcUsers.IsMale = Convert.ToBoolean(reader["IsMale"]); rcUsers.UserLevel = Convert.ToInt32(reader["UserLevel"]); rcUsers.Enabled = Convert.ToBoolean(reader["Enabled"]); rcUsers.RegisterTime = Convert.ToDateTime(reader["RegisterTime"]); rcUsers.LastLoginTime = Convert.ToDateTime(reader["LastLoginTime"]); } return(rcUsers); }
public static UserLoginContract Login(string userId, string password) { UserContract newContract = new UserContract(); UserLoginContract loginContract = new UserLoginContract(); using (IDataReader reader = DBRcUsers.GetOneByUserID(userId)) { string theResult = "登录不成功"; RcUsers theUser = PopulateFromReader(reader); if (theUser == null) { theResult = "用户不存在"; } else if (theUser.Password == password) { theResult = "success"; newContract.UserID = theUser.UserID; newContract.Name = theUser.Name; newContract.Declaring = theUser.Declaring; newContract.IsMale = theUser.IsMale; newContract.OnLine = true; } else { theResult = "密码不正确"; //密码不正确 } loginContract.Message = theResult; loginContract.UserContract = newContract; return(loginContract); } }