Index: ProScan/UI/PalletScherm.pas =================================================================== diff -u -r404 -r697 --- ProScan/UI/PalletScherm.pas (.../PalletScherm.pas) (revision 404) +++ ProScan/UI/PalletScherm.pas (.../PalletScherm.pas) (revision 697) @@ -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; @@ -23,6 +23,7 @@ private procedure SetContext; procedure SetModus(GescandeInput: string); + procedure ResetPopups; function ValideerPalletCode(GescandeInput: string): boolean; public { Public declarations } @@ -34,7 +35,7 @@ implementation uses - DnaCodeService, UiContext, Agent, ProScanMain, StrUtils, CommonFunctions; + DnaCodeService, QRcodeNaarKenmerkenService, UiContext, Agent, ProScanMain, StrUtils, CommonFunctions; {$R *.dfm} @@ -49,84 +50,102 @@ var fZoekViaPalletCodeResponse: ZoekViaPalletCodeResponse; fZoekViaToeleveringResponse: ZoekViaToeleveringResponse; - fPalletGevalideerd: boolean; + fAgent: TAgent; begin SetModus(edtPallet.Text); - fPalletGevalideerd := false; - if not (UiContext.Modus = modusKAD) then - fPalletGevalideerd := ValideerPalletCode(edtPallet.Text); - - //checken of pallet in gebruik is indien het vorige geslaagd is - if fPalletGevalideerd and not(UiContext.Modus = modusKAD )then begin - fZoekViaPalletCodeResponse := TAgent.Create(UiContext).ZoekViaPalletCode(edtPallet.Text); + if (UiContext.MoetTbpCodeGenereren = true) then begin + ResetPopups; + Self.ModalResult := mrDnaCode; + end else if (UiContext.Modus = modusKAD) then begin + Self.ModalResult := mrDnaCode; + end else if (UiContext.Modus = modusVHOSS) then begin + Self.ModalResult := mrDnaCode; + end else if (ValideerPalletCode(edtPallet.Text) = true) then begin + fAgent := TAgent.Create(UiContext); + fZoekViaPalletCodeResponse := fAgent.ZoekViaPalletCode(edtPallet.Text); + fAgent.Free; try if fZoekViaPalletCodeResponse.Header.Status = '200' then begin UiContext.Toelevering := fZoekViaPalletCodeResponse.DnaCodes[0].Toelevering; - Self.ModalResult := mrBestaandePallet; + SetContext; + if fZoekViaPalletCodeResponse.MeerdereToeleveringenToegestaan then + Self.ModalResult := mrBestaandePallet + else + Self.ModalResult := mrDnaCode; end else begin //enkel leegmaken indien de huidige toelevering al compleet is - fZoekViaToeleveringResponse := TAgent.Create(UiContext).ZoekViaToelevering(UiContext.Toelevering); - if fZoekViaToeleveringResponse.AantalInToelevering = fZoekViaToeleveringResponse.AantalReedsGescand then - UiContext.Toelevering := ''; + fAgent := TAgent.Create(UiContext); + try + fZoekViaToeleveringResponse := fAgent.ZoekViaToelevering(UiContext.Toelevering); + if fZoekViaToeleveringResponse.AantalInToelevering = fZoekViaToeleveringResponse.AantalReedsGescand then + UiContext.Toelevering := ''; + fZoekViaToeleveringResponse.Free; + finally + fAgent.Free; + end; Self.ModalResult := mrDnaCode; end; finally fZoekViaPalletCodeResponse.Free; end; - //popups resetten - UiContext.IsDirecteLeveringPopupGetoond := false; - UiContext.IsWegwerpPalletPopupGetoond := false; - UiContext.InternVhossId := ''; - end else if (UiContext.Modus = modusKAD) then begin - Self.ModalResult := mrDnaCode; + ResetPopups; end else begin Self.ModalResult := mrPallet; end; + PostMessage(Self.Handle,WM_Close,0,0); (Self.Parent.Parent As TfmProScanHoofdscherm).NavigeerNaar(Self.ModalResult); end; function TfmPalletScherm.ValideerPalletCode(GescandeInput: string): boolean; var fValideerPalletCodeResponse: ValideerPalletCodeResponse; + fAgent: TAgent; begin // pallet code valideren result := false; - fValideerPalletCodeResponse := TAgent.Create(UiContext).ValideerPalletCode(edtPallet.Text); - try - if fValideerPalletCodeResponse.Header.Status <> '200' then begin - Self.ModalResult := mrPallet; - ToonPopupScherm(fValideerPalletCodeResponse.Header.Omschrijving, 'Probeer opnieuw'); - edtPallet.Text := ''; - SetContext; - end else begin - result := true; + + if (UiContext.MoetTbpCodeGenereren) then begin + result := true; + end else begin + fAgent := TAgent.Create(UiContext); + fValideerPalletCodeResponse := fAgent.ValideerPalletCode(edtPallet.Text); + fAgent.Free; + try + if fValideerPalletCodeResponse.Header.Status <> '200' then begin + Self.ModalResult := mrPallet; + ToonPopupScherm(fValideerPalletCodeResponse.Header.Omschrijving, 'Probeer opnieuw'); + edtPallet.Text := ''; + SetContext; + end else begin + result := true; + end; + finally + fValideerPalletCodeResponse.Free; end; - finally - fValideerPalletCodeResponse.Free; end; end; +procedure TfmPalletScherm.ResetPopups; +begin + UiContext.IsDirecteLeveringPopupGetoond := false; + UiContext.IsWegwerpPalletPopupGetoond := false; + UiContext.IsSSTPopupGetoond := false; + UiContext.IsExportPopupGetoond := false; + UiContext.IsBlumXsPopupGetoond := false; + UiContext.IsKartonnenPalletPopupGetoond := false; + UiContext.InternVhossId := ''; +end; + + procedure TfmPalletScherm.btnGenereerTbpClick(Sender: TObject); -var - fGeefVolgendeTbpCodeResponse: GeefVolgendeTbpCodeResponse; begin inherited; - fGeefVolgendeTbpCodeResponse := TAgent.Create(UiContext).GeefVolgendeTbpCode(); - try - if fGeefVolgendeTbpCodeResponse.Header.Status <> '200' then begin - Self.ModalResult := mrPallet; - ToonPopupScherm(fGeefVolgendeTbpCodeResponse.Header.Omschrijving, 'Probeer opnieuw'); - edtPallet.Text := ''; - end else begin - edtPallet.Text := fGeefVolgendeTbpCodeResponse.VolgendeTbpCode; - UiContext.Toelevering := ''; - end; - SetContext; - finally - fGeefVolgendeTbpCodeResponse.Free; - end; + edtPallet.Text := ''; + UiContext.Toelevering := ''; + UiContext.Pallet := ''; + UiContext.MoetTbpCodeGenereren := true; actVolgendeExecute(Self); end; @@ -154,6 +173,7 @@ btnRechtsOnder.Action := actVolgende; edtPallet.Text := ''; edtPallet.SetFocus; + UiContext.MoetTbpCodeGenereren := false; SetContext; inherited; end;