Index: VerpakkingsDefinitie/ApplicationContext.pas =================================================================== diff -u -r563 -r564 --- VerpakkingsDefinitie/ApplicationContext.pas (.../ApplicationContext.pas) (revision 563) +++ VerpakkingsDefinitie/ApplicationContext.pas (.../ApplicationContext.pas) (revision 564) @@ -10,7 +10,7 @@ uses ObserverPattern, System.Generics.Collections, - OptiServerService; + OptiServerService, SysUtils; // SUB CONTEXTS: klassen die overeenkomen met bepaalde sub-context (bv. alles gerelateerd met authenticatie). @@ -42,13 +42,18 @@ FKol2: string; FKol3: string; FKol4: string; + function GetOmschrijving1(): string; + function GetOmschrijving2(): string; public property ProductNr: Integer read FProductNr write FProductNr; property Tekst: string read FTekst write FTekst; property Kol1: string read FKol1 write FKol1; property Kol2: string read FKol2 write FKol2; property Kol3: string read FKol3 write FKol3; property Kol4: string read FKol4 write FKol4; + + property Omschrijving1: string read GetOmschrijving1; + property Omschrijving2: string read GetOmschrijving2; end; TProductsContext = class(TSubject) @@ -106,17 +111,56 @@ implementation +// USER procedure TUserContext.NotifyChanged(); begin self.Change(); end; +// PRODUCT constructor TProductsContext.Create(); begin inherited Create(); FProducten := TList.Create(); end; +function TProductInformatie.GetOmschrijving1(): string; +var + S: string; +begin + if FKol4 = '' then + begin + Result := ''; + end + else + begin + try + Result := copy(FKol4, 0, Pos(',', FKol4) - 1); + except + Result := ''; + end; + + end; +end; + +function TProductInformatie.GetOmschrijving2(): string; +begin + if FKol4 = '' then + begin + Result := ''; + end + else + begin + try + Result := copy(FKol4, Pos(',', FKol4) + 2); + Result := copy(Result, 0, Pos(',', Result) - 1); // Tweede deel na de komma + except + Result := ''; + end; + + end; +end; + procedure TProductsContext.NotifyChanged(); begin self.Change(); @@ -127,6 +171,7 @@ self.Change(); end; +// APPLICATION CONTEXT constructor TApplicationContext.Create(); begin FUserContext := TUserContext.Create(); Index: VerpakkingsDefinitie/UI/GebruikerScherm.pas =================================================================== diff -u -r558 -r564 --- VerpakkingsDefinitie/UI/GebruikerScherm.pas (.../GebruikerScherm.pas) (revision 558) +++ VerpakkingsDefinitie/UI/GebruikerScherm.pas (.../GebruikerScherm.pas) (revision 564) @@ -23,15 +23,15 @@ FUserAgent: TUserAgent; procedure UpdateGui(Sender: TObject); public - Constructor Create(AOwner: TComponent; Navigator: TFormMain; ApplicationContext: TApplicationContext; + Constructor Create(AOwner: TComponent; Navigator: INavigator; ApplicationContext: TApplicationContext; GebruikerSubject: TSubject; UserAgent: TUserAgent); end; implementation {$R *.dfm} -constructor TFormGebruiker.Create(AOwner: TComponent; Navigator: TFormMain; ApplicationContext: TApplicationContext; +constructor TFormGebruiker.Create(AOwner: TComponent; Navigator: INavigator; ApplicationContext: TApplicationContext; GebruikerSubject: TSubject; UserAgent: TUserAgent); begin inherited Create(AOwner, Navigator, ApplicationContext); Index: VerpakkingsDefinitie/UI/ProductDetailScherm.dfm =================================================================== diff -u --- VerpakkingsDefinitie/UI/ProductDetailScherm.dfm (revision 0) +++ VerpakkingsDefinitie/UI/ProductDetailScherm.dfm (revision 564) @@ -0,0 +1,32 @@ +object FormProductDetail: TFormProductDetail + Left = 0 + Top = 0 + Caption = 'FormProductDetail' + ClientHeight = 539 + ClientWidth = 864 + Color = clBtnFace + Font.Charset = DEFAULT_CHARSET + Font.Color = clWindowText + Font.Height = -11 + Font.Name = 'Tahoma' + Font.Style = [] + OldCreateOrder = False + OnCreate = FormCreate + OnDestroy = FormDestroy + PixelsPerInch = 96 + TextHeight = 13 + object LabelOmschrijving1: TLabel + Left = 8 + Top = 8 + Width = 92 + Height = 13 + Caption = 'LabelOmschrijving1' + end + object LabelOmschrijving2: TLabel + Left = 8 + Top = 35 + Width = 92 + Height = 13 + Caption = 'LabelOmschrijving2' + end +end Index: VerpakkingsDefinitie/Main.pas =================================================================== diff -u -r562 -r564 --- VerpakkingsDefinitie/Main.pas (.../Main.pas) (revision 562) +++ VerpakkingsDefinitie/Main.pas (.../Main.pas) (revision 564) @@ -44,7 +44,7 @@ uses Subscherm, NavGridPanel, Util, - LogInScherm, ZoekProductenScherm, GebruikerScherm, GevondenProductenScherm; + LogInScherm, ZoekProductenScherm, GebruikerScherm, GevondenProductenScherm, ProductDetailScherm; {$R *.dfm} @@ -93,12 +93,10 @@ // 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, FProductsAgent), + NavGridPanelStandard.Init(TFormGebruiker.Create(NavGridPanelStandard, Self, FAppContext, FAppContext.UserContext, + FUserAgent), TFormZoekProducten.Create(NavGridPanelStandard, Self, FAppContext, FProductsAgent), TFormGevondenProducten.Create(NavGridPanelStandard, Self, FAppContext, FAppContext.ProductsContext, FProductsAgent), - TFormLogin.Create(NavGridPanelStandard, Self, FAppContext, FUserAgent) - ); + TFormProductDetail.Create(NavGridPanelStandard, Self, FAppContext, FAppContext.ProductDetailContext)); end; NAVLOGIN: Index: VerpakkingsDefinitie/VerpakkingsDefinitie.dpr =================================================================== diff -u -r562 -r564 --- VerpakkingsDefinitie/VerpakkingsDefinitie.dpr (.../VerpakkingsDefinitie.dpr) (revision 562) +++ VerpakkingsDefinitie/VerpakkingsDefinitie.dpr (.../VerpakkingsDefinitie.dpr) (revision 564) @@ -16,7 +16,8 @@ ProductsAgent in 'WS\ProductsAgent.pas', NavGridPanel in 'UI\NavGridPanel.pas', GevondenProductenScherm in 'UI\GevondenProductenScherm.pas' {FormGevondenProducten}, - OptiServerService in 'WS\OptiServerService.pas'; + OptiServerService in 'WS\OptiServerService.pas', + ProductDetailScherm in 'UI\ProductDetailScherm.pas' {FormProductDetail}; {$R *.res} Index: VerpakkingsDefinitie/VerpakkingsDefinitie.dproj =================================================================== diff -u -r562 -r564 --- VerpakkingsDefinitie/VerpakkingsDefinitie.dproj (.../VerpakkingsDefinitie.dproj) (revision 562) +++ VerpakkingsDefinitie/VerpakkingsDefinitie.dproj (.../VerpakkingsDefinitie.dproj) (revision 564) @@ -114,6 +114,10 @@ dfm + +
FormProductDetail
+ dfm +
Cfg_2 Base Index: VerpakkingsDefinitie/UI/ProductDetailScherm.pas =================================================================== diff -u --- VerpakkingsDefinitie/UI/ProductDetailScherm.pas (revision 0) +++ VerpakkingsDefinitie/UI/ProductDetailScherm.pas (revision 564) @@ -0,0 +1,59 @@ +unit ProductDetailScherm; + +interface + +uses + Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics, + Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, + Subscherm, Main, ApplicationContext, + ObserverPattern; + +type + TFormProductDetail = class(TFormSubscherm) + LabelOmschrijving1: TLabel; + LabelOmschrijving2: TLabel; + procedure FormCreate(Sender: TObject); + procedure FormDestroy(Sender: TObject); + private + FProductDetailsSubject: TSubject; + FProductDetailsSubjectObserver: TSubjectObserver; + procedure UpdateGui(Sender: TObject); + public + Constructor Create(AOwner: TComponent; Navigator: INavigator; ApplicationContext: TApplicationContext; + ProductDetailsSubject: TSubject); + end; + +implementation + +{$R *.dfm} + +Constructor TFormProductDetail.Create(AOwner: TComponent; Navigator: INavigator; ApplicationContext: TApplicationContext; + ProductDetailsSubject: TSubject); +begin + inherited Create(AOwner, Navigator, ApplicationContext); + self.FProductDetailsSubject := ProductDetailsSubject; + self.FProductDetailsSubjectObserver := TSubjectObserver.Create(self); + self.FProductDetailsSubjectObserver.OnChange := UpdateGui; +end; + +procedure TFormProductDetail.FormCreate(Sender: TObject); +begin + FProductDetailsSubject.RegisterObserver(FProductDetailsSubjectObserver); +end; + +procedure TFormProductDetail.FormDestroy(Sender: TObject); +begin + FProductDetailsSubject.UnregisterObserver(FProductDetailsSubjectObserver); +end; + +procedure TFormProductDetail.UpdateGui(Sender: TObject); +begin + if ApplicationContext.ProductDetailContext.GeselecteerdProduct <> nil then + begin + // Update with data from ApplicationContext + LabelOmschrijving1.Caption := ApplicationContext.ProductDetailContext.GeselecteerdProduct.Omschrijving1; + LabelOmschrijving2.Caption := ApplicationContext.ProductDetailContext.GeselecteerdProduct.Omschrijving2; + end; +end; + +end.