Example #1
0
        public bool AskThreeSupplier(ItemWithQtyModel_M itemQty)
        {
            PurchaseOrderController_M CPOC = new PurchaseOrderController_M();
            int inventory1 = CPOC.GetInventoryFromSupplier(itemQty.FirstSupplier_ID, itemQty.Item_ID);
            int inventory2 = CPOC.GetInventoryFromSupplier(itemQty.SecondSupplier_ID, itemQty.Item_ID);
            int inventory3 = CPOC.GetInventoryFromSupplier(itemQty.ThirdSupplier_ID, itemQty.Item_ID);

            if (inventory1 + inventory2 + inventory3 >= itemQty.Qty)
            {
                qtyCanSuppList[0] = inventory1;
                qtyCanSuppList[1] = inventory2;
                qtyCanSuppList[2] = itemQty.Qty - inventory1 - inventory2;
                supplierList[0]   = itemQty.FirstSupplier_ID;
                supplierList[1]   = itemQty.SecondSupplier_ID;
                supplierList[2]   = itemQty.ThirdSupplier_ID;
                status            = 123;
                return(true);
            }

            else
            {
                qtyCanSuppList[0] = inventory1;
                qtyCanSuppList[1] = inventory2;
                qtyCanSuppList[2] = inventory3;
                supplierList[0]   = itemQty.FirstSupplier_ID;
                supplierList[1]   = itemQty.SecondSupplier_ID;
                supplierList[2]   = itemQty.ThirdSupplier_ID;
                status            = -3;
                return(false);
            }
        }
Example #2
0
        public bool AskOneSupplier(ItemWithQtyModel_M itemQty)
        {
            PurchaseOrderController_M CPOC = new PurchaseOrderController_M();

            int inventory = CPOC.GetInventoryFromSupplier(itemQty.FirstSupplier_ID, itemQty.Item_ID);

            if (inventory >= itemQty.Qty)
            {
                qtyCanSuppList[0] = itemQty.Qty;
                supplierList[0]   = itemQty.FirstSupplier_ID;
                status            = 1;
                return(true);
            }
            //mean supplier 1 can fulfill the order
            else
            {
                inventory = CPOC.GetInventoryFromSupplier(itemQty.SecondSupplier_ID, itemQty.Item_ID);
                if (inventory >= itemQty.Qty)
                {
                    qtyCanSuppList[0] = itemQty.Qty;
                    supplierList[0]   = itemQty.SecondSupplier_ID;
                    status            = 2;
                    return(true);
                }
                //mean supplier 2 can fulfill the order
                else
                {
                    inventory = CPOC.GetInventoryFromSupplier(itemQty.ThirdSupplier_ID, itemQty.Item_ID);
                    if (inventory >= itemQty.Qty)
                    {
                        qtyCanSuppList[0] = itemQty.Qty;
                        supplierList[0]   = itemQty.ThirdSupplier_ID;
                        status            = 3;
                        return(true);
                    }
                    //mean supplier 3 can fulfill the order
                    else
                    {
                        status = -1;
                        return(false);
                    }
                    //no one supplier can fulfill
                }
            }
        }
Example #3
0
        public bool AskTwoSupplier(ItemWithQtyModel_M itemQty)
        {
            PurchaseOrderController_M CPOC = new PurchaseOrderController_M();
            int inventory1 = CPOC.GetInventoryFromSupplier(itemQty.FirstSupplier_ID, itemQty.Item_ID);
            int inventory2 = CPOC.GetInventoryFromSupplier(itemQty.SecondSupplier_ID, itemQty.Item_ID);

            if (inventory1 + inventory2 >= itemQty.Qty)
            {
                qtyCanSuppList[0] = inventory1;
                qtyCanSuppList[1] = itemQty.Qty - inventory1;
                supplierList[0]   = itemQty.FirstSupplier_ID;
                supplierList[1]   = itemQty.SecondSupplier_ID;
                status            = 12;
                return(true);
            }
            //means supplier 1 and supplier 2 can fulfill the order together
            else
            {
                inventory1 = CPOC.GetInventoryFromSupplier(itemQty.FirstSupplier_ID, itemQty.Item_ID);
                inventory2 = CPOC.GetInventoryFromSupplier(itemQty.ThirdSupplier_ID, itemQty.Item_ID);
                if (inventory1 + inventory2 >= itemQty.Qty)
                {
                    qtyCanSuppList[0] = inventory1;
                    qtyCanSuppList[1] = itemQty.Qty - inventory1;
                    supplierList[0]   = itemQty.FirstSupplier_ID;
                    supplierList[1]   = itemQty.ThirdSupplier_ID;
                    status            = 13;
                    return(true);
                }
                //means supplier 1 and supplier 3 can fulfill the order together
                else
                {
                    inventory1 = CPOC.GetInventoryFromSupplier(itemQty.SecondSupplier_ID, itemQty.Item_ID);
                    inventory2 = CPOC.GetInventoryFromSupplier(itemQty.ThirdSupplier_ID, itemQty.Item_ID);
                    if (inventory1 + inventory2 >= itemQty.Qty)
                    {
                        qtyCanSuppList[0] = inventory1;
                        qtyCanSuppList[1] = itemQty.Qty - inventory1;
                        supplierList[0]   = itemQty.SecondSupplier_ID;
                        supplierList[1]   = itemQty.ThirdSupplier_ID;
                        status            = 23;
                        return(true);
                    }
                    //means supplier 2 and supplier 3 can fulfill the order together
                    else
                    {
                        status = -2;
                        return(false);
                    }
                    //no two supplier can fulfill
                }
            }
        }