This repository has been archived on 2024-11-28. You can view files and clone it, but cannot push or open issues or pull requests.
Miguelo_FactuGES/BaseDatos/TablaPoblaciones.pas

127 lines
3.5 KiB
ObjectPascal
Raw Normal View History

{
===============================================================================
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.0
Fecha versi<EFBFBD>n actual: 03-11-2002
===============================================================================
Modificaciones:
Fecha Comentarios
---------------------------------------------------------------------------
===============================================================================
}
unit TablaPoblaciones;
interface
uses
//Generales
SysUtils, Classes, Controls, IBSQL, cxGridDBTableView, cxCustomData, DB,
//Particulares
cxDropDownEdit,
//Aplicacion
Framework, StrFunc, Entidades, Constantes, BaseDatos;
type
TdmTablaPoblaciones = class(TDataModule)
private
procedure IniciarSQL;
public
sqlGrid : TStrings;
function darNombrePoblacion (CodigoProvincia, CodigoPoblacion : Variant) : string;
constructor Create (AOwner : TComponent); override;
destructor Destroy; override;
procedure InicializarGridPoblaciones(var vGrid: TcxGridDBTableView);
end;
var
dmTablaPoblaciones: TdmTablaPoblaciones;
implementation
{$R *.DFM}
constructor TdmTablaPoblaciones.Create (AOwner : TComponent);
begin
inherited;
sqlGrid := TStringList.Create;
IniciarSQL;
end;
destructor TdmTablaPoblaciones.Destroy;
begin
sqlGrid.Free;
inherited;
end;
function TdmTablaPoblaciones.darNombrePoblacion(CodigoProvincia,
CodigoPoblacion: Variant): string;
var
oSQL : TIBSQL;
Descripcion : String;
begin
Descripcion := '';
oSQL := TIBSQL.Create(Self);
with oSQL do
begin
Database := dmBaseDatos.BD;
Transaction := dmBaseDatos.Transaccion;
SQL.Add('select DESCRIPCION');
SQL.Add('from POBLACIONES');
SQL.Add('where CODIGOPROVINCIA = :CODIGOPROVINCIA and ');
SQL.Add('CODIGOPOBLACION = :CODIGOPOBLACION');
try
ParamByName('CODIGOPROVINCIA').AsString := CodigoProvincia;
ParamByName('CODIGOPOBLACION').AsString := CodigoPoblacion;
Prepare;
ExecQuery;
Descripcion := Fields[0].AsString;
Result := Descripcion;
finally
Close;
Transaction := NIL;
Free;
end;
end;
end;
procedure TdmTablaPoblaciones.InicializarGridPoblaciones(var vGrid: TcxGridDBTableView);
var
Columna : TcxGridDBColumn;
begin
with vGrid do begin
{Columna DESCRIPCION}
Columna := CreateColumn;
Columna.DataBinding.FieldName := 'DESCRIPCION';
Columna.Caption := 'Nombre de la poblaci<63>n';
Columna.Options.Filtering := False;
Columna.SortOrder := soAscending;
end;
end;
procedure TdmTablaPoblaciones.IniciarSQL;
begin
with sqlGrid do
begin
Add('select DESCRIPCION, CODIGOPROVINCIA, CODIGOPOBLACION');
Add('from POBLACIONES ');
Add('where CODIGOPROVINCIA = :CODIGOPROVINCIA ');
end;
end;
end.