示例#1
0
        /// <summary>
        /// Requests all products available in the office and prints them.
        /// </summary>
        private void ViewAllProducts()
        {
            Console.Clear();

            Console.WriteLine(new string('-', 40));
            Console.WriteLine(new string(' ', 14) + "ALL PRODUCTS");
            Console.WriteLine(new string('-', 40) + '\n');

            string name;

            while (true)
            {
                Console.Write("Office name: ");
                name = Console.ReadLine();
                Console.WriteLine();

                if (OfficeBusiness.OfficeExists(name))
                {
                    break;
                }

                Console.WriteLine(new string('-', 26));
                Console.WriteLine("Please enter a valid office name!");
                Console.WriteLine(new string('-', 26) + '\n');
            }

            Console.WriteLine(OfficeBusiness.AllProductsAvailableInOffice(OfficeBusiness.GetID(name)));

            Console.ReadKey();
        }
示例#2
0
        /// <summary>
        /// Request a shipping from one office to another.
        /// </summary>
        private void ShipProduct()
        {
            string officeNameFrom, officeNameTo, productName;

            Console.Clear();

            Console.WriteLine(new string('-', 40));
            Console.WriteLine(new string(' ', 14) + "SHIP PRODUCT");
            Console.WriteLine(new string('-', 40));
            Console.WriteLine();

            while (true)
            {
                Console.Write("Office name(from): ");
                officeNameFrom = Console.ReadLine();
                Console.WriteLine();

                if (OfficeBusiness.OfficeExists(officeNameFrom))
                {
                    break;
                }

                Console.WriteLine(new string('-', 26));
                Console.WriteLine("Please enter a valid office name!");
                Console.WriteLine(new string('-', 26) + '\n');
            }

            while (true)
            {
                Console.Write("Office name(to): ");
                officeNameTo = Console.ReadLine();
                Console.WriteLine();

                if (OfficeBusiness.OfficeExists(officeNameTo))
                {
                    break;
                }

                Console.WriteLine(new string('-', 26));
                Console.WriteLine("Please enter a valid office name!");
                Console.WriteLine(new string('-', 26) + '\n');
            }

            while (true)
            {
                Console.Write("Product name: ");
                productName = Console.ReadLine();
                Console.WriteLine();

                if (OfficeBusiness.ProductAvailable(OfficeBusiness.GetID(officeNameFrom), ProductBusiness.GetID(productName)))
                {
                    break;
                }

                Console.WriteLine(new string('-', 27));
                Console.WriteLine("Please enter a valid price!");
                Console.WriteLine(new string('-', 27) + '\n');
            }

            OfficeBusiness.TransferProduct(OfficeBusiness.GetID(officeNameFrom), OfficeBusiness.GetID(officeNameTo), ProductBusiness.GetID(productName));
        }
示例#3
0
        /// <summary>
        /// Request a product to be loaded to an office.
        /// </summary>
        private void LoadProduct()
        {
            string officeName, distributorName, productName;
            int    stock;

            Console.Clear();

            Console.WriteLine(new string('-', 40));
            Console.WriteLine(new string(' ', 14) + "LOAD PRODUCT");
            Console.WriteLine(new string('-', 40) + '\n');

            while (true)
            {
                Console.Write("Office name: ");
                officeName = Console.ReadLine();
                Console.WriteLine();

                if (OfficeBusiness.OfficeExists(officeName))
                {
                    break;
                }

                Console.WriteLine(new string('-', 26));
                Console.WriteLine("Please enter a valid office name!");
                Console.WriteLine(new string('-', 26) + '\n');
            }

            while (true)
            {
                Console.Write("Distributor name: ");
                distributorName = Console.ReadLine();
                Console.WriteLine();

                if (!(distributorName.Length < 1) && DistributorBusiness.DistributorExists(DistributorBusiness.GetID(distributorName)))
                {
                    break;
                }

                Console.WriteLine(new string('-', 26));
                Console.WriteLine("Please enter a valid name!");
                Console.WriteLine(new string('-', 26) + '\n');
            }

            while (true)
            {
                Console.Write("Product name: ");
                productName = Console.ReadLine();
                Console.WriteLine();

                if (DistributorBusiness.CheckForProduct(DistributorBusiness.GetID(distributorName), ProductBusiness.GetID(productName)))
                {
                    break;
                }

                Console.WriteLine(new string('-', 27));
                Console.WriteLine("Please enter a valid price!");
                Console.WriteLine(new string('-', 27) + '\n');
            }

            while (true)
            {
                Console.Write("Stock: ");
                stock = int.Parse(Console.ReadLine());
                Console.WriteLine();

                if (!(stock < 0))
                {
                    break;
                }

                Console.WriteLine(new string('-', 27));
                Console.WriteLine("Please enter a valid stock!");
                Console.WriteLine(new string('-', 27) + '\n');
            }

            OfficeBusiness.LoadProduct(OfficeBusiness.GetID(officeName), DistributorBusiness.GetProduct(DistributorBusiness.GetID(distributorName), ProductBusiness.GetID(productName)), stock);
        }