Example #1
0
        public int CreateAccountType(Account_Type a)
        {
            int ret = 0;
            using (connect = new MySqlConnection(_connectionString))
            {
                connect.Open();
                using (MySqlTransaction transaction = connect.BeginTransaction())
                {
                    try
                    {
                        string query = "NewAccountType";
                        var cmd = new MySqlCommand(query, connect) { CommandType = CommandType.StoredProcedure };

                        cmd.Parameters.AddWithValue("AccountName", a.Name);
                        cmd.Parameters.AddWithValue("PBenifit", a.Benefit);
                        cmd.Parameters.AddWithValue("PCost", a.Cost);

                        ret = int.Parse(cmd.ExecuteScalar().ToString());

                        transaction.Commit();

                        connect.Close();
                    }
                    catch (InvalidOperationException ioException)
                    {
                        transaction.Rollback();
                        connect.Close();
                    }
                }
            }
            return ret;
        }
Example #2
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;
        }
Example #3
0
        public void EditAccount(Account_Type a)
        {
            using (connect = new MySqlConnection(_connectionString))
            {
                connect.Open();
                using (MySqlTransaction transaction = connect.BeginTransaction())
                {
                    try
                    {
                        string query = "EditAccountType";
                        var cmd = new MySqlCommand(query, connect) { CommandType = CommandType.StoredProcedure };

                        cmd.Parameters.AddWithValue("AccountTypeID", a.ID);
                        cmd.Parameters.AddWithValue("AccountName", a.Name);
                        cmd.Parameters.AddWithValue("PBenifit", a.Benefit);
                        cmd.Parameters.AddWithValue("PCost", a.Cost);

                        cmd.ExecuteNonQuery();

                        transaction.Commit();

                        connect.Close();
                    }
                    catch (InvalidOperationException ioException)
                    {
                        transaction.Rollback();
                        connect.Close();
                    }
                }
            }
        }
Example #4
0
 public Account_Type SearchAccountType(Account_Type a)
 {
     return SearchAccountType(a.ID);
 }
Example #5
0
        // The main method to get a user account.
        public Account_Type SearchAccountType(int ID)
        {
            var accountT = new Account_Type();

            using (connect = new MySqlConnection(_connectionString))
            {
                try
                {
                    string query = "GetAccountType";
                    var cmd = new MySqlCommand(query, connect) { CommandType = CommandType.StoredProcedure };

                    cmd.Parameters.AddWithValue("AccountTypeID", ID);
                    connect.Open();

                    var reader = cmd.ExecuteReader();
                    while (reader.Read())
                    {
                        accountT.ID = int.Parse(reader["Account_Type_ID "].ToString());
                        accountT.Name = reader["Account_Name"].ToString();
                        accountT.Benefit = reader["Benefit"].ToString();
                        accountT.Cost = decimal.Parse(reader["Cost "].ToString());
                    }

                    connect.Close();
                }
                catch (InvalidOperationException ioException)
                {
                    connect.Close();
                }

                return accountT;
            }
        }
Example #6
0
        public List<Account_Type> ListAccounts()
        {
            var accountList = new List<Account_Type>();

            using (connect = new MySqlConnection(_connectionString))
            {
                try
                {
                    string query = "ListAccountType";
                    var cmd = new MySqlCommand(query, connect) { CommandType = CommandType.StoredProcedure };

                    connect.Open();

                    var reader = cmd.ExecuteReader();
                    while (reader.Read())
                    {
                        var accountType = new Account_Type();
                        accountType.ID = int.Parse(reader["Account_Type_ID"].ToString());
                        accountType.Name = reader["Account_Name"].ToString();
                        accountType.Benefit = reader["Benefit"].ToString();
                        accountType.Cost = decimal.Parse(reader["Cost"].ToString());

                        accountList.Add(accountType);
                    }

                    connect.Close();
                }
                catch (InvalidOperationException ioException)
                {
                    connect.Close();
                }

                return accountList;
            }
        }
Example #7
0
 // Changes the customer specifed by the customer object account type to the Account_Type object.
 public void ChangeAccountType(Customer c, Account_Type type)
 {
     throw new NotImplementedException();
 }
Example #8
0
 // Gets a list of accounts by the values speicifed in the account_type object.
 public List<Account> SearchAccounts(Account_Type at)
 {
     throw new NotImplementedException();
 }