//tested public AccountInfo GetAccountInfo(string userID, string applicationID) { AccountInfo foundAccountInfo = null; if (userID != null && applicationID != null) { string sql = "select * from [tb_AccountInfo] where [UserID]=@userid and [ApplicationID]=@appid"; SqlCommand sc = new SqlCommand(sql); sc.Parameters.AddWithValue("@userid", userID); sc.Parameters.AddWithValue("@appid", applicationID); DataTable dtinfo = da.GetDataTable(sql, sc); if (dtinfo != null && dtinfo.Rows != null && dtinfo.Rows.Count > 0) { DataRowWrapper rowWrapper = new DataRowWrapper(dtinfo.Rows[0]); foundAccountInfo = new AccountInfo(); foundAccountInfo.ApplicationID = applicationID; foundAccountInfo.UserID = userID; foundAccountInfo.UserName = rowWrapper.GetColumnValueAsString("UserName"); foundAccountInfo.AccountType = (AccountType)rowWrapper.GetEnumColumnValue("AccountType", typeof(AccountType)); foundAccountInfo.Locked = rowWrapper.GetColumnValueAsBool("Locked"); foundAccountInfo.LockedDate = dtinfo.Rows[0]["LockedDate"].ToString() != "" ? Convert.ToDateTime(dtinfo.Rows[0]["LockedDate"].ToString()) : Convert.ToDateTime("1900-01-01"); foundAccountInfo.LockedDateSpecified = (foundAccountInfo.LockedDate.ToString("yyyy-MM-dd") == "1900-01-01") ? false : true; foundAccountInfo.LockCode = rowWrapper.GetColumnValueAsString("LockCode"); foundAccountInfo.ExpiryTime = dtinfo.Rows[0]["ExpiryTime"].ToString() != "" ? Convert.ToDateTime(dtinfo.Rows[0]["ExpiryTime"].ToString()) : Convert.ToDateTime("1900-01-01"); foundAccountInfo.ExpiryTimeSpecified = (foundAccountInfo.ExpiryTime.ToString("yyyy-MM-dd") == "1900-01-01") ? false : true; foundAccountInfo.PaymentInfo = rowWrapper.GetTypedColumnValue("PaymentInfo", typeof(PaymentInfo)) as PaymentInfo; foundAccountInfo.DeviceInfoList = rowWrapper.GetTypedColumnValue("DeviceInfos", typeof(DeviceInfoList)) as DeviceInfoList; } } return foundAccountInfo; }
//tested public UserAccountInfo GetUserAccountInfo(string userID) { UserAccountInfo foundAccountInfo = null; if (!string.IsNullOrEmpty(userID)) { DataTable dtuser = GetUserAccountInfoDT(userID, null, null, false); if (dtuser != null && dtuser.Rows != null && dtuser.Rows.Count > 0) { foundAccountInfo = new UserAccountInfo(); try { foundAccountInfo.UserID = userID; DataRowWrapper rowWrapper = new DataRowWrapper(dtuser.Rows[0]); foundAccountInfo.UserName = rowWrapper.GetColumnValueAsString("UserName"); foundAccountInfo.Password = rowWrapper.GetTypedColumnValue("Password", typeof(Password)) as Password; foundAccountInfo.ChangedPassword = rowWrapper.GetTypedColumnValue("ChangedPassword", typeof(Password)) as Password; foundAccountInfo.EmailAddress = rowWrapper.GetColumnValueAsString("EmailAddress"); foundAccountInfo.AccountType = (AccountType)rowWrapper.GetEnumColumnValue("AccountType", typeof(AccountType)); foundAccountInfo.VipPaymentInfo = rowWrapper.GetTypedColumnValue("VipPaymentInfo", typeof(PaymentInfo)) as PaymentInfo; foundAccountInfo.Activated = rowWrapper.GetColumnValueAsBool("Activated"); foundAccountInfo.Suspended = rowWrapper.GetColumnValueAsBool("Suspended"); } catch (Exception ex) { } } } return foundAccountInfo; }