{ =============================================================================== Copyright (©) 2001. 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: 01-10-2001 Versión actual: 1.0.2 Fecha versión actual: 12-05-2002 =============================================================================== Modificaciones: Fecha Comentarios --------------------------------------------------------------------------- 07-04-2002 Cambio de todos los procedimientos en los que se utiliza una transaccion nueva, por una unica transacción. 12-05-2002 Adaptación al grid 'TdxDBGrid'. =============================================================================== } unit TablaPoblaciones; interface uses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, DBTables, DB, IBCustomDataSet, IBSQL, BaseDatos, IBDatabase, dxDBGrid, dbgrids; 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 Grid: TdxDBGrid); end; var dmTablaPoblaciones: TdmTablaPoblaciones; implementation {$R *.DFM} uses IB, Mensajes, Excepciones, dxDBCtrl; constructor TdmTablaPoblaciones.Create (AOwner : TComponent); begin inherited; sqlGrid := TStringList.Create; IniciarSQL; 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; destructor TdmTablaPoblaciones.Destroy; begin sqlGrid.Free; inherited; end; procedure TdmTablaPoblaciones.InicializarGridPoblaciones(var Grid: TdxDBGrid); var Columna : TdxDBTreeListColumn; begin with Grid do begin DestroyColumns; {Columna DESCRIPCION} Columna := CreateColumn(TdxDBTreeListColumn); Columna.FieldName := 'DESCRIPCION'; Columna.Caption := 'Nombre de la población'; end; end; procedure TdmTablaPoblaciones.IniciarSQL; begin with sqlGrid do begin Add('select DESCRIPCION, CODIGOPROVINCIA, CODIGOPOBLACION'); Add('from POBLACIONES '); Add('where CODIGOPROVINCIA = :CODIGOPROVINCIA '); Add('order by DESCRIPCION'); end; end; end.