public static LoginResult Login(string account, string password, out User loginUser) { loginUser = null; using (StoreAccess access = new StoreAccess()) { try { User user = access.Login(account, password); if (user == null) { return(LoginResult.ValidateError); } else { loginUser = user; return(LoginResult.Success); } } catch (DbException err) { return(LoginResult.NetError); } finally { access.Close(); } } }