This repository has been archived on 2024-12-02. You can view files and clone it, but cannot push or open issues or pull requests.
FactuGES/BaseDatos/TablaPoblaciones.pas
2007-06-26 08:08:27 +00:00

127 lines
3.5 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 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ó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.