Esempio n. 1
0
        public static void StockReport()
        {
            Console.WriteLine("\n-----------------Commercial Data Processing Program-----------------");

            int    choice;
            bool   flag = true;
            string userName;

            List <Customer> customers = Utility.ReadCustomerData();

            while (flag)
            {
                Console.WriteLine();
                Console.WriteLine("1. Create an Account");
                Console.WriteLine("2. Login ");
                Console.WriteLine("3. Exit");
                Console.Write("Enter your Choice: ");
                choice = Convert.ToInt32(Console.ReadLine());

                switch (choice)
                {
                case 1:
                    StockAccount stockAccount = new StockAccount(CustomerPath);
                    break;

                case 2:
                    Console.WriteLine();
                    customers = Utility.ReadCustomerData();
                    Console.Write("Enter Your UserName: "******"Login Successfull");
                        flag = true;
                        StockLoginProgram.StockLogin(userName);
                    }
                    else
                    {
                        Console.WriteLine("UserName not Found!");
                        flag = true;
                    }
                    break;

                case 3:
                    flag = false;
                    break;

                default:
                    break;
                }
            }
        }
Esempio n. 2
0
        public static void StockLogin(string userName)
        {
            List <Stock> stocks;
            StockAccount stockAccount;
            int          amount, count, choice;
            string       shareName = null;
            bool         flag      = true;

            Console.WriteLine();
            Console.WriteLine("Welcome {0} to the Commercial Data Processing", userName);

            while (flag)
            {
                Console.WriteLine();
                Console.WriteLine("1. Your Account Value.");
                Console.WriteLine("2. Buy Shares.");
                Console.WriteLine("3. Sell Shares.");
                Console.WriteLine("4. Display Transaction.");
                Console.WriteLine("5. Print Report.");
                Console.WriteLine("6. Exit.");
                Console.Write("Enter your Choice: ");
                choice = Convert.ToInt32(Console.ReadLine());
                switch (choice)
                {
                case 1:
                    Console.WriteLine();
                    stockAccount = new StockAccount();
                    Console.WriteLine("Your Account Worth is: Rs.{0}", stockAccount.ValueOf());
                    break;

                case 2:
                    Console.WriteLine();
                    Utility.ShowStocks();
                    Console.Write("Enter your choice: ");
                    int userChoice = Convert.ToInt32(Console.ReadLine());

                    Console.Write("\nEnter the amount: ");
                    amount = Convert.ToInt32(Console.ReadLine());

                    count  = 1;
                    stocks = Utility.ReadStockData();
                    foreach (Stock data in stocks)
                    {
                        if (count == userChoice)
                        {
                            shareName = data.ShareName;
                            count++;
                        }
                    }
                    stockAccount = new StockAccount();
                    stockAccount.Buy(amount, shareName);
                    break;

                case 5:
                    Console.WriteLine();
                    stockAccount = new StockAccount();
                    stockAccount.PrintReport();
                    break;

                case 6:
                    flag = false;
                    break;
                }
            }
        }