222 lines
5.5 KiB
ObjectPascal
222 lines
5.5 KiB
ObjectPascal
|
|
{
|
|||
|
|
===============================================================================
|
|||
|
|
Copyright (<EFBFBD>) 2001. 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: 08-10-2004
|
|||
|
|
Versi<EFBFBD>n actual: 1.0.0
|
|||
|
|
Fecha versi<EFBFBD>n actual: 08-10-2004
|
|||
|
|
===============================================================================
|
|||
|
|
Modificaciones:
|
|||
|
|
|
|||
|
|
Fecha Comentarios
|
|||
|
|
---------------------------------------------------------------------------
|
|||
|
|
===============================================================================
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
unit TablaFabricantes;
|
|||
|
|
|
|||
|
|
interface
|
|||
|
|
|
|||
|
|
uses
|
|||
|
|
SysUtils, Windows, Messages, Classes, Graphics, Controls, Forms,
|
|||
|
|
Dialogs, DBTables, DB, IBCustomDataSet, IBSQL, BaseDatos, IBDatabase,
|
|||
|
|
dxDBGrid, dxDBCtrl, dbgrids, StrFunc, Mensajes, IB;
|
|||
|
|
|
|||
|
|
type
|
|||
|
|
TdmTablaFabricantes = class(TDataModule)
|
|||
|
|
private
|
|||
|
|
procedure IniciarSQL;
|
|||
|
|
|
|||
|
|
public
|
|||
|
|
sqlInsertar : TStrings;
|
|||
|
|
sqlModificar : TStrings;
|
|||
|
|
sqlConsultar : TStrings;
|
|||
|
|
sqlEliminar : TStrings;
|
|||
|
|
|
|||
|
|
//Metodos que llamaran a contador
|
|||
|
|
function DarNuevoCodigo : String;
|
|||
|
|
function IncrementarCodigo: boolean;
|
|||
|
|
function InsertarContador: boolean;
|
|||
|
|
function ValidarCodigo(Codigo : String) : Boolean;
|
|||
|
|
function FormatearCodigo(Codigo : String) : String;
|
|||
|
|
|
|||
|
|
constructor Create (AOwner : TComponent); override;
|
|||
|
|
destructor Destroy; override;
|
|||
|
|
procedure InicializarGridFabricantes(var Grid: TdxDBGrid);
|
|||
|
|
|
|||
|
|
procedure limpiarBlancos;
|
|||
|
|
function DarListaFabricantes: TStringList;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
var
|
|||
|
|
dmTablaFabricantes: TdmTablaFabricantes;
|
|||
|
|
|
|||
|
|
implementation
|
|||
|
|
|
|||
|
|
uses Constantes, RdxGestorContadores, Contadores, Excepciones;
|
|||
|
|
|
|||
|
|
{$R *.DFM}
|
|||
|
|
|
|||
|
|
{ TdmTablaFormasPago }
|
|||
|
|
|
|||
|
|
constructor TdmTablaFabricantes.Create(AOwner: TComponent);
|
|||
|
|
begin
|
|||
|
|
inherited;
|
|||
|
|
sqlInsertar := TStringList.Create;
|
|||
|
|
sqlModificar := TStringList.Create;
|
|||
|
|
sqlConsultar := TStringList.Create;
|
|||
|
|
sqlEliminar := TStringList.Create;
|
|||
|
|
|
|||
|
|
IniciarSQL;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TdmTablaFabricantes.limpiarBlancos;
|
|||
|
|
var
|
|||
|
|
oSQL : TIBSQL;
|
|||
|
|
begin
|
|||
|
|
oSQL := TIBSQL.Create(Self);
|
|||
|
|
|
|||
|
|
with oSQL do
|
|||
|
|
begin
|
|||
|
|
Database := dmBaseDatos.BD;
|
|||
|
|
Transaction := dmBaseDatos.Transaccion;
|
|||
|
|
SQL.Add('delete from FABRICANTES');
|
|||
|
|
SQL.Add('where NOMBRE is null');
|
|||
|
|
SQL.Add('or LTRIM(NOMBRE) = ''''');
|
|||
|
|
try
|
|||
|
|
Prepare;
|
|||
|
|
ExecQuery;
|
|||
|
|
finally
|
|||
|
|
Close;
|
|||
|
|
Transaction := NIL;
|
|||
|
|
Free;
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
function TdmTablaFabricantes.DarNuevoCodigo: String;
|
|||
|
|
begin
|
|||
|
|
Result := GestorContadores.DarNuevoCodigo(contFabricantes);
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
destructor TdmTablaFabricantes.Destroy;
|
|||
|
|
begin
|
|||
|
|
sqlInsertar.Free;
|
|||
|
|
sqlModificar.Free;
|
|||
|
|
sqlConsultar.Free;
|
|||
|
|
sqlEliminar.Free;
|
|||
|
|
|
|||
|
|
inherited;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
function TdmTablaFabricantes.FormatearCodigo(Codigo: String): String;
|
|||
|
|
begin
|
|||
|
|
Result := GestorContadores.FormatearCodigo(contFabricantes, Codigo);
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
function TdmTablaFabricantes.IncrementarCodigo: boolean;
|
|||
|
|
begin
|
|||
|
|
Result := GestorContadores.IncrementarValor(contFabricantes);
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TdmTablaFabricantes.InicializarGridFabricantes(var Grid: TdxDBGrid);
|
|||
|
|
var
|
|||
|
|
Columna : TdxDBTreeListColumn;
|
|||
|
|
|
|||
|
|
begin
|
|||
|
|
with Grid do begin
|
|||
|
|
DestroyColumns;
|
|||
|
|
{Columna CODIGO}
|
|||
|
|
Columna := CreateColumn(TdxDBTreeListColumn);
|
|||
|
|
Columna.FieldName := 'CODIGO';
|
|||
|
|
Columna.Caption := 'C<>digo';
|
|||
|
|
Columna.Visible := False;
|
|||
|
|
|
|||
|
|
{Columna NOMBRE}
|
|||
|
|
Columna := CreateColumn(TdxDBTreeListColumn);
|
|||
|
|
Columna.FieldName := 'NOMBRE';
|
|||
|
|
Columna.Caption := 'Nombre de fabricante';
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TdmTablaFabricantes.IniciarSQL;
|
|||
|
|
begin
|
|||
|
|
with sqlInsertar do
|
|||
|
|
begin
|
|||
|
|
Add('insert into FABRICANTES (CODIGO, NOMBRE) ');
|
|||
|
|
Add('values (:CODIGO, UPPER(:NOMBRE))');
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
with sqlModificar do
|
|||
|
|
begin
|
|||
|
|
Add('update FABRICANTES set ');
|
|||
|
|
Add('NOMBRE = UPPER(:NOMBRE) ');
|
|||
|
|
Add('where CODIGO = :CODIGO');
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
with sqlEliminar do
|
|||
|
|
begin
|
|||
|
|
Add('delete from FABRICANTES ');
|
|||
|
|
Add('where CODIGO = :CODIGO');
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
with sqlConsultar do
|
|||
|
|
begin
|
|||
|
|
Add('select CODIGO, NOMBRE ');
|
|||
|
|
Add('from FABRICANTES ');
|
|||
|
|
Add('order by NOMBRE');
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
function TdmTablaFabricantes.InsertarContador: boolean;
|
|||
|
|
begin
|
|||
|
|
Result := GestorContadores.InsertarContador(contFabricantes);
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
function TdmTablaFabricantes.ValidarCodigo(Codigo: String): Boolean;
|
|||
|
|
begin
|
|||
|
|
Result := GestorContadores.ValidarCodigo(contFabricantes, Codigo);
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
function TdmTablaFabricantes.DarListaFabricantes: TStringList;
|
|||
|
|
var
|
|||
|
|
oSQL : TIBSQL;
|
|||
|
|
Lista : TStringList;
|
|||
|
|
begin
|
|||
|
|
Lista := TStringList.Create;
|
|||
|
|
oSQL := TIBSQL.Create(Self);
|
|||
|
|
with oSQL do
|
|||
|
|
begin
|
|||
|
|
Database := dmBaseDatos.BD;
|
|||
|
|
Transaction := dmBaseDatos.Transaccion;
|
|||
|
|
SQL.Add('select NOMBRE ');
|
|||
|
|
SQL.Add('from FABRICANTES ');
|
|||
|
|
SQL.Add('order by NOMBRE');
|
|||
|
|
|
|||
|
|
try
|
|||
|
|
Prepare;
|
|||
|
|
ExecQuery;
|
|||
|
|
Lista.Add(CTE_TODOS);
|
|||
|
|
while not EOF do begin
|
|||
|
|
Lista.Add(Fields[0].AsString);
|
|||
|
|
Next;
|
|||
|
|
end;
|
|||
|
|
result := Lista;
|
|||
|
|
finally
|
|||
|
|
Close;
|
|||
|
|
Transaction := NIL;
|
|||
|
|
Free;
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
end.
|