Ejemplo n.º 1
0
 private void WeighingStationOnWeighingDataInRange(double value)
 {
     lblWeighing.ForeColor = Color.Green;
     // print grouping label
     if (!_weighingStation.NeedToRemove)
     {
         if (_groupBox.PendingDoPrint())
         {
             _groupingLabel?.Print();
         }
     }
 }
Ejemplo n.º 2
0
        private void OnPackingStateChanged(PackingStates states)
        {
            switch (states)
            {
            case PackingStates.Unknown:
                ShowInformation("Unknown State.");
                break;

            case PackingStates.WakingUp:
                ShowInformation("Memuat Ulang Work Order Terakhir yang running.");
                _workOrder = new WorkOrder(Settings.DatabaseWorkOrder, Settings.ProviderDataBase);
                _workOrder = _workOrder.GetByWorkOrderNumber(Settings.LastWorkOrder);
                if (_workOrder.ProdOrderNumber == null)
                {
                    SetPackingState(PackingStates.ReadBarcodeProdOrderNumber);
                    _barcodeEntry.State = BarcodeState.ReadWorkOrder;
                    break;
                }
                ShowWorkOrderLabels(_workOrder);
                SetPackingState(PackingStates.LoadingReference);
                break;

            case PackingStates.NoWorkOrder:
                break;

            case PackingStates.ReadBarcodeProdOrderNumber:
                ShowInformation("Scan Production Order Ticket.");
                break;

            case PackingStates.ReadBarcodeReferemce:
                ShowInformation("Scan Reference on Ticket.");
                break;

            case PackingStates.ReadBarcodeTarget:
                ShowInformation("Scan Quantity on Ticket.");
                break;

            case PackingStates.LoadingReference:
                ShowInformation("Memuat Product Reference.");
                var j = LoadReference(txtReference.Text);
                if (!j)
                {
                    SetPackingState(PackingStates.ReadBarcodeProdOrderNumber);
                    _barcodeEntry.State = BarcodeState.ReadWorkOrder;
                    break;
                }
                _barcodeEntry.State = BarcodeState.None;
                SetPackingState(PackingStates.CreateWorkOrder);
                break;

            case PackingStates.WaitingForProduct:
                ShowInformation("Menunggu Produk.");
                if (_zelioPlc.SensorProduct == IoSate.On)
                {
                    SetPackingState(PackingStates.PrintingLabeL);
                }
                break;

            case PackingStates.PrintingLabeL:
                ShowInformation("Mencetak Individual Label");
                if (_zelioPlc.SensorLabel == IoSate.Off)
                {
                    _individualLabel?.Print();
                    timerPrintDelay.Start();
                }
                else
                {
                    SetPackingState(PackingStates.AskToRemoveLabel);
                }
                break;

            case PackingStates.WaitingBarcode:
                ShowInformation("Pack product, kemudian:\r\n Scan Barcode pada Individual Box");
                _barcodeEntry.State = BarcodeState.ReadPastedLabel;
                break;

            case PackingStates.ProductPassed:
                ShowInformation("Packing Pass. Masukkan Ke Kotak ");
                IncreaseWorkOrderPass(1);
                SetPackingState(PackingStates.WaitingForProduct);
                break;

            case PackingStates.ProductFailed:
                ShowInformation("Packing Failed");
                SetPackingState(PackingStates.RejectBin);
                break;

            case PackingStates.RejectBin:
                ShowInformation("Masukkan Produk Ke Reject Bin");
                break;

            case PackingStates.BoxError:
                break;

            case PackingStates.PrintingGroupingLabel:
                break;

            case PackingStates.SetWeighing:
                break;

            case PackingStates.CreateWorkOrder:
                ShowInformation("Create or Load Work Order.");
                _workOrder = new WorkOrder(Settings.DatabaseWorkOrder, Settings.ProviderDataBase, txtProdOrderNumber.Text, txtReference.Text, Convert.ToInt32(txtTargetQuantity.Text));
                if (_workOrder.Reference != _referenceData.Reference.Reference)     //Confirm correct reference
                {
                    _referenceData.Unload();
                    txtReference.Text = _workOrder.Reference;
                    LoadReference(txtReference.Text);
                }

                if (_workOrder.ProdOrderNumber == null)
                {
                    SetPackingState(PackingStates.ReadBarcodeProdOrderNumber);
                    _barcodeEntry.State = BarcodeState.ReadWorkOrder;
                    break;
                }
                try
                {
                    if (_groupBox != null)
                    {
                        _groupBox.GroupingIsAchievedTarget -= GroupBoxOnGroupingIsAchievedTarget;
                        _groupBox.RemainingValueChanged    -= GroupBoxOnRemainingValueChanged;
                    }
                }

                finally
                {
                    _groupBox = new Grouping(_referenceData.Reference.QuantityGroup, _workOrder.QuantityPass);
                    _groupBox.GroupingIsAchievedTarget += GroupBoxOnGroupingIsAchievedTarget;
                    _groupBox.RemainingValueChanged    += GroupBoxOnRemainingValueChanged;

                    lblRemaining.Text = _groupBox.Remaining.ToString("000");
                }

                ShowWorkOrderLabels(_workOrder);
                Settings.LastWorkOrder = _workOrder.ProdOrderNumber;
                Settings.Save();
                Settings.Reload();

                if (_groupBox.Packed == _workOrder.QuantityTarget)
                {
                    MessageBox.Show(@"Target Quantity sudah terpenuhi.\r\nWorkOrder otomatis ditutup.", @"Target",
                                    MessageBoxButtons.OK, MessageBoxIcon.Information);
                    _barcodeEntry.State = BarcodeState.ReadWorkOrder;
                    _referenceData?.Unload();
                    SetPackingState(PackingStates.ReadBarcodeProdOrderNumber);
                }
                SetPackingState(PackingStates.WaitingForProduct);
                break;

            case PackingStates.AskToRemoveLabel:
                ShowInformation("Ambil label lalu tempelkan ke Box");
                break;

            case PackingStates.PrintingIndividualFail:
                ShowInformation("Printing Individual error. Silahkan Reset. dan Ulangi process");
                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(states), states, null);
            }
        }