public int CreateBank(Bank b) { int ret = 0; using (connect = new MySqlConnection(_connectionString)) { connect.Open(); using (MySqlTransaction transaction = connect.BeginTransaction()) { try { string query = "NewBank"; var cmd = new MySqlCommand(query, connect) { CommandType = CommandType.StoredProcedure }; cmd.Parameters.AddWithValue("SortCode", b.SortCode); cmd.Parameters.AddWithValue("AccountNumber", b.ID); ret = int.Parse(cmd.ExecuteScalar().ToString()); transaction.Commit(); connect.Close(); } catch (InvalidOperationException ioException) { transaction.Rollback(); connect.Close(); } } } return ret; }
// Creates a bank public int create( String sortCode, int accountNumber) { // Establishes model BankingModel bankModel = new BankingModel(); // Holds the new bank Bank newBank = new Bank(); // Stored details for the bank newBank.SortCode = sortCode; newBank.AccountNumber = accountNumber; // Creates the bank int bankID = bankModel.CreateBank(newBank); // Returns created bank return bankID; }
// Creates an account public int create(int accountTypeID, int bankID, int customerID, int contactID) { // Establishes model AccountModel accountModel = new AccountModel(); // Holds the new account Account newAccount = new Account(); Account_Type accountType = new Account_Type(); Bank newBank = new Bank(); // Stored details for the account newAccount.CustomerID = customerID; newAccount.ContactID = contactID; newAccount.AccountTypeID = accountTypeID; newAccount.BankID = bankID; // Creates the account int accountID = accountModel.CreateAccount(newAccount); // Returns accountID return accountID; }
// Due to the transaction we don't change banks we add new ones //public int EditBank(Bank b) // Due to the transaction we don't delete banks we add new ones //public void DeleteBank(Bank b) public List<Bank> ListBanking() { var bankList = new List<Bank>(); using (connect = new MySqlConnection(_connectionString)) { try { string query = "ListBank"; var cmd = new MySqlCommand(query, connect) { CommandType = CommandType.StoredProcedure }; connect.Open(); var reader = cmd.ExecuteReader(); while (reader.Read()) { var b = new Bank(); b.ID = int.Parse(reader["Banking_ID"].ToString()); b.Address_ID = int.Parse(reader["Address_ID"].ToString()); b.SortCode = reader["Sort_Code"].ToString(); b.AccountNumber = int.Parse(reader["Account_Number"].ToString()); bankList.Add(b); } connect.Close(); } catch (InvalidOperationException ioException) { connect.Close(); } return bankList; } }
public Bank SearchBanking(Customer c) { var bank = new Bank(); using (connect = new MySqlConnection(_connectionString)) { try { string query = "SearchBankingCustomer"; var cmd = new MySqlCommand(query, connect) { CommandType = CommandType.StoredProcedure }; cmd.Parameters.AddWithValue("CustomerID", c.ID); cmd.Parameters.AddWithValue("CustomerName", c.Name); cmd.Parameters.AddWithValue("AddressID", c.Address_ID); connect.Open(); var reader = cmd.ExecuteReader(); while (reader.Read()) { bank.ID = int.Parse(reader["Banking_ID"].ToString()); bank.Address_ID = int.Parse(reader["Address_ID"].ToString()); bank.SortCode = reader["Sort_Code"].ToString(); bank.AccountNumber = int.Parse(reader["Account_Number"].ToString()); } connect.Close(); } catch (InvalidOperationException ioException) { connect.Close(); } return bank; } }
public Bank SearchBank(Bank b) { return SearchBank(b.ID); }
// Finds Transactions with the specified details in the bank object. public List<Transaction> SearchTransactions(Bank b) { throw new NotImplementedException(); }