git-svn-id: https://192.168.0.254/svn/Proyectos.Acana_FactuGES/trunk@4 3f40d355-893c-4141-8e64-b1d9be72e7e7
849 lines
23 KiB
ObjectPascal
849 lines
23 KiB
ObjectPascal
{
|
|
===============================================================================
|
|
Copyright (©) 2002. Rodax Software.
|
|
===============================================================================
|
|
Los contenidos de este fichero son propiedad de Rodax Software titular del
|
|
copyright. Este fichero sólo podrá ser copiado, distribuido y utilizado,
|
|
en su totalidad o en parte, con el permiso escrito de Rodax Software, o de
|
|
acuerdo con los términos y condiciones establecidas en el acuerdo/contrato
|
|
bajo el que se suministra.
|
|
-----------------------------------------------------------------------------
|
|
Web: www.rodax-software.com
|
|
===============================================================================
|
|
Fecha primera versión: 03-11-2002
|
|
Versión actual: 1.0.0
|
|
Fecha versión actual: 03-11-2002
|
|
===============================================================================
|
|
Modificaciones:
|
|
|
|
Fecha Comentarios
|
|
---------------------------------------------------------------------------
|
|
===============================================================================
|
|
}
|
|
|
|
unit Empresa;
|
|
|
|
interface
|
|
|
|
uses
|
|
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
|
|
RdxBotones, StdCtrls, RdxMemo, RdxComboBox, RdxCampos, ExtCtrls,
|
|
RdxTitulos, ComCtrls, RdxCheckBox, Grids, DBGrids, RdxPaneles,
|
|
RdxBarras, Db, RdxFrame, RdxDBFrame, RdxFrameEmpresas, RXDBCtrl,
|
|
RdxPageControl, IB, cxStyles, cxCustomData, cxGraphics, cxFilter, cxData,
|
|
cxEdit, cxDBData, cxGridLevel, cxClasses, cxControls, cxGridCustomView,
|
|
cxGridCustomTableView, cxGridTableView, cxGridDBTableView, cxGrid,
|
|
cxGridCardView, cxGridDBCardView, RxMemDS, Configuracion, cxMemo,
|
|
cxDBEdit, cxContainer, cxTextEdit, cxMaskEdit, cxButtonEdit, AdvPanel,
|
|
cxImage, cxDropDownEdit, cxLookupEdit, cxDBLookupEdit, cxDBLookupComboBox,
|
|
IBCustomDataSet, cxCalendar, TablaTrimestres, cxSpinEdit,
|
|
TablaLibros, RdxEmpresaActiva, TablaEmpresas;
|
|
|
|
type
|
|
TfrEmpresa = class(TRdxFrameEmpresas)
|
|
pnlCuerpo: TPanel;
|
|
brDoble: TRdxBarraInferior;
|
|
bGuardar: TRdxBoton;
|
|
bCancelar: TRdxBoton;
|
|
brSimple: TRdxBarraInferior;
|
|
bSalir: TRdxBoton;
|
|
pnlTitulo: TRdxPanelTituloOperacion;
|
|
dsEmpresas: TDataSource;
|
|
pnlDatos: TAdvPanel;
|
|
eNIFCIF: TLabel;
|
|
eNombre: TLabel;
|
|
eCorreo: TLabel;
|
|
Label1: TLabel;
|
|
Label2: TLabel;
|
|
NIF: TcxDBTextEdit;
|
|
Nombre: TcxDBTextEdit;
|
|
Correo: TcxDBTextEdit;
|
|
Web: TcxDBTextEdit;
|
|
NombreComercial: TcxDBTextEdit;
|
|
dsLibros: TDataSource;
|
|
dsTrimestres: TDataSource;
|
|
RdxPagesControl1: TRdxPagesControl;
|
|
pagDirecciones: TTabSheet;
|
|
pagValores: TTabSheet;
|
|
pagLogo: TTabSheet;
|
|
bExaminar: TRdxBoton;
|
|
Logotipo: TcxDBImage;
|
|
eTrimestre: TLabel;
|
|
cbxTrimestres: TcxComboBox;
|
|
Label3: TLabel;
|
|
cbxLibros: TcxComboBox;
|
|
Label5: TLabel;
|
|
IvaDefecto: TcxDBSpinEdit;
|
|
Label4: TLabel;
|
|
validezdefecto: TcxDBSpinEdit;
|
|
Label7: TLabel;
|
|
Label6: TLabel;
|
|
Ano: TcxSpinEdit;
|
|
GroupBox1: TGroupBox;
|
|
eDireccion: TLabel;
|
|
Calle1: TcxTextEdit;
|
|
eProvincia: TLabel;
|
|
Provincia1: TcxTextEdit;
|
|
eNumero: TLabel;
|
|
Numero1: TcxTextEdit;
|
|
eCodigoPostal: TLabel;
|
|
CodigoPostal1: TcxTextEdit;
|
|
ePoblacion: TLabel;
|
|
Poblacion1: TcxTextEdit;
|
|
eTelefono: TLabel;
|
|
Telefono1: TcxTextEdit;
|
|
eFax: TLabel;
|
|
Fax1: TcxTextEdit;
|
|
GroupBox2: TGroupBox;
|
|
Label8: TLabel;
|
|
Label9: TLabel;
|
|
Label10: TLabel;
|
|
Label11: TLabel;
|
|
Label12: TLabel;
|
|
Label13: TLabel;
|
|
Label14: TLabel;
|
|
Calle2: TcxTextEdit;
|
|
Provincia2: TcxTextEdit;
|
|
Numero2: TcxTextEdit;
|
|
CodigoPostal2: TcxTextEdit;
|
|
Poblacion2: TcxTextEdit;
|
|
Telefono2: TcxTextEdit;
|
|
Fax2: TcxTextEdit;
|
|
Label15: TLabel;
|
|
IntervaloPagosCli: TcxDBSpinEdit;
|
|
Label16: TLabel;
|
|
procedure bAceptarClick(Sender: TObject);
|
|
procedure bCancelarClick(Sender: TObject);
|
|
procedure bSalirClick(Sender: TObject);
|
|
|
|
procedure bExaminarClick(Sender: TObject);
|
|
procedure GridBotonPoblacionClick(Sender: TObject; AButtonIndex: Integer);
|
|
procedure GridBotonProvinciaClick(Sender: TObject; AButtonIndex: Integer);
|
|
|
|
private
|
|
FListaTrimestres: TListaTrimestres;
|
|
FListaTiposLibro: TListaLibros;
|
|
|
|
FCodigoProvincia : Variant;
|
|
FCodigoPoblacion : Variant;
|
|
FListaDirecciones : TListaDireccionesEmpresa;
|
|
procedure ProvinciaSetText(Sender: TField; const Text: String);
|
|
function crearElementosAsociados: boolean;
|
|
procedure AsignarValoresDefecto;
|
|
procedure GuardarDirecciones;
|
|
procedure BorrarDirecciones;
|
|
procedure CargarDirecciones;
|
|
procedure LimpiarDirecciones;
|
|
function EsVaciaDir1 : Boolean;
|
|
function EsVaciaDir2 : Boolean;
|
|
protected
|
|
procedure ActivarModoAnadir; override;
|
|
procedure ActivarModoModificar; override;
|
|
procedure ActivarModoConsultar; override;
|
|
procedure ActivarModoEliminar; override;
|
|
function AnadirDatos : Boolean; override;
|
|
function ModificarDatos : Boolean; override;
|
|
function EliminarDatos : Boolean; override;
|
|
function CancelarAnadir : Boolean; override;
|
|
function CancelarModificar : Boolean; override;
|
|
function CancelarEliminar : Boolean; override;
|
|
function ComprobarDatos : Boolean; override;
|
|
procedure VerModal; override;
|
|
procedure SetCodigoProvincia (Value : Variant); virtual;
|
|
procedure SetCodigoPoblacion (Value : Variant); virtual;
|
|
procedure FreeContenido; override;
|
|
procedure BuscarEmpresa; override;
|
|
procedure CambiarModo(ModoAnterior, Modo : TRdxModo); override;
|
|
public
|
|
property CodigoProvincia : Variant read FCodigoProvincia write SetCodigoProvincia;
|
|
property CodigoPoblacion : Variant read FCodigoPoblacion write SetCodigoPoblacion;
|
|
constructor Create (AOwner : TComponent); override;
|
|
destructor Destroy; override;
|
|
published
|
|
property TablaEmpresas;
|
|
property CodigoEmpresa;
|
|
end;
|
|
|
|
var
|
|
frEmpresa: TfrEmpresa;
|
|
|
|
implementation
|
|
{$R *.DFM}
|
|
|
|
uses
|
|
RdxFrameVendedores, Mensajes, Provincias, Entidades, Poblaciones, Variants,
|
|
Vendedores, BaseDatos, RdxFrameProvincias, RdxFramePoblaciones, TablaProvincias,
|
|
StrFunc, TablaPoblaciones, Excepciones, IBErrorCodes, TablaVendedores,
|
|
Literales, Constantes, Framework;
|
|
|
|
constructor TfrEmpresa.Create (AOwner : TComponent);
|
|
var
|
|
i : integer;
|
|
begin
|
|
inherited Create(AOwner);
|
|
FCodigoProvincia := NULL;
|
|
FCodigoPoblacion := NULL;
|
|
FListaDirecciones := NIL;
|
|
Entidad := entEmpresas;
|
|
BaseDatos := dmBaseDatos.BD;
|
|
Transaccion := dmBaseDatos.Transaccion;
|
|
|
|
TablaEmpresas := TIBDataSet.Create(Self);
|
|
dsEmpresas.DataSet := TablaEmpresas;
|
|
with TablaEmpresas do
|
|
begin
|
|
Database := BaseDatos;
|
|
Transaction := Transaccion;
|
|
SelectSQL.Assign(dmTablaEmpresas.sqlConsultar);
|
|
InsertSQL.Assign(dmTablaEmpresas.sqlInsertar);
|
|
ModifySQL.Assign(dmTablaEmpresas.sqlModificar);
|
|
DeleteSQL.Assign(dmTablaEmpresas.sqlEliminar);
|
|
RefreshSQL.Assign(dmTablaEmpresas.sqlConsultar);
|
|
end;
|
|
|
|
FListaTrimestres := TListaTrimestres.Create(tlcTriDefecto);
|
|
cbxTrimestres.ItemIndex := FListaTrimestres.cargarLista(cbxTrimestres.Properties.Items);
|
|
FListaTiposLibro := TListaLibros.Create(tltDefecto);
|
|
cbxLibros.ItemIndex := FListaTiposLibro.cargarLista(cbxLibros);
|
|
|
|
bCancelar.Cancel := True;
|
|
bSalir.Cancel := True;
|
|
end;
|
|
|
|
procedure TfrEmpresa.bSalirClick(Sender: TObject);
|
|
begin
|
|
try
|
|
Rollback;
|
|
CloseFrame;
|
|
except
|
|
on E : EIBError do
|
|
TratarExcepcion(E);
|
|
on E : Exception do
|
|
TratarExcepcion(E);
|
|
end;
|
|
end;
|
|
|
|
procedure TfrEmpresa.bAceptarClick(Sender: TObject);
|
|
begin
|
|
if (RealizarOperacion) then
|
|
CloseFrame;
|
|
end;
|
|
|
|
function TfrEmpresa.AnadirDatos : boolean;
|
|
begin
|
|
Result := False;
|
|
try
|
|
GuardarDirecciones;
|
|
TablaEmpresas.FieldByName('CODIGOTRIMESTRE').AsString := dmTablaTrimestres.darCodigoTrimestre(Ano.Value, cbxTrimestres.ItemIndex);
|
|
TablaEmpresas.FieldByName('LIBRODEFECTO').AsString := FListaTiposLibro.Items[cbxLibros.ItemIndex].Codigo;
|
|
TablaEmpresas.Post;
|
|
//Creamos los trimestres y libros para la nueva empresa
|
|
if (crearElementosAsociados) then
|
|
begin
|
|
CodigoEmpresa := TablaEmpresas.FieldByName('CODIGO').AsString;
|
|
Commit;
|
|
TablaEmpresas.Close;
|
|
Result := True;
|
|
end
|
|
else
|
|
begin
|
|
VerMensajeFmt(msgCliCodCliRepetido, [CodigoEmpresa]);
|
|
TablaEmpresas.Edit;
|
|
end;
|
|
|
|
except
|
|
on E : EIBError do begin
|
|
if E.IBErrorCode = isc_unique_key_violation then
|
|
begin
|
|
VerMensajeFmt(msgCliCodCliRepetido, [CodigoEmpresa]);
|
|
TablaEmpresas.Edit;
|
|
end
|
|
else
|
|
TratarExcepcion(E);
|
|
end;
|
|
on E : Exception do
|
|
TratarExcepcion(E);
|
|
end;
|
|
end;
|
|
|
|
function TfrEmpresa.ModificarDatos : boolean;
|
|
begin
|
|
Result := False;
|
|
try
|
|
|
|
TablaEmpresas.FieldByName('CODIGOTRIMESTRE').AsString := dmTablaTrimestres.darCodigoTrimestre(Ano.Value, cbxTrimestres.ItemIndex);
|
|
TablaEmpresas.FieldByName('LIBRODEFECTO').AsString := FListaTiposLibro.Items[cbxLibros.ItemIndex].Codigo;
|
|
TablaEmpresas.Post;
|
|
GuardarDirecciones;
|
|
|
|
//Creamos los trimestres y libros para la nueva empresa
|
|
if (crearElementosAsociados) then
|
|
begin
|
|
Commit;
|
|
TablaEmpresas.Close;
|
|
|
|
//Refrescamos la empresa activa en el caso de se la empresa modificada
|
|
if (EmpresaActiva.Codigo = CodigoEmpresa) then
|
|
EmpresaActiva.refrescar;
|
|
|
|
Result := True;
|
|
end
|
|
else
|
|
begin
|
|
VerMensajeFmt(msgCliCodCliRepetido, [CodigoEmpresa]);
|
|
TablaEmpresas.Edit;
|
|
end;
|
|
|
|
except
|
|
on E : EIBError do
|
|
TratarExcepcion(E);
|
|
on E : Exception do
|
|
TratarExcepcion(E);
|
|
end;
|
|
end;
|
|
|
|
function TfrEmpresa.EliminarDatos : boolean;
|
|
begin
|
|
Result := False;
|
|
|
|
if (VerMensajePregunta(msgEmpBorrarEmp) <> IDYES) then
|
|
Exit;
|
|
|
|
try
|
|
TablaEmpresas.Delete;
|
|
Commit;
|
|
TablaEmpresas.Close;
|
|
Result := True;
|
|
except
|
|
on E : EIBError do
|
|
begin
|
|
case E.IBErrorCode of
|
|
isc_lock_conflict : VerMensajeFmt(msgCliCliBloqueado, [CodigoEmpresa]);
|
|
else
|
|
TratarExcepcion(E);
|
|
end;
|
|
end;
|
|
on E : Exception do
|
|
TratarExcepcion(E);
|
|
end;
|
|
end;
|
|
|
|
procedure TfrEmpresa.ActivarModoAnadir;
|
|
var
|
|
CodNuevo : Variant;
|
|
|
|
begin
|
|
dsEmpresas.AutoEdit := True;
|
|
|
|
cbxTrimestres.Properties.ReadOnly := False;
|
|
Ano.Properties.ReadOnly := False;
|
|
cbxLibros.Properties.ReadOnly := False;
|
|
|
|
Ano.Text := dmBaseDatos.DarAno;
|
|
|
|
try
|
|
CodNuevo := dmTablaEmpresas.DarNuevoCodigo;
|
|
|
|
with TablaEmpresas do
|
|
begin
|
|
Close;
|
|
Prepare;
|
|
Open;
|
|
//FieldByName('PROVINCIA').OnSetText := ProvinciaSetText;
|
|
Insert;
|
|
FieldByName('CODIGO').AsString := CodNuevo;
|
|
FieldByName('FECHAALTA').AsDateTime := dmBaseDatos.DarFecha;
|
|
FieldByName('USUARIO').AsString := dmBaseDatos.Usuario;
|
|
FieldByName('IVADEFECTO').AsString := CTE_IVA_DEFECTO;
|
|
FieldByName('VALIDEZDEFECTO').AsInteger := CTE_VAL_DEFECTO;
|
|
FieldByName('INTERVALOPAGOSCLI').AsInteger := CTE_INT_DEFECTO;
|
|
|
|
//Asignamos trimestre actual
|
|
cbxTrimestres.Text := dmTablaTrimestres.DarDescripcionTrimestreActual;
|
|
end;
|
|
LimpiarDirecciones;
|
|
|
|
// Visible := True;
|
|
// NombreComercial.SetFocus;
|
|
except
|
|
on E : EIBError do
|
|
TratarExcepcion(E);
|
|
on E : Exception do
|
|
TratarExcepcion(E);
|
|
end;
|
|
end;
|
|
|
|
procedure TfrEmpresa.ActivarModoModificar;
|
|
begin
|
|
dsEmpresas.AutoEdit := True;
|
|
|
|
cbxTrimestres.Properties.ReadOnly := False;
|
|
Ano.Properties.ReadOnly := False;
|
|
cbxLibros.Properties.ReadOnly := False;
|
|
|
|
try
|
|
with TablaEmpresas do
|
|
begin
|
|
Prepare;
|
|
Open;
|
|
//FieldByName('PROVINCIA').OnSetText := ProvinciaSetText;
|
|
if RecordCount = 0 then
|
|
begin
|
|
VerMensajeFmt(msgCliNoExisteCli, [CodigoEmpresa]);
|
|
CancelarModificar;
|
|
CloseFrame;
|
|
Exit;
|
|
end;
|
|
// Bloquear el Empresa
|
|
Edit;
|
|
Post;
|
|
Edit;
|
|
|
|
//Asignamos los valores por defecto
|
|
AsignarValoresDefecto;
|
|
end;
|
|
// Visible := True;
|
|
// NIF.SetFocus;
|
|
except
|
|
on E : EIBError do
|
|
begin
|
|
case E.IBErrorCode of
|
|
isc_lock_conflict : begin
|
|
VerMensajeFmt(msgCliCliBloqueado, [CodigoEmpresa]);
|
|
CancelarModificar;
|
|
CloseFrame;
|
|
Exit;
|
|
end
|
|
else
|
|
TratarExcepcion(E);
|
|
end;
|
|
end;
|
|
on E : Exception do
|
|
TratarExcepcion(E);
|
|
end;
|
|
end;
|
|
|
|
procedure TfrEmpresa.ActivarModoConsultar;
|
|
begin
|
|
dsEmpresas.AutoEdit := False;
|
|
|
|
//Asignamos los valores por defecto
|
|
AsignarValoresDefecto;
|
|
|
|
cbxTrimestres.Properties.ReadOnly := True;
|
|
Ano.Properties.ReadOnly := True;
|
|
cbxLibros.Properties.ReadOnly := True;
|
|
|
|
try
|
|
with TablaEmpresas do
|
|
begin
|
|
Prepare;
|
|
Open;
|
|
if RecordCount = 0 then
|
|
begin
|
|
VerMensajeFmt(msgCliNoExisteCli, [CodigoEmpresa]);
|
|
CancelarModificar;
|
|
CloseFrame;
|
|
Exit;
|
|
end;
|
|
end;
|
|
|
|
// Visible := True;
|
|
// NombreComercial.SetFocus;
|
|
except
|
|
on E : EIBError do
|
|
TratarExcepcion(E);
|
|
on E : Exception do
|
|
TratarExcepcion(E);
|
|
end;
|
|
end;
|
|
|
|
procedure TfrEmpresa.ActivarModoEliminar;
|
|
begin
|
|
dsEmpresas.AutoEdit := False;
|
|
|
|
//Asignamos los valores por defecto
|
|
AsignarValoresDefecto;
|
|
|
|
cbxTrimestres.Properties.ReadOnly := True;
|
|
Ano.Properties.ReadOnly := True;
|
|
cbxLibros.Properties.ReadOnly := True;
|
|
|
|
try
|
|
with TablaEmpresas do
|
|
begin
|
|
Prepare;
|
|
Open;
|
|
if RecordCount = 0 then
|
|
begin
|
|
VerMensajeFmt(msgCliNoExisteCli, [CodigoEmpresa]);
|
|
CancelarModificar;
|
|
CloseFrame;
|
|
Exit;
|
|
end;
|
|
end;
|
|
|
|
// Visible := True;
|
|
// NombreComercial.SetFocus;
|
|
except
|
|
on E : EIBError do
|
|
TratarExcepcion(E);
|
|
on E : Exception do
|
|
TratarExcepcion(E);
|
|
end;
|
|
end;
|
|
|
|
procedure TfrEmpresa.BuscarEmpresa;
|
|
begin
|
|
if Transaccion = NIL then
|
|
exit;
|
|
try
|
|
TablaEmpresas.Close;
|
|
|
|
LimpiarDirecciones;
|
|
// Buscar la fila a tratar si es necesario
|
|
if not esCadenaVacia(CodigoEmpresa) then
|
|
begin
|
|
TablaEmpresas.Params.ByName('CODIGO').AsString := CodigoEmpresa;
|
|
|
|
if Assigned(FListaDirecciones) then
|
|
FListaDirecciones.Free;
|
|
FListaDirecciones := TListaDireccionesEmpresa.Create(CodigoEmpresa);
|
|
CargarDirecciones;
|
|
end;
|
|
TablaEmpresas.Prepare;
|
|
TablaEmpresas.Open;
|
|
|
|
except
|
|
on E : EIBError do
|
|
TratarExcepcion(E);
|
|
on E : Exception do
|
|
TratarExcepcion(E);
|
|
end;
|
|
end;
|
|
|
|
function TfrEmpresa.CancelarAnadir: Boolean;
|
|
begin
|
|
Result := False;
|
|
try
|
|
RollBack;
|
|
|
|
TablaEmpresas.Close;
|
|
Result := True;
|
|
except
|
|
on E : EIBError do
|
|
TratarExcepcion(E);
|
|
on E : Exception do
|
|
TratarExcepcion(E);
|
|
end;
|
|
end;
|
|
|
|
function TfrEmpresa.CancelarEliminar: Boolean;
|
|
begin
|
|
Result := False;
|
|
try
|
|
RollBack;
|
|
TablaEmpresas.Close;
|
|
Result := True;
|
|
except
|
|
on E : EIBError do
|
|
TratarExcepcion(E);
|
|
on E : Exception do
|
|
TratarExcepcion(E);
|
|
end;
|
|
end;
|
|
|
|
function TfrEmpresa.CancelarModificar: Boolean;
|
|
begin
|
|
Result := False;
|
|
try
|
|
RollBack;
|
|
TablaEmpresas.Close;
|
|
Result := True;
|
|
except
|
|
on E : EIBError do
|
|
TratarExcepcion(E);
|
|
on E : Exception do
|
|
TratarExcepcion(E);
|
|
end;
|
|
end;
|
|
|
|
destructor TfrEmpresa.Destroy;
|
|
begin
|
|
if Assigned(FListaDirecciones) then
|
|
FListaDirecciones.Free;
|
|
|
|
TablaEmpresas.Close;
|
|
TablaEmpresas.UnPrepare;
|
|
TablaEmpresas.Free;
|
|
|
|
FListaTrimestres.Free;
|
|
FListaTrimestres := Nil;
|
|
FListaTiposLibro.Free;
|
|
FListaTiposLibro := Nil;
|
|
|
|
inherited;
|
|
end;
|
|
|
|
procedure TfrEmpresa.FreeContenido;
|
|
begin
|
|
if (ContenidoModal is TRdxFrameEmpresas) then begin
|
|
CodigoEmpresa := (ContenidoModal as TRdxFrameEmpresas).CodigoEmpresa;
|
|
ActivarModo;
|
|
end;
|
|
if (ContenidoModal is TRdxFrameProvincias) then
|
|
CodigoProvincia := (ContenidoModal as TRdxFrameProvincias).CodigoProvincia;
|
|
if (ContenidoModal is TRdxFramePoblaciones) then begin
|
|
CodigoProvincia := (ContenidoModal as TRdxFramePoblaciones).CodigoProvincia;
|
|
CodigoPoblacion := (ContenidoModal as TRdxFramePoblaciones).CodigoPoblacion;
|
|
end;
|
|
inherited FreeContenido;
|
|
end;
|
|
|
|
procedure TfrEmpresa.SetCodigoPoblacion(Value: Variant);
|
|
begin
|
|
if (not EsCadenaVacia(Value)) then
|
|
begin
|
|
FCodigoPoblacion := Value;
|
|
// Poblacion.DataBinding.Field.AsString := dmTablaPoblaciones.darNombrePoblacion(FCodigoProvincia, FCodigoPoblacion);
|
|
end;
|
|
end;
|
|
|
|
procedure TfrEmpresa.SetCodigoProvincia(Value: Variant);
|
|
begin
|
|
if (not EsCadenaVacia(Value)) then
|
|
begin
|
|
FCodigoProvincia := Value;
|
|
// Provincia.DataBinding.Field.AsString := dmTablaProvincias.DarNombreProvincia(FCodigoProvincia);
|
|
end;
|
|
end;
|
|
|
|
procedure TfrEmpresa.VerModal;
|
|
begin
|
|
if (ContenidoModal is TRdxFramePoblaciones) then
|
|
(ContenidoModal as TRdxFramePoblaciones).CodigoProvincia := CodigoProvincia;
|
|
inherited;
|
|
end;
|
|
|
|
procedure TfrEmpresa.bCancelarClick(Sender: TObject);
|
|
begin
|
|
if (TratarCambios = IDOK) then
|
|
CloseFrame;
|
|
end;
|
|
|
|
procedure TfrEmpresa.GridBotonPoblacionClick(Sender: TObject; AButtonIndex: Integer);
|
|
begin
|
|
{ if (esCadenaVacia(CodigoProvincia)) then begin
|
|
VerMensaje(msgSinProvincia);
|
|
Provincia.setFocus;
|
|
Exit;
|
|
end;
|
|
CodigoProvincia := CodigoProvincia;
|
|
CaptionModal := Format(msgListaPoblaciones, [dmTablaProvincias.darNombreProvincia(CodigoProvincia)]);
|
|
WidthModal := 280;
|
|
HeightModal := 460;
|
|
ContenidoModal := TfrPoblaciones.Create(Self);}
|
|
end;
|
|
|
|
function TfrEmpresa.ComprobarDatos: Boolean;
|
|
begin
|
|
Result := False;
|
|
|
|
if Length(Trim(NombreComercial.Text)) = 0 then
|
|
begin
|
|
VerMensajeFmt(msgEmpFaltaAlgo,[msgEmpNombreComercial]);
|
|
NombreComercial.SetFocus;
|
|
exit;
|
|
end;
|
|
|
|
Result := True;
|
|
end;
|
|
|
|
procedure TfrEmpresa.GridBotonProvinciaClick(Sender: TObject; AButtonIndex: Integer);
|
|
begin
|
|
CaptionModal := msgListaProvincias;
|
|
WidthModal := 280;
|
|
HeightModal := 460;
|
|
ContenidoModal := TfrProvincias.Create(Self);
|
|
end;
|
|
|
|
procedure TfrEmpresa.bExaminarClick(Sender: TObject);
|
|
begin
|
|
Logotipo.LoadFromFile;
|
|
end;
|
|
|
|
procedure TfrEmpresa.ProvinciaSetText(Sender: TField;
|
|
const Text: String);
|
|
begin
|
|
FCodigoProvincia := dmTablaProvincias.DarCodigoProvincia(Text);
|
|
Sender.AsString := Text;
|
|
end;
|
|
|
|
procedure TfrEmpresa.CambiarModo(ModoAnterior, Modo: TRdxModo);
|
|
begin
|
|
inherited;
|
|
|
|
end;
|
|
|
|
function TfrEmpresa.crearElementosAsociados: boolean;
|
|
begin
|
|
Result := (dmTablaLibros.crearLibros(TablaEmpresas.FieldByName('CODIGO').AsVariant)
|
|
AND dmTablaTrimestres.crearTrimestres(TablaEmpresas.FieldByName('CODIGO').AsVariant, Ano.Value));
|
|
end;
|
|
|
|
procedure TfrEmpresa.AsignarValoresDefecto;
|
|
var
|
|
i : Integer;
|
|
begin
|
|
//Asignamos el trimestre por defecto
|
|
cbxTrimestres.Text := dmTablaTrimestres.darDescripcionTrimestre(TablaEmpresas.FieldByName('CODIGOTRIMESTRE').AsString);
|
|
Ano.Text := FormatDateTime('yyyy', dmTablaTrimestres.darAnoTrimestre(CodigoEmpresa, TablaEmpresas.FieldByName('CODIGOTRIMESTRE').AsString));
|
|
|
|
//Asignamos libro por defecto
|
|
i := 0;
|
|
while ((FListaTiposLibro.Items[i].Codigo <> TablaEmpresas.FieldByName('LIBRODEFECTO').AsString)
|
|
and (i < FListaTiposLibro.Count - 1)) do inc (i);
|
|
if (FListaTiposLibro.Items[i].Codigo = TablaEmpresas.FieldByName('LIBRODEFECTO').AsString) then
|
|
cbxLibros.ItemIndex := i;
|
|
end;
|
|
|
|
procedure TfrEmpresa.CargarDirecciones;
|
|
begin
|
|
with FListaDirecciones do
|
|
begin
|
|
if Count > 0 then
|
|
begin
|
|
Calle1.Text := Items[0].Calle;
|
|
Numero1.Text := Items[0].Numero;
|
|
Provincia1.Text := Items[0].Provincia;
|
|
Poblacion1.Text := Items[0].Poblacion;
|
|
CodigoPostal1.Text := Items[0].CodigoPostal;
|
|
Telefono1.Text := Items[0].Telefono;
|
|
Fax1.Text := Items[0].Fax;
|
|
end;
|
|
|
|
if Count > 1 then
|
|
begin
|
|
Calle2.Text := Items[1].Calle;
|
|
Numero2.Text := Items[1].Numero;
|
|
Provincia2.Text := Items[1].Provincia;
|
|
Poblacion2.Text := Items[1].Poblacion;
|
|
CodigoPostal2.Text := Items[1].CodigoPostal;
|
|
Telefono2.Text := Items[1].Telefono;
|
|
Fax2.Text := Items[1].Fax;
|
|
end;
|
|
end;
|
|
end;
|
|
|
|
procedure TfrEmpresa.GuardarDirecciones;
|
|
var
|
|
Dir1,
|
|
Dir2 : TDatosDireccionEmpresa;
|
|
NumDirecciones : Integer;
|
|
begin
|
|
if FListaDirecciones = Nil then
|
|
exit;
|
|
|
|
Dir1 := TDatosDireccionEmpresa.Create;
|
|
Dir2 := TDatosDireccionEmpresa.Create;
|
|
try
|
|
|
|
while (FListaDirecciones.Count > 0) do
|
|
begin
|
|
FListaDirecciones.Items[0].Eliminar;
|
|
FListaDirecciones.Delete(0);
|
|
end;
|
|
|
|
NumDirecciones := 0;
|
|
if not EsVaciaDir1 then
|
|
begin
|
|
NumDirecciones := NumDirecciones + 1;
|
|
Dir1.CodigoEmpresa := FCodigoEmpresa;
|
|
Dir1.CodigoDireccion := NumDirecciones - 1;
|
|
Dir1.Calle := Calle1.Text;
|
|
Dir1.Numero := Numero1.Text;
|
|
Dir1.Provincia := Provincia1.Text;
|
|
Dir1.Poblacion := Poblacion1.Text;
|
|
Dir1.CodigoPostal := CodigoPostal1.Text;
|
|
Dir1.Telefono := Telefono1.Text;
|
|
Dir1.Fax := Fax1.Text;
|
|
Dir1.SalvarDatos;
|
|
end;
|
|
|
|
if not EsVaciaDir2 then
|
|
begin
|
|
NumDirecciones := NumDirecciones + 1;
|
|
Dir2.CodigoEmpresa := FCodigoEmpresa;
|
|
Dir2.CodigoDireccion := NumDirecciones - 1;
|
|
Dir2.Calle := Calle2.Text;
|
|
Dir2.Numero := Numero2.Text;
|
|
Dir2.Provincia := Provincia2.Text;
|
|
Dir2.Poblacion := Poblacion2.Text;
|
|
Dir2.CodigoPostal := CodigoPostal2.Text;
|
|
Dir2.Telefono := Telefono2.Text;
|
|
Dir2.Fax := Fax2.Text;
|
|
Dir2.SalvarDatos;
|
|
end;
|
|
|
|
finally
|
|
Dir1.Free;
|
|
Dir2.Free;
|
|
end;
|
|
|
|
{ with FListaDirecciones do
|
|
begin
|
|
|
|
if not EsVaciaDir1 then
|
|
begin
|
|
|
|
end;}
|
|
end;
|
|
|
|
procedure TfrEmpresa.LimpiarDirecciones;
|
|
begin
|
|
Calle1.Text := '';
|
|
Numero1.Text := '';
|
|
Provincia1.Text := '';
|
|
Poblacion1.Text := '';
|
|
CodigoPostal1.Text := '';
|
|
Telefono1.Text := '';
|
|
Fax1.Text := '';
|
|
|
|
Calle2.Text := '';
|
|
Numero2.Text := '';
|
|
Provincia2.Text := '';
|
|
Poblacion2.Text := '';
|
|
CodigoPostal2.Text := '';
|
|
Telefono2.Text := '';
|
|
Fax2.Text := '';
|
|
end;
|
|
|
|
function TfrEmpresa.EsVaciaDir1: Boolean;
|
|
begin
|
|
if EsCadenaVacia(Calle1.Text) and EsCadenaVacia(Numero1.Text) and
|
|
EsCadenaVacia(Provincia1.Text) and EsCadenaVacia(Poblacion1.Text) and
|
|
EsCadenaVacia(CodigoPostal1.Text) and EsCadenaVacia(Telefono1.Text) and
|
|
EsCadenaVacia(Fax1.Text) then
|
|
Result := True
|
|
else
|
|
Result := False;
|
|
end;
|
|
|
|
function TfrEmpresa.EsVaciaDir2: Boolean;
|
|
begin
|
|
if EsCadenaVacia(Calle2.Text) and EsCadenaVacia(Numero2.Text) and
|
|
EsCadenaVacia(Provincia2.Text) and EsCadenaVacia(Poblacion2.Text) and
|
|
EsCadenaVacia(CodigoPostal2.Text) and EsCadenaVacia(Telefono2.Text) and
|
|
EsCadenaVacia(Fax2.Text) then
|
|
Result := True
|
|
else
|
|
Result := False;
|
|
end;
|
|
|
|
procedure TfrEmpresa.BorrarDirecciones;
|
|
begin
|
|
|
|
end;
|
|
|
|
end.
|