Ejemplo n.º 1
0
        public void accountCreation()
        {
            int num;

            do
            {
                Console.Write("\nEnter Account Number:\n");
                string An = Console.ReadLine();

                Console.Write("\nEnter Account Title:\n");
                string At = Console.ReadLine();

                Console.Write("\nEnter CNIC:\n");
                string cnic = Console.ReadLine();

                Console.Write("\nEnter Contact Number:\n");
                string cn = Console.ReadLine();

                Console.Write("\nEnter Account Balance:\n");
                double bal = double.Parse(Console.ReadLine());

                Console.Write("\nChoose Account Type:\n");
                Console.Write("1.Saving Account.    2.Current Account.\n");
                int option = int.Parse(Console.ReadLine());

                if (option == 1)
                {
                    Console.WriteLine("\nEnter Profit Percentage:");
                    float pp = float.Parse(Console.ReadLine());

                    savingAccount savingAcc = new savingAccount(An, At, cnic, cn, bal, pp);
                    manager.createNewSavingAccount(savingAcc);
                }
                if (option == 2)
                {
                    Console.WriteLine("\nEnter Withdrawal Limit:");
                    double wl = double.Parse(Console.ReadLine());

                    currentAccount currentAcc = new currentAccount(An, At, cnic, cn, bal, wl);
                    manager.createNewCurrentAccount(currentAcc);
                }
                Console.WriteLine("\nPress 1 to continue creation of Accounts.");
                num = int.Parse(Console.ReadLine());
            }while (num == 1);
            manager.writeAllinFile();
        }
Ejemplo n.º 2
0
        public void writeAllCurrentAccount(List <currentAccount> ca)
        {
            StreamWriter writeCurrent = new StreamWriter("CurrentAccount.txt"); //write to file object
            int          totalAccount = ca.Count;

            for (int i = 0; i < totalAccount; i++)
            {
                currentAccount account = ca[i];
                writeCurrent.WriteLine(account.accountNoProperty);
                writeCurrent.WriteLine(account.accountTitleProperty);
                writeCurrent.WriteLine(account.balanceProperty);
                writeCurrent.WriteLine(account.cnicProperty);
                writeCurrent.WriteLine(account.contactNoProperty);
                writeCurrent.WriteLine(account.withdrawalLimitProperty);
            }
            writeCurrent.Close();
        }
Ejemplo n.º 3
0
        public List <currentAccount> readAllCurrentAccount()
        {
            StreamReader          read           = new StreamReader("CurrentAccount.txt"); //read from file object
            List <currentAccount> currentAccount = new List <currentAccount>();
            currentAccount        ca             = null;

            while (!read.EndOfStream)
            {
                string Ac   = read.ReadLine();
                string At   = read.ReadLine();
                double bal  = double.Parse(read.ReadLine());
                string cnic = read.ReadLine();
                string cn   = read.ReadLine();
                double wl   = double.Parse(read.ReadLine());
                ca = new currentAccount(Ac, At, cnic, cn, bal, wl);
                currentAccount.Add(ca);
            }
            read.Close();
            return(currentAccount);
        }
Ejemplo n.º 4
0
        public void transaction()
        {
            Console.Write("\nChoose Account Type:\n");
            Console.Write("1.Current Account.   2.Saving Account.\n");
            int num = int.Parse(Console.ReadLine());

            if (num == 1)
            {
                Console.WriteLine("\nEnter Account Number:");
                string accnum = Console.ReadLine();

                accountFile           obj      = new accountFile();
                List <currentAccount> accounts = obj.readAllCurrentAccount(); //simple list: saves same type of objects
                int  totalAccounts             = accounts.Count;              //built-in count list function
                bool found = false;

                for (int i = 0; i < totalAccounts; i++)
                {
                    if (accounts[i].accountNoProperty == accnum)
                    {
                        found = true;
                        Console.WriteLine("\nAccount Found.\n");

                        Console.Write("\nChoose Transaction Type:\n");
                        Console.Write("1.Deposit Amount.   2.Withdraw Amount.\n");
                        int option = int.Parse(Console.ReadLine());

                        if (option == 1)
                        {
                            Console.Write("Enter Deposit Amount:\n");
                            int depositAmount = int.Parse(Console.ReadLine());
                            accounts[i].balanceProperty = (accounts[i].balanceProperty + depositAmount);
                            accounts[i].deposit(depositAmount);
                        }
                        if (option == 2)
                        {
                            Console.Write("Enter Withdrawal Amount:\n");
                            int withdrawalAmount = int.Parse(Console.ReadLine());
                            if (withdrawalAmount <= accounts[i].withdrawalLimitProperty)
                            {
                                accounts[i].balanceProperty = (accounts[i].balanceProperty + withdrawalAmount);
                                accounts[i].withdraw(withdrawalAmount);
                            }
                            else
                            {
                                Console.Write("ERROR!!! Amount more than Withdrawal Limit.\n");
                            }
                        }
                    }
                }

                StreamWriter writeCurrent = new StreamWriter("CurrentAccount.txt"); //write to file object

                for (int j = 0; j < totalAccounts; j++)
                {
                    currentAccount account = accounts[j];
                    writeCurrent.WriteLine(account.accountNoProperty);
                    writeCurrent.WriteLine(account.accountTitleProperty);
                    writeCurrent.WriteLine(account.balanceProperty);
                    writeCurrent.WriteLine(account.cnicProperty);
                    writeCurrent.WriteLine(account.contactNoProperty);
                    writeCurrent.WriteLine(account.withdrawalLimitProperty);
                }
                writeCurrent.Close();
                return;
            }

            else if (num == 2)
            {
                Console.WriteLine("\nEnter Account Number:");
                string accnum = Console.ReadLine();

                accountFile obj      = new accountFile();
                ArrayList   accounts = obj.readAllSavingAccount(); //array list: saves diffeent types of objects

                int  totalAccounts = accounts.Count;               //built-in count list function
                bool found         = false;

                for (int i = 0; i < totalAccounts; i++)
                {
                    if ((accounts[i] as savingAccount).accountNoProperty == accnum)
                    {
                        found = true;
                        Console.WriteLine("\nAccount Found.\n");

                        Console.Write("\nChoose Transaction Type:\n");
                        Console.Write("1.Deposit Amount.   2.Withdraw Amount.\n");
                        int option = int.Parse(Console.ReadLine());

                        if (option == 1)
                        {
                            Console.Write("Enter Deposit Amount:\n");
                            int depositAmount = int.Parse(Console.ReadLine());
                            (accounts[i] as savingAccount).balanceProperty = ((accounts[i] as savingAccount).balanceProperty + depositAmount);
                            (accounts[i] as savingAccount).deposit(depositAmount);
                        }
                        if (option == 2)
                        {
                            Console.Write("Enter Withdrawal Amount:\n");
                            int withdrawalAmount = int.Parse(Console.ReadLine());
                            (accounts[i] as savingAccount).balanceProperty = ((accounts[i] as savingAccount).balanceProperty + withdrawalAmount);
                            (accounts[i] as savingAccount).withdraw(withdrawalAmount);
                        }
                    }
                }

                StreamWriter writeSaving = new StreamWriter("SavingAccount.txt"); //write to file object

                for (int j = 0; j < totalAccounts; j++)
                {
                    savingAccount account = accounts[j] as savingAccount;
                    writeSaving.WriteLine(account.accountNoProperty);
                    writeSaving.WriteLine(account.accountTitleProperty);
                    writeSaving.WriteLine(account.balanceProperty);
                    writeSaving.WriteLine(account.cnicProperty);
                    writeSaving.WriteLine(account.contactNoProperty);
                    writeSaving.WriteLine(account.profitPercentageProperty);
                }
                writeSaving.Close();
                return;
            }
            else
            {
                Console.WriteLine("Invalid Input\n");
            }
        }
