示例#1
0
 public void CreateAdjustEntry(StoredBox sBox, int itemPK, double adjustedQuantity, bool isRestored, bool isMinus, AdjustingSession adjustingSession)
 {
     try
     {
         Entry     entry;
         Accessory accessory;
         if (isRestored)
         {
             RestoredItem restoredItem = db.RestoredItems.Find(itemPK);
             accessory = db.Accessories.Find(restoredItem.AccessoryPK);
         }
         else
         {
             PassedItem     passedItem     = db.PassedItems.Find(itemPK);
             ClassifiedItem classifiedItem = db.ClassifiedItems.Find(passedItem.ClassifiedItemPK);
             PackedItem     packedItem     = db.PackedItems.Find(classifiedItem.PackedItemPK);
             OrderedItem    orderedItem    = db.OrderedItems.Find(packedItem.OrderedItemPK);
             accessory = db.Accessories.Find(orderedItem.AccessoryPK);
         }
         if (isMinus)
         {
             entry = new Entry(sBox, "AdjustingMinus", adjustingSession.AdjustingSessionPK, isRestored, adjustedQuantity, itemPK, accessory);
         }
         else
         {
             entry = new Entry(sBox, "AdjustingPlus", adjustingSession.AdjustingSessionPK, isRestored, adjustedQuantity, itemPK, accessory);
         }
         db.Entries.Add(entry);
         db.SaveChanges();
     }
     catch (Exception e)
     {
         throw e;
     }
 }
示例#2
0
 public void CreateDiscardEntry(StoredBox sBox, int itemPK, double discardedQuantity, bool isRestored, DiscardingSession discardingSession)
 {
     try
     {
         Entry     entry;
         Accessory accessory;
         if (isRestored)
         {
             RestoredItem restoredItem = db.RestoredItems.Find(itemPK);
             accessory = db.Accessories.Find(restoredItem.AccessoryPK);
         }
         else
         {
             PassedItem     passedItem     = db.PassedItems.Find(itemPK);
             ClassifiedItem classifiedItem = db.ClassifiedItems.Find(passedItem.ClassifiedItemPK);
             PackedItem     packedItem     = db.PackedItems.Find(classifiedItem.PackedItemPK);
             OrderedItem    orderedItem    = db.OrderedItems.Find(packedItem.OrderedItemPK);
             accessory = db.Accessories.Find(orderedItem.AccessoryPK);
         }
         entry = new Entry(sBox, "Discarding", discardingSession.DiscardingSessionPK, isRestored, discardedQuantity, itemPK, accessory);
         db.Entries.Add(entry);
         db.SaveChanges();
     }
     catch (Exception e)
     {
         throw e;
     }
 }
示例#3
0
 public void CreateRestoredItems(Restoration restoration, List <IssuingController.Client_AccessoryPK_RestoredQuantity> list)
 {
     try
     {
         // Add restoredItems
         foreach (var item in list)
         {
             RestoredItem restoredItem = new RestoredItem(item.AssessoryPK, item.RestoredQuantity, restoration.RestorationPK);
             db.RestoredItems.Add(restoredItem);
         }
         db.SaveChanges();
     }
     catch (Exception e)
     {
         throw e;
     }
 }
示例#4
0
 public void UpdateRestoredItems(List <IssuingController.Client_RestoredItemPK_RestoredQuantity> list)
 {
     try
     {
         // update restoredItems
         foreach (var item in list)
         {
             RestoredItem restoredItem = db.RestoredItems.Find(item.RestoredItemPK);
             restoredItem.RestoredQuantity = item.RestoredQuantity;
             db.Entry(restoredItem).State  = EntityState.Modified;
         }
         db.SaveChanges();
     }
     catch (Exception e)
     {
         throw e;
     }
 }
示例#5
0
        public void CreateIssueEntry(Client_InputPrepareRequestAPI input, IssuingSession issuingSession)
        {
            try
            {
                Entry     entry;
                Accessory accessory;
                foreach (var item_position_quantity in input.Item_position_quantities)
                {
                    // lấy hàng cần xuất
                    if (item_position_quantity.IsRestored)
                    {
                        RestoredItem restoredItem = db.RestoredItems.Find(item_position_quantity.ItemPK);
                        accessory = db.Accessories.Find(restoredItem.AccessoryPK);
                    }
                    else
                    {
                        PassedItem     passedItem     = db.PassedItems.Find(item_position_quantity.ItemPK);
                        ClassifiedItem classifiedItem = db.ClassifiedItems.Find(passedItem.ClassifiedItemPK);
                        PackedItem     packedItem     = db.PackedItems.Find(classifiedItem.PackedItemPK);
                        OrderedItem    orderedItem    = db.OrderedItems.Find(packedItem.OrderedItemPK);
                        accessory = db.Accessories.Find(orderedItem.AccessoryPK);
                    }
                    // tạo entry xuất trong n - thùng chưa hàng
                    foreach (var item in item_position_quantity.BoxAndQuantity)
                    {
                        StoredBox sBox = db.StoredBoxes.Find(item.StoredBoxPK);
                        if (sBox == null)
                        {
                            throw new Exception("Data StoreBoxes Lỗi!");
                        }

                        entry = new Entry(sBox, "Issuing", issuingSession.IssuingSessionPK, item_position_quantity.IsRestored,
                                          item.Quantity, item_position_quantity.ItemPK, accessory);
                        db.Entries.Add(entry);
                    }
                }
                db.SaveChanges();
            }
            catch (Exception e)
            {
                throw e;
            }
        }
