Exemple #1
0
        private int AddAccount(int acctType, int customerID, decimal balance = 0)
        {
            int accountID = 0;

            using (DataClasses1DataContext dbml = new DataClasses1DataContext())
            {
                try
                {
                    Account acct = new Account();
                    acct.AccountType = acctType;
                    acct.Balance     = balance;

                    dbml.Accounts.InsertOnSubmit(acct);
                    dbml.SubmitChanges();

                    accountID = acct.AccountID;

                    CustomersInAccount cia = new CustomersInAccount();
                    cia.CustomerID = customerID;
                    cia.AccountID  = accountID;

                    dbml.CustomersInAccounts.InsertOnSubmit(cia);
                    dbml.SubmitChanges();
                }
                catch
                {
                    accountID = -1;
                    // future- error code for account problems
                }
                return(accountID);
            }
        }
Exemple #2
0
        private int AddCustomerToAccount(int accountID, int customerID)
        {
            int ciaID;

            using (DataClasses1DataContext dbml = new DataClasses1DataContext())
            {
                CustomersInAccount cia = new CustomersInAccount();
                cia.CustomerID = customerID;
                cia.AccountID  = accountID;

                dbml.CustomersInAccounts.InsertOnSubmit(cia);
                dbml.SubmitChanges();
                ciaID = cia.CustomersInAccountID;
            }
            return(ciaID);
        }