//获取好友 private static IList <UserContract> LoadUserContractList(IDataReader reader) { IList <UserContract> rcUsersList = new List <UserContract>(); try { while (reader.Read()) { UserContract rcUsers = new UserContract(); rcUsers.UserID = reader["UserID"].ToString(); rcUsers.Name = reader["Name"].ToString(); rcUsers.Declaring = reader["Declaring"].ToString(); rcUsers.IsMale = Convert.ToBoolean(reader["IsMale"]); rcUsers.OnLine = false; rcUsersList.Add(rcUsers); } } finally { reader.Close(); } return(rcUsersList); }
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); } }
public UserLoginContract(string message, UserContract userContract) { this.Message = message; this.UserContract = userContract; }