Exemplo n.º 1
0
        private void button2_Click(object sender, EventArgs e)
        {
            var selectdAccountID = Convert.ToString(listBox1.SelectedItem);

            if (listBox1.SelectedItem == null)
            {
                MessageBox.Show("Please select the account to withdraw from");
            }
            else
            {
                /*dataAccess.InsertData(@"use ApteanEdgeBank update Account
                 * set AccountBalance=AccountBalance+"+Convert.ToString(textBox1.Text)+@"where AccountID =" + selectdAccountID, UserDAO.connectionString);*/
                if (GetAccountType(Convert.ToInt32(selectdAccountID)) == "CA")
                {
                    Account A = new ChequingAccount();
                    A.Withdraw(Convert.ToDouble(textBox2.Text), Convert.ToInt32(selectdAccountID));
                    //MessageBox.Show("Amount withdraw successfull!");
                }
                else if (GetAccountType(Convert.ToInt32(selectdAccountID)) == "TFS")
                {
                    Account A = new TaxFreeSavingsAccount();
                    A.Withdraw(Convert.ToDouble(textBox2.Text), Convert.ToInt32(selectdAccountID));
                    //MessageBox.Show("Amount withdraw successfull!");
                }
                else
                {
                    MessageBox.Show("Amount could not be withdrawn!");
                }
            }

            textBox2.Clear();
        }
Exemplo n.º 2
0
        private void button2_Click(object sender, EventArgs e)
        {
            var selectdAccountID = Convert.ToString(listBox1.SelectedItem);

            if (listBox1.SelectedItem == null)
            {
                MessageBox.Show("Please select the account in which to be Deposited");
            }
            else
            {
                /*dataAccess.InsertData(@"use ApteanEdgeBank update Account
                 * set AccountBalance=AccountBalance+"+Convert.ToString(textBox1.Text)+@"where AccountID =" + selectdAccountID, UserDAO.connectionString);*/
                if (GetAccountType(Convert.ToInt32(selectdAccountID)) == "CA")
                {
                    Account A = new ChequingAccount();
                    A.Deposit(Convert.ToDouble(textBox1.Text), Convert.ToInt32(selectdAccountID));
                    AccountActivityLedger Ledger = new AccountActivityLedger();
                    double newBalance            = Ledger.CalculateAccountBalance(Convert.ToInt32(selectdAccountID));
                    label4.Text = "Balance: $" + Convert.ToString(newBalance);
                    MessageBox.Show("Amount deposited successfully!");
                }
                else if (GetAccountType(Convert.ToInt32(selectdAccountID)) == "TFS")
                {
                    Account A = new TaxFreeSavingsAccount();
                    A.Deposit(Convert.ToDouble(textBox1.Text), Convert.ToInt32(selectdAccountID));
                    //MessageBox.Show("Amount deposited successfully!");
                }
                else
                {
                    MessageBox.Show("Amount could not be deposited");
                }
            }

            textBox1.Clear();
        }
Exemplo n.º 3
0
        private void button2_Click(object sender, EventArgs e)
        {
            var selectdAccountID = Convert.ToString(listBox1.SelectedItem);
            if (listBox1.SelectedItem == null)
            {
                MessageBox.Show("Please select the account in which to be Deposited");
            }
            else
            {
                /*dataAccess.InsertData(@"use ApteanEdgeBank update Account
            set AccountBalance=AccountBalance+"+Convert.ToString(textBox1.Text)+@"where AccountID =" + selectdAccountID, UserDAO.connectionString);*/
                if (GetAccountType(Convert.ToInt32(selectdAccountID)) == "CA")
                {
                    Account A = new ChequingAccount();
                    A.Deposit(Convert.ToDouble(textBox1.Text), Convert.ToInt32(selectdAccountID));
                    AccountActivityLedger Ledger = new AccountActivityLedger();
                    double newBalance = Ledger.CalculateAccountBalance(Convert.ToInt32(selectdAccountID));
                    label4.Text = "Balance: $" + Convert.ToString(newBalance);
                    MessageBox.Show("Amount deposited successfully!");
                }
                else if (GetAccountType(Convert.ToInt32(selectdAccountID)) == "TFS")
                {
                    Account A = new TaxFreeSavingsAccount();
                    A.Deposit(Convert.ToDouble(textBox1.Text), Convert.ToInt32(selectdAccountID));
                    //MessageBox.Show("Amount deposited successfully!");
                }
                else
                {
                    MessageBox.Show("Amount could not be deposited");
                }
            }

            textBox1.Clear();
        }
Exemplo n.º 4
0
        private void button2_Click(object sender, EventArgs e)
        {
            var selectdAccountID = Convert.ToString(listBox1.SelectedItem);
            if (listBox1.SelectedItem == null)
            {
                MessageBox.Show("Please select the account to withdraw from");
            }
            else
            {
                /*dataAccess.InsertData(@"use ApteanEdgeBank update Account
            set AccountBalance=AccountBalance+"+Convert.ToString(textBox1.Text)+@"where AccountID =" + selectdAccountID, UserDAO.connectionString);*/
                if (GetAccountType(Convert.ToInt32(selectdAccountID)) == "CA")
                {
                    Account A = new ChequingAccount();
                    A.Withdraw(Convert.ToDouble(textBox2.Text), Convert.ToInt32(selectdAccountID));
                    //MessageBox.Show("Amount withdraw successfull!");
                }
                else if (GetAccountType(Convert.ToInt32(selectdAccountID)) == "TFS")
                {
                    Account A = new TaxFreeSavingsAccount();
                    A.Withdraw(Convert.ToDouble(textBox2.Text), Convert.ToInt32(selectdAccountID));
                    //MessageBox.Show("Amount withdraw successfull!");
                }
                else
                {
                    MessageBox.Show("Amount could not be withdrawn!");
                }
            }

            textBox2.Clear();
        }
