private void HandleButtonSelected(object sender, ButtonMatrix.ButtonSelectedEventArgs e)
        {
            dateSel = (Order.PackedOn)e.obj;

            DialogResult = DialogResult.OK;
            Close();
        }
        public ChooseReworkDateDialog()
        {
            InitializeComponent();

            buttonMatrix1.ButtonSelected += HandleButtonSelected;
            dateSel = null;
        }
Beispiel #3
0
        private void btnChooseSlDate_Click(object sender, EventArgs e)
        {
            if (CommonData.slDates.Count == 0)
            {
                MessageLogger.Add("No packing dates maintained", MessageLogger.MsgLevel.error);
                return;
            }

            var cd = new ChooseReworkDateDialog();

            cd.dateSel = reworkDateSel;
            if (cd.ShowDialog() == DialogResult.OK)
            {
                reworkDateSel = cd.dateSel;
                UpdateModeText();
            }
        }
Beispiel #4
0
        private void MainScreen_Load(object sender, EventArgs e)
        {
            MessageLogger.SetLogControl(this.messageLog1);

            this.Text        += " - " + CommonData.sapSettings.device;
            btnRecord.Visible = false;
            grpBoxSelectedMaterial.Visible = false;

            barcodeScanner1.startRunning(this);

            if (CommonData.localSettings.OtherPackingStationPort != 0)
            {
                backgroundWorker1.RunWorkerAsync();
            }

            txtUserName.Text = string.Format("User: {0}", ThisApp.user);

            // Do main application initialisation in a separate thread, showing the startup dialog while we're waiting
            new BusyDialog(ThisApp.Initialise).ShowDialog();

            if (CommonData.slDates.Count > 0)
            {
                reworkDateSel = CommonData.slDates[0];
            }

            scaleIndicator1.SetReader(ScaleReader.GetScaleReader());
            ThisApp.scale = scaleIndicator1;

            buttonMatrix1.Setup(4, 2, CommonData.normalOrders.Cast <ButtonMatrix.MatrixObject>().ToList());

            numericKeypad1.ValueChanged  += HandleFilterValueChanged;
            buttonMatrix1.ButtonSelected += HandleButtonSelected;
            barcodeScanner1.BarcodeRead  += HandleBarcodeScanned;

            UpdateModeText();
        }
Beispiel #5
0
        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);
        }