Index: VerpakkingsDefinitie/VerpakkingsDefinitie.dpr =================================================================== diff -u -r559 -r561 --- VerpakkingsDefinitie/VerpakkingsDefinitie.dpr (.../VerpakkingsDefinitie.dpr) (revision 559) +++ VerpakkingsDefinitie/VerpakkingsDefinitie.dpr (.../VerpakkingsDefinitie.dpr) (revision 561) @@ -14,7 +14,8 @@ ObserverPattern in 'UI\ObserverPattern.pas', SelectService in 'WS\SelectService.pas', ProductsAgent in 'WS\ProductsAgent.pas', - NavGridPanel in 'UI\NavGridPanel.pas'; + NavGridPanel in 'UI\NavGridPanel.pas', + GevondenProductenScherm in 'UI\GevondenProductenScherm.pas' {FormGevondenProducten}; {$R *.res} Index: VerpakkingsDefinitie/UI/GevondenProductenScherm.dfm =================================================================== diff -u --- VerpakkingsDefinitie/UI/GevondenProductenScherm.dfm (revision 0) +++ VerpakkingsDefinitie/UI/GevondenProductenScherm.dfm (revision 561) @@ -0,0 +1,32 @@ +object FormGevondenProducten: TFormGevondenProducten + Left = 0 + Top = 0 + Caption = 'Gevonden producten' + ClientHeight = 491 + ClientWidth = 317 + Color = clBtnFace + Font.Charset = DEFAULT_CHARSET + Font.Color = clWindowText + Font.Height = -11 + Font.Name = 'Tahoma' + Font.Style = [] + OldCreateOrder = False + OnCreate = FormCreate + OnDestroy = FormDestroy + DesignSize = ( + 317 + 491) + PixelsPerInch = 96 + TextHeight = 13 + object ListViewProducten: TListView + Left = 0 + Top = 0 + Width = 313 + Height = 489 + Anchors = [akLeft, akTop, akRight, akBottom] + Columns = <> + TabOrder = 0 + ViewStyle = vsReport + OnSelectItem = ListViewProductenSelectItem + end +end Index: VerpakkingsDefinitie/UI/GevondenProductenScherm.pas =================================================================== diff -u --- VerpakkingsDefinitie/UI/GevondenProductenScherm.pas (revision 0) +++ VerpakkingsDefinitie/UI/GevondenProductenScherm.pas (revision 561) @@ -0,0 +1,95 @@ +unit GevondenProductenScherm; + +interface + +uses + Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics, + Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.Grids, Vcl.DBGrids, + Data.DB, Data.Win.ADODB, + ObserverPattern, Util, + Subscherm, + UserAgent, Main, ApplicationContext, Vcl.StdCtrls, Vcl.ComCtrls, Vcl.DBCGrids; + +const + GridColNamen: array [1 .. 6] of System.string = ('ProductNr', 'Tekst', 'Kol1', 'Kol2', 'Kol3', 'Kol4'); + +type + TFormGevondenProducten = class(TFormSubscherm) + ListViewProducten: TListView; + procedure FormDestroy(Sender: TObject); + procedure FormCreate(Sender: TObject); + procedure ListViewProductenSelectItem(Sender: TObject; Item: TListItem; Selected: Boolean); + private + FProductSubject: TSubject; + FSubjectObserver: TSubjectObserver; + procedure UpdateGui(Sender: TObject); + public + Constructor Create(AOwner: TComponent; Navigator: TFormMain; ApplicationContext: TApplicationContext; + ProductSubject: TSubject); + end; + +implementation + +{$R *.dfm} + +uses SelectService; + +constructor TFormGevondenProducten.Create(AOwner: TComponent; Navigator: TFormMain; ApplicationContext: TApplicationContext; + ProductSubject: TSubject); +begin + inherited Create(AOwner, Navigator, ApplicationContext); + self.FProductSubject := ProductSubject; + self.FSubjectObserver := TSubjectObserver.Create(self); + self.FSubjectObserver.OnChange := UpdateGui; +end; + +procedure TFormGevondenProducten.FormCreate(Sender: TObject); +var + ColNaam: string; +begin + FProductSubject.RegisterObserver(FSubjectObserver); + + for ColNaam in GridColNamen do + begin + with ListViewProducten.Columns.Add do + begin + Caption := ColNaam; + Alignment := taLeftJustify; + Width := -1; + end; + end; +end; + +procedure TFormGevondenProducten.FormDestroy(Sender: TObject); +begin + FProductSubject.UnregisterObserver(FSubjectObserver); +end; + +procedure TFormGevondenProducten.ListViewProductenSelectItem(Sender: TObject; Item: TListItem; Selected: Boolean); +begin + ApplicationContext.ProductDetailContext.GeselecteerdProduct := Item.Data; +end; + +procedure TFormGevondenProducten.UpdateGui(Sender: TObject); +var + Product: TProductInformatie; + NieuwItem: TListItem; +begin + // Update with data from ApplicationContext + for Product in ApplicationContext.ProductsContext.Producten do + begin + With ListViewProducten.Items.Add Do + begin + Caption := IntToStr(Product.ProductNr); // Deze casting geeft geen access violation + SubItems.Add(Product.Tekst); + SubItems.Add(Product.Kol1); + SubItems.Add(Product.Kol2); + SubItems.Add(Product.Kol3); + SubItems.Add(Product.Kol4); + Data := Product; + end; + end; + +end; + +end. Index: VerpakkingsDefinitie/ApplicationContext.pas =================================================================== diff -u -r560 -r561 --- VerpakkingsDefinitie/ApplicationContext.pas (.../ApplicationContext.pas) (revision 560) +++ VerpakkingsDefinitie/ApplicationContext.pas (.../ApplicationContext.pas) (revision 561) @@ -67,16 +67,35 @@ property InternalErrorMessage: string read FInternalErrorMessage write FInternalErrorMessage; end; + TProductDetailContext = class(TSubject) + private + FSessionKey: string; + FGeselecteerdProduct: TProductInformatie; + + FIsOK: Boolean; + FErrorMessage: string; + FInternalErrorMessage: string; + public + procedure NotifyChanged(); + property GeselecteerdProduct: TProductInformatie read FGeselecteerdProduct write FGeselecteerdProduct; + + property IsOK: Boolean read FIsOK write FIsOK; + property ErrorMessage: string read FErrorMessage write FErrorMessage; + property InternalErrorMessage: string read FInternalErrorMessage write FInternalErrorMessage; + end; + // APPLICATION CONTEXT // Application context bevat alle sub-contexts TApplicationContext = class private FUserContext: TUserContext; FProductsContext: TProductsContext; + FProductDetailContext: TProductDetailContext; public constructor Create(); property UserContext: TUserContext read FUserContext write FUserContext; property ProductsContext: TProductsContext read FProductsContext write FProductsContext; + property ProductDetailContext: TProductDetailContext read FProductDetailContext write FProductDetailContext; end; implementation @@ -97,10 +116,16 @@ self.Change(); end; +procedure TProductDetailContext.NotifyChanged(); +begin + self.Change(); +end; + constructor TApplicationContext.Create(); begin FUserContext := TUserContext.Create(); FProductsContext := TProductsContext.Create(); + FProductDetailContext := TProductDetailContext.Create(); end; end. Index: VerpakkingsDefinitie/Main.pas =================================================================== diff -u -r559 -r561 --- VerpakkingsDefinitie/Main.pas (.../Main.pas) (revision 559) +++ VerpakkingsDefinitie/Main.pas (.../Main.pas) (revision 561) @@ -44,7 +44,7 @@ uses Subscherm, NavGridPanel, Util, - LogInScherm, ZoekProductenScherm, GebruikerScherm; + LogInScherm, ZoekProductenScherm, GebruikerScherm, GevondenProductenScherm; {$R *.dfm} @@ -93,11 +93,12 @@ // Zoekscherm daaronder links // Resultaten scherm daaronder links // Rechts is helemaal voor detail scherm - NavGridPanelStandard.Init(TFormGebruiker.Create(NavGridPanelStandard, Self, FAppContext, FAppContext.UserContext, - FUserAgent), - TFormZoekProducten.Create(NavGridPanelStandard, Self, FAppContext, FProductAgent), - TFormLogin.Create(NavGridPanelStandard, Self, FAppContext, FUserAgent), - TFormLogin.Create(NavGridPanelStandard, Self, FAppContext, FUserAgent)); + NavGridPanelStandard.Init( + TFormGebruiker.Create(NavGridPanelStandard, Self, FAppContext, FAppContext.UserContext,FUserAgent), + TFormZoekProducten.Create(NavGridPanelStandard, Self, FAppContext, FProductAgent), + TFormGevondenProducten.Create(NavGridPanelStandard, Self, FAppContext, FAppContext.ProductsContext), + TFormLogin.Create(NavGridPanelStandard, Self, FAppContext, FUserAgent) + ); end; NAVLOGIN: Index: VerpakkingsDefinitie/VerpakkingsDefinitie.dproj =================================================================== diff -u -r559 -r561 --- VerpakkingsDefinitie/VerpakkingsDefinitie.dproj (.../VerpakkingsDefinitie.dproj) (revision 559) +++ VerpakkingsDefinitie/VerpakkingsDefinitie.dproj (.../VerpakkingsDefinitie.dproj) (revision 561) @@ -109,6 +109,10 @@ + +
FormGevondenProducten
+ dfm +
Cfg_2 Base