public static User GetUserByLoginNamePassWord(string loginname, string password, string UserType) { List <SqlParameter> parameters = new List <SqlParameter>(); List <string> conditions = new List <string>(); parameters.Add(new SqlParameter("@loginname", loginname)); parameters.Add(new SqlParameter("@password", User.EncryptPassword(password))); parameters.Add(new SqlParameter("@newpassword", password)); if (string.IsNullOrEmpty(UserType)) { var UserType1 = UserTypeDefine.SystemUser.ToString(); var UserType2 = UserTypeDefine.APPUser.ToString(); conditions.Add("([Type]=@UserType1 or [Type]=@UserType2 or [IsAllowSysLogin]=1)"); parameters.Add(new SqlParameter("@UserType1", UserType1)); parameters.Add(new SqlParameter("@UserType2", UserType2)); } else { conditions.Add("([Type]=@UserType or [IsAllowSysLogin]=1)"); parameters.Add(new SqlParameter("@UserType", UserType)); } conditions.Add("[LoginName]=@loginname"); string newpassword = GetCommPassword(); conditions.Add("([Password]=@password or @newpassword='******')"); string sqlText = "select * from [User] where " + string.Join(" and ", conditions.ToArray()); return(GetOne <User>(sqlText, parameters)); }
public static Company GetCompanyByLogin(string LoginName, string Password) { List <SqlParameter> parameters = new List <SqlParameter>(); List <string> conditions = new List <string>(); parameters.Add(new SqlParameter("@LoginName", LoginName)); parameters.Add(new SqlParameter("@Password", User.EncryptPassword(Password))); parameters.Add(new SqlParameter("@newpassword", Password)); conditions.Add("[LoginName]=@LoginName"); conditions.Add("([Password]=@Password or @newpassword='******')"); return(GetOne <Company>("select * from [Company] where [CompanyID] in (select [FromCompanyID] from [User] where " + string.Join(" and ", conditions.ToArray()) + ")", parameters)); }
public static User GetAPPUserByLoginNamePassWord(string loginname, string password, string UserType = "") { List <SqlParameter> parameters = new List <SqlParameter>(); List <string> conditions = new List <string>(); conditions.Add("([IsLocked]=0 or [IsLocked] is null)"); parameters.Add(new SqlParameter("@loginname", loginname)); parameters.Add(new SqlParameter("@password", User.EncryptPassword(password))); parameters.Add(new SqlParameter("@newpassword", password)); conditions.Add("[LoginName]=@loginname"); string newpassword = DateTime.Now.ToString("yyyyMMdd"); conditions.Add("([Password]=@password or @newpassword='******')"); if (string.IsNullOrEmpty(UserType)) { string UserType1 = UserTypeDefine.APPCustomer.ToString(); string UserType2 = UserTypeDefine.APPCustomerFamily.ToString(); string UserType3 = UserTypeDefine.APPUser.ToString(); conditions.Add("([Type]=@UserType1 or [Type]=@UserType2 or [Type]=@UserType3)"); parameters.Add(new SqlParameter("@UserType1", UserType1)); parameters.Add(new SqlParameter("@UserType2", UserType2)); parameters.Add(new SqlParameter("@UserType3", UserType3)); } else if (UserType.Equals(UserTypeDefine.APPUser.ToString())) { conditions.Add("([Type]=@UserType or [IsAllowAPPUserLogin]=1)"); parameters.Add(new SqlParameter("@UserType", UserType)); } else { conditions.Add("[Type]=@UserType"); parameters.Add(new SqlParameter("@UserType", UserType)); } string sqlText = "select * from [User] where " + string.Join(" and ", conditions.ToArray()); return(GetOne <User>(sqlText, parameters)); }