コード例 #1
0
 public void CreateEntriesUpdatePassedItem(Box box, StoredBox storedBox, StoringSession storingSession)
 {
     try
     {
         IdentifyItemDAO       identifyItemDAO = new IdentifyItemDAO();
         BoxDAO                boxDAO          = new BoxDAO();
         UnstoredBox           unstoredBox     = boxDAO.GetUnstoredBoxbyBoxPK(box.BoxPK);
         List <IdentifiedItem> identifiedItems = (from iI in db.IdentifiedItems
                                                  where iI.UnstoredBoxPK == unstoredBox.UnstoredBoxPK
                                                  select iI).ToList();
         foreach (var identifiedItem in identifiedItems)
         {
             PackedItem packedItem = db.PackedItems.Find(identifiedItem.PackedItemPK);
             // lấy accessory
             OrderedItem orderedItem = db.OrderedItems.Find(packedItem.OrderedItemPK);
             Accessory   accessory   = db.Accessories.Find(orderedItem.AccessoryPK);
             //
             ClassifiedItem classifiedItem = (from cI in db.ClassifiedItems
                                              where cI.PackedItemPK == packedItem.PackedItemPK
                                              select cI).FirstOrDefault();
             if (classifiedItem != null)
             {
                 PassedItem passedItem = (from pI in db.PassedItems
                                          where pI.ClassifiedItemPK == classifiedItem.ClassifiedItemPK
                                          select pI).FirstOrDefault();
                 if (passedItem != null)
                 {
                     UpdatePassedItem(passedItem.PassedItemPK);
                     // tạo entry
                     Entry entry = new Entry(storedBox, "Storing", storingSession.StoringSessionPK, false,
                                             identifyItemDAO.ActualQuantity(identifiedItem.IdentifiedItemPK), passedItem.PassedItemPK, accessory);
                     db.Entries.Add(entry);
                 }
                 else
                 {
                     throw new Exception("ITEM KHÔNG HỢP LỆ");
                 }
             }
             else
             {
                 throw new Exception("ITEM KHÔNG HỢP LỆ");
             }
         }
         db.SaveChanges();
     }
     catch (Exception e)
     {
         throw e;
     }
 }
コード例 #2
0
        public IHttpActionResult GetIdentifyItemByBoxID(string boxID)
        {
            List <IdentifiedItem> identifiedItems;
            List <Client_IdentifiedItemStored> client_IdentifiedItems = new List <Client_IdentifiedItemStored>();
            BoxDAO          boxController   = new BoxDAO();
            IdentifyItemDAO identifyItemDAO = new IdentifyItemDAO();

            try
            {
                Box         box  = boxController.GetBoxByBoxID(boxID);
                UnstoredBox uBox = boxController.GetUnstoredBoxbyBoxPK(box.BoxPK);
                if (!boxController.IsStored(box.BoxPK) && uBox.IsIdentified == true)
                {
                    identifiedItems = (from iI in db.IdentifiedItems.OrderByDescending(unit => unit.PackedItemPK)
                                       where iI.UnstoredBoxPK == uBox.UnstoredBoxPK
                                       select iI).ToList();

                    foreach (var identifiedItem in identifiedItems)
                    {
                        PackedItem     packedItem     = db.PackedItems.Find(identifiedItem.PackedItemPK);
                        ClassifiedItem classifiedItem = (from cI in db.ClassifiedItems
                                                         where cI.PackedItemPK == packedItem.PackedItemPK
                                                         select cI).FirstOrDefault();
                        if (classifiedItem != null)
                        {
                            PassedItem passedItem = (from pI in db.PassedItems
                                                     where pI.ClassifiedItemPK == classifiedItem.ClassifiedItemPK
                                                     select pI).FirstOrDefault();
                            if (passedItem != null)
                            {
                                // lấy pack ID
                                Pack pack = (from p in db.Packs
                                             where p.PackPK == packedItem.PackPK
                                             select p).FirstOrDefault();

                                // lấy phụ liệu tương ứng
                                OrderedItem orderedItem = (from oI in db.OrderedItems
                                                           where oI.OrderedItemPK == packedItem.OrderedItemPK
                                                           select oI).FirstOrDefault();

                                Accessory accessory = (from a in db.Accessories
                                                       where a.AccessoryPK == orderedItem.AccessoryPK
                                                       select a).FirstOrDefault();

                                client_IdentifiedItems.Add(new Client_IdentifiedItemStored(identifiedItem, accessory, pack,
                                                                                           identifyItemDAO.ActualQuantity(identifiedItem.IdentifiedItemPK)));
                            }
                            else
                            {
                                return(Content(HttpStatusCode.Conflict, "TỒN TẠI ÍT NHẤT MỘT CỤM PHỤ LIỆU KHÔNG ĐẠT!"));
                            }
                        }
                        else
                        {
                            return(Content(HttpStatusCode.Conflict, "TỒN TẠI ÍT NHẤT MỘT CỤM PHỤ LIỆU KHÔNG ĐẠT!"));
                        }
                    }
                }
                else
                {
                    return(Content(HttpStatusCode.Conflict, "BOX ĐÃ ĐƯỢC STORE HOẶC CHƯA IDENTIFIED !"));
                }
            }
            catch (Exception e)
            {
                return(Content(HttpStatusCode.Conflict, new Content_InnerException(e).InnerMessage()));
            }

            return(Content(HttpStatusCode.OK, client_IdentifiedItems));
        }