Example #1
0
        /// <summary>
        /// Admin LogIn
        /// </summary>
        public void AdminLogIn()
        {
ReEnterAdmin:
            Console.WriteLine("Enter login");
            string userId = Console.ReadLine();

            Console.WriteLine("Enter Pin code");

            int pin = System.Convert.ToInt32(Console.ReadLine());

            UserObj bo = new UserObj {
                ID = userId, pswd = pin
            };
            LogInVerfication temp   = new LogInVerfication();
            Boolean          verify = temp.AdminVerification(bo);
            SignedInUser     s      = new SignedInUser();
            MenuView         m      = new MenuView();

            if (verify == true)
            {
                NameAndPswd dataHolder = s.setValues(userId, pin);

                m.AdminMenu();
            }

            else
            {
                char choose;
ReEnter2:
                Console.WriteLine("\nYou have enetered invalid ID or PIN! Do you want to enter again (y/n)?\n");
                try
                {
                    choose = System.Convert.ToChar(Console.ReadLine());
                }
                catch (Exception)
                {
                    Console.WriteLine("Please choose correct optioin (y/n)");
                    goto ReEnter2;
                }
                if (choose.Equals('y') || choose.Equals('Y'))
                {
                    goto ReEnterAdmin;
                }
                else if (choose.Equals('n') || choose.Equals('N'))
                {
                    Console.Clear();
                    Console.WriteLine("/////////////////////////////////////////\n   Welcome to ATM Managment System       \n/////////////////////////////////////////\n");

                    AdminUserView v = new AdminUserView();
                    v.ChooseAdminUser();
                }
                else
                {
                    Console.WriteLine("Please choose right choice!");
                    goto ReEnter2;
                }
            }
        }
 public void DisplayBalance(NameAndPswd val)
 {
     for (int i = 0; i < list.Count; i++)
     {
         if (list[i].ID == val.SignedUserName)
         {
             Console.WriteLine($"Account #{list[i].UserID}\nDate:  {today.ToString("dd/MM/yyyy")}\n\nBalance: {list[i].cash}\n ");
             break;
         }
     }
 }
        public void FastCash(NameAndPswd val, int value)
        {
            int userId = 0;

            for (int i = 0; i < list.Count; i++)
            {
                if (list[i].ID == val.SignedUserName)
                {
                    if (value <= list[i].cash)
                    {
                        userId       = list[i].UserID;
                        list[i].cash = list[i].cash - value;
                        list[i].date = today;
                        CopyTransactionData(list, userId, "withdraw", value);
                        Console.WriteLine("Cash Suceessfully Withdrawn");
                        char c;
receiptCheck:
                        Console.Write("\nDo you wish to print a receipt(y/n)?");
                        try
                        {
                            c = System.Convert.ToChar(Console.ReadLine());
                        }
                        catch (Exception)
                        {
                            Console.WriteLine("Please enter valid value (y/n)!");
                            goto receiptCheck;
                        }

                        if (c.Equals('y') || c.Equals('Y'))
                        {
                            Console.WriteLine($"\nAccount #{list[i].UserID}\nDate:  {list[i].date.ToString("dd/MM/yyyy")}\n\nWithdrawn : {value}\nBalance :{list[i].cash}\n");
                            break;
                        }
                        else if (c.Equals('n') || c.Equals('N'))
                        {
                            break;
                        }
                        else
                        {
                            Console.WriteLine("\nPlease choose right choice from (y/n)");
                            goto receiptCheck;
                        }
                    }
                    else
                    {
                        Console.WriteLine("You dont have enough balance");
                        break;
                    }
                }
            }
            p.writeData(list);
        }
        public void CashTransfer(decimal amount, int AccNo, NameAndPswd SignedInUser)
        {
            for (int i = 0; i < list.Count; i++)
            {
                if (list[i].UserID == AccNo)
                {
                    list[i].cash += amount;
                    ReduceAmount(amount, SignedInUser);

                    CopyTransactionData(list, AccNo, "Cash Recieved", System.Convert.ToInt32(amount));
                }
            }

            p.writeData(list);
        }
        public bool checkAccountBalance(int amount, NameAndPswd SignedInUser)
        {
            bool result = false;

            for (int i = 0; i < list.Count; i++)
            {
                if (list[i].ID.Equals(SignedInUser.SignedUserName))
                {
                    if (list[i].cash >= amount)
                    {
                        result = true;
                        break;
                    }
                }
            }
            return(result);
        }
        public void ReduceAmount(decimal amount, NameAndPswd SignedInUser)
        {
            int userId = 0;

            for (int i = 0; i < list.Count; i++)
            {
                if (list[i].ID.Equals(SignedInUser.SignedUserName))
                {
                    userId = list[i].UserID;
                    Console.Write($"Previoius Balance :{list[i].cash}\n");
                    list[i].cash -= amount;
                    Console.WriteLine($"Remaining Balance: { list[i].cash}\nYou have successfully Transferred Rs.{amount}\n");
                    CopyTransactionData(list, userId, "Cash Transfer", System.Convert.ToInt32(amount));
                }
            }
            p.writeData(list);
        }
        ///DeositCash
        public void DepositCash(NameAndPswd val, decimal value)
        {
            int userId = 0;

            for (int i = 0; i < list.Count; i++)
            {
                if (list[i].ID == val.SignedUserName)
                {
                    userId       = list[i].UserID;
                    list[i].cash = list[i].cash + value;
                    list[i].date = today;
                    Console.WriteLine("Cash Deposited Suceessfully.");
                    CopyTransactionData(list, userId, "deposit", System.Convert.ToInt32(value));
                    char c;
receiptCheck:
                    Console.Write("\nDo you wish to print a receipt(y/n)?");
                    try
                    {
                        c = System.Convert.ToChar(Console.ReadLine());
                    }
                    catch (Exception)
                    {
                        Console.WriteLine("Please enter valid value (y/n)!");
                        goto receiptCheck;
                    }

                    if (c.Equals('y') || c.Equals('Y'))
                    {
                        Console.WriteLine($"\nAccount #{list[i].UserID}\nDate:  {list[i].date.ToString("dd/MM/yyyy")}\n\nDeposited : {value}\nBalance :{list[i].cash}\n");
                        break;
                    }
                    else if (c.Equals('n') || c.Equals('N'))
                    {
                        break;
                    }
                    else
                    {
                        Console.WriteLine("Please enter valid value (y/n)!");
                        goto receiptCheck;
                    }
                }
            }

            p.writeData(list);
        }
        public void NormalCash(NameAndPswd val, decimal value)
        {
            int userId = 0;

            for (int i = 0; i < list.Count; i++)
            {
                if (list[i].ID == val.SignedUserName && value <= list[i].cash)
                {
                    userId       = list[i].UserID;
                    list[i].cash = list[i].cash - value;
                    //today = DateTime.Today;
                    list[i].date = today;
                    Console.WriteLine($"\nAccount #{list[i].UserID}\nDate:  {list[i].date.ToString("dd/MM/yyyy")}\n\nWithdrawn : {value}\nBalance :{list[i].cash}\n");
                    CopyTransactionData(list, userId, "withdraw", System.Convert.ToInt32(value));
                    p.writeData(list);
                }
            }
        }