Ejemplo n.º 5
0
        public void deleteAccount()
        {
            Console.Write("\nChoose Account Type:\n");
            Console.Write("1.Current Account.   2.Saving Account.\n");
            int num = int.Parse(Console.ReadLine());

            if (num == 1)
            {
                Console.WriteLine("\nEnter Account Number:");
                string                accnum   = Console.ReadLine();
                accountFile           obj      = new accountFile();
                List <currentAccount> accounts = obj.readAllCurrentAccount(); //simple list: saves same type of objects
                int  totalAccounts             = accounts.Count;              //built-in count list function
                bool found = false;

                for (int i = 0; i < totalAccounts; i++)
                {
                    if (accounts[i].accountNoProperty == accnum)
                    {
                        found = true;
                        Console.WriteLine("\nAccount Found.\n");

                        accounts.Remove(accounts[i]); //deletes that object with i index
                        totalAccounts--;
                    }
                }

                StreamWriter writeCurrent = new StreamWriter("CurrentAccount.txt"); //write to file object

                for (int j = 0; j < totalAccounts; j++)
                {
                    currentAccount account = accounts[j];
                    writeCurrent.WriteLine(account.accountNoProperty);
                    writeCurrent.WriteLine(account.accountTitleProperty);
                    writeCurrent.WriteLine(account.balanceProperty);
                    writeCurrent.WriteLine(account.cnicProperty);
                    writeCurrent.WriteLine(account.contactNoProperty);
                    writeCurrent.WriteLine(account.withdrawalLimitProperty);
                }
                writeCurrent.Close();
                return;
            }

            else if (num == 2)
            {
                Console.WriteLine("\nEnter Account Number:");
                string      accnum        = Console.ReadLine();
                accountFile obj           = new accountFile();
                ArrayList   accounts      = obj.readAllSavingAccount(); //array list: saves diffeent types of objects
                int         totalAccounts = accounts.Count;             //built-in count list function
                bool        found         = false;

                for (int i = 0; i < totalAccounts; i++)
                {
                    if ((accounts[i] as savingAccount).accountNoProperty == accnum)
                    {
                        found = true;
                        Console.WriteLine("\nAccount Found.\n");

                        accounts.Remove(accounts[i]); //deletes that object with i index
                        totalAccounts--;
                    }
                }

                StreamWriter writeSaving = new StreamWriter("SavingAccount.txt"); //write to file object

                for (int j = 0; j < totalAccounts; j++)
                {
                    savingAccount account = accounts[j] as savingAccount;
                    writeSaving.WriteLine(account.accountNoProperty);
                    writeSaving.WriteLine(account.accountTitleProperty);
                    writeSaving.WriteLine(account.balanceProperty);
                    writeSaving.WriteLine(account.cnicProperty);
                    writeSaving.WriteLine(account.contactNoProperty);
                    writeSaving.WriteLine(account.profitPercentageProperty);
                }
                writeSaving.Close();
                return;
            }
            else
            {
                Console.WriteLine("Invalid Input\n");
            }
        }
Ejemplo n.º 6
0
 public void createNewCurrentAccount(currentAccount ca)
 {
     this.currentAccountList.Add(ca); //adding object to simple list
 }