Index: VerpakkingsDefinitie/UI/ProductDetailScherm.pas =================================================================== diff -u -r581 -r582 --- VerpakkingsDefinitie/UI/ProductDetailScherm.pas (.../ProductDetailScherm.pas) (revision 581) +++ VerpakkingsDefinitie/UI/ProductDetailScherm.pas (.../ProductDetailScherm.pas) (revision 582) @@ -11,6 +11,7 @@ resourceString GEEN_DATA_CAPTION = 'Geen data om te tonen'; + NERGENS_DEEL_VAN_CAPTION = '--Nergens deel van--'; type TFormProductDetail = class(TFormSubscherm) @@ -101,71 +102,84 @@ procedure TFormProductDetail.UpdateGui(Sender: TObject); var - ProductDetailInformatie: OptiServerService.pxBoxData; - PPSPrioriteitEl: OptiServerService.pxemPPSPrioriteit; + ProductVerpakking: TProductVerpakking; TempStr: string; Item: string; I: Integer; + VorigeIndexInList: Integer; begin if (ApplicationContext.ProductDetailContext.GeselecteerdProduct = nil) or - (ApplicationContext.ProductDetailContext.ProductDetailInformatie = nil) then + (ApplicationContext.ProductDetailContext.ProductVerpakkingen.Count = 0) then begin UpdateGuiDataAanwezigheid(False); exit; end else UpdateGuiDataAanwezigheid(True); - // Update with data from ApplicationContext + // Update met data uit ApplicationContext LabelOmschrijving1.Caption := ApplicationContext.ProductDetailContext.GeselecteerdProduct.Omschrijving1; LabelOmschrijving2.Caption := ApplicationContext.ProductDetailContext.GeselecteerdProduct.Omschrijving2; LabelProductNaam.Caption := ApplicationContext.ProductDetailContext.GeselecteerdProduct.Kol1; - ProductDetailInformatie := ApplicationContext.ProductDetailContext.ProductDetailInformatie; + VorigeIndexInList := ListViewDozen.ItemIndex; // List view (grid) ListViewDozen.Clear(); - With ListViewDozen.Items.Add Do + for ProductVerpakking in ApplicationContext.ProductDetailContext.ProductVerpakkingen do begin - // Caption := IntToStr(Product.ProductNr); // Deze casting geeft geen access violation - Caption := IntToStr(ProductDetailInformatie.CutOrder); - SubItems.Add(ProductDetailInformatie.MetaCaption); - SubItems.Add(ProductDetailInformatie.Breedte + ' x ' + ProductDetailInformatie.Diepte + ' x ' + - ProductDetailInformatie.Hoogte); - SubItems.Add(ProductDetailInformatie.Aantal); - SubItems.Add(ProductDetailInformatie.MaxCombinAantal); - SubItems.Add(ProductDetailInformatie.DeelVanCaption); + With ListViewDozen.Items.Add Do + begin + // Caption := IntToStr(Product.ProductNr); // Deze casting geeft geen access violation + Caption := IntToStr(ProductVerpakking.CutOrder); + SubItems.Add(ProductVerpakking.MetaCaption); + SubItems.Add(ProductVerpakking.Breedte + ' x ' + ProductVerpakking.Diepte + ' x ' + ProductVerpakking.Hoogte); + SubItems.Add(ProductVerpakking.Aantal); + SubItems.Add(ProductVerpakking.MaxCombinAantal); + // SubItems.Add(ProductVerpakking.DeelVanCaption); + end; end; + // Kijk of dezelfde verpakking als voor de update opnieuw geselecteerd kan worden + if (VorigeIndexInList >= 0) and (VorigeIndexInList < ApplicationContext.ProductDetailContext.ProductVerpakkingen.Count) then + ProductVerpakking := ApplicationContext.ProductDetailContext.ProductVerpakkingen[VorigeIndexInList] + else if ApplicationContext.ProductDetailContext.ProductVerpakkingen.Count > 0 then + ProductVerpakking := ApplicationContext.ProductDetailContext.ProductVerpakkingen[0] // Default eerste verpakking selecteren + else + exit; // Geen verpakking aanwezig + // Linkerhelft - EditMeta.Text := ProductDetailInformatie.MetaCaption; + EditMeta.Text := ProductVerpakking.MetaCaption; // DeelVan ComboBoxDeelVan.Items.Clear(); // ComboBox vullen en item selecteren. - for TempStr in SplitString(ProductDetailInformatie.DefaultData.DeelVanCaption, ';') do + for TempStr in ApplicationContext.ProductDetailContext.GetDeelVanOpties(ProductVerpakking) do begin ComboBoxDeelVan.Items.Add(TempStr); end; - if ComboBoxDeelVan.Items.IndexOf(ProductDetailInformatie.DeelVanCaption) >= 0 then - ComboBoxDeelVan.ItemIndex := ComboBoxDeelVan.Items.IndexOf(ProductDetailInformatie.DeelVanCaption) - else if ComboBoxDeelVan.Items.Count > 0 then - ComboBoxDeelVan.ItemIndex := 0; + ComboBoxDeelVan.Items.Add(NERGENS_DEEL_VAN_CAPTION); + // Item selecteren + if ProductVerpakking.DeelVan <> nil then + // Index zoeken in lijst van producten + ComboBoxDeelVan.ItemIndex := ApplicationContext.ProductDetailContext.ProductVerpakkingen.IndexOf(ProductVerpakking.DeelVan) + else + ComboBoxDeelVan.ItemIndex := ComboBoxDeelVan.Items.Count - 1; // Default waarde: 'niks' optie selecteren - if ProductDetailInformatie.Breedte <> '' then - EditBreedte.Text := ProductDetailInformatie.Breedte + if ProductVerpakking.Breedte <> '' then + EditBreedte.Text := ProductVerpakking.Breedte else - EditBreedte.Text := ProductDetailInformatie.DefaultData.Breedte; // Default - if ProductDetailInformatie.Diepte <> '' then - EditDiepte.Text := ProductDetailInformatie.Diepte + EditBreedte.Text := ProductVerpakking.DefaultBreedte; // Default + if ProductVerpakking.Diepte <> '' then + EditDiepte.Text := ProductVerpakking.Diepte else - EditDiepte.Text := ProductDetailInformatie.DefaultData.Diepte; // Default - if ProductDetailInformatie.Hoogte <> '' then - EditHoogte.Text := ProductDetailInformatie.Hoogte + EditDiepte.Text := ProductVerpakking.DefaultDiepte; // Default + if ProductVerpakking.Hoogte <> '' then + EditHoogte.Text := ProductVerpakking.Hoogte else - EditHoogte.Text := ProductDetailInformatie.DefaultData.Hoogte; - EditMaxCombAantal.Text := ProductDetailInformatie.MaxCombinAantal; - EditAantal.Text := ProductDetailInformatie.Aantal; + EditHoogte.Text := ProductVerpakking.DefaultHoogte; + EditMaxCombAantal.Text := ProductVerpakking.MaxCombinAantal; + EditAantal.Text := ProductVerpakking.Aantal; // Rechterhelft @@ -176,7 +190,7 @@ begin ComboBoxPlaatsing.Items.Add(Item); end; - if (ApplicationContext.UiInstellingenContext.Plaatsing.TryGetValue(ProductDetailInformatie.Plaatsing, Item) = True) then + if (ApplicationContext.UiInstellingenContext.Plaatsing.TryGetValue(ProductVerpakking.Plaatsing, Item) = True) then ComboBoxPlaatsing.ItemIndex := ComboBoxPlaatsing.Items.IndexOf(Item) else if ComboBoxPlaatsing.Items.Count > 0 then ComboBoxPlaatsing.ItemIndex := 0; @@ -189,12 +203,12 @@ begin CheckComboBoxPositie.Items.Add(Item); end; - if ProductDetailInformatie.Positie = '' then + if ProductVerpakking.Positie = '' then // Lege positie betekent alles aangeduid for I := 0 to CheckComboBoxPositie.Items.Count - 1 do CheckComboBoxPositie.Checked[I] := True else - for TempStr in SplitString(ProductDetailInformatie.Positie, '') do + for TempStr in SplitString(ProductVerpakking.Positie, '') do if CheckComboBoxPositie.Items.IndexOf(TempStr) >= 0 then CheckComboBoxPositie.Checked[CheckComboBoxPositie.Items.IndexOf(TempStr)] := True; @@ -206,18 +220,11 @@ begin CheckComboBoxRichting.Items.Add(Item); end; - if ProductDetailInformatie.Rotatie <> '' then + if ProductVerpakking.Richting <> '' then begin - for TempStr in SplitString(ProductDetailInformatie.Rotatie, '') do + for TempStr in SplitString(ProductVerpakking.Richting, '') do if CheckComboBoxRichting.Items.IndexOf(TempStr) >= 0 then CheckComboBoxRichting.Checked[CheckComboBoxRichting.Items.IndexOf(TempStr)] := True; - end - else - begin - // Leeg, kies default waarden - for TempStr in SplitString(ProductDetailInformatie.DefaultData.Rotatie, ';') do - if CheckComboBoxRichting.Items.IndexOf(TempStr) >= 0 then - CheckComboBoxRichting.Checked[CheckComboBoxRichting.Items.IndexOf(TempStr)] := True; end; UpdateControlsEnableStatus()