Index: ProScan/UI/PalletScherm.pas =================================================================== diff -u -r665 -r668 --- ProScan/UI/PalletScherm.pas (.../PalletScherm.pas) (revision 665) +++ ProScan/UI/PalletScherm.pas (.../PalletScherm.pas) (revision 668) @@ -3,7 +3,7 @@ interface uses - Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics, + Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, System.IniFiles, Vcl.Graphics, Vcl.Controls, Vcl.Forms, Vcl.Dialogs, DrieKnoppenScherm, Vcl.ActnList, Vcl.StdCtrls, Vcl.ExtCtrls, Vcl.Imaging.pngimage; @@ -25,6 +25,7 @@ procedure SetModus(GescandeInput: string); function ValideerPalletCode(GescandeInput: string): boolean; function GeefLpnCode(): string; + function MoetNieuweLpnCodeAangemaaktWorden(): boolean; public { Public declarations } end; @@ -61,9 +62,9 @@ //checken of pallet in gebruik is indien het vorige geslaagd is if fPalletGevalideerd and not(UiContext.Modus = modusKAD) and not(UiContext.Modus = modusVHOSS ) then begin + UiContext.LpnCode := GeefLpnCode(); fAgent := TAgent.Create(UiContext); fZoekViaPalletCodeResponse := fAgent.ZoekViaPalletCode(edtPallet.Text); - UiContext.LpnCode := GeefLpnCode(); fAgent.Free; try if fZoekViaPalletCodeResponse.Header.Status = '200' then begin @@ -132,25 +133,56 @@ function TfmPalletScherm.GeefLpnCode(): string; var - fZoekViaLpnCodeResponse: ZoekViaLpnCodeResponse; fGeefVolgendeLpnCodeResponse: GeefVolgendeLpnCodeResponse; fAgent: TAgent; begin - fAgent := TAgent.Create(UiContext); - fZoekViaLpnCodeResponse := fAgent.ZoekViaLpnCode(UiContext.LpnCode); try - if (fZoekViaLpnCodeResponse.Header.Status <> '200') or (Length(fZoekViaLpnCodeResponse.DnaCodes) >= 2) then begin + if (Self.MoetNieuweLpnCodeAangemaaktWorden()) then begin + fAgent := TAgent.Create(UiContext); fGeefVolgendeLpnCodeResponse := fAgent.GeefVolgendeLpnCode(); + fAgent.Free; result := fGeefVolgendeLpnCodeResponse.VolgendeLpnCode; fGeefVolgendeLpnCodeResponse.Free; - end else + end else begin result := UiContext.LpnCode; + end; finally + end; +end; + + +function TfmPalletScherm.MoetNieuweLpnCodeAangemaaktWorden(): boolean; +var + fZoekViaLpnCodeResponse: ZoekViaLpnCodeResponse; + fUniekePalletCodes: THashedStringList; + fDnaCode: DnaCode; + fAgent: TAgent; +begin + fAgent := TAgent.Create(UiContext); + fZoekViaLpnCodeResponse := fAgent.ZoekViaLpnCode(UiContext.LpnCode); + result := false; + try + if (fZoekViaLpnCodeResponse.Header.Status <> '200') then begin + result := true; + end else begin + fUniekePalletCodes := THashedStringList.Create; + fUniekePalletCodes.Duplicates := dupIgnore; + + for fDnaCode in fZoekViaLpnCodeResponse.DnaCodes do + fUniekePalletCodes.Add(fDnaCode.PalletCode); + + if (fUniekePalletCodes.Count > 1) then + result := true; + + fUniekePalletCodes.Free; + end; + finally fZoekViaLpnCodeResponse.Free; end; fAgent.Free; end; + procedure TfmPalletScherm.btnGenereerTbpClick(Sender: TObject); var fGeefVolgendeTbpCodeResponse: GeefVolgendeTbpCodeResponse;