git-svn-id: https://192.168.0.254/svn/Proyectos.AbetoDesign_FactuGES/trunk@162 93f398dd-4eb6-7a46-baf6-13f46f578da2
244 lines
6.6 KiB
ObjectPascal
244 lines
6.6 KiB
ObjectPascal
unit uEditorTiendaEmpresa;
|
|
|
|
interface
|
|
|
|
uses Windows, SysUtils, Classes, Graphics, Forms, Controls, StdCtrls,
|
|
Buttons, ExtCtrls, Mask, DBCtrls, DB, uDADataTable, PngSpeedButton,
|
|
cxControls, cxContainer, cxEdit, cxTextEdit, cxHyperLinkEdit, cxDBEdit,
|
|
uIEditorTiendaEmpresa, uTiendasEmpresaController, uBizEmpresasTiendas,
|
|
cxCurrencyEdit, uDAInterfaces, cxGraphics, cxMaskEdit, cxDropDownEdit;
|
|
|
|
type
|
|
TfEditorTiendaEmpresa = class(TForm, IEditorTiendaEmpresa)
|
|
OKBtn: TButton;
|
|
CancelBtn: TButton;
|
|
Bevel1: TBevel;
|
|
eDireccion: TDBEdit;
|
|
cbPoblacion: TcxDBComboBox;
|
|
cbProvincia: TcxDBComboBox;
|
|
eCodigoPostal: TDBEdit;
|
|
Label1: TLabel;
|
|
Label2: TLabel;
|
|
Label3: TLabel;
|
|
Label4: TLabel;
|
|
dsTienda: TDADataSource;
|
|
Label5: TLabel;
|
|
eNombre: TDBEdit;
|
|
Label6: TLabel;
|
|
ePersonaContacto: TDBEdit;
|
|
Label7: TLabel;
|
|
eTelefono: TDBEdit;
|
|
eMail: TcxDBHyperLinkEdit;
|
|
PngSpeedButton3: TPngSpeedButton;
|
|
Label8: TLabel;
|
|
Label9: TLabel;
|
|
eNotas: TDBMemo;
|
|
Label11: TLabel;
|
|
eMovil: TDBEdit;
|
|
Label12: TLabel;
|
|
eFax: TDBEdit;
|
|
Bevel2: TBevel;
|
|
eCodigoContable: TDBEdit;
|
|
Label10: TLabel;
|
|
procedure PngSpeedButton3Click(Sender: TObject);
|
|
procedure eMailPropertiesEditValueChanged(Sender: TObject);
|
|
procedure eMailPropertiesValidate(Sender: TObject;
|
|
var DisplayValue: Variant; var ErrorText: TCaption; var Error: Boolean);
|
|
procedure cbPoblacionPropertiesInitPopup(Sender: TObject);
|
|
procedure cbProvinciaPropertiesInitPopup(Sender: TObject);
|
|
private
|
|
FProvincias : TStringList;
|
|
FIDProvincia : Integer; //Almacenará la provincia que hay seleccionada para no cargar las poblaciones si no es necesario
|
|
FPoblaciones : TStringList;
|
|
procedure CargarProvincias;
|
|
procedure CargarPoblaciones;
|
|
protected
|
|
FController : ITiendasEmpresaController;
|
|
FTienda: IBizEmpresaTienda;
|
|
|
|
function GetController : ITiendasEmpresaController;
|
|
procedure SetController (const Value : ITiendasEmpresaController);
|
|
function GetTienda: IBizEmpresaTienda;
|
|
procedure SetTienda(const Value: IBizEmpresaTienda);
|
|
public
|
|
constructor Create(AOwner: TComponent); override;
|
|
destructor Destroy; override;
|
|
property Controller : ITiendasEmpresaController read GetController write SetController;
|
|
property Tienda: IBizEmpresaTienda read GetTienda write SetTienda;
|
|
end;
|
|
|
|
implementation
|
|
|
|
{$R *.dfm}
|
|
{$INCLUDE ..\..\..\FactuGES.inc}
|
|
|
|
uses
|
|
Variants, uProvinciasPoblacionesController, uStringsUtils;
|
|
|
|
|
|
type
|
|
THackcxDBHyperLinkEdit = class(TcxDBHyperLinkEdit);
|
|
|
|
{ TfEditorTiendaEmpresa }
|
|
|
|
procedure TfEditorTiendaEmpresa.CargarPoblaciones;
|
|
var
|
|
i : integer;
|
|
|
|
begin
|
|
if (FIDProvincia <> StrToInt(FProvincias.Values[cbProvincia.Text])) then
|
|
Begin
|
|
FIDProvincia := StrToInt(FProvincias.Values[cbProvincia.Text]);
|
|
with TProvinciasPoblacionesController.Create do
|
|
begin
|
|
try
|
|
FPoblaciones := DarListaPoblaciones(FIDProvincia);
|
|
with cbPoblacion.Properties.Items do
|
|
begin
|
|
BeginUpdate;
|
|
try
|
|
Clear;
|
|
for i := 0 to FPoblaciones.Count - 1 do
|
|
Add(FPoblaciones.Names[i]);
|
|
finally
|
|
EndUpdate;
|
|
end;
|
|
end;
|
|
finally
|
|
Free;
|
|
end;
|
|
end;
|
|
End;
|
|
end;
|
|
|
|
procedure TfEditorTiendaEmpresa.CargarProvincias;
|
|
var
|
|
i : integer;
|
|
begin
|
|
with TProvinciasPoblacionesController.Create do
|
|
begin
|
|
try
|
|
FProvincias := DarListaProvincias;
|
|
|
|
with cbProvincia.Properties.Items do
|
|
begin
|
|
BeginUpdate;
|
|
try
|
|
Clear;
|
|
for i := 0 to FProvincias.Count - 1 do
|
|
Add(FProvincias.Names[i]);
|
|
finally
|
|
EndUpdate;
|
|
end;
|
|
end;
|
|
finally
|
|
Free;
|
|
end;
|
|
end;
|
|
end;
|
|
|
|
procedure TfEditorTiendaEmpresa.cbPoblacionPropertiesInitPopup(Sender: TObject);
|
|
begin
|
|
ShowHourglassCursor;
|
|
try
|
|
FreeANDNIL(FPoblaciones);
|
|
if not Assigned(FProvincias) then
|
|
CargarProvincias;
|
|
if not EsCadenaVacia(cbProvincia.Text) and (FProvincias.IndexOfName(cbProvincia.Text) <> -1) then
|
|
CargarPoblaciones
|
|
finally
|
|
HideHourglassCursor;
|
|
end;
|
|
end;
|
|
|
|
procedure TfEditorTiendaEmpresa.cbProvinciaPropertiesInitPopup(Sender: TObject);
|
|
begin
|
|
ShowHourglassCursor;
|
|
try
|
|
if not Assigned(FProvincias) then
|
|
CargarProvincias;
|
|
finally
|
|
HideHourglassCursor;
|
|
end;
|
|
end;
|
|
|
|
constructor TfEditorTiendaEmpresa.Create(AOwner: TComponent);
|
|
begin
|
|
inherited;
|
|
FController := NIL;
|
|
FIDProvincia := 0;
|
|
FProvincias := NIL;
|
|
FPoblaciones := NIL;
|
|
|
|
{$IFDEF CONTABILIDAD}
|
|
Bevel2.Visible := True;
|
|
Label10.Visible := True;
|
|
eCodigoContable.Visible := True;
|
|
{$ELSE}
|
|
Bevel2.Visible := False;
|
|
Label10.Visible := False;
|
|
eCodigoContable.Visible := False;
|
|
{$ENDIF}
|
|
|
|
//Lo desactivamos porque a ellos no les interesa
|
|
Bevel2.Visible := False;
|
|
Label10.Visible := False;
|
|
eCodigoContable.Visible := False;
|
|
end;
|
|
|
|
destructor TfEditorTiendaEmpresa.Destroy;
|
|
begin
|
|
if Assigned(FProvincias) then
|
|
FreeANDNIL(FProvincias);
|
|
|
|
if Assigned(FPoblaciones) then
|
|
FreeANDNIL(FPoblaciones);
|
|
|
|
FController := NIL;
|
|
inherited;
|
|
end;
|
|
|
|
procedure TfEditorTiendaEmpresa.eMailPropertiesEditValueChanged(Sender: TObject);
|
|
begin
|
|
if not VarIsNull((Sender as TcxDBHyperLinkEdit).EditValue) then
|
|
(Sender as TcxDBHyperLinkEdit).EditValue := StringReplace((Sender as TcxDBHyperLinkEdit).EditValue, (Sender as TcxDBHyperLinkEdit).Properties.Prefix, '', []);
|
|
end;
|
|
|
|
procedure TfEditorTiendaEmpresa.eMailPropertiesValidate(Sender: TObject;
|
|
var DisplayValue: Variant; var ErrorText: TCaption; var Error: Boolean);
|
|
begin
|
|
if not VarIsNull(DisplayValue) then
|
|
DisplayValue := StringReplace(DisplayValue, (Sender as TcxDBHyperLinkEdit).Properties.Prefix, '', []);
|
|
end;
|
|
|
|
function TfEditorTiendaEmpresa.GetController: ITiendasEmpresaController;
|
|
begin
|
|
Result := FController;
|
|
end;
|
|
|
|
function TfEditorTiendaEmpresa.GetTienda: IBizEmpresaTienda;
|
|
begin
|
|
Result := FTienda;
|
|
end;
|
|
|
|
procedure TfEditorTiendaEmpresa.PngSpeedButton3Click(Sender: TObject);
|
|
begin
|
|
THackcxDBHyperLinkEdit(eMail).DoStart;
|
|
end;
|
|
|
|
procedure TfEditorTiendaEmpresa.SetController(const Value: ITiendasEmpresaController);
|
|
begin
|
|
FController := Value;
|
|
end;
|
|
|
|
procedure TfEditorTiendaEmpresa.SetTienda(const Value: IBizEmpresaTienda);
|
|
begin
|
|
FTienda := Value;
|
|
if Assigned(FTienda) then
|
|
dsTienda.DataTable := FTienda.DataTable
|
|
else
|
|
dsTienda.DataTable := NIL;
|
|
end;
|
|
|
|
end.
|