示例#6
0
        public void CreateEntryReceiving(List <IssuingController.Client_Box_List> list, ReceivingSession receivingSession)
        {
            BoxDAO boxDAO = new BoxDAO();

            try
            {
                Dictionary <int, double> mapRestoredItems = new Dictionary <int, double>();
                foreach (var items in list)
                {
                    Box       box  = boxDAO.GetBoxByBoxID(items.BoxID);
                    StoredBox sBox = boxDAO.GetStoredBoxbyBoxPK(box.BoxPK);
                    foreach (var item in items.ListItem)
                    {
                        RestoredItem restoredItem = db.RestoredItems.Find(item.RestoredItemPK);
                        if (!mapRestoredItems.ContainsKey(restoredItem.RestoredItemPK))
                        {
                            mapRestoredItems.Add(restoredItem.RestoredItemPK, item.PlacedQuantity);
                        }
                        else
                        {
                            mapRestoredItems[restoredItem.RestoredItemPK] += item.PlacedQuantity;
                        }
                        Accessory accessory = db.Accessories.Find(restoredItem.AccessoryPK);
                        Entry     entry     = new Entry(sBox, "Receiving", receivingSession.ReceivingSessionPK, true, item.PlacedQuantity, item.RestoredItemPK, accessory);
                        db.Entries.Add(entry);
                    }
                }
                foreach (var item in mapRestoredItems)
                {
                    RestoredItem restoredItem = db.RestoredItems.Find(item.Key);
                    if (item.Value != restoredItem.RestoredQuantity)
                    {
                        throw new Exception("TỔNG HÀNG LƯU KHO KHÔNG GIỐNG HÀNG ĐƯỢC TRẢ!");
                    }
                }
                db.SaveChanges();
            }
            catch (Exception e)
            {
                throw e;
            }
        }
示例#7
0
 public void CreateInAndOutEntry(List <Client_ItemPK_TransferQuantity_IsRestored> list, StoredBox sBoxFrom, StoredBox sBoxTo, TransferringSession transferringSession)
 {
     try
     {
         foreach (var item in list)
         {
             Accessory accessory;
             if (item.IsRestored)
             {
                 RestoredItem restoredItem = db.RestoredItems.Find(item.ItemPK);
                 accessory = db.Accessories.Find(restoredItem.AccessoryPK);
             }
             else
             {
                 PassedItem     passedItem     = db.PassedItems.Find(item.ItemPK);
                 ClassifiedItem classifiedItem = db.ClassifiedItems.Find(passedItem.ClassifiedItemPK);
                 PackedItem     packedItem     = db.PackedItems.Find(classifiedItem.PackedItemPK);
                 OrderedItem    orderedItem    = db.OrderedItems.Find(packedItem.OrderedItemPK);
                 accessory = db.Accessories.Find(orderedItem.AccessoryPK);
             }
             // Tạo out entry
             Entry entry = new Entry(sBoxFrom, "Out", transferringSession.TransferingSessionPK,
                                     item.IsRestored, item.TransferQuantity, item.ItemPK, accessory);
             db.Entries.Add(entry);
             // Tạo in entry
             entry = new Entry(sBoxTo, "In", transferringSession.TransferingSessionPK,
                               item.IsRestored, item.TransferQuantity, item.ItemPK, accessory);
             db.Entries.Add(entry);
         }
         db.SaveChanges();
     }
     catch (Exception e)
     {
         throw e;
     }
 }
