public Client_CheckingSession(Accessory accessory, Pack pack, CheckingSession checkingSession) { CheckingSessionPK = checkingSession.CheckingSessionPK; ExecutedDate = checkingSession.ExecutedDate; AccessoryID = accessory.AccessoryID; AccessoryDescription = accessory.AccessoryDescription; Art = accessory.Art; Color = accessory.Color; Item = accessory.Item; PackID = pack.PackID; }
internal void createCheckingSession(CheckingSession checkingSession) { try { db.CheckingSessions.Add(checkingSession); db.SaveChanges(); } catch (Exception e) { throw e; } }
public void deleteCheckingSession(int checkingSessionPK) { try { CheckingSession checkingSession = db.CheckingSessions.Find(checkingSessionPK); db.CheckingSessions.Remove(checkingSession); db.SaveChanges(); } catch (Exception e) { throw e; } }
public void updateCheckingSession(int checkingSessionPK, double checkedQuantity, double unqualifiedQuantity, string comment) { try { CheckingSession checkingSession = db.CheckingSessions.Find(checkingSessionPK); checkingSession.CheckedQuantity = checkedQuantity; checkingSession.UnqualifiedQuantity = unqualifiedQuantity; checkingSession.ExecutedDate = DateTime.Now; checkingSession.Comment = comment; db.Entry(checkingSession).State = EntityState.Modified; db.SaveChanges(); } catch (Exception e) { throw e; } }
public Client_CheckingSessionDetail(Accessory accessory, Pack pack, CheckingSession checkingSession, Box box, PackedItem packedItem, double sample) { CheckingSessionPK = checkingSession.CheckingSessionPK; ExecutedDate = checkingSession.ExecutedDate; CheckedQuantity = checkingSession.CheckedQuantity; UnqualifiedQuantity = checkingSession.UnqualifiedQuantity; Comment = checkingSession.Comment; AccessoryID = accessory.AccessoryID; AccessoryDescription = accessory.AccessoryDescription; Art = accessory.Art; Color = accessory.Color; Item = accessory.Item; PackID = pack.PackID; BoxID = box.BoxID; IsClassified = packedItem.IsClassified; Sample = sample; }
public void IsInitAllCalculate(int packedItemPK) { try { double tempSample = 0; double tempDefectLimit = 0; List <IdentifiedItem> identifiedItems = (from iI in db.IdentifiedItems where iI.PackedItemPK == packedItemPK select iI).ToList(); foreach (var item in identifiedItems) { // init session CountingSession countingSession = (from countss in db.CountingSessions where countss.IdentifiedItemPK == item.IdentifiedItemPK select countss).FirstOrDefault(); CheckingSession checkingSession = (from checkss in db.CheckingSessions where checkss.IdentifiedItemPK == item.IdentifiedItemPK select checkss).FirstOrDefault(); // assign value to variable tempSample += item.IdentifiedQuantity; tempDefectLimit += item.IdentifiedQuantity; SumOfIdentifiedQuantity += item.IdentifiedQuantity; if (countingSession != null) { SumOfCountedQuantity += countingSession.CountedQuantity; } if (checkingSession != null) { SumOfUnqualifiedQuantity += checkingSession.UnqualifiedQuantity; SumOfCheckedQuantity += checkingSession.CheckedQuantity; } } Sample = SampleCaculate(tempSample); DefectLimit = DefectLimitCaculate(tempDefectLimit); } catch (Exception e) { throw new Exception("HÀM TÍNH SAMPLE VÀ DEFECT LIMIT BỊ LỖI"); } }
public double FinalQuantity(int packedItemPK) { double result = 0; try { List <IdentifiedItem> identifiedItems = (from iI in db.IdentifiedItems where iI.PackedItemPK == packedItemPK select iI).ToList(); foreach (var item in identifiedItems) { int numCase = 0; CheckingSession checkingSession = (from checkss in db.CheckingSessions where checkss.IdentifiedItemPK == item.IdentifiedItemPK select checkss).FirstOrDefault(); CountingSession countingSession = (from countss in db.CountingSessions where countss.IdentifiedItemPK == item.IdentifiedItemPK select countss).FirstOrDefault(); if (item.IsChecked == false && item.IsCounted == false) { numCase = 1; } if (item.IsChecked == false && item.IsCounted == true) { numCase = 2; } if (item.IsChecked == true && item.IsCounted == false) { numCase = 3; } if (item.IsChecked == true && item.IsCounted == true) { if (checkingSession.ExecutedDate < countingSession.ExecutedDate) { numCase = 4; } else { numCase = 5; } } switch (numCase) { case 1: result += item.IdentifiedQuantity; break; case 2: result += countingSession.CountedQuantity; break; case 3: result += item.IdentifiedQuantity - checkingSession.UnqualifiedQuantity; break; case 4: result += countingSession.CountedQuantity; break; case 5: result += countingSession.CountedQuantity - checkingSession.UnqualifiedQuantity; break; default: break; } } } catch (Exception e) { throw e; } return(result); }