public static void CancelLast() { if (packLastPrint == null) { MessageLogger.Add("No last carton to cancel", MessageLogger.MsgLevel.error); return; //Nothing receipted yet, or has already been cancelled } if (packLastPrint.SetCancelled()) { MessageLogger.Add(string.Format("Barcode {0} Material {1} Weight {2} cancelled", packLastPrint.barcode, packLastPrint.materialNum, packLastPrint.netWeight), MessageLogger.MsgLevel.info); ordLastPrint.IncreaseDeliveredQty(-packLastPrint.qty, incOrdLastPrint); if (CommonData.localSettings.OtherPackingStationPort != 0) { // Start new thread to send carton receipt info to the other packing station var ri = new InterStationComms.ReceiptInfo(); ri.materialNum = incOrdLastPrint.materialNum; ri.orderNum = incOrdLastPrint.orderNum; ri.qtyPacked = -packLastPrint.qty; ThreadPool.QueueUserWorkItem(new WaitCallback(InterStationComms.SendToOtherStation), ri); } ordLastPrint = null; incOrdLastPrint = null; packLastPrint = null; } }
public static bool CancelCartonReceipt(string bc) { if (bc.Length < 8) { MessageLogger.Add(string.Format("Funny looking barcode {0} - cannot process", bc), MessageLogger.MsgLevel.error); return(false); } ulong serial; if (!ulong.TryParse(bc.Substring(0, bc.Length - 3), out serial)) { MessageLogger.Add(string.Format("Non-numeric barcode {0} - cannot process", bc), MessageLogger.MsgLevel.error); return(false); } Pack p = Pack.ReadSingle(serial); if (p == null) { MessageLogger.Add(string.Format("Unrecognised barcode {0}", bc), MessageLogger.MsgLevel.error); return(false); } if (p.cancelled) { MessageLogger.Add(string.Format("Barcode {0} - already cancelled", bc), MessageLogger.MsgLevel.error); return(false); } if (p.SetCancelled()) { MessageLogger.Add(string.Format("Barcode {0} Material {1} Weight {2} cancelled", bc, p.materialNum, p.netWeight), MessageLogger.MsgLevel.info); } var ord = CommonData.normalOrders.Find(o => o.materialNum.Equals(p.materialNum)); if (ord == null) { ord = CommonData.reworkOrders.Find(o => o.materialNum.Equals(p.materialNum)); } if (ord != null) { var incOrd = ord.incOrders.Find(i => i.orderNum.Equals(p.orderNum)); if (incOrd != null) { ord.IncreaseDeliveredQty(-p.qty, incOrd); if (CommonData.localSettings.OtherPackingStationPort != 0) { // Start new thread to send carton receipt info to the other packing station var ri = new InterStationComms.ReceiptInfo(); ri.materialNum = incOrd.materialNum; ri.orderNum = incOrd.orderNum; ri.qtyPacked = -p.qty; ThreadPool.QueueUserWorkItem(new WaitCallback(InterStationComms.SendToOtherStation), ri); } if (packLastPrint?.serial == p.serial) { // Have just cancelled the last pack receipted, clear out "Last Pack" fields ordLastPrint = null; incOrdLastPrint = null; packLastPrint = null; } return(true); } } return(false); }
public static bool PostReceipt(Order ord, Mode mode, Order.PackedOn reworkDateSel = null, Order.IncOrder incOrderSel = null) { // Get weight from scale if (scale.ReadScale(out decimal gross, out decimal net, out decimal tare) != ScaleReader.Stability.stableWeight) { MessageLogger.Add("Stable weight not returned from scale", MessageLogger.MsgLevel.error); return(false); } if (tare <= 0) { MessageLogger.Add("No tare weight returned from scale", MessageLogger.MsgLevel.error); return(false); } Order.IncOrder incOrd; if (incOrderSel == null) { // No specific order selected by user - use the order at the top of the list, which is always sorted to // put the highest priority, not-yet-completely-delivered order at the top. incOrd = ord.incOrders[0]; } else { // User has selected a specific order i.e. we're in bin receipting mode incOrd = incOrderSel; } if (net < 0) { MessageLogger.Add("Negative net weight returned from scale.", MessageLogger.MsgLevel.error); return(false); } if (!ThisApp.weightToleranceDisabled) { // Check maximum and minimum carton weights if (ord.material.minWeight != 0M && net < ord.material.minWeight) { MessageLogger.Add(string.Format("Weight ({1:0.00} kg) is below the minimum weight of {0:0.00}", ord.material.minWeight, net), MessageLogger.MsgLevel.error); return(false); } if (ord.material.maxWeight != 0M && net > ord.material.maxWeight) { MessageLogger.Add(string.Format("Weight ({1:0.00} kg) is above the maximum weight of {0:0.00}", ord.material.maxWeight, net), MessageLogger.MsgLevel.error); return(false); } } decimal qtyToPack; if (ord.material.baseUom.Equals("KG")) { qtyToPack = net; // Receipting a bin } else { qtyToPack = 1; // Packing a single carton } //Check over delivery tolerance if (ord.maxQty != 0M && (ord.packedQty + qtyToPack) > ord.maxQty) { MessageLogger.Add(string.Format("Maximum qty of {0} {1} already packed for this product", ord.maxQty, ord.Uom), MessageLogger.MsgLevel.error); return(false); } if (mode == Mode.Rework && reworkDateSel == null) { MessageLogger.Add("Please select a production date for re-work,", MessageLogger.MsgLevel.error); return(false); } decimal actWeight = net; DateTime manuDate; string slaughterDates; if (mode == Mode.Rework) { manuDate = reworkDateSel.packedOn; slaughterDates = reworkDateSel.slaughterDates; } else { manuDate = DateTime.Now; slaughterDates = incOrd.slaughterDates; } if (ord.material.fixedWeight) { net = ord.material.nomWeight; //Fixed weight carton, always pack at nominal weight } Pack pack = new Pack(incOrd: incOrd, mat: ord.material, _qty: qtyToPack, _uom: ord.material.baseUom, _netWeight: net, _tareWeight: tare, _actualWeight: actWeight, _manuDate: manuDate, _slaughterDates: slaughterDates, _terminal: CommonData.sapSettings.device, _batch: manuDate.ToString("yyyyMMdd"), _user: ThisApp.user?.userId); DBOperations.BeginTransaction(); pack.InsertSingle(); ord.IncreaseDeliveredQty(qtyToPack, incOrd); DBOperations.CommitTransaction(); var barcode = PrintLabel(ord, incOrd, pack); if (CommonData.localSettings.OtherPackingStationPort != 0) { // Start new thread to send carton receipt info to the other packing station var ri = new InterStationComms.ReceiptInfo(); ri.materialNum = incOrd.materialNum; ri.orderNum = incOrd.orderNum; ri.qtyPacked = qtyToPack; ThreadPool.QueueUserWorkItem(new WaitCallback(InterStationComms.SendToOtherStation), ri); } MessageLogger.Add(string.Format("Packed material {0} barcode {1} weight {2}", pack.materialNum, pack.serial, net), MessageLogger.MsgLevel.info); return(true); }