示例#1
0
        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;
        }
示例#2
0
        // 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;
        }
示例#3
0
        // 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;
        }
示例#4
0
        // 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;
            }
        }
示例#5
0
        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;
            }
        }
示例#6
0
 public Bank SearchBank(Bank b)
 {
     return SearchBank(b.ID);
 }
示例#7
0
 // Finds Transactions with the specified details in the bank object.
 public List<Transaction> SearchTransactions(Bank b)
 {
     throw new NotImplementedException();
 }