Index: ProScan/UI/DnaCodeScherm.pas =================================================================== diff -u -r451 -r696 --- ProScan/UI/DnaCodeScherm.pas (.../DnaCodeScherm.pas) (revision 451) +++ 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) @@ -25,9 +25,11 @@ 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); @@ -39,14 +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; @@ -76,20 +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(5, imgExport.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(); @@ -100,53 +111,67 @@ 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) then begin - PalletBijwerken(DnaCodeStatus.InBuffer,false); - UiContext.Pallet := ''; - Self.ModalResult := mrPallet; - end else if (UiContext.Modus = modusVHOSS) then begin - PalletBijwerken(DnaCodeStatus.InBuffer,false); - UiContext.Pallet := ''; - Self.ModalResult := mrPallet; - 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; + 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); - DrukProboxEtiketAfIndienNodig; + end else begin UiContext.Pallet := ''; Self.ModalResult := mrPallet; - end else begin - Self.ModalResult := mrDnaCode; end; - end else - Self.ModalResult := mrPallet; - PostMessage(Self.Handle,WM_Close,0,0); - (Self.Parent.Parent As TfmProScanHoofdscherm).NavigeerNaar(Self.ModalResult); + 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); @@ -158,57 +183,74 @@ inherited; if UiContext.Toelevering = '' then exit; - - if (UiContext.Modus = modusKAD) then begin - RondAfKaderdeurDag(); - UiContext.Toelevering := ''; - UiContext.Pallet := ''; - end else if (UiContext.Modus = modusVHOSS) then begin - PalletBijwerken(DnaCodeStatus.InBuffer,false); - 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); - UiContext.Toelevering := ''; - UiContext.BatchId := ''; + if lblAantalGescand.Caption = lblTotaalAantal.Caption then begin + if fIsDirecteLevering then begin + ToonPopupScherm('Directe levering', 'OK','',15,-1,-1,clBlue); + imgDirecteLevering.Visible := true; + end; DrukProboxEtiketAfIndienNodig; - end; - end else begin - fOnvolledigeToeleveringScherm := TfmOnvolledigeToeleveringScherm.Create(self); - try - fOnvolledigeToeleveringScherm.UiContext := UiContext; - fWaarschuwingModalResult := fOnvolledigeToeleveringScherm.ShowModal; - if fWaarschuwingModalResult = mrNo then begin - ZetToeleveringStatus(DnaCodeStatus.InBuffer, fIsDirecteLevering); - UiContext.Toelevering := ''; - UiContext.BatchId := ''; - Self.ModalResult := mrPallet; + ZetToeleveringStatus(DnaCodeStatus.InBuffer, fIsDirecteLevering); + if Self.ModalResult = mrPallet then begin + ToonPopupScherm('Toelevering succesvol afgerond','OK','',19,-1,-1,clGreen); end else begin - Self.ModalResult := mrDnaCode; + ToonPopupScherm('Toelevering niet succesvol afgerond, etiket weggooien','OK','',2,-1,-1, clRed); end; - finally - fOnvolledigeToeleveringScherm.Free; + 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; - 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); @@ -220,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); @@ -237,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; @@ -252,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; @@ -282,13 +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; @@ -298,28 +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.BatchId := Response.BatchId; + 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[0]); + 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; + -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 @@ -329,12 +420,54 @@ (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'); @@ -354,8 +487,11 @@ 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') @@ -365,7 +501,7 @@ lblTotaalAantal.Caption := IntToStr(Response.AantalInToelevering); ZetInfoIcoontjeZichtbaar; ZetIcoontjesBovenaan; - VerwerkMogelijkePopups(Response.DnaCodes[0]); + VerwerkMogelijkePopups(Response.DnaCodes, UiContext.Toelevering); Self.ModalResult := mrDnaCode; end; finally @@ -379,9 +515,12 @@ 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 if fZoekAlleDnaCodesDieOpVhossMoetenResponse.Header.Status <> '-1021' then @@ -409,7 +548,9 @@ 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') @@ -420,9 +561,6 @@ 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; @@ -438,50 +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 - fBewerkKlantinstellingenResponse := TAgent.Create(UiContext).BewerkKlantinstellingen('List','',false, false, false); - while ii <= length(fBewerkKlantinstellingenResponse.Klantinstellingen)-1 do begin - if fBewerkKlantinstellingenResponse.Klantinstellingen[ii].KlantId = EersteDnaCode.KlantNummer then begin - if fBewerkKlantinstellingenResponse.Klantinstellingen[ii].IsExport then begin - ToonPopupScherm('Export', 'OK','',21,-1,-1,clRed); - UiContext.IsExportPopupGetoond := true; - imgExport.Visible := true; - end; + 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; - ii := ii + 1; + 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 @@ -502,27 +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 (not (UiContext.Modus = modusKAD)) and (UiContext.LaatsteDnaCode <> '') then + 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; - Response := TAgent.Create(UiContext).RondAfKaderdeurDag(UiContext.LaatsteDnaCode); + 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); @@ -541,6 +763,8 @@ 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; @@ -550,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; @@ -574,15 +849,19 @@ DnaCodesStringList: TStringList; DnaCodes: ArrayOfDnaCodeDnaCode; ii: integer; + fAgent: TAgent; begin if not (System.StrUtils.LeftStr(UiContext.Pallet,3) = 'TBP') then exit; - 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 DnaCodes := fZoekViaPalletCodeResponse.DnaCodes; end else begin + Self.ModalResult := mrHome; ToonPopupScherm(fZoekViaPalletCodeResponse.Header.Omschrijving, 'Bel planning'); end; @@ -593,12 +872,17 @@ ii := ii + 1; end; - fProboxAfdrukkenResponse := TAgent.Create(UiContext).ProboxEtiketAfdrukken(DnaCodesStringList); + fAgent := TAgent.Create(UiContext); + fProboxAfdrukkenResponse := fAgent.ProboxEtiketAfdrukken(DnaCodesStringList); + fAgent.Free; try if fProboxAfdrukkenResponse.Header.Status <> '200' then begin - Self.ModalResult := mrDnaCode; + Self.ModalResult := mrHome; ToonPopupScherm(fProboxAfdrukkenResponse.Header.Omschrijving, 'Bel planning') end else begin + UiContext.LaatstAfgedrukteDnaCodes.Clear; + UiContext.LaatstAfgedrukteDnaCodes := DnaCodesStringList; + Self.ModalResult := mrPallet; end; finally @@ -609,4 +893,32 @@ end; end; +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; + +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.