168 lines
4.6 KiB
ObjectPascal
168 lines
4.6 KiB
ObjectPascal
|
|
{
|
|||
|
|
===============================================================================
|
|||
|
|
Copyright (<EFBFBD>) 2002. Rodax Software.
|
|||
|
|
===============================================================================
|
|||
|
|
Los contenidos de este fichero son propiedad de Rodax Software titular del
|
|||
|
|
copyright. Este fichero s<EFBFBD>lo podr<EFBFBD> ser copiado, distribuido y utilizado,
|
|||
|
|
en su totalidad o en parte, con el permiso escrito de Rodax Software, o de
|
|||
|
|
acuerdo con los t<EFBFBD>rminos y condiciones establecidas en el acuerdo/contrato
|
|||
|
|
bajo el que se suministra.
|
|||
|
|
-----------------------------------------------------------------------------
|
|||
|
|
Web: www.rodax-software.com
|
|||
|
|
===============================================================================
|
|||
|
|
Fecha primera versi<EFBFBD>n: 03-11-2002
|
|||
|
|
Versi<EFBFBD>n actual: 1.0.2
|
|||
|
|
Fecha versi<EFBFBD>n actual: 05-08-2004
|
|||
|
|
===============================================================================
|
|||
|
|
Modificaciones:
|
|||
|
|
|
|||
|
|
Fecha Comentarios
|
|||
|
|
---------------------------------------------------------------------------
|
|||
|
|
30-07-2004 p284. Se han a<EFBFBD>adido los datos de inscripci<EFBFBD>n del Registro
|
|||
|
|
Mercantil a la tabla de empresas.
|
|||
|
|
|
|||
|
|
05-08-2004 P279. A<EFBFBD>adido el campo 'MODELOINFORME' para determinar por
|
|||
|
|
empresa qu<EFBFBD> formato usar<EFBFBD>n los informes (no internos).
|
|||
|
|
===============================================================================
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
unit TablaEmpresas;
|
|||
|
|
|
|||
|
|
interface
|
|||
|
|
|
|||
|
|
uses
|
|||
|
|
//Generales
|
|||
|
|
SysUtils, Classes, Controls, IBSQL, cxGridDBTableView, cxCustomData, DB,
|
|||
|
|
//Particulares
|
|||
|
|
IBCustomDataSet, Graphics, IBQuery, Forms,
|
|||
|
|
|
|||
|
|
//Aplicacion
|
|||
|
|
Framework, StrFunc, Entidades, Constantes, BaseDatos, RdxEmpresaActiva;
|
|||
|
|
|
|||
|
|
type
|
|||
|
|
TdmTablaEmpresas = class(TDataModule)
|
|||
|
|
private
|
|||
|
|
procedure IniciarSQL;
|
|||
|
|
|
|||
|
|
public
|
|||
|
|
sqlInsertar : TStrings;
|
|||
|
|
sqlModificar : TStrings;
|
|||
|
|
sqlConsultar : TStrings;
|
|||
|
|
sqlEliminar : TStrings;
|
|||
|
|
sqlGrid : TStrings;
|
|||
|
|
|
|||
|
|
function DarNuevoCodigo : String;
|
|||
|
|
constructor Create (AOwner : TComponent); override;
|
|||
|
|
destructor Destroy; override;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
var
|
|||
|
|
dmTablaEmpresas: TdmTablaEmpresas;
|
|||
|
|
|
|||
|
|
implementation
|
|||
|
|
|
|||
|
|
{$R *.DFM}
|
|||
|
|
|
|||
|
|
uses
|
|||
|
|
Literales;
|
|||
|
|
|
|||
|
|
constructor TdmTablaEmpresas.Create (AOwner : TComponent);
|
|||
|
|
begin
|
|||
|
|
inherited;
|
|||
|
|
sqlInsertar := TStringList.Create;
|
|||
|
|
sqlModificar := TStringList.Create;
|
|||
|
|
sqlConsultar := TStringList.Create;
|
|||
|
|
sqlEliminar := TStringList.Create;
|
|||
|
|
sqlGrid := TStringList.Create;
|
|||
|
|
IniciarSQL;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
destructor TdmTablaEmpresas.Destroy;
|
|||
|
|
begin
|
|||
|
|
sqlInsertar.Free;
|
|||
|
|
sqlModificar.Free;
|
|||
|
|
sqlConsultar.Free;
|
|||
|
|
sqlEliminar.Free;
|
|||
|
|
sqlGrid.Free;
|
|||
|
|
inherited;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TdmTablaEmpresas.IniciarSQL;
|
|||
|
|
begin
|
|||
|
|
with sqlInsertar do
|
|||
|
|
begin
|
|||
|
|
Add('INSERT INTO EMPRESAS (CODIGO, NOMBRE, NIFCIF, ');
|
|||
|
|
Add('CALLE, NUMERO, CODIGOPOSTAL, POBLACION, PROVINCIA, TELEFONO, FAX, ');
|
|||
|
|
Add('CORREO, WEB, LOGOTIPO, REGISTROMERCANTIL, MODELOINFORME) ');
|
|||
|
|
Add('VALUES (:CODIGO, :NOMBRE, :NIFCIF, ');
|
|||
|
|
Add(':CALLE, :NUMERO, :CODIGOPOSTAL, :POBLACION, :PROVINCIA, :TELEFONO, :FAX, ');
|
|||
|
|
Add(':CORREO, :WEB, :LOGOTIPO, :REGISTROMERCANTIL, :MODELOINFORME)');
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
with sqlModificar do
|
|||
|
|
begin
|
|||
|
|
Add('UPDATE EMPRESAS SET');
|
|||
|
|
Add('NOMBRE = :NOMBRE, ');
|
|||
|
|
Add('NIFCIF = :NIFCIF, ');
|
|||
|
|
Add('CALLE = :CALLE, ');
|
|||
|
|
Add('NUMERO = :NUMERO, ');
|
|||
|
|
Add('CODIGOPOSTAL = :CODIGOPOSTAL, ');
|
|||
|
|
Add('POBLACION = :POBLACION, ');
|
|||
|
|
Add('PROVINCIA = :PROVINCIA, ');
|
|||
|
|
Add('TELEFONO = :TELEFONO, ');
|
|||
|
|
Add('FAX = :FAX, ');
|
|||
|
|
Add('CORREO = :CORREO, ');
|
|||
|
|
Add('WEB = :WEB, ');
|
|||
|
|
Add('REGISTROMERCANTIL = :REGISTROMERCANTIL, ');
|
|||
|
|
Add('MODELOINFORME = :MODELOINFORME, ');
|
|||
|
|
Add('LOGOTIPO = :LOGOTIPO ');
|
|||
|
|
Add('WHERE (CODIGO = :CODIGO)');
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
with sqlEliminar do
|
|||
|
|
begin
|
|||
|
|
Add('delete from EMPRESAS ');
|
|||
|
|
Add('where CODIGO = :CODIGO');
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
with sqlConsultar do
|
|||
|
|
begin
|
|||
|
|
Add('select * from EMPRESAS ');
|
|||
|
|
Add('where CODIGO = :CODIGO');
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
with sqlGrid do
|
|||
|
|
begin
|
|||
|
|
Add('select CODIGO, NIFCIF, NOMBRE, LOGOTIPO, CALLE');
|
|||
|
|
Add('from EMPRESAS ');
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
function TdmTablaEmpresas.DarNuevoCodigo : String;
|
|||
|
|
var
|
|||
|
|
oSQL : TIBSQL;
|
|||
|
|
begin
|
|||
|
|
Result := '0';
|
|||
|
|
|
|||
|
|
oSQL := TIBSQL.Create(Self);
|
|||
|
|
with oSQL do
|
|||
|
|
begin
|
|||
|
|
Database := dmBaseDatos.BD;
|
|||
|
|
Transaction := dmBaseDatos.Transaccion;
|
|||
|
|
SQL.Add('select max(CODIGO) + 1 ');
|
|||
|
|
SQL.Add('from EMPRESAS ');
|
|||
|
|
try
|
|||
|
|
Prepare;
|
|||
|
|
ExecQuery;
|
|||
|
|
if not esCadenaVacia(Fields[0].AsString) then
|
|||
|
|
Result := Fields[0].AsString;
|
|||
|
|
finally
|
|||
|
|
Close;
|
|||
|
|
Transaction := NIL;
|
|||
|
|
Free;
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
end.
|