Пример #1
0
        public void Ordertablet()
        {
            Console.WriteLine("Available tablets");
            Console.WriteLine("-----------------------");
            List <Tablet> tablet = new List <Tablet>();

            tablet.Add(new Tablet(1, "citrizen", 5, 500));
            tablet.Add(new Tablet(2, "paracetamol", 10, 200));
            tablet.Add(new Tablet(3, "ativan", 7, 300));
            tablet.Add(new Tablet(4, "colpal", 8, 500));
            Tablet[] tabletInfo = TabletBLL.showTablet(tablet);
            foreach (var t in tabletInfo)
            {
                Console.WriteLine(t.ToString());
            }
            Console.WriteLine("  ");
            Console.WriteLine("  ");
            Console.WriteLine("-----------------------");
            List <Order> order = new List <Order>();

            Console.WriteLine("Enter tablet to order");
            String tabName1 = Console.ReadLine();

            Console.WriteLine("Enter no. of tablets");
            int count  = Convert.ToInt32(Console.ReadLine());
            int cst    = TabletBLL.order1(tabName1, tablet);
            int amount = count * cst;

            Console.WriteLine("Total Amount payable:" + amount);
            Console.WriteLine("-----------------------");
            Console.WriteLine("Press 1 to place order");
            Console.WriteLine("press 2 to exit from current order");
            int b = Convert.ToInt32(Console.ReadLine());

            switch (b)
            {
            case 1:
                Random    rand     = new Random();
                const int maxValue = 99;
                int       ordId    = rand.Next(maxValue + 1);

                DateTime dateTime  = DateTime.Now;
                string   DateValue = dateTime.ToShortDateString();
                //Console.WriteLine(amount);
                Console.WriteLine("  ");
                Console.WriteLine("-----------------------");
                Console.WriteLine("your order is successful");
                Console.WriteLine("-----------------------");
                Console.WriteLine("  ");
                string updStk = TabletBLL.updateStock1(tabName1, count, tablet);

                /*foreach (var t in tabletInfo)
                 * {
                 *  Console.WriteLine(t.ToString());
                 * }*/
                //Console.WriteLine("your order is :" + tabName1);

                /*int tabId = 1;
                 * string date = "12/12/2020"*/
                Console.WriteLine("Press 1 to view order history");
                Console.WriteLine("Press 2 to place another order");

                int a = Convert.ToInt32(Console.ReadLine());
                switch (a)
                {
                case 1:
                    Console.WriteLine("view orders history");
                    Console.WriteLine("-----------------------");
                    Console.WriteLine("Order ID    Tablet Name    No.of Tablets    Tablet Cost    Total Amount    Date of order");
                    string ord = OrderBLL.orderTablet(ordId, tabName1, count, cst, amount, DateValue, order);
                    //Console.WriteLine(ord);
                    Order[] orderInfo = OrderBLL.showOrder(order);
                    foreach (var o in orderInfo)
                    {
                        Console.WriteLine(o.ToString());
                    }
                    break;

                //Console.ReadLine();
                case 2:
                    Ordertablet();
                    break;

                default:
                    Console.WriteLine(" Invalid Choice");
                    Console.WriteLine("Please choose from below if you wish to continue with other services");
                    Console.WriteLine("-----------------------");
                    Console.WriteLine("1.view the medicine list");
                    Console.WriteLine("2.Place order");
                    Console.WriteLine("3.View order details");
                    Console.WriteLine("4.Exit");
                    custop();
                    break;
                }
                break;

            case 2:
                Ordertablet();
                break;

            default:
                Console.WriteLine(" Invalid Choice");
                Console.WriteLine("Please choose from below if you wish to continue with other services");
                Console.WriteLine("-----------------------");
                Console.WriteLine("1.view the medicine list");
                Console.WriteLine("2.Place order");
                Console.WriteLine("3.View order details");
                Console.WriteLine("4.Exit");
                custop();
                break;
            }
        }