FactuGES2/Source/ApplicationBase/Empresas/Views/uViewTienda.pas
2008-01-29 20:08:46 +00:00

92 lines
2.3 KiB
ObjectPascal

unit uViewTienda;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, uViewBase, ExtCtrls, StdCtrls, DB, uDADataTable, cxGraphics,
cxTextEdit, cxMaskEdit, cxDropDownEdit, cxDBEdit, cxControls,
cxContainer, cxEdit, cxLabel, cxDBLabel, cxCurrencyEdit, cxSpinEdit,
cxCheckBox, cxMemo, uDAInterfaces, cxLookupEdit, cxDBLookupEdit,
cxDBLookupComboBox, dxLayoutControl, uTiendasEmpresaController,
uIntegerListUtils;
type
TfrViewTienda = class(TfrViewBase)
cbTienda: TcxDBComboBox;
dxLayoutControl1Group_Root: TdxLayoutGroup;
dxLayoutControl1: TdxLayoutControl;
dxLayoutControl1Item1: TdxLayoutItem;
dxLayoutControl1Item2: TdxLayoutItem;
cbVendedor: TcxDBLookupComboBox;
dsVendedores: TDADataSource;
procedure CustomViewCreate(Sender: TObject);
procedure CustomViewDestroy(Sender: TObject);
private
FListaTiendas: TStringList;
FListaIDTiendas: TIntegerList;
public
function getIDTienda: Integer;
procedure SetIDTienda(const ID: Integer);
end;
implementation
{$R *.dfm}
procedure TfrViewTienda.CustomViewCreate(Sender: TObject);
begin
inherited;
FListaTiendas := Nil;
FListaIDTiendas := Nil;
with TTiendasEmpresaController.Create do
begin
FListaTiendas := DarListaTiendas;
FListaIDTiendas := DarListaIDTiendas;
end;
if Assigned(FListaTiendas) then
with cbTienda.Properties.Items do
begin
BeginUpdate;
try
Clear;
AddStrings(FListaTiendas);
finally
EndUpdate;
end;
cbTienda.ItemIndex := 0;
end;
end;
procedure TfrViewTienda.CustomViewDestroy(Sender: TObject);
begin
inherited;
if Assigned(FListaTiendas) then
FreeAndNil(FListaTiendas);
if Assigned(FListaIDTiendas) then
FreeAndNil(FListaIDTiendas);
end;
function TfrViewTienda.getIDTienda: Integer;
begin
if FListaTiendas.IndexOf(cbTienda.Text) < 0 then
Result := FListaTiendas.IndexOf(cbTienda.Text)
else
Result := FListaIDTiendas.Integers[FListaTiendas.IndexOf(cbTienda.Text)];
end;
procedure TfrViewTienda.SetIDTienda(const ID: Integer);
var
AIndex: Integer;
begin
if FListaIDTiendas.Find(ID, AIndex) then
cbTienda.Text := FListaTiendas.Strings[AIndex];
end;
end.