Tecsitel_FactuGES2/Source/Modulos/Formas de pago/Views/uEditorFormaPago.pas

216 lines
6.5 KiB
ObjectPascal

{
===============================================================================
Copyright (©) 2006. 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: 22-05-2006
Versión actual: 1.0.0
Fecha versión actual: 22-05-2006
===============================================================================
Modificaciones:
Fecha Comentarios
---------------------------------------------------------------------------
===============================================================================
}
unit uEditorFormaPago;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Grids, DBGrids, StdCtrls, Mask, DBCtrls, DB,
uBizFormasPago, uBizFormasPagoPlazos,
uFormasPagoController, uFormasPagoPlazosController,
uDADataTable, uIEditorFormaPago, ActnList, ExtCtrls, JvExControls,
JvComponent, JvEnterTab, cxStyles, cxCustomData, cxGraphics, cxFilter, cxData,
cxDataStorage, cxEdit, cxDBData, cxSpinEdit, cxGridCustomTableView,
cxGridTableView, cxGridDBTableView, cxGridLevel, cxClasses, cxControls,
cxGridCustomView, cxGrid, uDAInterfaces;
type
TfEditorFormaPago = class(TForm, IEditorFormaPago)
ActionList1: TActionList;
dsFormaPago: TDADataSource;
actAnadir: TAction;
actEliminar: TAction;
actAceptar: TAction;
actCancelar: TAction;
bAceptar: TButton;
bCancelar: TButton;
actCerrar: TAction;
actModificar: TAction;
eReferencia: TDBEdit;
eDescripcion: TDBEdit;
dsPlazos: TDADataSource;
Label1: TLabel;
Bevel1: TBevel;
Label2: TLabel;
Label3: TLabel;
Label11: TLabel;
Bevel3: TBevel;
Bevel4: TBevel;
bAnadir: TButton;
bEliminar: TButton;
JvEnterAsTab1: TJvEnterAsTab;
ListaFormasPagoDBTableView1: TcxGridDBTableView;
ListaFormasPagoLevel1: TcxGridLevel;
ListaFormasPago: TcxGrid;
ListaFormasPagoDBTableView1NUM_DIAS: TcxGridDBColumn;
ListaFormasPagoDBTableView1PORCENTAJE: TcxGridDBColumn;
procedure FormShow(Sender: TObject);
procedure actAnadirExecute(Sender: TObject);
procedure actEliminarExecute(Sender: TObject);
procedure actAceptarExecute(Sender: TObject);
procedure actCancelarExecute(Sender: TObject);
procedure actCerrarExecute(Sender: TObject);
procedure actAnadirUpdate(Sender: TObject);
procedure actEliminarUpdate(Sender: TObject);
protected
FFormaPago: IBizFormaPago;
FPlazos : IBizFormaPagoPlazos;
FController : IFormasPagoController;
FPlazosController: IFormasPagoPlazosController;
function GetFormaPago: IBizFormaPago;
procedure SetFormaPago(const Value: IBizFormaPago);
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
property FormaPago: IBizFormaPago read GetFormaPago write SetFormaPago;
end;
implementation
{$R *.dfm}
{ TfEditorFormasPago }
uses
Dialogs, uDialogUtils, uDataModuleFormasPago;
function TfEditorFormaPago.GetFormaPago: IBizFormaPago;
begin
Result := FFormaPago;
end;
procedure TfEditorFormaPago.SetFormaPago(const Value: IBizFormaPago);
begin
FFormaPago := Value;
if Assigned(FFormaPago) then
begin
FPlazos := FFormaPago.Plazos;
dsFormaPago.DataTable := FFormaPago.DataTable;
dsPlazos.DataTable := FPlazos.DataTable;
dsFormaPago.DataTable.Open;
dsPlazos.DataTable.Open;
end
else begin
dsFormaPago.DataTable := NIL;
dsPlazos.DataTable := NIL;
end;
end;
procedure TfEditorFormaPago.actAnadirExecute(Sender: TObject);
begin
FPlazos.Append;
end;
procedure TfEditorFormaPago.actEliminarExecute(Sender: TObject);
begin
FPlazos.Delete;
end;
procedure TfEditorFormaPago.actEliminarUpdate(Sender: TObject);
begin
(Sender as TAction).Enabled := False;
// No operar con los plazos
{(Sender as TAction).Enabled := Assigned(FPlazos) and
FPlazos.DataTable.Active and
(FPlazos.DataTable.RecordCount > 0);}
end;
constructor TfEditorFormaPago.Create(AOwner: TComponent);
begin
inherited;
FController := TFormasPagoController.Create;
FPlazosController := TFormasPagoPlazosController.Create;
end;
destructor TfEditorFormaPago.Destroy;
begin
FFormaPago := NIL;
FPlazosController := NIL;
FController := NIL;
inherited;
end;
procedure TfEditorFormaPago.actAceptarExecute(Sender: TObject);
begin
{if (ListaFormasPago.ActiveView.DataController.RecordCount = 0) then
if (ShowConfirmMessage('Forma de pago sin plazos', 'No ha indicado plazos de pago para esta forma de pago por lo tanto no se podrán generarar los recibos correspondientes.' + #10#13 + '¿Desea continuar guardando la forma de pago?') = IDNO) then
Exit;}
if (FPlazos.RecordCount > 0) then
begin
FPlazos.Last;
while FPlazos.RecordCount > 0 do
begin
FPlazos.Delete;
end;
end;
if FController.Guardar(FFormaPago) then
actCerrar.Execute;
end;
procedure TfEditorFormaPago.actCancelarExecute(Sender: TObject);
begin
FController.DescartarCambios(FFormaPago);
actCerrar.Execute;
end;
procedure TfEditorFormaPago.actCerrarExecute(Sender: TObject);
begin
Close;
end;
procedure TfEditorFormaPago.actAnadirUpdate(Sender: TObject);
begin
(Sender as TAction).Enabled := Assigned(FPlazos) and
FPlazos.DataTable.Active;
end;
procedure TfEditorFormaPago.FormShow(Sender: TObject);
begin
// Ocultar los plazos
Label11.Visible := False;
Bevel3.Visible := False;
ListaFormasPago.Visible := False;
bAnadir.Visible := False;
bEliminar.Visible := False;
actAnadir.Enabled := False;
actEliminar.Enabled := False;
if not FFormaPago.DataTable.Active then
FFormaPago.DataTable.Active := True;
if FFormaPago.EsNuevo then
Self.Caption := 'Nueva forma de pago'
else
Self.Caption := 'Modificar forma de pago';
end;
end.