unit DnaCodeScherm; interface uses Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics, Vcl.Controls, Vcl.Forms, Vcl.Dialogs, DrieKnoppenScherm, Vcl.ActnList, Vcl.StdCtrls, DnaCodeService, AfdrukService, Vcl.ExtCtrls, Images, Vcl.Imaging.pngimage, System.StrUtils; type TfmDnaCodeScherm = class(TfmDrieKnoppenScherm) lblToeleveringData: TLabel; lblScancode: TLabel; edtDnaCode: TEdit; lblHuidigePalletData: TLabel; lblLaatstGescandData: TLabel; lblAantalGescand: TLabel; lblTotaalAantal: TLabel; lblSlash: TLabel; imgDirecteLevering: TImage; lblScanPallet: TLabel; imgWegwerpPallet: TImage; btnInfo: TButton; imgToelevering: TImage; imgPallet: TImage; imgLaatstGescand: TImage; imgExport: TImage; imgBlumXs: TImage; lblAantalOpPallet: TLabel; procedure FormShow(Sender: TObject); procedure actPalletExecute(Sender: TObject); procedure actAfrondenExecute(Sender: TObject); procedure edtDnaCodeKeyPress(Sender: TObject; var Key: Char); procedure FormCreate(Sender: TObject); procedure btnInfoClick(Sender: TObject); procedure FormActivate(Sender: TObject); private fImagesScherm: TImagesScherm; procedure MeldDnaCodeAf(); procedure ZetToeleveringStatus(Status: DnaCodeStatus; isDirecteLevering: boolean = false); procedure ToeleveringDataOphalen(); procedure VhossDataOphalen(); procedure VerwerkMogelijkePopups(DnaCodes: ArrayofDnaCodeDnaCode; Toelevering: String; IsSST: boolean = false); function BepaalIndexEersteRelevanteDnaCode(DnaCodes: ArrayofDnaCodeDnaCode; Toelevering: String): integer; function BepaalAantalLadesOpHuidigePallet: integer; function BepaalDirecteLevering: boolean; procedure PalletBijwerken(Status: DnaCodeStatus; IsDirecteLevering: boolean); procedure ZetIcoontjesBovenaan; procedure ZetInfoIcoontjeZichtbaar; procedure DrukProboxEtiketAfIndienNodig; procedure RondAfKaderdeurDag(); procedure RondAfVhossBatch(); procedure ZetAfrondActieStatus(actief: boolean); function GeefJuisteToelevering(fDnaCodeAfmeldenResponse: DnaCodeAfmeldenResponse; fDnaCode: string): string; function GeefAantalOpPallet(Palletcode: String): integer; public end; var fmDnaCodeScherm: TfmDnaCodeScherm; implementation uses UiContext, Agent, CommonFunctions, ProScanMain, Datasnap.DBClient, Data.DB, OnvolledigeToeleveringScherm; {$R *.dfm} procedure TfmDnaCodeScherm.FormActivate(Sender: TObject); begin inherited; ActiveControl := edtDnaCode; end; procedure TfmDnaCodeScherm.FormCreate(Sender: TObject); begin inherited; fImagesScherm := TImagesScherm.Create(self); end; procedure TfmDnaCodeScherm.FormShow(Sender: TObject); begin btnLinksOnder.Action := actPallet; btnRechtsOnder.Action := actAfronden; edtDnaCode.Text := ''; lblHuidigePalletData.Caption := UiContext.Pallet; lblToeleveringData.Caption := UiContext.Toelevering; lblAantalGescand.Caption := ''; lblTotaalAantal.Caption := ''; lblAantalOpPallet.Caption := IntToStr(GeefAantalOpPallet(UiContext.Pallet)); btnInfo.Visible := false; fImagesScherm.ilAlgemeen64.GetIcon(8, imgToelevering.Picture.Icon); fImagesScherm.ilAlgemeen64.GetIcon(9, imgPallet.Picture.Icon); fImagesScherm.ilAlgemeen64.GetIcon(10, imgLaatstGescand.Picture.Icon); fImagesScherm.ilAlgemeen32.GetIcon(5, imgWegwerpPallet.Picture.Icon); fImagesScherm.ilAlgemeen32.GetIcon(3, imgDirecteLevering.Picture.Icon); fImagesScherm.ilAlgemeen32.GetIcon(4, imgExport.Picture.Icon); fImagesScherm.ilAlgemeen32.GetIcon(6, imgBlumXs.Picture.Icon); if UiContext.Modus = modusVHOSS then begin VhossDataOphalen(); end else begin if (not (UiContext.Toelevering = '')) then ToeleveringDataOphalen() else begin imgDirecteLevering.Visible := false; imgWegwerpPallet.Visible := false; imgExport.Visible := false; imgBlumXs.Visible := false; end; end; ZetIcoontjesBovenaan; edtDnaCode.SetFocus; inherited; end; procedure TfmDnaCodeScherm.actPalletExecute(Sender: TObject); var fAantalLadesOpHuidigePallet: integer; fIsDirecteLevering: boolean; begin inherited; ZetAfrondActieStatus(false); try fAantalLadesOpHuidigePallet := BepaalAantalLadesOpHuidigePallet; if fAantalLadesOpHuidigePallet > 0 then begin if (UiContext.Modus = modusKAD) then begin PalletBijwerken(DnaCodeStatus.InBuffer,false); UiContext.Pallet := ''; Self.ModalResult := mrPallet; end else if (UiContext.Modus = modusVHOSS) then begin if lblAantalGescand.Caption = lblTotaalAantal.Caption then begin PalletBijwerken(DnaCodeStatus.InBuffer,false); UiContext.Pallet := ''; UiContext.Toelevering := ''; UiContext.BatchId := ''; Self.ModalResult := mrPallet; end else begin if (ToonPopupScherm('Vhoss nog niet volledig.'+#13#10+'Toch verwerken?','Ja','Annuleren',14,6,7) = mrYes) then begin PalletBijwerken(DnaCodeStatus.InBuffer,false); UiContext.Pallet := ''; Self.ModalResult := mrPallet; end else begin Self.ModalResult := mrDnaCode; end; end; end else if ((UiContext.Modus = modusDefault) and (ToonPopupScherm(lblHuidigePalletData.Caption+' verwerken?'+#13#10+inttostr(fAantalLadesOpHuidigePallet)+' lade(s)','Ja','Annuleren',14,6,7) = mrYes)) then begin fIsDirecteLevering := (UiContext.Modus = modusDefault) and BepaalDirecteLevering; if fIsDirecteLevering then begin ToonPopupScherm('Directe levering', 'OK','',15,-1,-1,clBlue); imgDirecteLevering.Visible := true; end; PalletBijwerken(DnaCodeStatus.InBuffer,fIsDirecteLevering); DrukProboxEtiketAfIndienNodig; UiContext.Pallet := ''; Self.ModalResult := mrPallet; end else begin Self.ModalResult := mrDnaCode; end; end else Self.ModalResult := mrPallet; finally ZetAfrondActieStatus(true); PostMessage(Self.Handle,WM_Close,0,0); (Self.Parent.Parent As TfmProScanHoofdscherm).NavigeerNaar(Self.ModalResult); end; end; procedure TfmDnaCodeScherm.actAfrondenExecute(Sender: TObject); var fWaarschuwingModalResult: TModalResult; fIsDirecteLevering: boolean; fOnvolledigeToeleveringScherm: TfmOnvolledigeToeleveringScherm; begin inherited; if UiContext.Toelevering = '' then exit; ZetAfrondActieStatus(false); try if (UiContext.Modus = modusKAD) then begin RondAfKaderdeurDag(); UiContext.Toelevering := ''; UiContext.Pallet := ''; end else if (UiContext.Modus = modusVHOSS) then begin RondAfVhossBatch(); UiContext.Toelevering := ''; UiContext.Pallet := ''; end else begin fIsDirecteLevering := (UiContext.Modus = modusDefault) and BepaalDirecteLevering; if lblAantalGescand.Caption = lblTotaalAantal.Caption then begin if fIsDirecteLevering then begin ToonPopupScherm('Directe levering', 'OK','',15,-1,-1,clBlue); imgDirecteLevering.Visible := true; end; DrukProboxEtiketAfIndienNodig; ZetToeleveringStatus(DnaCodeStatus.InBuffer, fIsDirecteLevering); if Self.ModalResult = mrPallet then begin ToonPopupScherm('Toelevering succesvol afgerond','OK','',19,-1,-1,clGreen); end else begin ToonPopupScherm('Toelevering niet succesvol afgerond, etiket weggooien','OK','',2,-1,-1, clRed); end; UiContext.Toelevering := ''; UiContext.BatchId := ''; end else begin fOnvolledigeToeleveringScherm := TfmOnvolledigeToeleveringScherm.Create(self); try fOnvolledigeToeleveringScherm.UiContext := UiContext; fWaarschuwingModalResult := fOnvolledigeToeleveringScherm.ShowModal; if fWaarschuwingModalResult = mrNo then begin DrukProboxEtiketAfIndienNodig; ZetToeleveringStatus(DnaCodeStatus.InBuffer, fIsDirecteLevering); UiContext.Toelevering := ''; UiContext.BatchId := ''; Self.ModalResult := mrPallet; end else begin Self.ModalResult := mrDnaCode; end; finally fOnvolledigeToeleveringScherm.Free; end; end; end; finally ZetAfrondActieStatus(true); PostMessage(Self.Handle,WM_Close,0,0); (Self.Parent.Parent As TfmProScanHoofdscherm).NavigeerNaar(Self.ModalResult); end; end; function TfmDnaCodeScherm.BepaalAantalLadesOpHuidigePallet: integer; var fZoekViaPalletCodeResponse: ZoekViaPalletCodeResponse; fZoekAlleVhossLadesBijDnaCodeResponse: ZoekAlleVhossLadesBijDnaCodeResponse; fAgent: TAgent; begin result := 0; if UiContext.LaatsteDnaCode = '' then exit; if StartsText('O1',UiContext.Pallet) then begin fAgent := TAgent.Create(UiContext); fZoekAlleVhossLadesBijDnaCodeResponse := fAgent.ZoekAlleVhossLadesBijDnaCode(UiContext.LaatsteDnaCode); fAgent.Free; try if fZoekAlleVhossLadesBijDnaCodeResponse.Header.Status = '200' then begin result := length(fZoekAlleVhossLadesBijDnaCodeResponse.DnaCodes); end else begin ToonPopupScherm(fZoekAlleVhossLadesBijDnaCodeResponse.Header.Omschrijving, 'Probeer opnieuw'); result := 0 end; finally fZoekAlleVhossLadesBijDnaCodeResponse.Free; end; end else begin fAgent := TAgent.Create(UiContext); fZoekViaPalletCodeResponse := fAgent.ZoekViaPalletCode(UiContext.Pallet); fAgent.Free; try if fZoekViaPalletCodeResponse.Header.Status = '200' then begin result := length(fZoekViaPalletCodeResponse.DnaCodes); end else begin ToonPopupScherm(fZoekViaPalletCodeResponse.Header.Omschrijving, 'Probeer opnieuw'); result := 0 end; finally fZoekViaPalletCodeResponse.Free; end; end; end; function TfmDnaCodeScherm.BepaalDirecteLevering: boolean; var fDirecteLeveringResponse: DirecteLeveringResponse; fAgent: TAgent; begin fAgent := TAgent.Create(UiContext); fDirecteLeveringResponse := fAgent.IsDirecteLevering(UiContext.Toelevering); fAgent.Free; try if fDirecteLeveringResponse.Header.Status = '200' then begin result := fDirecteLeveringResponse.IsDirecteLevering; end else begin ToonPopupScherm(fDirecteLeveringResponse.Header.Omschrijving, 'Probeer opnieuw'); result := false; end; finally fDirecteLeveringResponse.Free; end; end; function TfmDnaCodeScherm.BepaalIndexEersteRelevanteDnaCode( DnaCodes: ArrayofDnaCodeDnaCode; Toelevering: String): integer; var fArrayTeller: integer; fResultaat: integer; begin fArrayTeller := 0; fResultaat := 0; while fArrayTeller < length(DnaCodes) do begin if DnaCodes[fArrayTeller].Toelevering = Toelevering then begin fResultaat := fArrayTeller; break; end; fArrayTeller := fArrayTeller + 1; end; result := fResultaat; end; procedure TfmDnaCodeScherm.btnInfoClick(Sender: TObject); begin inherited; if UiContext.Modus = modusVHOSS then begin UiContext.InfoLogSchermToonGescand := true; Self.ModalResult := mrInfoLog; end else begin if UiContext.Toelevering = '' then Self.ModalResult := mrDnaCode else begin UiContext.InfoLogSchermToonGescand := true; Self.ModalResult := mrInfoLog; end; end; PostMessage(Self.Handle,WM_Close,0,0); (Self.Parent.Parent As TfmProScanHoofdscherm).NavigeerNaar(Self.ModalResult); end; procedure TfmDnaCodeScherm.edtDnaCodeKeyPress(Sender: TObject; var Key: Char); begin inherited; if ord(Key) = VK_RETURN then begin Key := #0; MeldDnaCodeAf; end; end; procedure TfmDnaCodeScherm.MeldDnaCodeAf; var Response: DnaCodeAfmeldenResponse; List: TStrings; Locatie: string; fAgent: TAgent; begin if edtDnaCode.Text = '' then exit; UiContext.LaatsteDnaCode := edtDnaCode.Text; lblLaatstGescandData.Caption := edtDnaCode.Text; if (UiContext.Modus = modusKAD) then begin Locatie := UiContext.Pallet; end else begin Locatie := '' end; fAgent := TAgent.Create(UiContext); Response := fAgent.DnaCodeAfmelden(edtDnaCode.Text,UiContext.Toelevering,UiContext.Pallet,1,Locatie); fAgent.Free; try List := TStringList.Create; ExtractStrings([':'], [], PChar(Response.Header.Status), List); case strtoint(List[0]) of 200: begin UiContext.Toelevering := GeefJuisteToelevering(Response, edtDnaCode.Text); UiContext.BatchId := Response.DnaCodes[0].BatchId; lblAantalGescand.Caption := IntToStr(Response.AantalReedsGescand); lblTotaalAantal.Caption := IntToStr(Response.AantalInToelevering); ZetInfoIcoontjeZichtbaar; ZetIcoontjesBovenaan; VerwerkMogelijkePopups(Response.DnaCodes, UiContext.Toelevering, Response.isSST); Self.ModalResult := mrDnaCode; UiContext.LaatsteDnaCodeGoedAfgemeld := true; end; 1005: begin //reeds gescand ZetInfoIcoontjeZichtbaar; Self.ModalResult := mrDnaCodeReedsGescand; UiContext.LaatsteDnaCodeGoedAfgemeld := false; end; else begin Self.ModalResult := mrDnaCode; ToonPopupScherm(Response.Header.Omschrijving, 'Probeer opnieuw'); UiContext.LaatsteDnaCodeGoedAfgemeld := false; end; end; finally Response.Free; end; PostMessage(Self.Handle,WM_Close,0,0); (Self.Parent.Parent As TfmProScanHoofdscherm).NavigeerNaar(Self.ModalResult); end; function TfmDnaCodeScherm.GeefJuisteToelevering(fDnaCodeAfmeldenResponse: DnaCodeAfmeldenResponse; fDnaCode: string): string; var fDnaCodeTeller: integer; begin result := fDnaCodeAfmeldenResponse.DnaCodes[0].Toelevering; fDnaCodeTeller := 0; while fDnaCodeTeller < length(fDnaCodeAfmeldenResponse.DnaCodes) do begin if (fDnaCodeAfmeldenResponse.DnaCodes[fDnaCodeTeller].DnaCode = fDnaCode) then result := fDnaCodeAfmeldenResponse.DnaCodes[fDnaCodeTeller].Toelevering; fDnaCodeTeller := fDnaCodeTeller + 1; end; end; procedure TfmDnaCodeScherm.PalletBijwerken(Status: DnaCodeStatus; IsDirecteLevering: boolean); var Response: PalletBijwerkenResponse; fAgent: TAgent; begin fAgent := TAgent.Create(UiContext); Response := fAgent.PalletBijwerken(UiContext.Pallet,Status,IsDirecteLevering); fAgent.Free; try if Response.Header.Status <> '200' then begin ToonPopupScherm(Response.Header.Omschrijving, 'Probeer opnieuw'); Self.ModalResult := mrPallet; end else begin if not (UiContext.Modus = modusKAD) then ToonPopupScherm('Pallet '+UiContext.Pallet+' verwerkt','OK','',19,-1,-1,clGreen); Self.ModalResult := mrPallet; end; finally Response.Free; end; PostMessage(Self.Handle,WM_Close,0,0); //(Self.Parent.Parent As TfmProScanHoofdscherm).NavigeerNaar(Self.ModalResult); end; procedure TfmDnaCodeScherm.ToeleveringDataOphalen; var Response: ZoekViaToeleveringResponse; fAgent: TAgent; begin fAgent := TAgent.Create(UiContext); Response := fAgent.ZoekViaToelevering(UiContext.Toelevering); fAgent.Free; try if Response.Header.Status <> '200' then begin ToonPopupScherm(Response.Header.Omschrijving, 'Probeer opnieuw') end else begin UiContext.Toelevering := Response.DnaCodes[0].Toelevering; lblAantalGescand.Caption := IntToStr(Response.AantalReedsGescand); lblTotaalAantal.Caption := IntToStr(Response.AantalInToelevering); ZetInfoIcoontjeZichtbaar; ZetIcoontjesBovenaan; VerwerkMogelijkePopups(Response.DnaCodes, UiContext.Toelevering); Self.ModalResult := mrDnaCode; end; finally Response.Free; end; end; procedure TfmDnaCodeScherm.VhossDataOphalen; var fZoekAlleVhossLadesBijDnaCodeResponse: ZoekAlleVhossLadesBijDnaCodeResponse; fZoekAlleDnaCodesDieOpVhossMoetenResponse: ZoekAlleDnaCodesDieOpVhossMoetenResponse; fDnaCodeTeller: integer; fAantalGescand: integer; fAgent: TAgent; begin if (UiContext.LaatsteDnaCode = '') or (not UiContext.LaatsteDnaCodeGoedAfgemeld) or (UiContext.Toelevering = '') then begin fAgent := TAgent.Create(UiContext); fZoekAlleDnaCodesDieOpVhossMoetenResponse := fAgent.ZoekAlleDnaCodesDieOpVhossMoeten(UiContext.Pallet); fAgent.Free; try if fZoekAlleDnaCodesDieOpVhossMoetenResponse.Header.Status <> '200' then begin if fZoekAlleDnaCodesDieOpVhossMoetenResponse.Header.Status <> '-1021' then ToonPopupScherm(fZoekAlleDnaCodesDieOpVhossMoetenResponse.Header.Omschrijving, 'Probeer opnieuw') end else begin fDnaCodeTeller := 0; fAantalGescand := 0; while fDnaCodeTeller < length(fZoekAlleDnaCodesDieOpVhossMoetenResponse.DnaCodes) do begin if not (fZoekAlleDnaCodesDieOpVhossMoetenResponse.DnaCodes[fDnaCodeTeller].ScanTijdstip = nil) then fAantalGescand := fAantalGescand + 1; if fZoekAlleDnaCodesDieOpVhossMoetenResponse.DnaCodes[fDnaCodeTeller].DnaCode = UiContext.LaatsteDnaCode then UiContext.Toelevering := fZoekAlleDnaCodesDieOpVhossMoetenResponse.DnaCodes[fDnaCodeTeller].Toelevering; fDnaCodeTeller := fDnaCodeTeller + 1; end; lblAantalGescand.Caption := IntToStr(fAantalGescand); lblTotaalAantal.Caption := IntToStr(length(fZoekAlleDnaCodesDieOpVhossMoetenResponse.DnaCodes)); ZetInfoIcoontjeZichtbaar; ZetIcoontjesBovenaan; Self.ModalResult := mrDnaCode; end; finally fZoekAlleDnaCodesDieOpVhossMoetenResponse.Free; end; end else begin fAgent := TAgent.Create(UiContext); fZoekAlleVhossLadesBijDnaCodeResponse := fAgent.ZoekAlleVhossLadesBijDnaCode(UiContext.LaatsteDnaCode); fAgent.Free; try if fZoekAlleVhossLadesBijDnaCodeResponse.Header.Status <> '200' then begin ToonPopupScherm(fZoekAlleVhossLadesBijDnaCodeResponse.Header.Omschrijving, 'Probeer opnieuw') end else begin fDnaCodeTeller := 0; fAantalGescand := 0; while fDnaCodeTeller < length(fZoekAlleVhossLadesBijDnaCodeResponse.DnaCodes) do begin if not (fZoekAlleVhossLadesBijDnaCodeResponse.DnaCodes[fDnaCodeTeller].ScanTijdstip = nil) then fAantalGescand := fAantalGescand + 1; fDnaCodeTeller := fDnaCodeTeller + 1; end; lblAantalGescand.Caption := IntToStr(fAantalGescand); lblTotaalAantal.Caption := IntToStr(length(fZoekAlleVhossLadesBijDnaCodeResponse.DnaCodes)); ZetInfoIcoontjeZichtbaar; ZetIcoontjesBovenaan; Self.ModalResult := mrDnaCode; end; finally fZoekAlleVhossLadesBijDnaCodeResponse.Free; end; end; end; procedure TfmDnaCodeScherm.VerwerkMogelijkePopups(DnaCodes: ArrayofDnaCodeDnaCode; Toelevering: String; IsSST: boolean = false); var fBewerkKlantinstellingenResponse: BewerkKlantinstellingenResponse; ii: integer; fAgent: TAgent; fIndexEersteRelevanteDnaCode: integer; begin if UiContext.Modus = modusDefault then begin fIndexEersteRelevanteDnaCode := BepaalIndexEersteRelevanteDnaCode(DnaCodes, Toelevering); if DnaCodes[fIndexEersteRelevanteDnaCode].IsDirecteLevering then begin if not UiContext.IsDirecteLeveringPopupGetoond then begin ToonPopupScherm('Directe levering', 'OK','',15,-1,-1,clBlue); UiContext.IsDirecteLeveringPopupGetoond := true; end; end; imgDirecteLevering.Visible := DnaCodes[fIndexEersteRelevanteDnaCode].IsDirecteLevering; if DnaCodes[fIndexEersteRelevanteDnaCode].IsWegwerpPallet then begin if not UiContext.IsWegwerpPalletPopupGetoond then begin ToonPopupScherm('Wegwerppallet', 'OK','',16,-1,-1,clYellow); UiContext.IsWegwerpPalletPopupGetoond := true; end; end; imgWegwerpPallet.Visible := DnaCodes[fIndexEersteRelevanteDnaCode].IsWegwerpPallet; if IsSST then begin if not UIContext.IsSSTPopupGetoond then begin ToonPopupScherm('SpaceStep aanwezig', 'OK','',13,-1,-1,clGray); UIContext.IsSSTPopupGetoond := true; end; end; ii := 0; if not UiContext.IsExportPopupGetoond then begin try fAgent := TAgent.Create(UiContext); fBewerkKlantinstellingenResponse := fAgent.BewerkKlantinstellingen('List','',false, false, false, false); fAgent.Free; while ii <= length(fBewerkKlantinstellingenResponse.Klantinstellingen)-1 do begin if fBewerkKlantinstellingenResponse.Klantinstellingen[ii].KlantId = DnaCodes[fIndexEersteRelevanteDnaCode].KlantNummer then begin if fBewerkKlantinstellingenResponse.Klantinstellingen[ii].IsExport then begin ToonPopupScherm('Export', 'OK','',21,-1,-1,clRed); UiContext.IsExportPopupGetoond := true; imgExport.Visible := true; end; end; ii := ii + 1; end; finally fBewerkKlantinstellingenResponse.Free; end; end else begin imgExport.Visible := true; end; ii := 0; if not UiContext.IsBlumXsPopupGetoond then begin try fAgent := TAgent.Create(UiContext); fBewerkKlantinstellingenResponse := fAgent.BewerkKlantinstellingen('List','',false, false, false, false); fAgent.Free; while ii <= length(fBewerkKlantinstellingenResponse.Klantinstellingen)-1 do begin if fBewerkKlantinstellingenResponse.Klantinstellingen[ii].KlantId = DnaCodes[fIndexEersteRelevanteDnaCode].KlantNummer then begin if fBewerkKlantinstellingenResponse.Klantinstellingen[ii].IsBlumXs then begin ToonPopupScherm('Blum XS', 'OK','',22,-1,-1,clWebDarkOrange); UiContext.IsBlumXsPopupGetoond := true; imgBlumXs.Visible := true; end; end; ii := ii + 1; end; finally fBewerkKlantinstellingenResponse.Free; end; end else begin imgBlumXs.Visible := true; end; Repaint; end; end; procedure TfmDnaCodeScherm.ZetAfrondActieStatus(actief: boolean); begin if actief then begin pnlLinksOnder.Color := $001717CD; actPallet.OnExecute := actPalletExecute; pnlCentraalOnder.Color := $001717CD; pnlRechtsOnder.Color := $001717CD; actAfronden.OnExecute := actAfrondenExecute; end else begin pnlLinksOnder.Color := clGray; pnlCentraalOnder.Color := clGray; pnlRechtsOnder.Color := clGray; actAfronden.OnExecute := nil; actPallet.OnExecute := nil; end; Repaint; end; procedure TfmDnaCodeScherm.ZetIcoontjesBovenaan; begin if UiContext.Pallet = '' then begin lblHuidigePalletData.Caption := ''; imgPallet.Visible := false; end else begin lblHuidigePalletData.Caption := UiContext.Pallet; imgPallet.Visible := true; end; if UiContext.Toelevering = '' then begin lblToeleveringData.Caption := ''; imgToelevering.Visible := false; end else begin lblToeleveringData.Caption := UiContext.Toelevering; imgToelevering.Visible := true; end; if UiContext.LaatsteDnaCode = '' then begin lblLaatstGescandData.Caption := ''; imgLaatstGescand.Visible := false; end else begin lblLaatstGescandData.Caption := Copy(UiContext.LaatsteDnaCode,5,3); imgLaatstGescand.Visible := true; end; end; procedure TfmDnaCodeScherm.ZetInfoIcoontjeZichtbaar; begin if (UiContext.Modus = modusVHOSS) and (UiContext.Pallet <> '') then btnInfo.Visible := true; if (UiContext.Modus = modusDefault) and (UiContext.Toelevering <> '') then btnInfo.Visible := true; end; procedure TfmDnaCodeScherm.RondAfKaderdeurDag; var Response: RondAfKaderdeurDagResponse; cdsRondAfKaderdeurDag: TClientDataset; antwoordlijnTeller: integer; fAgent: TAgent; begin if (UiContext.LaatsteDnaCode = '') then exit; fAgent := TAgent.Create(UiContext); Response := fAgent.RondAfKaderdeurDag(UiContext.LaatsteDnaCode); fAgent.Free; cdsRondAfKaderdeurDag := TClientDataset.Create(self); cdsRondAfKaderdeurDag.FieldDefs.Add('Toelevering',ftString,20); cdsRondAfKaderdeurDag.FieldDefs.Add('Nog te scannen',ftInteger); try cdsRondAfKaderdeurDag.CreateDataSet; if Response.Header.Status = '200' then begin for antwoordlijnTeller := 0 to System.Length(Response.ToeleveringMetAantallen) -1 do begin cdsRondAfKaderdeurDag.InsertRecord([Response.ToeleveringMetAantallen[antwoordlijnTeller].ToeleveringID, strtoint(Response.ToeleveringMetAantallen[antwoordlijnTeller].AantalKaderdeuren)-strtoint(Response.ToeleveringMetAantallen[antwoordlijnTeller].AantalKaderdeurenGescand) ]); end; if System.Length(Response.ToeleveringMetAantallen) > 0 then begin if System.Length(Response.ToeleveringMetAantallen) = 1 then ToonPopupScherm('Onvolledige toelevering','OK','',0,-1,-1,$001717CD,cdsRondAfKaderdeurDag) else ToonPopupScherm('Onvolledige toeleveringen','OK','',0,-1,-1,$001717CD,cdsRondAfKaderdeurDag) end else ToonPopupScherm('Toeleveringen afgerond','OK','',19,-1,-1,clGreen); UiContext.Toelevering := ''; UiContext.Pallet := ''; end else begin ToonPopupScherm(Response.Header.Omschrijving, 'Probeer opnieuw'); end; Self.ModalResult := mrPallet; finally Response.Free; end; end; procedure TfmDnaCodeScherm.RondAfVhossBatch; var Response: RondAfVhossBatchResponse; cdsRondAfVhossBatch: TClientDataset; antwoordlijnTeller: integer; fAgent: TAgent; function HernoemInterneVhossKast(InterneVhossKast: String):String; begin result := StringReplace(InterneVhossKast,'-1','-A',[]); result := StringReplace(result,'-2','-B',[]); end; begin if (UiContext.BatchId = '') then exit; fAgent := TAgent.Create(UiContext); Response := fAgent.RondAfVhossBatch(UiContext.BatchId); fAgent.Free; cdsRondAfVhossBatch := TClientDataset.Create(self); cdsRondAfVhossBatch.FieldDefs.Add('Vhoss',ftString,20); cdsRondAfVhossBatch.FieldDefs.Add('Nog te scannen',ftInteger); try cdsRondAfVhossBatch.CreateDataSet; if Response.Header.Status = '200' then begin for antwoordlijnTeller := 0 to System.Length(Response.VhossKastenMetAantallen) -1 do begin cdsRondAfVhossBatch.InsertRecord([HernoemInterneVhossKast(Response.VhossKastenMetAantallen[antwoordlijnTeller].Vhosskast), strtoint(Response.VhossKastenMetAantallen[antwoordlijnTeller].AantalLades)-strtoint(Response.VhossKastenMetAantallen[antwoordlijnTeller].AantalLadesGescand) ]); end; if System.Length(Response.VhossKastenMetAantallen) > 0 then begin if System.Length(Response.VhossKastenMetAantallen) = 1 then begin ToonPopupScherm('Onvolledige Vhosskast','OK','',0,-1,-1,$001717CD,cdsRondAfVhossBatch) end else begin ToonPopupScherm('Onvolledige Vhosskasten','OK','',0,-1,-1,$001717CD,cdsRondAfVhossBatch) end; end else begin ToonPopupScherm('Batch afgerond','OK','',19,-1,-1,clGreen); end; UiContext.BatchId := ''; end else begin ToonPopupScherm(Response.Header.Omschrijving, 'Probeer opnieuw'); end; Self.ModalResult := mrPallet; finally Response.Free; end; end; procedure TfmDnaCodeScherm.ZetToeleveringStatus(Status: DnaCodeStatus; isDirecteLevering: boolean = false); var Response: ToeleveringBijwerkenResponse; fAgent: TAgent; begin fAgent := TAgent.Create(UiContext); Response := fAgent.ToeleveringBijwerken(UiContext.Toelevering,Status,isDirecteLevering); fAgent.Free; try if Response.Header.Status <> '200' then begin Self.ModalResult := mrDnaCode; ToonPopupScherm(Response.Header.Omschrijving, 'Probeer opnieuw') end else begin Self.ModalResult := mrPallet; end; finally Response.Free; end; end; procedure TfmDnaCodeScherm.DrukProboxEtiketAfIndienNodig; var fProboxAfdrukkenResponse: ProboxEtiketAfdrukkenResponse; fZoekViaPalletCodeResponse: ZoekViaPalletCodeResponse; DnaCodesStringList: TStringList; DnaCodes: ArrayOfDnaCodeDnaCode; ii: integer; fAgent: TAgent; begin if not (System.StrUtils.LeftStr(UiContext.Pallet,3) = 'TBP') then exit; fAgent := TAgent.Create(UiContext); fZoekViaPalletCodeResponse := fAgent.ZoekViaPalletCode(UiContext.Pallet); fAgent.Free; try if fZoekViaPalletCodeResponse.Header.Status = '200' then begin DnaCodes := fZoekViaPalletCodeResponse.DnaCodes; end else begin Self.ModalResult := mrHome; ToonPopupScherm(fZoekViaPalletCodeResponse.Header.Omschrijving, 'Bel planning'); end; DnaCodesStringList := TStringList.Create(); ii := 0; while ii < length(DnaCodes) do begin DnaCodesStringList.Add(DnaCodes[ii].DnaCode); ii := ii + 1; end; fAgent := TAgent.Create(UiContext); fProboxAfdrukkenResponse := fAgent.ProboxEtiketAfdrukken(DnaCodesStringList); fAgent.Free; try if fProboxAfdrukkenResponse.Header.Status <> '200' then begin Self.ModalResult := mrHome; ToonPopupScherm(fProboxAfdrukkenResponse.Header.Omschrijving, 'Bel planning') end else begin UiContext.LaatstAfgedrukteDnaCodes.Clear; UiContext.LaatstAfgedrukteDnaCodes := DnaCodesStringList; Self.ModalResult := mrPallet; end; finally fProboxAfdrukkenResponse.Free; end; finally fZoekViaPalletCodeResponse.Free; end; end; function TfmDnaCodeScherm.GeefAantalOpPallet(PalletCode: string): integer; var fAgent: TAgent; fZoekViaPalletCodeResponse: ZoekViaPalletCodeResponse; fAantal: integer; begin fAgent := TAgent.Create(UiContext); fZoekViaPalletCodeResponse := fAgent.ZoekViaPalletCode(PalletCode); fAgent.Free; fAantal := length(fZoekViaPalletCodeResponse.DnaCodes); fZoekViaPalletCodeResponse.Free; Result := fAantal; end; end.