git-svn-id: https://192.168.0.254/svn/Proyectos.Acana_FactuGES/trunk@4 3f40d355-893c-4141-8e64-b1d9be72e7e7
259 lines
7.2 KiB
ObjectPascal
259 lines
7.2 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: 04-12-2002
|
|
Versión actual: 1.0.0
|
|
Fecha versión actual: 04-12-2002
|
|
===============================================================================
|
|
Modificaciones:
|
|
|
|
Fecha Comentarios
|
|
---------------------------------------------------------------------------
|
|
===============================================================================
|
|
}
|
|
|
|
unit FormasPago;
|
|
|
|
interface
|
|
|
|
uses
|
|
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
|
|
RDXDBFRAME, RdxBotones, ExtCtrls, RdxPaneles, RdxBarras, RdxTitulos,
|
|
RXDBCtrl, IBCustomDataSet, Db, StdCtrls, DBTables, Configuracion,
|
|
cxStyles, cxCustomData, cxGraphics, cxFilter, cxData, cxEdit, cxDBData,
|
|
cxGridLevel, cxClasses, cxControls, cxGridCustomView,
|
|
cxGridCustomTableView, cxGridTableView, cxGridDBTableView, cxGrid, Grids,
|
|
DBGrids, Entidades, cxDataStorage;
|
|
|
|
|
|
type
|
|
TfrFormasPago = class(TRdxDBFrame)
|
|
BarraSuperior: TRdxBarraSuperior;
|
|
dsFormasPago: TDataSource;
|
|
brDoble: TRdxBarraInferior;
|
|
bAceptar: TRdxBoton;
|
|
bCancelar: TRdxBoton;
|
|
RdxPanel1: TRdxPanel;
|
|
RdxPanel3: TRdxPanel;
|
|
bAnadir: TRdxBoton;
|
|
bEliminar: TRdxBoton;
|
|
gridFormasPago: TcxGrid;
|
|
gridFormasPagoDBTableView1: TcxGridDBTableView;
|
|
gridFormasPagoLevel1: TcxGridLevel;
|
|
imgSombra: TImage;
|
|
procedure bAnadirClick(Sender: TObject);
|
|
procedure bEliminarClick(Sender: TObject);
|
|
procedure bAceptarClick(Sender: TObject);
|
|
procedure bCancelarClick(Sender: TObject);
|
|
procedure RdxDBFrameShow(Sender: TObject);
|
|
private
|
|
TablaFormasPago : TIBDataSet;
|
|
procedure ActualizarBotones;
|
|
protected
|
|
procedure ActivarModoAnadir; override;
|
|
function CambiarEntidad(EntidadAnterior, Entidad : TRdxEntidad): Boolean; override;
|
|
public
|
|
constructor Create (AOwner : TComponent); override;
|
|
destructor Destroy; override;
|
|
published
|
|
procedure AppException(Sender: TObject; E: Exception);
|
|
procedure FormasPagoAfterInsert(DataSet: TDataSet);
|
|
property BaseDatos;
|
|
property Transaccion;
|
|
end;
|
|
|
|
var
|
|
frFormasPago: TfrFormasPago;
|
|
|
|
implementation
|
|
|
|
{$R *.DFM}
|
|
|
|
{ TfrFormasPago }
|
|
|
|
uses
|
|
BaseDatos, TablaFormasPago, IB, Mensajes,
|
|
Excepciones, IBErrorCodes, Literales;
|
|
|
|
constructor TfrFormasPago.Create(AOwner: TComponent);
|
|
begin
|
|
inherited Create(AOwner);
|
|
Entidad := entFormasPago;
|
|
ConfigurarFrame(Self, Entidad);
|
|
|
|
Application.OnException := AppException;
|
|
BaseDatos := dmBaseDatos.BD;
|
|
Transaccion := dmBaseDatos.Transaccion;
|
|
TablaFormasPago := TIBDataSet.Create(Self);
|
|
TablaFormasPago.AfterInsert := FormasPagoAfterInsert;
|
|
|
|
dsFormasPago.DataSet := TablaFormasPago;
|
|
|
|
with TablaFormasPago do
|
|
begin
|
|
Database := BaseDatos;
|
|
Transaction := Transaccion;
|
|
InsertSQL.Assign(dmTablaFormasPago.sqlInsertar);
|
|
ModifySQL.Assign(dmTablaFormasPago.sqlModificar);
|
|
DeleteSQL.Assign(dmTablaFormasPago.sqlEliminar);
|
|
SelectSQL.Assign(dmTablaFormasPago.sqlConsultar);
|
|
end;
|
|
bCancelar.Cancel := True;
|
|
end;
|
|
|
|
destructor TfrFormasPago.Destroy;
|
|
begin
|
|
Application.OnException := NIL;
|
|
TablaFormasPago.Close;
|
|
TablaFormasPago.UnPrepare;
|
|
TablaFormasPago.Free;
|
|
inherited;
|
|
end;
|
|
|
|
procedure TfrFormasPago.bAnadirClick(Sender: TObject);
|
|
begin
|
|
TablaFormasPago.Append;
|
|
gridFormasPago.SetFocus;
|
|
end;
|
|
|
|
procedure TfrFormasPago.bEliminarClick(Sender: TObject);
|
|
begin
|
|
if (VerMensajePregunta(msgDeseaBorrar) = IDNO) then
|
|
Exit;
|
|
try
|
|
if TablaFormasPago.RecordCount = 0
|
|
{ Hacemos un cancel de la tabla por si el registro actual estuviera
|
|
recien creado }
|
|
then TablaFormasPago.Cancel
|
|
else TablaFormasPago.Delete;
|
|
except
|
|
on E : EIBError do
|
|
TratarExcepcion(E);
|
|
on E : Exception do
|
|
TratarExcepcion(E);
|
|
end;
|
|
end;
|
|
|
|
procedure TfrFormasPago.bAceptarClick(Sender: TObject);
|
|
begin
|
|
if TablaFormasPago.State in [dsEdit, dsInsert] then
|
|
TablaFormasPago.Post;
|
|
Commit;
|
|
CloseFrame;
|
|
end;
|
|
|
|
procedure TfrFormasPago.bCancelarClick(Sender: TObject);
|
|
begin
|
|
try
|
|
Rollback;
|
|
CloseFrame;
|
|
except
|
|
on E : EIBError do
|
|
TratarExcepcion(E);
|
|
on E : Exception do
|
|
TratarExcepcion(E);
|
|
end;
|
|
end;
|
|
|
|
procedure TfrFormasPago.FormasPagoAfterInsert(DataSet: TDataSet);
|
|
begin
|
|
DataSet.FieldByName('DB_KEY').AsString := '-';
|
|
end;
|
|
|
|
procedure TfrFormasPago.AppException(Sender: TObject; E: Exception);
|
|
begin
|
|
if E.Message = 'Field ''DESCRIPCION'' must have a value' then begin
|
|
VerMensaje(msgDatosFaltaDescripcionFpago);
|
|
TablaFormasPago.Edit;
|
|
end
|
|
else if E.Message = 'violation of PRIMARY or UNIQUE KEY constraint "PK_FORMASPAGO" on table "FORMASPAGO"' then begin
|
|
VerMensajeFmt(msgDatosFormaPagoRepetida, [UpperCase(TablaFormasPago.FieldByName('DESCRIPCION').AsString)]);
|
|
TablaFormasPago.Edit;
|
|
end
|
|
else
|
|
VerMensaje(E.Message);
|
|
end;
|
|
|
|
procedure TfrFormasPago.ActualizarBotones;
|
|
begin
|
|
if BaseDatos.IsReadOnly then
|
|
begin
|
|
bAnadir.Enabled := False;
|
|
bEliminar.Enabled := False;
|
|
gridFormasPago.Enabled := False;
|
|
end
|
|
else begin
|
|
bAnadir.Enabled := True;
|
|
bEliminar.Enabled := True;
|
|
gridFormasPago.Enabled := True;
|
|
end;
|
|
end;
|
|
|
|
procedure TfrFormasPago.ActivarModoAnadir;
|
|
begin
|
|
try
|
|
with TablaFormasPago do
|
|
begin
|
|
Prepare;
|
|
Open;
|
|
ActualizarBotones;
|
|
|
|
if RecordCount = 0 then
|
|
begin
|
|
Edit;
|
|
FieldByName('DESCRIPCION').AsString := ' ';
|
|
Post;
|
|
Delete
|
|
end
|
|
else
|
|
begin
|
|
Edit;
|
|
Post;
|
|
end;
|
|
end;
|
|
dmTablaFormasPago.InicializarGridFormasPago(gridFormasPagoDBTableView1);
|
|
ActivarEdicionGridDetalles(gridFormasPago);
|
|
except
|
|
on E : EIBError do
|
|
begin
|
|
case E.IBErrorCode of
|
|
isc_lock_conflict : begin
|
|
Rollback;
|
|
VerMensaje(msgDatosTablaFpagoBloqueada);
|
|
CloseFrame;
|
|
end
|
|
else begin
|
|
Rollback;
|
|
TratarExcepcion(E);
|
|
end;
|
|
end;
|
|
end;
|
|
on E : Exception do begin
|
|
Rollback;
|
|
TratarExcepcion(E);
|
|
end;
|
|
end;
|
|
end;
|
|
|
|
procedure TfrFormasPago.RdxDBFrameShow(Sender: TObject);
|
|
begin
|
|
bCancelar.SetFocus;
|
|
end;
|
|
|
|
function TfrFormasPago.CambiarEntidad(EntidadAnterior, Entidad: TRdxEntidad): Boolean;
|
|
begin
|
|
inherited CambiarEntidad(EntidadAnterior, Entidad);
|
|
ConfigurarFrame(Self, Self.Entidad);
|
|
end;
|
|
|
|
end.
|