Exemplo n.º 5
0
        private void button2_Click(object sender, EventArgs e)
        {
            if (CustomerAvailabilityCheck())
            {

                CustomerID = Convert.ToInt32(textBox1.Text);
                //AccountID=0;
                if (AccountType == "'CA'")
                {
                    try
                    {
                        ChequingAccount A = new ChequingAccount();
                        bool flag = A.DoesChequingAccountExist(CustomerID);
                        if (flag == false)
                        {
                            AccountID = A.Create(AccountType, DateTime.Now, Convert.ToDouble(textBox2.Text));
                            UserDAO udao = new UserDAO();
                            udao.InsertData("use ApteanEdgeBank insert into CustomerAccount values(" + CustomerID + "," + AccountID + ")", UserDAO.connectionString);
                            MessageBox.Show("Account added successfully!");
                        }
                        else
                        {
                            MessageBox.Show("Chequing account for this cutomer already exists!");
                        }
                    }
                    catch(Exception ex)
                    {
                        MessageBox.Show("Check if the fields are filled properly!");
                    }
                }

                else if (AccountType == "'TFS'")
                {
                    try
                    {
                        TaxFreeSavingsAccount A = new TaxFreeSavingsAccount();
                        bool flag = A.DoesTFSAccountExist(CustomerID);
                        if (flag == false)
                        {
                            AccountID = A.Create(AccountType, DateTime.Now, Convert.ToDouble(textBox2.Text));
                            UserDAO udao = new UserDAO();
                            udao.InsertData("use ApteanEdgeBank insert into CustomerAccount values(" + CustomerID + "," + AccountID + ")", UserDAO.connectionString);
                            MessageBox.Show("Account added successfully!");
                        }
                        else
                        {
                            MessageBox.Show("TFS account for this customer already exists!");
                        }
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show("Check if the fields are filled properly!"+ex);
                    }
                }
                else
                {
                    MessageBox.Show("Not a Valid account Type");
                }
                /*initialBalance = textBox2.Text;

                MessageBox.Show("Account Type is " + AccountType + "For Customer ID " + CustomerID + " With initial Balance " + initialBalance);
                UserDAO udao = new UserDAO();
                DataTable dataTable = new DataTable();
                udao.InsertData("use ApteanEdgeBank insert into Account (AccountType,AccountBalance,DateOfOpening,DateOfClosing) values(" + AccountType + "," + initialBalance + "," + "cast(getdate() as date),null)", UserDAO.connectionString);
                dataTable = udao.GetData("use ApteanEdgeBank select max(AccountID) as max from Account", UserDAO.connectionString);
                AccountID = Convert.ToString(dataTable.Rows[0]["max"]);*/

            }
            else
            {
                MessageBox.Show("Customer Not Fount, Please Create Customer First");
            }
        }
Exemplo n.º 6
0
        private void button2_Click(object sender, EventArgs e)
        {
            if (CustomerAvailabilityCheck())
            {
                CustomerID = Convert.ToInt32(textBox1.Text);
                //AccountID=0;
                if (AccountType == "'CA'")
                {
                    try
                    {
                        ChequingAccount A    = new ChequingAccount();
                        bool            flag = A.DoesChequingAccountExist(CustomerID);
                        if (flag == false)
                        {
                            AccountID = A.Create(AccountType, DateTime.Now, Convert.ToDouble(textBox2.Text));
                            UserDAO udao = new UserDAO();
                            udao.InsertData("use ApteanEdgeBank insert into CustomerAccount values(" + CustomerID + "," + AccountID + ")", UserDAO.connectionString);
                            MessageBox.Show("Account added successfully!");
                        }
                        else
                        {
                            MessageBox.Show("Chequing account for this cutomer already exists!");
                        }
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show("Check if the fields are filled properly!");
                    }
                }

                else if (AccountType == "'TFS'")
                {
                    try
                    {
                        TaxFreeSavingsAccount A = new TaxFreeSavingsAccount();
                        bool flag = A.DoesTFSAccountExist(CustomerID);
                        if (flag == false)
                        {
                            AccountID = A.Create(AccountType, DateTime.Now, Convert.ToDouble(textBox2.Text));
                            UserDAO udao = new UserDAO();
                            udao.InsertData("use ApteanEdgeBank insert into CustomerAccount values(" + CustomerID + "," + AccountID + ")", UserDAO.connectionString);
                            MessageBox.Show("Account added successfully!");
                        }
                        else
                        {
                            MessageBox.Show("TFS account for this customer already exists!");
                        }
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show("Check if the fields are filled properly!" + ex);
                    }
                }
                else
                {
                    MessageBox.Show("Not a Valid account Type");
                }

                /*initialBalance = textBox2.Text;
                 *
                 * MessageBox.Show("Account Type is " + AccountType + "For Customer ID " + CustomerID + " With initial Balance " + initialBalance);
                 * UserDAO udao = new UserDAO();
                 * DataTable dataTable = new DataTable();
                 * udao.InsertData("use ApteanEdgeBank insert into Account (AccountType,AccountBalance,DateOfOpening,DateOfClosing) values(" + AccountType + "," + initialBalance + "," + "cast(getdate() as date),null)", UserDAO.connectionString);
                 * dataTable = udao.GetData("use ApteanEdgeBank select max(AccountID) as max from Account", UserDAO.connectionString);
                 * AccountID = Convert.ToString(dataTable.Rows[0]["max"]);*/
            }
            else
            {
                MessageBox.Show("Customer Not Fount, Please Create Customer First");
            }
        }