Example #9
0
        public void Usermenu(NameAndPswd values)
        {
            int choice;

ReSelectMenu:
            Console.WriteLine("\n\n********Customer Menu********");
choiceCheckUser:
            Console.WriteLine("1----Withdraw Cash\n2----Cash Transfer\n3----Deposit Cash\n4----Display Balance\n5---Exit");
            Console.WriteLine("\nPlease choose any option from 1-5");

            try
            {
                choice = System.Convert.ToInt32(Console.ReadLine());
            }
            catch (Exception)
            {
                Console.WriteLine("Please enter valid choice.\n");
                goto choiceCheckUser;
            }


            if (choice == 1)
            {
                int  amount = 0;
                char c;
reEnter:
                Console.WriteLine("Choose (a/b)\n\na)Fast Cash\nb)Normal Cash");
                Console.Write("Please select a mode of withdrawl: ");
                try
                {
                    c = System.Convert.ToChar(Console.ReadLine());
                }
                catch (Exception)
                {
                    Console.WriteLine("\nPlease enter right choice (a/b) ?");
                    goto reEnter;
                }

                if (c.Equals('a'))
                {
                    int a;
reSelect:
                    Console.Write("\n1----500\n2----1000\n3----2000\n4----5000\n5----10000\n6----15000\n7----20000\n\n Select one of the denominations of money: ");

                    try
                    {
                        a = System.Convert.ToInt32(Console.ReadLine());
                    }
                    catch (Exception)
                    {
                        Console.WriteLine("\nPlease enter right choice (1-7) ?");
                        goto reSelect;
                    }

                    if (a == 1 || a == 2 || a == 3 || a == 4 || a == 5 || a == 6 || a == 7)
                    {
                        switch (a)
                        {
                        case 1:
                            amount = 500;
                            break;

                        case 2:
                            amount = 1000;
                            break;

                        case 3:
                            amount = 2000;
                            break;

                        case 4:
                            amount = 5000;
                            break;

                        case 5:
                            amount = 10000;
                            break;

                        case 6:
                            amount = 15000;
                            break;

                        case 7:
                            amount = 20000;
                            break;
                        }

                        char sure;
sureCheck:
                        Console.Write($"\nAre you sure you want to withdraw Rs.{amount} (y/n) ? ");
                        try
                        {
                            sure = System.Convert.ToChar(Console.ReadLine());
                            if (sure.Equals('y') || sure.Equals('Y'))
                            {
                                cash.FastCash(values, amount);
                            }
                            else if (sure.Equals('n') || sure.Equals('N'))
                            {
                                goto reSelect;
                            }
                            else
                            {
                                Console.WriteLine("Please Enter right choice (y/n) ?");
                                goto sureCheck;
                            }
                        }
                        catch (Exception)
                        {
                            Console.WriteLine("Please choose right option (y/n) \n");
                            goto sureCheck;
                        }
                    }
                    else
                    {
                        Console.WriteLine("Please choose options from (1-7) !");
                        goto reSelect;
                    }
                }
                else if (c.Equals('b'))
                {
                    int x;
AmountWithdrawCheck:
                    Console.WriteLine("Enter Amount you want to withdraw");
                    try
                    {
                        x = System.Convert.ToInt32(Console.ReadLine());
                    }
                    catch (Exception)
                    {
                        Console.WriteLine("Please Enter Valid Amount");
                        goto AmountWithdrawCheck;
                    }
                    if (cash.checkAccountBalance(x, values) == true)
                    {
                        cash.NormalCash(values, x);
                    }
                    else
                    {
                        Console.Write("You dont have enough balance!\n");
EnterAgain:
                        Console.WriteLine("Do you want try another amount (y/n): ");
                        char ch = System.Convert.ToChar(Console.ReadLine());
                        if (ch.Equals('y') || ch.Equals('Y'))
                        {
                            goto AmountWithdrawCheck;
                        }
                        else if (ch.Equals('n') || ch.Equals('N'))
                        {
                            goto ReSelectMenu;
                        }
                        else
                        {
                            Console.WriteLine("\nPlease choose right option (y/n) ?\n");
                            goto EnterAgain;
                        }
                    }
                }

                else
                {
                    Console.WriteLine("Please enter right choice (a/b): ");
                    goto reEnter;
                }
            }
            if (choice == 2)
            {
                decimal confirmedAmount;
                decimal depositAmount;
ReEnterAmount:
                Console.Write("Enter amount in multiples of 500:  ");
                try
                {
                    depositAmount = System.Convert.ToInt32(Console.ReadLine());
                }
                catch (Exception)
                {
                    Console.WriteLine("Please Enter valid amount\n");
                    goto ReEnterAmount;
                }
                if (depositAmount % 500 == 0)
                {
                    confirmedAmount = depositAmount;

                    if (cash.checkAccountBalance(System.Convert.ToInt32(confirmedAmount), values) == true)
                    {
                        int AccNo;
AcountNoCheck:
                        Console.Write("\nEnter the account number to which you want to transfer:  ");
                        try
                        {
                            AccNo = System.Convert.ToInt32(Console.ReadLine());
                        }
                        catch (Exception)
                        {
                            Console.WriteLine("Please Enter Valid Value.\n");
                            goto AcountNoCheck;
                        }
                        bool verify = cash.checkAccountNumber(AccNo);
                        if (verify == true)
                        {
                            cash.CashTransfer(confirmedAmount, AccNo, values);


choiceCheck:
                            Console.WriteLine("\nDo you want to perform any other transaction (y/n) ? \n");
                            char c;
                            try
                            {
                                c = System.Convert.ToChar(Console.ReadLine());
                            }
                            catch (Exception)
                            {
                                Console.WriteLine("Please enter right choice (y/n) ?");
                                goto choiceCheck;
                            }
                            if (c.Equals('y') | c.Equals('Y'))
                            {
                                goto ReSelectMenu;
                            }
                            else if (c.Equals('n') | c.Equals('N'))
                            {
                                Console.Clear();
                                Console.WriteLine("/////////////////////////////////////////\n   Welcome to ATM Managment System       \n/////////////////////////////////////////\n");

                                AdminUserView v = new AdminUserView();
                                v.ChooseAdminUser();
                            }
                            else
                            {
                                Console.WriteLine("Please enter right choice (y/n) ?");
                                goto choiceCheck;
                            }
                        }
                        else
                        {
                            Console.WriteLine("Acount No.does not exists\n");
choiceCheck:
                            Console.WriteLine("\n Do your want to enter again (y/n) ? \n");
                            char c;
                            try
                            {
                                c = System.Convert.ToChar(Console.ReadLine());
                            }
                            catch (Exception)
                            {
                                Console.WriteLine("Please enter right choice (y/n) ?");
                                goto choiceCheck;
                            }
                            if (c.Equals('y') | c.Equals('Y'))
                            {
                                goto AcountNoCheck;
                            }
                            else if (c.Equals('n') | c.Equals('N'))
                            {
                                goto ReSelectMenu;
                            }
                            else
                            {
                                Console.WriteLine("Please enter right choice (y/n) ?");
                                goto choiceCheck;
                            }
                        }
                    }
                    else
                    {
                        Console.Write("You dont have enough balance!\n");
EnterAgain:
                        Console.WriteLine("Do you want to do any other transaction (y/n): ");
                        char c = System.Convert.ToChar(Console.ReadLine());
                        if (c.Equals('y') || c.Equals('Y'))
                        {
                            goto ReSelectMenu;
                        }
                        else if (c.Equals('n') || c.Equals('N'))
                        {
                            Console.Clear();
                            AdminUserView v = new AdminUserView();
                            v.ChooseAdminUser();
                        }
                        else
                        {
                            Console.WriteLine("\nPlease choose right option (y/n) ?\n");
                            goto EnterAgain;
                        }
                    }
                }
                else
                {
YNCheck:
                    Console.WriteLine("You have entered wrong amount\nDo you want to enter again (y/n)\n");
                    char x = System.Convert.ToChar(Console.ReadLine());
                    if (x.Equals('y') || x.Equals('Y'))
                    {
                        goto ReEnterAmount;
                    }
                    else if (x.Equals('n') || x.Equals('N'))
                    {
                        goto ReSelectMenu;
                    }
                    else
                    {
                        Console.WriteLine("\nPlease choose right option (y/n) ?\n");
                        goto YNCheck;
                    }
                }
            }

            else if (choice == 3)
            {
                decimal x;
cashDepositCheck:
                Console.WriteLine("Enter the cash amount to deposit: ");
                try
                {
                    x = System.Convert.ToDecimal(Console.ReadLine());
                }
                catch (Exception)
                {
                    Console.WriteLine("Please Enter Valid Value.\n");
                    goto cashDepositCheck;
                }
                cash.DepositCash(values, x);
choiceCheck:
                Console.WriteLine("\nDo you want to perform any other transaction (y/n) ? \n");
                char c;
                try
                {
                    c = System.Convert.ToChar(Console.ReadLine());
                }
                catch (Exception)
                {
                    Console.WriteLine("Please enter right choice (y/n) ?");
                    goto choiceCheck;
                }
                if (c.Equals('y') | c.Equals('Y'))
                {
                    goto ReSelectMenu;
                }
                else if (c.Equals('n') | c.Equals('N'))
                {
                    Console.Clear();
                    Console.WriteLine("/////////////////////////////////////////\n   Welcome to ATM Managment System       \n/////////////////////////////////////////\n");

                    AdminUserView v = new AdminUserView();
                    v.ChooseAdminUser();
                }
                else
                {
                    Console.WriteLine("Please enter right choice (y/n) ?");
                    goto choiceCheck;
                }
            }
            else if (choice == 4)
            {
                cash.DisplayBalance(values);
choiceCheck:
                Console.WriteLine("\nDo you want to perform any other transaction (y/n) ? \n");
                char c;
                try
                {
                    c = System.Convert.ToChar(Console.ReadLine());
                }
                catch (Exception)
                {
                    Console.WriteLine("Please enter right choice (y/n) ?");
                    goto choiceCheck;
                }
                if (c.Equals('y') | c.Equals('Y'))
                {
                    goto ReSelectMenu;
                }
                else if (c.Equals('n') | c.Equals('N'))
                {
                    Console.Clear();
                    Console.WriteLine("/////////////////////////////////////////\n   Welcome to ATM Managment System       \n/////////////////////////////////////////\n");

                    AdminUserView v = new AdminUserView();
                    v.ChooseAdminUser();
                }
                else
                {
                    Console.WriteLine("Please enter right choice (y/n) ?");
                    goto choiceCheck;
                }
            }
            else if (choice == 5)
            {
                Console.Clear();

                Console.WriteLine("/////////////////////////////////////////\n   Welcome to ATM Managment System       \n/////////////////////////////////////////\n");

                AdminUserView v = new AdminUserView();
                v.ChooseAdminUser();
            }

            else
            {
                Console.WriteLine("\nPlease enter right choice (1-5)? \n");
                goto ReSelectMenu;
            }
        }