Beispiel #1
0
        //---------------------------------------------------------------------------------------------------------------------1)
        public bool AddAccountBL()
        {
            bool    result  = false;
            Account account = new Account();

            //AddCustomer(); //  First we will make him a customer in Customer if he already exists then skip this step
            Console.WriteLine("Choose Account Type(Savings, Current,FD)");
            if ((Enum.TryParse(Console.ReadLine(), out account._accType) == true))
            {
            }
            else
            {
                throw new EnterValidAccountTypeException("Enter Valid Account Type");
            }
            Console.WriteLine("Choose Your Home Branch");
            account.HomeBranch = Console.ReadLine();

            Console.WriteLine("Enter Initial Amount(For FD minimum 20,000)");
            double temp = double.Parse(Console.ReadLine());

            if ((int)account._accType == 2 && temp < 20000)
            {
                throw new InitialAmountOfFDException("Amount should be Atleast 20000");
            }
            else if ((int)account._accType == 2 && temp > 20000)
            {
                account.FdDeposit = temp;
            }
            else
            {
                account.InitialAmount = temp;
                account.Balance       = account.Balance + account.InitialAmount;
            }
            if ((int)account._accType == 0)
            {
                account.InterestRate = 5;
                if (AccnogenSavings.Count == 0)            // If list empty then only

                {
                    account.AccountNo = 500001;            // Account No of Savings Account Starts with 5 series
                    AccnogenSavings.Add(account.AccountNo);
                }
                else
                {
                    int i = AccnogenSavings.Count;
                    account.AccountNo = (AccnogenSavings[i - 1] + 1); // Add the existing list number + 1 (eg 500001 +1)
                }
            }

            else if ((int)account._accType == 1)
            {
                account.InterestRate = 0;
                if (AccnogenCurrent.Count == 0)

                {
                    account.AccountNo = 400001;                 // Account No of Current Account Starts with 4 series
                    AccnogenCurrent.Add(account.AccountNo);
                }

                else
                {
                    int i = AccnogenCurrent.Count;
                    account.AccountNo = (AccnogenCurrent[i - 1] + 1);
                }
            }

            else
            {
                if (account.InitialAmount > 100000)
                {
                    account.InterestRate = 5.5;
                }

                if (account.InitialAmount < 100000)
                {
                    account.InterestRate = 5;
                }


                if (AccnogenFD.Count == 0)

                {
                    account.AccountNo = 300001;                      // Account No of FD Account Starts with 3 series
                    AccnogenFD.Add(account.AccountNo);
                }

                else
                {
                    int i = AccnogenFD.Count;
                    account.AccountNo = (AccnogenFD[i - 1] + 1);
                }
            }

            AccountDAL ad = new AccountDAL();

            result = ad.AddAccountDAL(account); // After adding Method


            return(result);
        }