Exemplo n.º 1
0
        public decimal GetBalance(IAccount account)
        {
            account = new HomeLoanAccount();
            decimal bal = account.Balance;

            return(bal);
        }
Exemplo n.º 2
0
        public IAccount OpenHomeLoanAccount(string customerName, DateTimeOffset openedDate)
        {
            IAccount homeLoan = new HomeLoanAccount();

            DataTable        dt   = new DataTable();
            SQLiteConnection conn = new SQLiteConnection(this.source);

            conn.Open();

            //in order to generate account number
            //we need to keep track of the number of account in the db
            String            homeQuery = "UPDATE accountType SET counter = counter + 1 where name='homeLoan'";
            SQLiteDataAdapter sda       = new SQLiteDataAdapter(homeQuery, conn);

            sda.Fill(dt);
            dt.Clear();

            //now select the last element in the db
            //so we can assign the account number correctly
            homeQuery = "SELECT counter FROM accountType where name='homeLoan' ";
            SQLiteDataAdapter da = new SQLiteDataAdapter(homeQuery, conn);

            da.Fill(dt);
            int number = Int32.Parse(dt.Rows[0].ItemArray[0].ToString());

            //gather the account number
            string code      = "LN";
            string accountNo = accNoGenerator(code, number);

            Console.WriteLine(accountNo);
            dt.Clear();
            string date = DateTime.Now.ToString();

            //insert new account into the db
            homeQuery = "Insert into account(dateOpened, accountNumber, balance, customerName) " +
                        "values ('" + date + "', '" + accountNo + "', '" + 0.0 + "', '" + customerName + "')";
            SQLiteDataAdapter newDa = new SQLiteDataAdapter(homeQuery, conn);

            newDa.Fill(dt);
            Response.Redirect("AccountLister");
            return(homeLoan);
        }