Ejemplo n.º 1
0
        public MainMenu(IBL bl)
        {
            this.itsBL = bl;
            string cmd;

            while (true)
            {
                Console.Clear();
                Console.WriteLine("Please select an option:");
                Console.WriteLine("\t1. Add ");
                Console.WriteLine("\t2. Search ");
                //Console.WriteLine("\t3. Show all ");
                Console.WriteLine("\t3. Save ");
                Console.WriteLine("\t4. Exit ");
                cmd = Console.ReadLine();

                switch (cmd)
                {
                case "1":                                             // Add
                    AddScreen addMenu = new AddScreen(itsBL);
                    addMenu.run();                                    // move to add menu
                    break;

                case "2":                                               // search
                    Search searchMenu = new Search(itsBL);
                    searchMenu.run();                                   // move to search menu
                    break;

                //case "3":

                //    break;

                case "3":                                                //save
                    itsBL.saveDataToFile();
                    Console.WriteLine(" saved ");
                    Thread.Sleep(1500);
                    break;

                case "4":                                                    // exit
                    ExitScreen finalScreen = new ExitScreen(itsBL);          // move to exit menu
                    break;

                default:
                    Console.WriteLine("You have performed an illegal move. choose number between 1-4 ");
                    Thread.Sleep(2300);
                    break;
                }
            }
        }
Ejemplo n.º 2
0
        public void showProductList()                                               // Displays the list of products
        {
            AddScreen      addprodect   = new AddScreen(itsBL);
            Receipt        receiptToAdd = new Receipt();
            List <Product> list;
            string         choice;
            bool           ans = true;

            while (ans)
            {
                Console.WriteLine("How do you want to find the product: ");        // first we create list according to what the user want to search
                Console.WriteLine("\t1. by product name");
                Console.WriteLine("\t2. by product ID");
                choice = Console.ReadLine();

                switch (choice)
                {
                case "1":                                                                           // by product name
                    Console.WriteLine("Enter product name");
                    string name = Console.ReadLine();
                    list = itsBL.queryByString(Classes.Product, stringFields.name, name).Cast <Product>().ToList();
                    Console.WriteLine("row.  Product Name | Product Type | Inventory ID");
                    if (list.LongCount() == 0)
                    {
                        Console.WriteLine("There are no items to show");
                        Thread.Sleep(1200);
                        AddScreen back = new AddScreen(itsBL);
                        back.run();
                    }
                    int counter = 1;
                    foreach (Product p in list)
                    {
                        Console.WriteLine("\t" + counter + ". " + p.Name + "  |  " + p.Type.ToString() + "  |  " + p.InventoryID.ToString());
                        counter++;
                    }
                    receiptToAdd = addprodect.creatReceipt(list, counter);
                    ans          = false;
                    break;

                case "2":                                                               //by prodect ID
                    Console.WriteLine("Enter product ID: ");
                    string id = Console.ReadLine();
                    while (!(InputCheck.isInt(id)))                             // check that the ID is numbers
                    {
                        Console.WriteLine("ID must be number. enter id again");
                        id = Console.ReadLine();
                    }
                    list = itsBL.queryByString(Classes.Product, stringFields.inventoryID, id).Cast <Product>().ToList();
                    Console.WriteLine("row. | Product Name | Product Type | Inventory ID");
                    if (list.LongCount() == 0)
                    {
                        Console.WriteLine("There are no items to show");
                        Thread.Sleep(1200);
                        AddScreen back = new AddScreen(itsBL);
                        back.run();
                    }
                    int counter2 = 1;
                    foreach (Product p in list)
                    {
                        Console.WriteLine("\t" + counter2 + ". " + p.Name + "  |  " + p.Type.ToString() + "  |  " + p.InventoryID.ToString());
                        counter2++;
                    }
                    receiptToAdd = addprodect.creatReceipt(list, counter2);
                    ans          = false;
                    break;

                default:
                    Console.WriteLine("You have to choose 1 or 2 \n");
                    Thread.Sleep(2200);
                    break;
                }
            }
        }