Index: ProScan/UI/DnaCodeScherm.pas =================================================================== diff -u -r396 -r696 --- ProScan/UI/DnaCodeScherm.pas (.../DnaCodeScherm.pas) (revision 396) +++ ProScan/UI/DnaCodeScherm.pas (.../DnaCodeScherm.pas) (revision 696) @@ -5,7 +5,7 @@ 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, Vcl.ExtCtrls, Images, Vcl.Imaging.pngimage, System.StrUtils; + Vcl.StdCtrls, DnaCodeService, AfdrukService, Vcl.ExtCtrls, Images, Vcl.Imaging.pngimage, System.StrUtils; type TfmDnaCodeScherm = class(TfmDrieKnoppenScherm) @@ -24,9 +24,12 @@ imgToelevering: TImage; imgPallet: TImage; imgLaatstGescand: TImage; + imgExport: TImage; + imgBlumXs: TImage; + lblAantalOpPallet: TLabel; + imgKartonnenPallet: TImage; procedure FormShow(Sender: TObject); procedure actPalletExecute(Sender: TObject); - procedure actHomeExecute(Sender: TObject); procedure actAfrondenExecute(Sender: TObject); procedure edtDnaCodeKeyPress(Sender: TObject; var Key: Char); procedure FormCreate(Sender: TObject); @@ -38,13 +41,21 @@ procedure ZetToeleveringStatus(Status: DnaCodeStatus; isDirecteLevering: boolean = false); procedure ToeleveringDataOphalen(); procedure VhossDataOphalen(); - procedure VerwerkMogelijkePopups(EersteDnaCode: DnaCode); + 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; + procedure GenereerTbpCode(DnaCode: DnaCode); + procedure ZetPalletContext(PalletCode: string); public end; @@ -54,7 +65,8 @@ implementation uses - UiContext, Agent, CommonFunctions, ProScanMain, Datasnap.DBClient, Data.DB; + UiContext, Agent, CommonFunctions, ProScanMain, Datasnap.DBClient, Data.DB, + OnvolledigeToeleveringScherm; {$R *.dfm} @@ -73,19 +85,22 @@ procedure TfmDnaCodeScherm.FormShow(Sender: TObject); begin btnLinksOnder.Action := actPallet; - btnCentraalOnder.Action := actHome; 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(4, imgWegwerpPallet.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); + fImagesScherm.ilAlgemeen32.GetIcon(7, imgKartonnenPallet.Picture.Icon); if UiContext.Modus = modusVHOSS then begin VhossDataOphalen(); @@ -95,99 +110,147 @@ else begin imgDirecteLevering.Visible := false; imgWegwerpPallet.Visible := false; + imgExport.Visible := false; + imgBlumXs.Visible := false; + imgKartonnenPallet.Visible := false; end; end; ZetIcoontjesBovenaan; edtDnaCode.SetFocus; inherited; end; -procedure TfmDnaCodeScherm.actHomeExecute(Sender: TObject); -begin - inherited; - PostMessage(Self.Handle,WM_Close,0,0); - (Self.Parent.Parent As TfmProScanHoofdscherm).NavigeerNaar(mrHome); -end; - procedure TfmDnaCodeScherm.actPalletExecute(Sender: TObject); var fAantalLadesOpHuidigePallet: integer; fIsDirecteLevering: boolean; begin inherited; - fAantalLadesOpHuidigePallet := BepaalAantalLadesOpHuidigePallet; - if fAantalLadesOpHuidigePallet > 0 then begin - if (UiContext.Modus = modusKAD) or - ((UiContext.Modus = modusDefault) and (ToonPopupScherm(lblHuidigePalletData.Caption+' volledig?'+#13#10+inttostr(fAantalLadesOpHuidigePallet)+' lades','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; + 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; - PalletBijwerken(DnaCodeStatus.InBuffer,fIsDirecteLevering); - UiContext.Toelevering := ''; + end else begin UiContext.Pallet := ''; Self.ModalResult := mrPallet; - end else begin - Self.ModalResult := mrDnaCode; end; + finally + ZetAfrondActieStatus(true); + PostMessage(Self.Handle,WM_Close,0,0); + (Self.Parent.Parent As TfmProScanHoofdscherm).NavigeerNaar(Self.ModalResult); end; - PostMessage(Self.Handle,WM_Close,0,0); - (Self.Parent.Parent As TfmProScanHoofdscherm).NavigeerNaar(Self.ModalResult); end; procedure TfmDnaCodeScherm.actAfrondenExecute(Sender: TObject); var fWaarschuwingModalResult: TModalResult; fIsDirecteLevering: boolean; + fOnvolledigeToeleveringScherm: TfmOnvolledigeToeleveringScherm; begin inherited; if UiContext.Toelevering = '' then exit; - - if (UiContext.Modus = modusKAD) then begin - RondAfKaderdeurDag(); - UiContext.Toelevering := ''; - UiContext.Pallet := ''; - end else begin - if lblAantalGescand.Caption = lblTotaalAantal.Caption then begin + 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 fIsDirecteLevering then begin - ToonPopupScherm('Directe levering', 'OK','',15,-1,-1,clBlue); - imgDirecteLevering.Visible := true; - end; - ZetToeleveringStatus(DnaCodeStatus.InBuffer, fIsDirecteLevering); - if Self.ModalResult = mrPallet then begin - ToonPopupScherm('Toelevering succesvol afgerond','OK','',19,-1,-1,clGreen); + 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 := ''; - if System.StrUtils.LeftStr(UiContext.Pallet,3) = 'TBP' then - DrukProboxEtiketAfIndienNodig; - end; - end else begin - fWaarschuwingModalResult := ToonPopupScherm('Onvolledige toelevering','Scan code','Nieuw',18,11,12); - if fWaarschuwingModalResult = mrYes then begin - Self.ModalResult := mrDnaCode; + UiContext.BatchId := ''; end else begin - fWaarschuwingModalResult := ToonPopupScherm('Nieuwe toelevering starten?','Ja','Nee',14,6,7); - if fWaarschuwingModalResult = mrYes then begin - ZetToeleveringStatus(DnaCodeStatus.OnHold,BepaalDirecteLevering); - Self.ModalResult := mrPallet; + 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; - PostMessage(Self.Handle,WM_Close,0,0); - (Self.Parent.Parent As TfmProScanHoofdscherm).NavigeerNaar(Self.ModalResult); end; function TfmDnaCodeScherm.BepaalAantalLadesOpHuidigePallet: integer; var fZoekViaPalletCodeResponse: ZoekViaPalletCodeResponse; fZoekAlleVhossLadesBijDnaCodeResponse: ZoekAlleVhossLadesBijDnaCodeResponse; + fAgent: TAgent; begin result := 0; - if StartsText('O1',UiContext.Pallet) then begin - fZoekAlleVhossLadesBijDnaCodeResponse := TAgent.Create(UiContext).ZoekAlleVhossLadesBijDnaCode(UiContext.LaatsteDnaCode); + if UiContext.LaatsteDnaCode = '' then + exit; + + if UiContext.Pallet = '' then begin + result := 0; + end else 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); @@ -199,7 +262,9 @@ fZoekAlleVhossLadesBijDnaCodeResponse.Free; end; end else begin - fZoekViaPalletCodeResponse := TAgent.Create(UiContext).ZoekViaPalletCode(UiContext.Pallet); + fAgent := TAgent.Create(UiContext); + fZoekViaPalletCodeResponse := fAgent.ZoekViaPalletCode(UiContext.Pallet); + fAgent.Free; try if fZoekViaPalletCodeResponse.Header.Status = '200' then begin result := length(fZoekViaPalletCodeResponse.DnaCodes); @@ -216,9 +281,11 @@ function TfmDnaCodeScherm.BepaalDirecteLevering: boolean; var fDirecteLeveringResponse: DirecteLeveringResponse; + fAgent: TAgent; begin - result := false; - fDirecteLeveringResponse := TAgent.Create(UiContext).IsDirecteLevering(UiContext.Toelevering); + fAgent := TAgent.Create(UiContext); + fDirecteLeveringResponse := fAgent.IsDirecteLevering(UiContext.Toelevering); + fAgent.Free; try if fDirecteLeveringResponse.Header.Status = '200' then begin result := fDirecteLeveringResponse.IsDirecteLevering; @@ -231,6 +298,24 @@ 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; @@ -261,10 +346,30 @@ procedure TfmDnaCodeScherm.MeldDnaCodeAf; var + fZoekViaDnaCodeResponse: ZoekViaDnaCodeResponse; + fDnaCode: DnaCode; Response: DnaCodeAfmeldenResponse; List: TStrings; Locatie: string; + fAgent: TAgent; begin + if edtDnaCode.Text = '' then + exit; + + if UiContext.MoetTbpCodeGenereren then begin + fAgent := TAgent.Create(UiContext); + fZoekViaDnaCodeResponse := fAgent.ZoekViaDnaCode(edtDnaCode.Text); + fAgent.Free; + + if fZoekViaDnaCodeResponse.Header.Status <> '200' then begin + ToonPopupScherm(fZoekViaDnaCodeResponse.Header.Omschrijving, 'Probeer opnieuw') + end else begin + fDnaCode := fZoekViaDnaCodeResponse.DnaCodes; + GenereerTbpCode(fDnaCode); + UiContext.MoetTbpCodeGenereren := false; + end; + end; + UiContext.LaatsteDnaCode := edtDnaCode.Text; lblLaatstGescandData.Caption := edtDnaCode.Text; @@ -274,30 +379,38 @@ Locatie := '' end; - Response := TAgent.Create(UiContext).DnaCodeAfmelden(edtDnaCode.Text,UiContext.Toelevering,UiContext.Pallet,1,Locatie); + 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 := Response.DnaCodes[0].Toelevering; - UiContext.InternVhossId := Response.InterneVhossKastId; + UiContext.Toelevering := GeefJuisteToelevering(Response, edtDnaCode.Text); + UiContext.BatchId := Response.DnaCodes[0].BatchId; lblAantalGescand.Caption := IntToStr(Response.AantalReedsGescand); lblTotaalAantal.Caption := IntToStr(Response.AantalInToelevering); - if not (UiContext.Modus = modusKAD) then - btnInfo.Visible := true; + ZetInfoIcoontjeZichtbaar; ZetIcoontjesBovenaan; - VerwerkMogelijkePopups(Response.DnaCodes[0]); + VerwerkMogelijkePopups(Response.DnaCodes, UiContext.Toelevering, Response.isSST); Self.ModalResult := mrDnaCode; + UiContext.LaatsteDnaCodeGoedAfgemeld := true; end; 1005: begin //reeds gescand - if not (UiContext.Modus = modusKAD) then - btnInfo.Visible := true; + ZetInfoIcoontjeZichtbaar; Self.ModalResult := mrDnaCodeReedsGescand; + UiContext.LaatsteDnaCodeGoedAfgemeld := false; end; + -1021: begin //Geen geldige DNA code + Self.ModalResult := mrDnaCode; + ToonPopupScherm(Response.Header.Omschrijving, 'Probeer opnieuw'); + UiContext.LaatsteDnaCodeGoedAfgemeld := false; + end; else begin - Self.ModalResult := mrDnaCode; - ToonPopupScherm(Response.Header.Omschrijving, 'Probeer opnieuw') + Self.ModalResult := mrPallet; + ToonPopupScherm(Response.Header.Omschrijving, 'Probeer opnieuw'); + UiContext.LaatsteDnaCodeGoedAfgemeld := false; end; end; finally @@ -307,44 +420,88 @@ (Self.Parent.Parent As TfmProScanHoofdscherm).NavigeerNaar(Self.ModalResult); end; +procedure TfmDnaCodeScherm.GenereerTbpCode(DnaCode: DnaCode); +var + fGeefVolgendeTbpCodeResponse: GeefVolgendeTbpCodeResponse; + fTbpCode: string; + fAgent: TAgent; +begin + inherited; + fAgent := TAgent.Create(UiContext); + fGeefVolgendeTbpCodeResponse := fAgent.GeefVolgendeTbpCode(DnaCode.Toelevering, DnaCode.ProductNummer); + fAgent.Free; + try + if fGeefVolgendeTbpCodeResponse.Header.Status <> '200' then begin + Self.ModalResult := mrPallet; + ToonPopupScherm(fGeefVolgendeTbpCodeResponse.Header.Omschrijving, 'Probeer opnieuw'); + fTbpCode := ''; + end else begin + fTbpCode := fGeefVolgendeTbpCodeResponse.VolgendeTbpCode; + UiContext.Toelevering := ''; + end; + ZetPalletContext(fTbpCode); + finally + fGeefVolgendeTbpCodeResponse.Free; + end; +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 - Response := TAgent.Create(UiContext).PalletBijwerken(UiContext.Pallet,Status,IsDirecteLevering); + 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+' volledig verwerkt','OK','',19,-1,-1,clGreen); + 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); + //(Self.Parent.Parent As TfmProScanHoofdscherm).NavigeerNaar(Self.ModalResult); end; procedure TfmDnaCodeScherm.ToeleveringDataOphalen; var Response: ZoekViaToeleveringResponse; + fAgent: TAgent; begin - Response := TAgent.Create(UiContext).ZoekViaToelevering(UiContext.Toelevering); + 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); - if not (UiContext.Modus = modusKAD) then - btnInfo.Visible := true; + ZetInfoIcoontjeZichtbaar; ZetIcoontjesBovenaan; - VerwerkMogelijkePopups(Response.DnaCodes[0]); + VerwerkMogelijkePopups(Response.DnaCodes, UiContext.Toelevering); Self.ModalResult := mrDnaCode; end; finally @@ -358,12 +515,16 @@ fZoekAlleDnaCodesDieOpVhossMoetenResponse: ZoekAlleDnaCodesDieOpVhossMoetenResponse; fDnaCodeTeller: integer; fAantalGescand: integer; + fAgent: TAgent; begin - if UiContext.LaatsteDnaCode = '' then begin - fZoekAlleDnaCodesDieOpVhossMoetenResponse := TAgent.Create(UiContext).ZoekAlleDnaCodesDieOpVhossMoeten(UiContext.Pallet); + 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 - ToonPopupScherm(fZoekAlleDnaCodesDieOpVhossMoetenResponse.Header.Omschrijving, 'Probeer opnieuw') + if fZoekAlleDnaCodesDieOpVhossMoetenResponse.Header.Status <> '-1021' then + ToonPopupScherm(fZoekAlleDnaCodesDieOpVhossMoetenResponse.Header.Omschrijving, 'Probeer opnieuw') end else begin fDnaCodeTeller := 0; fAantalGescand := 0; @@ -379,15 +540,17 @@ lblAantalGescand.Caption := IntToStr(fAantalGescand); lblTotaalAantal.Caption := IntToStr(length(fZoekAlleDnaCodesDieOpVhossMoetenResponse.DnaCodes)); - btnInfo.Visible := true; + ZetInfoIcoontjeZichtbaar; ZetIcoontjesBovenaan; Self.ModalResult := mrDnaCode; end; finally fZoekAlleDnaCodesDieOpVhossMoetenResponse.Free; end; end else begin - fZoekAlleVhossLadesBijDnaCodeResponse := TAgent.Create(UiContext).ZoekAlleVhossLadesBijDnaCode(UiContext.LaatsteDnaCode); + 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') @@ -398,15 +561,12 @@ if not (fZoekAlleVhossLadesBijDnaCodeResponse.DnaCodes[fDnaCodeTeller].ScanTijdstip = nil) then fAantalGescand := fAantalGescand + 1; - if fZoekAlleVhossLadesBijDnaCodeResponse.DnaCodes[fDnaCodeTeller].DnaCode = UiContext.LaatsteDnaCode then - UiContext.Toelevering := fZoekAlleVhossLadesBijDnaCodeResponse.DnaCodes[fDnaCodeTeller].Toelevering; - fDnaCodeTeller := fDnaCodeTeller + 1; end; lblAantalGescand.Caption := IntToStr(fAantalGescand); lblTotaalAantal.Caption := IntToStr(length(fZoekAlleVhossLadesBijDnaCodeResponse.DnaCodes)); - btnInfo.Visible := true; + ZetInfoIcoontjeZichtbaar; ZetIcoontjesBovenaan; Self.ModalResult := mrDnaCode; end; @@ -416,28 +576,129 @@ end; end; -procedure TfmDnaCodeScherm.VerwerkMogelijkePopups(EersteDnaCode: DnaCode); +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 - if EersteDnaCode.IsDirecteLevering 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 := EersteDnaCode.IsDirecteLevering; + imgDirecteLevering.Visible := DnaCodes[fIndexEersteRelevanteDnaCode].IsDirecteLevering; - if EersteDnaCode.IsWegwerpPallet then begin + 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 := EersteDnaCode.IsWegwerpPallet; + 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, 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, 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; + + ii := 0; + if not UiContext.IsKartonnenPalletPopupGetoond then begin + try + fAgent := TAgent.Create(UiContext); + fBewerkKlantinstellingenResponse := fAgent.BewerkKlantinstellingen('List','',false, false, 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].KartonnenPallet then begin + ToonPopupScherm('Kartonnen pallet', 'OK','',23,-1,-1,clRed); + UiContext.IsKartonnenPalletPopupGetoond := true; + imgKartonnenPallet.Visible := true; + end; + end; + ii := ii + 1; + end; + finally + fBewerkKlantinstellingenResponse.Free; + end; + end else begin + imgKartonnenPallet.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 @@ -458,18 +719,32 @@ lblLaatstGescandData.Caption := ''; imgLaatstGescand.Visible := false; end else begin - lblLaatstGescandData.Caption := TCommonFunctions.VerkorteDnaCode(UiContext.LaatsteDnaCode); + 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 - Response := TAgent.Create(UiContext).RondAfKaderdeurDag(UiContext.LaatsteDnaCode); + 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); @@ -481,8 +756,15 @@ strtoint(Response.ToeleveringMetAantallen[antwoordlijnTeller].AantalKaderdeuren)-strtoint(Response.ToeleveringMetAantallen[antwoordlijnTeller].AantalKaderdeurenGescand) ]); end; - if System.Length(Response.ToeleveringMetAantallen) > 0 then - ToonPopupScherm('Onvolledige toelevering(en)','Ok','',0,6,0,$001717CD,cdsRondAfKaderdeurDag); + 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; @@ -492,11 +774,62 @@ 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 - Response := TAgent.Create(UiContext).ToeleveringBijwerken(UiContext.Toelevering,Status,isDirecteLevering); + fAgent := TAgent.Create(UiContext); + Response := fAgent.ToeleveringBijwerken(UiContext.Toelevering,Status,isDirecteLevering); + fAgent.Free; try if Response.Header.Status <> '200' then begin Self.ModalResult := mrDnaCode; @@ -516,35 +849,76 @@ DnaCodesStringList: TStringList; DnaCodes: ArrayOfDnaCodeDnaCode; ii: integer; + fAgent: TAgent; begin - {fZoekViaPalletCodeResponse := TAgent.Create(UiContext).ZoekViaPalletCode(UiContext.Pallet); + 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; - DnaCodesStringList := TStringList.Create(); - ii := 0; - while ii < length(DnaCodes)-1 do begin - DnaCodesStringList.Add(DnaCodes[ii].DnaCode) <-- geeft AV in test6 +function TfmDnaCodeScherm.GeefAantalOpPallet(PalletCode: string): integer; +var + fAgent: TAgent; + fZoekViaPalletCodeResponse: ZoekViaPalletCodeResponse; + fAantal: integer; +begin + if (UiContext.MoetTbpCodeGenereren = true) then begin + fAantal := 0; + end else begin + fAgent := TAgent.Create(UiContext); + fZoekViaPalletCodeResponse := fAgent.ZoekViaPalletCode(PalletCode); + fAgent.Free; + fAantal := length(fZoekViaPalletCodeResponse.DnaCodes); + fZoekViaPalletCodeResponse.Free; end; + Result := fAantal; +end; - fProboxAfdrukkenResponse := TAgent.Create(UiContext).ProboxEtiketAfdrukken(DnaCodesStringList); - try - if fProboxAfdrukkenResponse.Header.Status <> '200' then begin - Self.ModalResult := mrDnaCode; - ToonPopupScherm(fProboxAfdrukkenResponse.Header.Omschrijving, 'Bel planning') - end else begin - Self.ModalResult := mrPallet; - end; - finally - fProboxAfdrukkenResponse.Free; - end;} +procedure TfmDnaCodeScherm.ZetPalletContext(PalletCode: string); +begin + if TCommonFunctions.IsKaderdeurLocatie(PalletCode) then + UiContext.Pallet := PalletCode + else + UiContext.Pallet := UpperCase(PalletCode); + + lblHuidigePalletData.Caption := UiContext.Pallet; end; end.