示例#8
0
        public List <Client_Box_Shelf_Row> StoredBox_ItemPK_IsRestoredOfEntries(Accessory accessory)
        {
            List <Client_Box_Shelf_Row> result = new List <Client_Box_Shelf_Row>();
            StoringDAO storingDAO = new StoringDAO();

            try
            {
                // cực phẩm IQ
                double inStoredQuantity = InStoredQuantity(accessory.AccessoryPK);
                if (inStoredQuantity == 0)
                {
                    throw new Exception("HÀNG TRONG KHO ĐÃ HẾT!");
                }
                List <Entry> entries = (from e in db.Entries
                                        where e.AccessoryPK == accessory.AccessoryPK
                                        select e).ToList();
                Dictionary <StoredBox_ItemPK_IsRestored, InBoxQuantity_AvailableQuantity> tempDictionary = new Dictionary <StoredBox_ItemPK_IsRestored, InBoxQuantity_AvailableQuantity>();
                foreach (var entry in entries)
                {
                    double    inBoxQuantity = 0;
                    StoredBox storedBox     = db.StoredBoxes.Find(entry.StoredBoxPK);

                    if (entry.KindRoleName == "AdjustingMinus" || entry.KindRoleName == "AdjustingPlus")
                    {
                        AdjustingSession adjustingSession = db.AdjustingSessions.Find(entry.SessionPK);
                        Verification     verification     = db.Verifications.Where(unit => unit.SessionPK == adjustingSession.AdjustingSessionPK &&
                                                                                   unit.IsDiscard == false).FirstOrDefault();
                        if (verification != null && verification.IsApproved)
                        {
                            inBoxQuantity = storingDAO.EntryQuantity(entry);
                        }
                    }
                    else if (entry.KindRoleName == "Discarding")
                    {
                        DiscardingSession discardingSession = db.DiscardingSessions.Find(entry.SessionPK);
                        Verification      verification      = db.Verifications.Where(unit => unit.SessionPK == discardingSession.DiscardingSessionPK &&
                                                                                     unit.IsDiscard == true).FirstOrDefault();
                        if (verification != null && verification.IsApproved)
                        {
                            inBoxQuantity = storingDAO.EntryQuantity(entry);
                        }
                    }
                    else
                    {
                        inBoxQuantity = storingDAO.EntryQuantity(entry);
                    }

                    Box          box = db.Boxes.Find(storedBox.BoxPK);
                    PassedItem   passedItem;
                    RestoredItem restoredItem;
                    StoredBox_ItemPK_IsRestored key;
                    if (entry.IsRestored)
                    {
                        restoredItem = db.RestoredItems.Find(entry.ItemPK);
                        key          = new StoredBox_ItemPK_IsRestored(storedBox.StoredBoxPK, restoredItem.RestoredItemPK, entry.IsRestored);
                    }
                    else
                    {
                        passedItem = db.PassedItems.Find(entry.ItemPK);
                        key        = new StoredBox_ItemPK_IsRestored(storedBox.StoredBoxPK, passedItem.PassedItemPK, entry.IsRestored);
                    }
                    if (box.IsActive)
                    {
                        InBoxQuantity_AvailableQuantity tmp = new InBoxQuantity_AvailableQuantity(inBoxQuantity, storingDAO.EntryQuantity(entry));
                        if (!tempDictionary.ContainsKey(key))
                        {
                            tempDictionary.Add(key, tmp);
                        }
                        else
                        {
                            tempDictionary[key].InBoxQuantity     += tmp.InBoxQuantity;
                            tempDictionary[key].AvailableQuantity += tmp.AvailableQuantity;
                        }
                    }
                }

                foreach (var item in tempDictionary)
                {
                    if (item.Value.AvailableQuantity > 0)
                    {
                        StoredBox storedBox = db.StoredBoxes.Find(item.Key.StoredBoxPK);
                        Box       box       = db.Boxes.Find(storedBox.BoxPK);
                        Shelf     shelf     = db.Shelves.Find(storedBox.ShelfPK);
                        Row       row       = db.Rows.Find(shelf.RowPK);
                        if (item.Key.IsRestored)
                        {
                            RestoredItem restoredItem = db.RestoredItems.Find(item.Key.ItemPK);
                            Restoration  restoration  = db.Restorations.Find(restoredItem.RestorationPK);
                            result.Add(new Client_Box_Shelf_Row(box.BoxID, storedBox.StoredBoxPK, shelf.ShelfID, row.RowID, item.Key.ItemPK, item.Key.IsRestored, item.Value.InBoxQuantity, restoration.RestorationID, item.Value.AvailableQuantity));
                        }
                        else
                        {
                            PassedItem     passedItem     = db.PassedItems.Find(item.Key.ItemPK);
                            ClassifiedItem classifiedItem = db.ClassifiedItems.Find(passedItem.ClassifiedItemPK);
                            PackedItem     packedItem     = db.PackedItems.Find(classifiedItem.PackedItemPK);
                            Pack           pack           = db.Packs.Find(packedItem.PackPK);
                            result.Add(new Client_Box_Shelf_Row(box.BoxID, storedBox.StoredBoxPK, shelf.ShelfID, row.RowID, item.Key.ItemPK, item.Key.IsRestored, item.Value.InBoxQuantity, pack.PackID, item.Value.AvailableQuantity));
                        }
                    }
                }
            }
            catch (Exception e)
            {
                throw e;
            }
            return(result);
        }