public static Account_TypeDAO GetSelf() { if (self == null) { self = new Account_TypeDAO(); } return(self); }
// SELECT /* ExecuteSelect function for Account */ /// <summary> /// Retrieves data from Account table and saves in a List. /// </summary> public List <Account> ExecuteReader_Account(string query, List <MySqlParameter> parameters) { conn = new MySqlConnection(connectionString); comm = new MySqlCommand(query, conn); if (parameters.Count() > 0) { foreach (MySqlParameter p in parameters) { comm.Parameters.AddWithValue(p.ParameterName, p.Value); } } List <Account> result = new List <Account>(); try { using (MySqlDataReader reader = comm.ExecuteReader()) { while (reader.Read()) { Account newAcc = new Account(); newAcc.idAccount = reader.GetInt32("idAccount"); newAcc.nameAccount = reader.GetString("nameAccount"); newAcc.balanceAmount = reader.GetDouble("balanceAccount"); newAcc.memoAccount = reader.GetString("memoAccount"); newAcc.accountType = Account_TypeDAO.GetAccountTypeById(reader.GetInt32("accountType")); result.Add(newAcc); } } } catch (Exception Ex) { throw new Exception("An error ocurred.Description: " + Ex.Message); } finally { conn.Close(); } if (result.Count() > 0) { return(result); } return(null); }