public void updateAllIdentifiedItemsToVirtualBox(int failedItemPK) { try { FailedItem failedItem = db.FailedItems.Find(failedItemPK); ClassifiedItem classifiedItem = db.ClassifiedItems.Find(failedItem.ClassifiedItemPK); PackedItem packedItem = db.PackedItems.Find(classifiedItem.PackedItemPK); List <IdentifiedItem> identifiedItems = (from iI in db.IdentifiedItems where iI.PackedItemPK == packedItem.PackedItemPK select iI).ToList(); UnstoredBox virtualBox = (from uB in db.UnstoredBoxes where uB.BoxPK == (from b in db.Boxes where b.BoxID == "InvisibleBox" select b).FirstOrDefault().BoxPK select uB).FirstOrDefault(); foreach (var item in identifiedItems) { item.UnstoredBoxPK = virtualBox.UnstoredBoxPK; db.Entry(item).State = EntityState.Modified; } db.SaveChanges(); } catch (Exception e) { throw e; } }
public void CreateBox(int boxKind, int boxPK) { try { UnstoredBox unstoredBox; //StoredBox storedBox; switch (boxKind) { case 1: unstoredBox = new UnstoredBox(boxPK, false); db.UnstoredBoxes.Add(unstoredBox); break; case 2: unstoredBox = new UnstoredBox(boxPK, true); db.UnstoredBoxes.Add(unstoredBox); break; case 3: break; default: break; } db.SaveChanges(); } catch (Exception e) { throw e; } }
public void UpdateIsIdentifyUnstoreBox(UnstoredBox uBox, bool value) { try { uBox.IsIdentified = value; db.Entry(uBox).State = EntityState.Modified; db.SaveChanges(); } catch (Exception e) { throw e; } }
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; } }
public IHttpActionResult GetItemByBoxID(string boxID) { BoxDAO boxDAO = new BoxDAO(); StoringDAO storingDAO = new StoringDAO(); try { Box box = boxDAO.GetBoxByBoxID(boxID); if (box != null) { StoredBox sBox = boxDAO.GetStoredBoxbyBoxPK(box.BoxPK); UnstoredBox uBox = boxDAO.GetUnstoredBoxbyBoxPK(box.BoxPK); // Nếu box chưa identify if (uBox.IsIdentified) { // nếu box chưa được store if (!(boxDAO.IsStored(box.BoxPK))) { List <Client_IdentifiedItemRead> client_IdentifiedItems = new List <Client_IdentifiedItemRead>(); List <IdentifiedItem> identifiedItems; 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); // lấy pack ID Pack pack = db.Packs.Find(packedItem.PackPK); // lấy phụ liệu tương ứng OrderedItem orderedItem = db.OrderedItems.Find(packedItem.OrderedItemPK); Accessory accessory = db.Accessories.Find(orderedItem.AccessoryPK); // lấy qualityState ClassifiedItem classifiedItem = (from cI in db.ClassifiedItems where cI.PackedItemPK == packedItem.PackedItemPK select cI).FirstOrDefault(); int?qualityState = null; if (classifiedItem != null) { qualityState = classifiedItem.QualityState; } client_IdentifiedItems.Add(new Client_IdentifiedItemRead(identifiedItem, accessory, pack.PackID, qualityState)); } return(Content(HttpStatusCode.OK, client_IdentifiedItems)); } else { Client_InBoxItems_Shelf <Client_Shelf> result; Client_Shelf client_Shelf; List <Client_InBoxItem> client_InBoxItems = new List <Client_InBoxItem>(); Shelf shelf = db.Shelves.Find(sBox.ShelfPK); Row row = db.Rows.Find(shelf.RowPK); client_Shelf = new Client_Shelf(shelf.ShelfID, row.RowID); // Get list inBoxItem List <Entry> entries = (from e in db.Entries where e.StoredBoxPK == sBox.StoredBoxPK select e).ToList(); HashSet <KeyValuePair <int, bool> > listItemPK = new HashSet <KeyValuePair <int, bool> >(); foreach (var entry in entries) { listItemPK.Add(new KeyValuePair <int, bool>(entry.ItemPK, entry.IsRestored)); } foreach (var itemPK in listItemPK) { List <Entry> tempEntries = new List <Entry>(); foreach (var entry in entries) { if (entry.ItemPK == itemPK.Key && entry.IsRestored == itemPK.Value) { tempEntries.Add(entry); } } if (tempEntries.Count > 0 && storingDAO.EntriesQuantity(tempEntries) > 0) { Entry entry = tempEntries[0]; PassedItem passedItem; RestoredItem restoredItem; if (entry.IsRestored) { restoredItem = db.RestoredItems.Find(entry.ItemPK); Restoration restoration = db.Restorations.Find(restoredItem.RestorationPK); Accessory accessory = db.Accessories.Find(restoredItem.AccessoryPK); client_InBoxItems.Add(new Client_InBoxItem(accessory, restoration.RestorationID, storingDAO.EntriesQuantity(tempEntries), restoredItem.RestoredItemPK, true)); } else { passedItem = db.PassedItems.Find(entry.ItemPK); ClassifiedItem classifiedItem = db.ClassifiedItems.Find(passedItem.ClassifiedItemPK); PackedItem packedItem = db.PackedItems.Find(classifiedItem.PackedItemPK); // 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_InBoxItems.Add(new Client_InBoxItem(accessory, pack.PackID, storingDAO.EntriesQuantity(tempEntries), passedItem.PassedItemPK, false)); } } } result = new Client_InBoxItems_Shelf <Client_Shelf>(client_Shelf, client_InBoxItems); return(Content(HttpStatusCode.OK, result)); } } else { return(Content(HttpStatusCode.Conflict, "THÙNG NÀY CHƯA ĐƯỢC GHI NHẬN")); } } else { return(Content(HttpStatusCode.Conflict, "ĐỐI TƯỢNG KHÔNG TỒN TẠI")); } } catch (Exception e) { return(Content(HttpStatusCode.Conflict, new Content_InnerException(e).InnerMessage())); } }
public List <Client_Session_Activity_Angular> GetSessions(int sessionNum) { List <Client_Session_Activity_Angular> result = new List <Client_Session_Activity_Angular>(); switch (sessionNum) { case 1: List <IdentifyingSession> identifyingSessions = (from ss in db.IdentifyingSessions select ss).ToList(); foreach (var ss in identifyingSessions) { SystemUser systemUser = db.SystemUsers.Find(ss.UserID); // query pack IdentifiedItem identifiedItem = (from iI in db.IdentifiedItems where iI.IdentifyingSessionPK == ss.IdentifyingSessionPK select iI).FirstOrDefault(); PackedItem packedItem = db.PackedItems.Find(identifiedItem.PackedItemPK); Pack pack = db.Packs.Find(packedItem.PackPK); string content = "Ghi nhận " + "cụm phụ liệu thuộc Phiếu nhập mã số " + pack.PackID; result.Add(new Client_Session_Activity_Angular(ss.ExecutedDate, systemUser.Name + " (" + ss.UserID + ")", content)); } break; case 2: List <CountingSession> countingSessions = (from ss in db.CountingSessions select ss).ToList(); foreach (var ss in countingSessions) { SystemUser systemUser = db.SystemUsers.Find(ss.UserID); // query pack IdentifiedItem identifiedItem = db.IdentifiedItems.Find(ss.IdentifiedItemPK); PackedItem packedItem = db.PackedItems.Find(identifiedItem.PackedItemPK); Pack pack = db.Packs.Find(packedItem.PackPK); string content = "Kiểm số lượng " + "cụm phụ liệu thuộc Phiếu nhập mã số " + pack.PackID; result.Add(new Client_Session_Activity_Angular(ss.ExecutedDate, systemUser.Name + " (" + ss.UserID + ")", content)); } break; case 3: List <CheckingSession> checkingSessions = (from ss in db.CheckingSessions select ss).ToList(); foreach (var ss in checkingSessions) { SystemUser systemUser = db.SystemUsers.Find(ss.UserID); IdentifiedItem identifiedItem = db.IdentifiedItems.Find(ss.IdentifiedItemPK); PackedItem packedItem = db.PackedItems.Find(identifiedItem.PackedItemPK); Pack pack = db.Packs.Find(packedItem.PackPK); string content = "Kiểm chất lượng " + "cụm phụ liệu thuộc Phiếu nhập mã số " + pack.PackID; result.Add(new Client_Session_Activity_Angular(ss.ExecutedDate, systemUser.Name + " (" + ss.UserID + ")", content)); } break; case 4: List <ClassifyingSession> classifyingSessions = (from ss in db.ClassifyingSessions select ss).ToList(); foreach (var ss in classifyingSessions) { SystemUser systemUser = db.SystemUsers.Find(ss.UserID); ClassifiedItem classifiedItem = db.ClassifiedItems.Find(ss.ClassifiedItemPK); PackedItem packedItem = db.PackedItems.Find(classifiedItem.PackedItemPK); Pack pack = db.Packs.Find(packedItem.PackPK); string content = "Đánh giá " + "phụ liệu thuộc Phiếu nhập mã số " + pack.PackID; result.Add(new Client_Session_Activity_Angular(ss.ExecutedDate, systemUser.Name + " (" + ss.UserID + ")", content)); } break; case 5: List <ArrangingSession> arrangingSessions = (from ss in db.ArrangingSessions select ss).ToList(); foreach (var ss in arrangingSessions) { SystemUser systemUser = db.SystemUsers.Find(ss.UserID); UnstoredBox uBox1 = db.UnstoredBoxes.Find(ss.StartBoxPK); Box box1 = db.Boxes.Find(uBox1.BoxPK); UnstoredBox uBox2 = db.UnstoredBoxes.Find(ss.DestinationBoxPK); Box box2 = db.Boxes.Find(uBox2.BoxPK); string content = "Sắp xếp " + "cụm phụ liệu từ thùng mã số " + box1.BoxID.Substring(0, box1.BoxID.Length - 3) + "sang thùng mã số " + box2.BoxID.Substring(0, box2.BoxID.Length - 3); result.Add(new Client_Session_Activity_Angular(ss.ExecutedDate, systemUser.Name + " (" + ss.UserID + ")", content)); } break; case 6: List <ReturningSession> returningSessions = (from ss in db.ReturningSessions select ss).ToList(); foreach (var ss in returningSessions) { SystemUser systemUser = db.SystemUsers.Find(ss.UserID); FailedItem failedItem = db.FailedItems.Find(ss.FailedItemPK); ClassifiedItem classifiedItem = db.ClassifiedItems.Find(failedItem.ClassifiedItemPK); PackedItem packedItem = db.PackedItems.Find(classifiedItem.PackedItemPK); Pack pack = db.Packs.Find(packedItem.PackPK); string content = "Trả hàng lỗi " + "thuộc Phiếu nhập mã số " + pack.PackID; result.Add(new Client_Session_Activity_Angular(ss.ExecutedDate, systemUser.Name + " (" + ss.UserID + ")", content)); } break; case 7: List <StoringSession> storingSessions = (from ss in db.StoringSessions select ss).ToList(); foreach (var ss in storingSessions) { SystemUser systemUser = db.SystemUsers.Find(ss.UserID); Box box = db.Boxes.Find(ss.BoxPK); string content = "Lưu kho " + "thùng mã số " + box.BoxID.Substring(0, box.BoxID.Length - 3); result.Add(new Client_Session_Activity_Angular(ss.ExecutedDate, systemUser.Name + " (" + ss.UserID + ")", content)); } break; case 8: List <MovingSession> movingSessions = (from ss in db.MovingSessions select ss).ToList(); foreach (var ss in movingSessions) { SystemUser systemUser = db.SystemUsers.Find(ss.UserID); StoredBox sBox = db.StoredBoxes.Find(ss.StoredBoxPK); Box box = db.Boxes.Find(sBox.BoxPK); Shelf shelf1 = db.Shelves.Find(ss.StartShelfPK); Shelf shelf2 = db.Shelves.Find(ss.DestinationShelfPK); string content = "Di chuyển thùng " + "mã số " + box.BoxID.Substring(0, box.BoxID.Length - 3) + "từ kệ " + shelf1.ShelfID + "sang kệ " + shelf2.ShelfID; result.Add(new Client_Session_Activity_Angular(ss.ExecutedDate, systemUser.Name + " (" + ss.UserID + ")", content)); } break; case 9: List <TransferringSession> tranferringSessions = (from ss in db.TransferringSessions select ss).ToList(); foreach (var ss in tranferringSessions) { SystemUser systemUser = db.SystemUsers.Find(ss.UserID); StoredBox sBox1 = db.StoredBoxes.Find(ss.StartBoxPK); Box box1 = db.Boxes.Find(sBox1.BoxPK); StoredBox sBox2 = db.StoredBoxes.Find(ss.StartBoxPK); Box box2 = db.Boxes.Find(sBox2.BoxPK); string content = "Chuyển phụ liệu " + "tồn kho từ thùng mã số " + box1.BoxID.Substring(0, box1.BoxID.Length - 3) + "sang thùng mã số " + box2.BoxID.Substring(0, box2.BoxID.Length - 3); result.Add(new Client_Session_Activity_Angular(ss.ExecutedDate, systemUser.Name + " (" + ss.UserID + ")", content)); } break; case 10: List <IssuingSession> issuingSessions = (from ss in db.IssuingSessions select ss).ToList(); foreach (var ss in issuingSessions) { SystemUser systemUser = db.SystemUsers.Find(ss.UserID); Request request = db.Requests.Find(ss.RequestPK); string content = "Xuất kho " + "phụ liệu cho Yêu cầu nhận mã số " + request.RequestID; result.Add(new Client_Session_Activity_Angular(ss.ExecutedDate, systemUser.Name + " (" + ss.UserID + ")", content)); } break; case 11: List <ReceivingSession> restoringSessions = (from ss in db.ReceivingSessions select ss).ToList(); foreach (var ss in restoringSessions) { SystemUser systemUser = db.SystemUsers.Find(ss.UserID); Restoration restoration = db.Restorations.Find(ss.RestorationPK); string content = "Nhận tồn " + "phụ liệu thuộc Phiếu trả mã số " + restoration.RestorationID; result.Add(new Client_Session_Activity_Angular(ss.ExecutedDate, systemUser.Name + " (" + ss.UserID + ")", content)); } break; default: break; } return(result); }
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)); }