Index: VerpakkingsDefinitie/ApplicationContext.pas =================================================================== diff -u -r603 -r607 --- VerpakkingsDefinitie/ApplicationContext.pas (.../ApplicationContext.pas) (revision 603) +++ VerpakkingsDefinitie/ApplicationContext.pas (.../ApplicationContext.pas) (revision 607) @@ -248,6 +248,41 @@ property InternalErrorMessage: string read FInternalErrorMessage write FInternalErrorMessage; end; + // VERPAKKING META + TProductVerpakkingMeta = class + private + FID: Integer; + FName: string; + FOptiType: string; + public + property ID: Integer read FID write FID; + property Name: string read FName write FName; + property OptiType: string read FOptiType write FOptiType; + end; + + TProductVerpakkingMetaContext = class(TSubject) + private + FProductGroepen: TList; + FMetas: TList; + + FIsOK: Boolean; + FErrorMessage: string; + FInternalErrorMessage: string; + + function GetProductGroepen: TReadOnlyList; + function GetProductMetas: TReadOnlyList; + public + constructor Create(); + property ProductGroepen: TReadOnlyList read GetProductGroepen; + procedure SetProductGroepen(Collection: TEnumerable); + property Metas: TReadOnlyList read GetProductMetas; + procedure SetMetas(Collection: TEnumerable); + + 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 @@ -256,12 +291,15 @@ FUiInstellingenContext: TUiInstellingenContext; FProductsContext: TProductsContext; FProductDetailContext: TProductVerpakkingenContext; + FProductVerpakkingMetaContext: TProductVerpakkingMetaContext; public constructor Create(); property UserContext: TUserContext read FUserContext write FUserContext; property UiInstellingenContext: TUiInstellingenContext read FUiInstellingenContext write FUiInstellingenContext; property ProductsContext: TProductsContext read FProductsContext write FProductsContext; property ProductVerpakkingContext: TProductVerpakkingenContext read FProductDetailContext write FProductDetailContext; + property ProductVerpakkingMetaContext: TProductVerpakkingMetaContext read FProductVerpakkingMetaContext + write FProductVerpakkingMetaContext; end; implementation @@ -532,13 +570,47 @@ FParameters.AddRange(Collection); end; +// VERPAKKING META +constructor TProductVerpakkingMetaContext.Create(); +begin + inherited Create(); + + FProductGroepen := TList.Create(); + FMetas := TList.Create(); +end; + +function TProductVerpakkingMetaContext.GetProductGroepen(): TReadOnlyList; +begin + Result := TReadOnlyList.Create(FProductGroepen); +end; + +function TProductVerpakkingMetaContext.GetProductMetas(): TReadOnlyList; +begin + Result := TReadOnlyList.Create(FMetas); +end; + +procedure TProductVerpakkingMetaContext.SetProductGroepen(Collection: TEnumerable); +begin + FProductGroepen.Clear(); + FProductGroepen.AddRange(Collection); + self.Change(); +end; + +procedure TProductVerpakkingMetaContext.SetMetas(Collection: TEnumerable); +begin + FMetas.Clear(); + FMetas.AddRange(Collection); + self.Change(); +end; + // APPLICATION CONTEXT constructor TApplicationContext.Create(); begin FUserContext := TUserContext.Create(); FUiInstellingenContext := TUiInstellingenContext.Create(); FProductsContext := TProductsContext.Create(); FProductDetailContext := TProductVerpakkingenContext.Create(); + FProductVerpakkingMetaContext := TProductVerpakkingMetaContext.Create(); end; end. Index: VerpakkingsDefinitie/WS/OptiServerService.pas =================================================================== diff -u -r563 -r607 --- VerpakkingsDefinitie/WS/OptiServerService.pas (.../OptiServerService.pas) (revision 563) +++ VerpakkingsDefinitie/WS/OptiServerService.pas (.../OptiServerService.pas) (revision 607) @@ -1784,15 +1784,15 @@ GetAllProductGroepenResponse = class(TRemotable) private FGetAllProductGroepenResult: pxStatus; - FvarDataSet: anyType; + FvarDataSet: string; FvarDataSet_Specified: boolean; - procedure SetvarDataSet(Index: Integer; const AanyType: anyType); + procedure SetvarDataSet(Index: Integer; const AanyType: string); function varDataSet_Specified(Index: Integer): boolean; public destructor Destroy; override; published property GetAllProductGroepenResult: pxStatus read FGetAllProductGroepenResult write FGetAllProductGroepenResult; - property varDataSet: anyType Index(IS_OPTN)read FvarDataSet write SetvarDataSet stored varDataSet_Specified; + property varDataSet: string Index(IS_OPTN)read FvarDataSet write SetvarDataSet stored varDataSet_Specified; end; // ************************************************************************ // @@ -4665,7 +4665,7 @@ inherited Destroy; end; -procedure GetAllProductGroepenResponse.SetvarDataSet(Index: Integer; const AanyType: anyType); +procedure GetAllProductGroepenResponse.SetvarDataSet(Index: Integer; const AanyType: string); begin FvarDataSet := AanyType; FvarDataSet_Specified := True; Index: VerpakkingsDefinitie/UI/NavProductScherm.pas =================================================================== diff -u -r602 -r607 --- VerpakkingsDefinitie/UI/NavProductScherm.pas (.../NavProductScherm.pas) (revision 602) +++ VerpakkingsDefinitie/UI/NavProductScherm.pas (.../NavProductScherm.pas) (revision 607) @@ -28,7 +28,7 @@ uses Util, - ZoekProductenScherm, GebruikerScherm, GevondenProductenScherm, ProductDetailScherm, VerpakkingDetailScherm; + ZoekProductenScherm, GebruikerScherm, GevondenProductenScherm, ProductDetailScherm, VerpakkingDetailScherm, ProductMetaScherm; constructor TFormProductNav.Create(AOwner: TComponent; Navigator: INavigator; ApplicationContext: TApplicationContext; UserAgent: TUserAgent; ProductsAgent: TProductsAgent); @@ -84,6 +84,10 @@ NAVTOONPRODUCTVERPAKKING: begin end; + NAVTOONPRODUCTVERPAKKINGMETA: + begin + TFormVerpakkingMeta.Create(GridPanelLeft, self, ApplicationContext, FProductsAgent).ShowModal(); + end; else Exception.Create('SchermID: ' + IntToStr(schermId) + ' is onbekend'); NavigeerNaar(NAVHOME); Index: VerpakkingsDefinitie/UI/ProductMetaScherm.pas =================================================================== diff -u --- VerpakkingsDefinitie/UI/ProductMetaScherm.pas (revision 0) +++ VerpakkingsDefinitie/UI/ProductMetaScherm.pas (revision 607) @@ -0,0 +1,92 @@ +unit ProductMetaScherm; + +interface + +uses + Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics, + Vcl.Controls, Vcl.Forms, Vcl.Dialogs, + ObserverPattern, + Navigator, ApplicationContext, Subscherm, + ProductsAgent, Vcl.ComCtrls, Vcl.StdCtrls; + +type + TFormVerpakkingMeta = class(TForm) + ComboBoxGroep: TComboBox; + GroupBox1: TGroupBox; + GroupBox2: TGroupBox; + ListViewMetas: TListView; + Button1: TButton; + procedure FormCreate(Sender: TObject); + procedure Button1Click(Sender: TObject); + private + FNavigator: INavigator; + FApplicationContext: TApplicationContext; + FProductsAgent: TProductsAgent; + procedure ToonGroepen(); + procedure VerwerkProductAgentCall(); + public + Constructor Create(AOwner: TComponent; Navigator: INavigator; ApplicationContext: TApplicationContext; + ProductsAgent: TProductsAgent); + end; + +implementation + +{$R *.dfm} + +procedure TFormVerpakkingMeta.Button1Click(Sender: TObject); +begin + self.Close(); +end; + +constructor TFormVerpakkingMeta.Create(AOwner: TComponent; Navigator: INavigator; ApplicationContext: TApplicationContext; + ProductsAgent: TProductsAgent); +begin + inherited Create(AOwner); + + self.FNavigator := Navigator; + self.FApplicationContext := ApplicationContext; + self.FProductsAgent := ProductsAgent; +end; + +procedure TFormVerpakkingMeta.FormCreate(Sender: TObject); +begin + ToonGroepen(); +end; + +procedure TFormVerpakkingMeta.ToonGroepen(); +var + TempProductGroep: string; +begin + if FApplicationContext.ProductVerpakkingMetaContext.ProductGroepen.Count = 0 then + begin + // Inladen uit Agent + FProductsAgent.LaadProductGroepen(FApplicationContext.UserContext, FApplicationContext.ProductVerpakkingMetaContext); + VerwerkProductAgentCall(); + end; + + // Tonen, in ComboBox laden. + if FApplicationContext.ProductVerpakkingMetaContext.ProductGroepen.Count > 0 then + begin + ComboBoxGroep.Items.BeginUpdate; + for TempProductGroep in FApplicationContext.ProductVerpakkingMetaContext.ProductGroepen do + ComboBoxGroep.Items.Add(TempProductGroep); + ComboBoxGroep.Items.EndUpdate; + end; +end; + +procedure TFormVerpakkingMeta.VerwerkProductAgentCall(); +var + ErrorMessage: string; +begin + if FApplicationContext.ProductVerpakkingMetaContext.IsOK = false then + begin + // Opzoeking gefaald + ErrorMessage := FApplicationContext.ProductVerpakkingMetaContext.ErrorMessage; + if FApplicationContext.ProductVerpakkingMetaContext.InternalErrorMessage <> '' then + ErrorMessage := ErrorMessage + sLineBreak + FApplicationContext.ProductVerpakkingMetaContext.InternalErrorMessage; + + MessageDlg(ErrorMessage, TMsgDlgType.mtInformation, [mbOK], 0, mbCancel); + end; +end; + +end. Index: VerpakkingsDefinitie/WS/ProductsAgent.pas =================================================================== diff -u -r606 -r607 --- VerpakkingsDefinitie/WS/ProductsAgent.pas (.../ProductsAgent.pas) (revision 606) +++ VerpakkingsDefinitie/WS/ProductsAgent.pas (.../ProductsAgent.pas) (revision 607) @@ -48,6 +48,11 @@ ProductVerpakkingenContext: TProductVerpakkingenContext): TProductVerpakking; function GeefVerpakkingenMetIDs(VerpakkingIDs: TList; UserContext: TUserContext; ProductVerpakkingenContext: TProductVerpakkingenContext): TList; + // Verpakking meta + procedure RegistreerProductGroepenDataset(ProductVerpakkingMetaContext: TProductVerpakkingMetaContext; DataSet: string); + procedure RegistreerGelukteVerpakkingMetaQuery(ProductVerpakkingMetaContext: TProductVerpakkingMetaContext); + procedure RegistreerMislukteVerpakkingMetaQuery(ProductVerpakkingMetaContext: TProductVerpakkingMetaContext; + pxStatusObj: OptiServerService.pxStatus); public Constructor Create(); // UI @@ -66,12 +71,13 @@ ProductVerpakkingenContext: TProductVerpakkingenContext); procedure VerwijderVerpakking(ProductVerpakking: TProductVerpakking; UserContext: TUserContext; ProductVerpakkingenContext: TProductVerpakkingenContext); + // Verpakking meta + procedure LaadProductGroepen(UserContext: TUserContext; ProductVerpakkingMetaContext: TProductVerpakkingMetaContext); end; implementation -uses - StrUtils, Xml.XMLIntf, Xml.XMLDoc; +uses StrUtils, Xml.XMLIntf, Xml.XMLDoc; constructor TProductsAgent.Create(); begin @@ -636,7 +642,8 @@ // Opslaan OpslaanProductVerpakking(NieuweVerpakking, UserContext, ProductVerpakkingenContext); if ProductVerpakkingenContext.IsOK then - ProductVerpakkingenContext.AddProductVerpakking(NieuweVerpakking); // Notify gebeurt hier + ProductVerpakkingenContext.AddProductVerpakking(NieuweVerpakking); + // Notify gebeurt hier end; procedure TProductsAgent.OpslaanGewijzigdeProductVerpakking(ProductVerpakking: TProductVerpakking; UserContext: TUserContext; @@ -933,4 +940,103 @@ ProductVerpakkingenContext.InternalErrorMessage := pxStatusObj.InternalMessage; end; +// Verpakking meta +procedure TProductsAgent.LaadProductGroepen(UserContext: TUserContext; + ProductVerpakkingMetaContext: TProductVerpakkingMetaContext); +var + RequestData: OptiServerService.GetAllProductGroepen; + GetAllProductGroepenResponseObj: OptiServerService.GetAllProductGroepenResponse; +begin + RequestData := nil; + try + // Request + RequestData := OptiServerService.GetAllProductGroepen.Create(); + RequestData.SessionKey := UserContext.SessionKey; + + // Verpakking wissen + GetAllProductGroepenResponseObj := FOptiBoxServerSoap.GetAllProductGroepen(RequestData); + + // Response + if GetAllProductGroepenResponseObj.GetAllProductGroepenResult = nil then + begin + // Gelukt + RegistreerGelukteVerpakkingMetaQuery(ProductVerpakkingMetaContext); + RegistreerProductGroepenDataset(ProductVerpakkingMetaContext, + GetAllProductGroepenResponseObj.varDataSet); + end + else + // Mislukt + RegistreerMislukteVerpakkingMetaQuery(ProductVerpakkingMetaContext, + GetAllProductGroepenResponseObj.GetAllProductGroepenResult); + + finally + FreeAndNil(RequestData); + end; +end; + +procedure TProductsAgent.RegistreerProductGroepenDataset(ProductVerpakkingMetaContext: TProductVerpakkingMetaContext; + DataSet: string); +var + TempStr: string; + Lijn: string; + Lijnen: TStringList; + LijnenProduct: TStringList; + XMLDoc: IXMLDocument; + ProductGroepen: TList; +begin + try + // Producten inladen + LijnenProduct := TStringList.Create; + Lijnen := GeefBruikbareLijnenUitXMLDataSet(DataSet); + ProductGroepen := TList.Create(); + // De 'Select' elementen overlopen en elk element mappen naar een property van een instantie. + // Deze instantie toevoegen aan de lijst. + for Lijn in Lijnen do + begin + if ContainsStr(Lijn, '') then + begin + // Product blok afgerond + + // De eindtag zit geplakt aan de tag voor het nieuwe product. Bv