FactuGES2/Source/ApplicationBase/Empresas/Views/uViewTienda.pas
2008-07-10 15:58:06 +00:00

142 lines
3.9 KiB
ObjectPascal

unit uViewTienda;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, uViewBase, ExtCtrls, StdCtrls, DB, uDADataTable, cxGraphics,
dxLayoutControl, cxContainer, cxEdit, cxTextEdit, cxMaskEdit, cxDropDownEdit,
cxControls, dxSkinsCore, dxSkinBlack, dxSkinBlue, dxSkinCaramel, dxSkinCoffee,
dxSkinGlassOceans, dxSkiniMaginary, dxSkinLilian, dxSkinLiquidSky,
dxSkinLondonLiquidSky, dxSkinMcSkin, dxSkinMoneyTwins, dxSkinOffice2007Black,
dxSkinOffice2007Blue, dxSkinOffice2007Green, dxSkinOffice2007Pink,
dxSkinOffice2007Silver, dxSkinSilver, dxSkinStardust, dxSkinsDefaultPainters,
dxSkinValentine, dxSkinXmas2008Blue, dxSkinsdxLCPainter;
type
IViewTienda = interface(IViewBase)
['{9FD357AB-2E87-4CAF-8AEB-04368AD075AF}']
end;
TfrViewTienda = class(TfrViewBase, IViewTienda)
cbTienda: TcxComboBox;
dxLayoutControl1Group_Root: TdxLayoutGroup;
dxLayoutControl1: TdxLayoutControl;
dxLayoutControl1Item1: TdxLayoutItem;
procedure CustomViewCreate(Sender: TObject);
procedure CustomViewDestroy(Sender: TObject);
procedure cbTiendaPropertiesValidate(Sender: TObject;
var DisplayValue: Variant; var ErrorText: TCaption; var Error: Boolean);
private
FDataItem : TDADataTable;
FListaTiendas : TStringList;
function GetDataItem: TDADataTable;
procedure SetDataItem(const Value: TDADataTable);
public
property DataItem : TDADataTable read GetDataItem write SetDataItem;
procedure ElegirTienda(const AIDTienda : Integer);
function getIDTienda: Integer;
procedure SetIDTienda(const ID: Integer);
end;
implementation
{$R *.dfm}
uses
uFactuGES_App;
procedure TfrViewTienda.cbTiendaPropertiesValidate(Sender: TObject;
var DisplayValue: Variant; var ErrorText: TCaption; var Error: Boolean);
var
AIndex : integer;
begin
inherited;
if Assigned(FDataItem) and FDataItem.Active then
begin
AIndex := StrToInt(FListaTiendas.Values[DisplayValue]);
FDataItem.Edit;
if Assigned(FDataItem.FindField('ID_TIENDA')) then
FDataItem.FieldByName('ID_TIENDA').AsInteger := AIndex;
if Assigned(FDataItem.FindField('TIENDA')) then
FDataItem.FieldByName('TIENDA').AsString := DisplayValue;
FDataItem.post;
end;
end;
procedure TfrViewTienda.CustomViewCreate(Sender: TObject);
var
i : integer;
begin
inherited;
FListaTiendas := AppFactuGES.EmpresasController.DarListaTiendas(AppFactuGES.EmpresaActiva);
with cbTienda.Properties.Items do
begin
BeginUpdate;
try
Clear;
for i := 0 to FListaTiendas.Count - 1 do
Add(FListaTiendas.Names[i]);
finally
EndUpdate;
end;
end;
end;
procedure TfrViewTienda.CustomViewDestroy(Sender: TObject);
begin
FreeAndNIL(FListaTiendas);
inherited;
end;
procedure TfrViewTienda.ElegirTienda(const AIDTienda: Integer);
var
i : integer;
begin
for i := 0 to FListaTiendas.Count-1 do
begin
if FListaTiendas.ValueFromIndex[i] = IntToStr(AIDTienda) then
begin
cbTienda.Text := FListaTiendas.Names[i];
Break;
end;
end;
end;
function TfrViewTienda.GetDataItem: TDADataTable;
begin
Result := FDataItem;
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.SetDataItem(const Value: TDADataTable);
begin
FDataItem := Value;
if Assigned(FDataItem.FindField('ID_TIENDA')) then
ElegirTienda(FDataItem.FieldByName('ID_TIENDA').AsInteger);
end;
procedure TfrViewTienda.SetIDTienda(const ID: Integer);
var
AIndex: Integer;
begin
{ if FListaIDTiendas.Find(ID, AIndex) then
cbTienda.Text := FListaTiendas.Strings[AIndex];}
end;
end.