Index: VerpakkingsDefinitie/UI/GevondenProductenScherm.pas =================================================================== diff -u -r561 -r562 --- VerpakkingsDefinitie/UI/GevondenProductenScherm.pas (.../GevondenProductenScherm.pas) (revision 561) +++ VerpakkingsDefinitie/UI/GevondenProductenScherm.pas (.../GevondenProductenScherm.pas) (revision 562) @@ -5,10 +5,11 @@ uses Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics, Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.Grids, Vcl.DBGrids, + Vcl.StdCtrls, Vcl.ComCtrls, Vcl.DBCGrids, Data.DB, Data.Win.ADODB, ObserverPattern, Util, Subscherm, - UserAgent, Main, ApplicationContext, Vcl.StdCtrls, Vcl.ComCtrls, Vcl.DBCGrids; + ProductsAgent, Main, ApplicationContext; const GridColNamen: array [1 .. 6] of System.string = ('ProductNr', 'Tekst', 'Kol1', 'Kol2', 'Kol3', 'Kol4'); @@ -22,10 +23,11 @@ private FProductSubject: TSubject; FSubjectObserver: TSubjectObserver; + FProductsAgent: TProductsAgent; procedure UpdateGui(Sender: TObject); public Constructor Create(AOwner: TComponent; Navigator: TFormMain; ApplicationContext: TApplicationContext; - ProductSubject: TSubject); + ProductSubject: TSubject; ProductsAgent: TProductsAgent); end; implementation @@ -35,12 +37,13 @@ uses SelectService; constructor TFormGevondenProducten.Create(AOwner: TComponent; Navigator: TFormMain; ApplicationContext: TApplicationContext; - ProductSubject: TSubject); + ProductSubject: TSubject; ProductsAgent: TProductsAgent); begin inherited Create(AOwner, Navigator, ApplicationContext); self.FProductSubject := ProductSubject; self.FSubjectObserver := TSubjectObserver.Create(self); self.FSubjectObserver.OnChange := UpdateGui; + self.FProductsAgent := ProductsAgent; end; procedure TFormGevondenProducten.FormCreate(Sender: TObject); @@ -67,7 +70,16 @@ procedure TFormGevondenProducten.ListViewProductenSelectItem(Sender: TObject; Item: TListItem; Selected: Boolean); begin + if Item = nil then + exit; + if Item.Data = nil then + exit; ApplicationContext.ProductDetailContext.GeselecteerdProduct := Item.Data; + FProductsAgent.ZoekProductDataMetProductNr(TProductInformatie(Item.Data).ProductNr, self.ApplicationContext.UserContext, + self.ApplicationContext.ProductsContext); + + ApplicationContext.ProductDetailContext.NotifyChanged(); + end; procedure TFormGevondenProducten.UpdateGui(Sender: TObject);