Witam, mam 10 podobnych procedur które różnią się tylko jedną zmienną która wskazuje na inną klasę. Aż się prosi aby to jakoś połączyć w jedną procedurę ale nie wiem jak do zmiennej przypisać różne klasy.
Oto 2 przykładowe procedury
procedure GetVatToComboBox(ComboBox: TComboBox);
var
I: Integer;
Save: Integer;
List: TListTax;
begin
Save := ComboBox.ItemIndex;
List := TListTax.Create;
try
List.Read;
for I := 0 to List.Count - 1 do
if ComboBox.Items.Count > I then
ComboBox.Items[I] := List[I].ValueName
else
ComboBox.Items.Add(List[I].ValueName);
// Jeżeli drugi raz ładuje i okazuje się że w combo jest więcej pozycji to trzeba je usunąć
if List.Count < ComboBox.Items.Count then
for I := List.Count to ComboBox.Items.Count - 1 do
ComboBox.Items.Delete(List.Count);
finally
List.Free;
end;
if Save = -1 then
Save := 0;
if ComboBox.Items.Count > Save then
ComboBox.ItemIndex := Save;
end;
procedure GetUnitToComboBox(ComboBox: TComboBox);
var
I: Integer;
Save: Integer;
List: TListUnit;
begin
Save := ComboBox.ItemIndex;
List := TListUnit.Create;
try
List.Read;
for I := 0 to List.Count - 1 do
if ComboBox.Items.Count > I then
ComboBox.Items[I] := List[I].ValueName
else
ComboBox.Items.Add(List[I].ValueName);
// Jeżeli drugi raz ładuje i okazuje się że w combo jest więcej pozycji to trzeba je usunąć
if List.Count < ComboBox.Items.Count then
for I := List.Count to ComboBox.Items.Count - 1 do
ComboBox.Items.Delete(List.Count);
finally
List.Free;
end;
if Save = -1 then
Save := 0;
if ComboBox.Items.Count > Save then
ComboBox.ItemIndex := Save;
end;
//a można by tak tylko jak :)
type TClassType = (Vat,Unit);
procedure GetToComboBox(ComboBox: TComboBox; AType: TClassType);