Ejemplo n.º 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);
            }
        }
Ejemplo n.º 2
0
        public void DistributeToSuppliers(List <OrderDetailController_M> odList)
        {
            PurchaseOrderController_M CPOC = new PurchaseOrderController_M();

            foreach (OrderDetailController_M od in odList)
            {
                for (int i = 0; i < od.supplierList.Length; i++)
                {
                    Item item = CPOC.GetItemByItem_ID(od.Item_ID);
                    switch (od.supplierList[i])
                    {
                    case "ALPA":
                        ItemWithQtyModel_M iwq0 = new ItemWithQtyModel_M();
                        iwq0.Item_ID     = item.Item_ID;
                        iwq0.Qty         = od.qtyCanSuppList[i];
                        iwq0.Category_ID = item.ItemCategory.Category_ID;
                        iwq0.Item_Name   = item.Item_Name;
                        iwq0.UOM         = item.UOM;
                        ALPAod.Add(iwq0);
                        break;

                    case "BANE":
                        ItemWithQtyModel_M iwq1 = new ItemWithQtyModel_M();
                        iwq1.Item_ID     = item.Item_ID;
                        iwq1.Qty         = od.qtyCanSuppList[i];
                        iwq1.Category_ID = item.ItemCategory.Category_ID;
                        iwq1.Item_Name   = item.Item_Name;
                        iwq1.UOM         = item.UOM;

                        BANEod.Add(iwq1);
                        break;

                    case "CHEP":
                        ItemWithQtyModel_M iwq2 = new ItemWithQtyModel_M();
                        iwq2.Item_ID     = item.Item_ID;
                        iwq2.Qty         = od.qtyCanSuppList[i];
                        iwq2.Category_ID = item.ItemCategory.Category_ID;
                        iwq2.Item_Name   = item.Item_Name;
                        iwq2.UOM         = item.UOM;
                        CHEPod.Add(iwq2);
                        break;

                    case "OMEG":
                        ItemWithQtyModel_M iwq3 = new ItemWithQtyModel_M();
                        iwq3.Item_ID     = item.Item_ID;
                        iwq3.Qty         = od.qtyCanSuppList[i];
                        iwq3.Category_ID = item.ItemCategory.Category_ID;
                        iwq3.Item_Name   = item.Item_Name;
                        iwq3.UOM         = item.UOM;
                        OMEGod.Add(iwq3);
                        break;

                    default:
                        break;
                    }
                }
            }
        }
Ejemplo n.º 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
                }
            }
        }
Ejemplo n.º 4
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
                }
            }
        }