public static LoginMessage queryLogin(LoginModel loginModel) { LoginMessage loginMessage = new LoginMessage(); zAccountDetailModel zAccountDetailModel = new zAccountDetailModel(); ReturnStatusModel returnStatusModel = new ReturnStatusModel(); string CommandText = "SELECT * " + "FROM zAccount_Detail " + "WHERE " + "account_username = '******' " + "AND account_password ='******'"; sqlConnection.Open(); sqlCommand = sqlConnection.CreateCommand(); using (SQLiteCommand cmd = new SQLiteCommand(CommandText, DatabaseConnection.sqlConnection)) { using (SQLiteDataReader rdr = cmd.ExecuteReader()) { if (rdr.HasRows != false) { while (rdr.Read()) { zAccountDetailModel.account_id = (rdr["account_id"].ToString()); zAccountDetailModel.account_username = (rdr["account_username"].ToString()); zAccountDetailModel.account_password = (rdr["account_password"].ToString()); zAccountDetailModel.account_created_date = (rdr["account_created_date"].ToString()); zAccountDetailModel.account_created_by = (rdr["account_created_by"].ToString()); zAccountDetailModel.account_firstname = (rdr["account_firstname"].ToString()); zAccountDetailModel.account_lastname = (rdr["account_lastname"].ToString()); zAccountDetailModel.account_lastlogin_time = (rdr["account_lastlogin_time"].ToString()); zAccountDetailModel.account_lastlogin_date = (rdr["account_lastlogin_date"].ToString()); zAccountDetailModel.account_language_default = (rdr["account_language_default"].ToString()); zAccountDetailModel.account_role_id = (rdr["account_role_id"].ToString()); zAccountDetailModel.account_expire_date = (rdr["account_expire_date"].ToString()); zAccountDetailModel.account_status = (rdr["account_status"].ToString()); } returnStatusModel.status = true; returnStatusModel.error_message = Messages.m_login_success; } else { returnStatusModel.status = false; returnStatusModel.error_message = Messages.m_user_or_pass_inc; } } } loginMessage.zAccountDetailModel = zAccountDetailModel; loginMessage.returnStatusModel = returnStatusModel; sqlConnection.Close(); return(loginMessage); }
public static LoginMessage queryLoginUsername(LoginModel loginModel) { LoginMessage loginMessage = new LoginMessage(); zAccountDetailModel zAccountDetailModel = new zAccountDetailModel(); ReturnStatusModel returnStatusModel = new ReturnStatusModel(); string CommandText = "SELECT account_username " + "FROM zAccount_Detail " + "WHERE " + "account_username = '******'"; sqlConnection.Open(); sqlCommand = sqlConnection.CreateCommand(); using (SQLiteCommand cmd = new SQLiteCommand(CommandText, DatabaseConnection.sqlConnection)) { using (SQLiteDataReader rdr = cmd.ExecuteReader()) { if (rdr.HasRows != false && rdr.Read()) { zAccountDetailModel.account_username = (rdr["account_username"].ToString()); returnStatusModel.status = false; returnStatusModel.error_message = Messages.m_pass_inc; } else { returnStatusModel.status = false; returnStatusModel.error_message = Messages.m_user_not_exist; } } } loginMessage.zAccountDetailModel = zAccountDetailModel; loginMessage.returnStatusModel = returnStatusModel; sqlConnection.Close(); return(loginMessage); }