コード例 #1
0
        /// <summary>
        /// local static funtion that calculates product stock of particular warehouseid and warehouse addressid of a product and displays all products available and no of quantity
        /// </summary>
        public static void  GetAllStocks()
        {
            ProductBusiness         productBusinessLogic    = new ProductBusiness();
            MenuPrensentor          wareHousePresentation   = new MenuPrensentor();
            StockBusinessLogicLayer stockBusinessLogicLayer = new StockBusinessLogicLayer();
            Stock stock = new Stock();
            bool  check = false;

            do
            {
                try
                {
                    System.Console.WriteLine("Enter WareHouseID");
                    System.Console.WriteLine("It should not contain spaces and length be exactly 6");
                    stock.WareHouseID = System.Console.ReadLine();
                    if (wareHousePresentation.CheckWareHouseId(stock.WareHouseID)) //checking whether the Warehouse Id is present in the list of warehouse
                    {
                        bool check1 = false;
                        check = true;
                        do
                        {
                            try
                            {
                                System.Console.WriteLine("Enter Address ID");
                                System.Console.WriteLine("It should not contain spaces or Special Characters and length should be exactly 4");
                                stock.AddressID = System.Console.ReadLine();
                                if (wareHousePresentation.CheckAddressId(stock.AddressID))//checking whether the warehouse address is present in list of warehouse adress

                                {
                                    check1 = true;
                                    List <Stock> stocks = stockBusinessLogicLayer.GetAllStocks(stock.WareHouseID, stock.AddressID);

                                    System.Console.WriteLine("ProductID     " + "      " + "StockAvalibale");
                                    foreach (Stock item in stocks)
                                    {
                                        System.Console.WriteLine(item.ProductID + "  " + item.TotalQuantity);
                                    }
                                }
                            }
                            catch (StockException e)
                            {
                                System.Console.WriteLine(e.Message);
                            }
                        } while (check1 == false);
                    }
                }
                catch (StockException e)
                {
                    System.Console.WriteLine(e.Message);
                }
            } while (check == false);
        }
コード例 #2
0
        /// <summary>
        /// Local Function to Add Stock
        /// </summary>
        public static void AddStock()
        {
            ProductBusiness productBusinessLogic  = new ProductBusiness();
            MenuPrensentor  wareHousePresentation = new MenuPrensentor();

            StockBusinessLogicLayer stockBusinessLogicLayer = new StockBusinessLogicLayer(); // creation stockBusinessLogic object
            Stock stock = new Stock();                                                       //creation of stock object of entite Layer
            bool  check = false;

            try
            {
                System.Console.WriteLine("Enter StockID");
                stock.StockID = System.Console.ReadLine();


                do
                {
                    try
                    {
                        bool check1 = false;
                        System.Console.WriteLine("Enter WareHouseID");
                        System.Console.WriteLine("It should not contain spaces and length be exactly 6");
                        stock.WareHouseID = System.Console.ReadLine();
                        if (wareHousePresentation.CheckWareHouseId(stock.WareHouseID) == true)//checking whether the Warehouse Id is present in the list of warehouse
                        {
                            do
                            {
                                try
                                {
                                    check = true;
                                    System.Console.WriteLine("Enter Address ID");
                                    System.Console.WriteLine("It should not contain spaces or Special Characters and length should be exactly 4");
                                    stock.AddressID = System.Console.ReadLine();
                                    if (wareHousePresentation.CheckAddressId(stock.AddressID))//checking whether the warehouse address is present in list of warehouse adress
                                    {
                                        bool check2 = false;
                                        check1 = true;
                                        do
                                        {
                                            try
                                            {
                                                System.Console.WriteLine("Enter Product ID");
                                                System.Console.WriteLine("Product ID Should not NULL and ProductID Should Start with PID and 0-9 number and length should be 6");
                                                stock.ProductID = System.Console.ReadLine();
                                                if (productBusinessLogic.CheckProductID(stock.ProductID))//checking whether product is available in the list or not
                                                {
                                                    check2 = true;

                                                    System.Console.WriteLine("Enter no of Quantities u want to add");
                                                    stock.Quantity = System.Convert.ToInt32(System.Console.ReadLine());

                                                    stockBusinessLogicLayer.AddStock(stock);
                                                    Console.WriteLine("Stock Added Sucessfully!!");
                                                }
                                            }

                                            catch (StockException e)
                                            {
                                                System.Console.WriteLine(e.Message);
                                            }
                                        } while (check2 == false);
                                    }
                                }
                                catch (StockException e)
                                {
                                    System.Console.WriteLine(e.Message);
                                }
                            } while (check1 == false);
                        }
                    }
                    catch (StockException e)
                    {
                        System.Console.WriteLine(e.Message);
                    }
                } while (check == false);
            }
            catch (StockException e)
            {
                System.Console.WriteLine(e.Message);
            }
        }
コード例 #3
0
        /// <summary>
        /// used to update the stock of the product
        /// </summary>
        public void UpdateStockQuantity()
        {
            StockBusinessLogicLayer stockBusinessLogicLayer = new StockBusinessLogicLayer();
            Stock           stock = new Stock();
            ProductBusiness productBusinessLogic  = new ProductBusiness();
            MenuPrensentor  wareHousePresentation = new MenuPrensentor();
            bool            check = false;

            do
            {
                try
                {
                    System.Console.WriteLine("enter to which WarehouseId you want to update the quantity:");
                    System.Console.WriteLine("It should not contain spaces and length be exactly 6");
                    stock.WareHouseID = System.Console.ReadLine();
                    if (wareHousePresentation.CheckWareHouseId(stock.WareHouseID)) //checking whether the Warehouse Id is present in the list of warehouse
                    {
                        bool check1 = false;
                        check = true;
                        do
                        {
                            try
                            {
                                System.Console.WriteLine("enter to which WarehouseAddress you want to update the quantity:");
                                System.Console.WriteLine("It should not contain spaces or Special Characters and length should be exactly 4");
                                stock.AddressID = System.Console.ReadLine();
                                if (wareHousePresentation.CheckAddressId(stock.AddressID))//checking whether the warehouse address is present in list of warehouse adress

                                {
                                    bool check2 = false;
                                    check1 = true;
                                    do
                                    {
                                        try
                                        {
                                            System.Console.WriteLine("enter to which ProductID you want to update the quantity");
                                            System.Console.WriteLine("Product ID Should not NULL and ProductID Should Start with PID and 0-9 number and length should be 6");
                                            stock.ProductID = System.Console.ReadLine();
                                            if (productBusinessLogic.CheckProductID(stock.ProductID))//checking whether product is available in the list or not
                                            {
                                                check2 = true;
                                                System.Console.WriteLine("enter the quantity to be updated:");
                                                stock.Quantity = System.Convert.ToInt32(System.Console.ReadLine());

                                                stockBusinessLogicLayer.UpdateStockQuantity(stock);
                                                System.Console.WriteLine("Stock quntity Updated Sucessfully");
                                            }
                                        }
                                        catch (StockException e)
                                        {
                                            System.Console.WriteLine(e.Message);
                                        }
                                    } while (check2 == false);
                                }
                            }
                            catch (StockException e)
                            {
                                System.Console.WriteLine(e.Message);
                            }
                        } while (check1 == false);
                    }
                }
                catch (StockException e)
                {
                    System.Console.WriteLine(e.Message);
                }
            } while (check == false);
        }