2007-06-11 15:29:06 +00:00
|
|
|
|
unit uEditorComision;
|
|
|
|
|
|
|
|
|
|
|
|
interface
|
|
|
|
|
|
|
|
|
|
|
|
uses
|
|
|
|
|
|
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
|
|
|
|
|
|
Dialogs, uEditorDBItem, ToolWin, ComCtrls, JvExControls, JvComponent,
|
|
|
|
|
|
uViewComision, JvNavigationPane, ActnList,
|
|
|
|
|
|
uEditorBase, StdActns, TB2Dock, TB2Toolbar, TBX, ImgList, PngImageList,
|
|
|
|
|
|
TB2Item, uEditorItem, DB, uDADataTable, uEditorDBBase, JvFormAutoSize,
|
|
|
|
|
|
uDAScriptingProvider, uDACDSDataTable, StdCtrls, pngimage, ExtCtrls,
|
|
|
|
|
|
TBXDkPanels, JvButton, AppEvnts, uCustomView, uViewBase,
|
|
|
|
|
|
JvAppStorage, JvAppRegistryStorage, JvFormPlacement, JvComponentBase,
|
|
|
|
|
|
cxCustomData, uBizComisiones,
|
|
|
|
|
|
uIEditorComision, uComisionesController, JvExComCtrls,
|
|
|
|
|
|
JvStatusBar, dxLayoutLookAndFeels, uViewGridBase, uViewGrid,
|
|
|
|
|
|
uViewDetallesGenerico, uViewFacturasComision, dxLayoutControl, cxControls,
|
|
|
|
|
|
uViewTotales;
|
|
|
|
|
|
|
|
|
|
|
|
type
|
|
|
|
|
|
TfEditorComision = class(TfEditorDBItem, IEditorComision)
|
|
|
|
|
|
TBXSubmenuItem2: TTBXSubmenuItem;
|
|
|
|
|
|
TBXItem7: TTBXItem;
|
|
|
|
|
|
frViewComision1: TfrViewComision;
|
|
|
|
|
|
frViewFacturasComision1: TfrViewFacturasComision;
|
|
|
|
|
|
dxLayoutControl1Group_Root: TdxLayoutGroup;
|
|
|
|
|
|
dxLayoutControl1: TdxLayoutControl;
|
|
|
|
|
|
dxLayoutControl1Group1: TdxLayoutGroup;
|
|
|
|
|
|
dxLayoutControl1Item1: TdxLayoutItem;
|
|
|
|
|
|
frViewTotales1: TfrViewTotales;
|
|
|
|
|
|
procedure FormShow(Sender: TObject);
|
|
|
|
|
|
procedure CustomEditorClose(Sender: TObject; var Action: TCloseAction);
|
|
|
|
|
|
|
|
|
|
|
|
procedure actAnadirRecibosExecute(Sender: TObject);
|
|
|
|
|
|
procedure actEliminarReciboExecute(Sender: TObject);
|
|
|
|
|
|
procedure JvFormStorageRestorePlacement(Sender: TObject);
|
|
|
|
|
|
procedure JvFormStorageSavePlacement(Sender: TObject);
|
|
|
|
|
|
procedure dsDataTableDataChange(Sender: TObject; Field: TField);
|
|
|
|
|
|
procedure frViewFacturasComision1cxGridViewDataControllerSummaryAfterSummary(
|
|
|
|
|
|
ASender: TcxDataSummary);
|
|
|
|
|
|
protected
|
|
|
|
|
|
FController : IComisionesController;
|
|
|
|
|
|
FComision: IBizComisiones;
|
|
|
|
|
|
FViewComision : IViewComision;
|
|
|
|
|
|
|
|
|
|
|
|
function GetController : IComisionesController;
|
|
|
|
|
|
procedure SetController (const Value : IComisionesController); virtual;
|
|
|
|
|
|
function GetComision: IBizComisiones; virtual;
|
|
|
|
|
|
procedure SetComision(const Value: IBizComisiones); virtual;
|
|
|
|
|
|
function GetViewComision: IViewComision;
|
|
|
|
|
|
procedure SetViewComision(const Value: IViewComision);
|
|
|
|
|
|
property ViewComision: IViewComision read GetViewComision write SetViewComision;
|
|
|
|
|
|
|
|
|
|
|
|
procedure GuardarInterno; override;
|
|
|
|
|
|
procedure EliminarInterno; override;
|
|
|
|
|
|
procedure PrevisualizarInterno; override;
|
|
|
|
|
|
procedure ImprimirInterno; override;
|
|
|
|
|
|
// procedure CerrarInterno; override;
|
|
|
|
|
|
|
|
|
|
|
|
procedure PonerTitulos(const ATitulo: string = ''); override;
|
|
|
|
|
|
// function GetModified: Boolean; override;
|
|
|
|
|
|
|
|
|
|
|
|
public
|
|
|
|
|
|
property Comision: IBizComisiones read GetComision write SetComision;
|
|
|
|
|
|
constructor Create(AOwner: TComponent); override;
|
|
|
|
|
|
destructor Destroy; override;
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
implementation
|
|
|
|
|
|
|
|
|
|
|
|
{$R *.dfm}
|
|
|
|
|
|
|
|
|
|
|
|
uses
|
|
|
|
|
|
uDataTableUtils, uDataModuleUsuarios, uDialogUtils, uCustomEditor,
|
|
|
|
|
|
uDataModuleBase;
|
|
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
******************************* TfEditorComision *******************************
|
|
|
|
|
|
}
|
|
|
|
|
|
function TfEditorComision.GetComision: IBizComisiones;
|
|
|
|
|
|
begin
|
|
|
|
|
|
Result := FComision;
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
function TfEditorComision.GetController: IComisionesController;
|
|
|
|
|
|
begin
|
|
|
|
|
|
Result := FController;
|
|
|
|
|
|
end;
|
|
|
|
|
|
{
|
|
|
|
|
|
function TfEditorComision.GetModified: Boolean;
|
|
|
|
|
|
var
|
|
|
|
|
|
bCambiado : Boolean;
|
|
|
|
|
|
begin
|
|
|
|
|
|
bCambiado := inherited GetModified;
|
|
|
|
|
|
//Si no hay cambios miramos que no los halla en la lista de recibos
|
|
|
|
|
|
if not bCambiado then
|
|
|
|
|
|
bCambiado := frViewRecibosComision1.Modified;
|
|
|
|
|
|
Result := bCambiado;
|
|
|
|
|
|
end;
|
|
|
|
|
|
}
|
|
|
|
|
|
function TfEditorComision.GetViewComision: IViewComision;
|
|
|
|
|
|
begin
|
|
|
|
|
|
Result := FViewComision;
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
procedure TfEditorComision.GuardarInterno;
|
|
|
|
|
|
var
|
|
|
|
|
|
bEsNuevo : Boolean;
|
|
|
|
|
|
begin
|
|
|
|
|
|
inherited;
|
|
|
|
|
|
bEsNuevo := False;
|
|
|
|
|
|
|
|
|
|
|
|
ShowHourglassCursor;
|
|
|
|
|
|
// frViewRecibosComision1.OnViewModified := Nil;
|
|
|
|
|
|
//frViewDetallesFacturaCliente1.SaveGridStatus; // Para guardar estado del grid
|
|
|
|
|
|
// frViewDetallesFacturaCliente1.BeginUpdate; // Para que no se mueva el foco
|
|
|
|
|
|
try
|
|
|
|
|
|
bEsNuevo := FComision.EsNuevo;
|
|
|
|
|
|
FController.Guardar(FComision);
|
|
|
|
|
|
|
|
|
|
|
|
finally
|
|
|
|
|
|
// frViewDetallesFacturaCliente1.EndUpdate;
|
|
|
|
|
|
// frViewDetallesFacturaCliente1.RestoreGridStatus;
|
|
|
|
|
|
HideHourglassCursor;
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
if bEsNuevo then
|
|
|
|
|
|
ShowInfoMessage('La liquidaci<63>n de comisiones se ha dado de alta con el c<>digo ' + FComision.REFERENCIA);
|
|
|
|
|
|
Modified := False;
|
|
|
|
|
|
// frViewRecibosComision1.Modified := False;
|
|
|
|
|
|
// frViewRecibosComision1.OnViewModified := OnRecibosChanged;
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
procedure TfEditorComision.ImprimirInterno;
|
|
|
|
|
|
begin
|
|
|
|
|
|
inherited;
|
2007-07-03 18:57:02 +00:00
|
|
|
|
if (Application.MessageBox('<27>Desea previsualizar la liquidaci<63>n de comisiones sin desglosar?', 'Atenci<63>n', MB_YESNO) = IDYES) then
|
|
|
|
|
|
FController.Print(FComision, False)
|
|
|
|
|
|
else
|
|
|
|
|
|
FController.Print(FComision, True);
|
2007-06-11 15:29:06 +00:00
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
procedure TfEditorComision.JvFormStorageRestorePlacement(Sender: TObject);
|
|
|
|
|
|
begin
|
|
|
|
|
|
inherited;
|
|
|
|
|
|
//frViewRecibosComision1.RestoreFromRegistry(JvAppRegistryStorage.Root);
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
procedure TfEditorComision.JvFormStorageSavePlacement(Sender: TObject);
|
|
|
|
|
|
begin
|
|
|
|
|
|
inherited;
|
|
|
|
|
|
//frViewRecibosComision1.StoreToRegistry(JvAppRegistryStorage.Root);
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
procedure TfEditorComision.PonerTitulos(const ATitulo: string);
|
|
|
|
|
|
var
|
|
|
|
|
|
FTitulo : String;
|
|
|
|
|
|
begin
|
|
|
|
|
|
FTitulo := ATitulo;
|
|
|
|
|
|
if (FTitulo = '') and Assigned(Comision) then
|
|
|
|
|
|
begin
|
|
|
|
|
|
if Comision.EsNuevo then
|
|
|
|
|
|
FTitulo := 'Nueva liquidaci<63>n de comisiones'
|
|
|
|
|
|
else
|
|
|
|
|
|
FTitulo := 'Liquidaci<63>n de comisiones';
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
inherited PonerTitulos(FTitulo);
|
|
|
|
|
|
|
|
|
|
|
|
Self.Caption := FTitulo + ' (' + dmUsuarios.EmpresaActual.NOMBRE + ')';
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
procedure TfEditorComision.PrevisualizarInterno;
|
|
|
|
|
|
begin
|
|
|
|
|
|
inherited;
|
2007-07-03 18:57:02 +00:00
|
|
|
|
if (Application.MessageBox('<27>Desea previsualizar la liquidaci<63>n de comisiones sin desglosar?', 'Atenci<63>n', MB_YESNO) = IDYES) then
|
|
|
|
|
|
FController.Preview(FComision, False)
|
|
|
|
|
|
else
|
|
|
|
|
|
FController.Preview(FComision, True);
|
2007-06-11 15:29:06 +00:00
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
procedure TfEditorComision.SetComision(const Value: IBizComisiones);
|
|
|
|
|
|
begin
|
|
|
|
|
|
FComision := Value;
|
|
|
|
|
|
if Assigned(FComision) then
|
|
|
|
|
|
begin
|
|
|
|
|
|
dsDataTable.DataTable := FComision.DataTable;
|
|
|
|
|
|
frViewFacturasComision1.Comision := FComision;
|
|
|
|
|
|
// frViewRecibosComision1.OnViewModified := OnRecibosChanged;
|
|
|
|
|
|
end
|
|
|
|
|
|
else
|
|
|
|
|
|
begin
|
|
|
|
|
|
dsDataTable.DataTable := Nil;
|
|
|
|
|
|
frViewFacturasComision1.Comision := Nil;
|
|
|
|
|
|
// frViewRecibosComision1.OnViewModified := Nil;
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
if Assigned(FViewComision) then
|
|
|
|
|
|
FViewComision.Comision := FComision;
|
|
|
|
|
|
|
|
|
|
|
|
frViewTotales1.DADataSource.DataTable := dsDataTable.DataTable;
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
procedure TfEditorComision.SetController(const Value: IComisionesController);
|
|
|
|
|
|
begin
|
|
|
|
|
|
FController := Value;
|
|
|
|
|
|
if Assigned(FController) then
|
|
|
|
|
|
begin
|
|
|
|
|
|
frViewFacturasComision1.Controller := FController;
|
|
|
|
|
|
end;
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
procedure TfEditorComision.SetViewComision(const Value: IViewComision);
|
|
|
|
|
|
begin
|
|
|
|
|
|
FViewComision := Value;
|
|
|
|
|
|
|
|
|
|
|
|
if Assigned(FViewComision) and Assigned(Comision) then
|
|
|
|
|
|
begin
|
|
|
|
|
|
FViewComision.Comision := Comision;
|
|
|
|
|
|
// FViewComision.Controller := (FController as IComisionesController);
|
|
|
|
|
|
end;
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
procedure TfEditorComision.FormShow(Sender: TObject);
|
|
|
|
|
|
begin
|
|
|
|
|
|
inherited;
|
|
|
|
|
|
|
|
|
|
|
|
if not Assigned(FViewComision) then
|
|
|
|
|
|
raise Exception.Create('No hay ninguna vista asignada');
|
|
|
|
|
|
|
|
|
|
|
|
if not Assigned(Comision) then
|
|
|
|
|
|
raise Exception.Create('No hay ning<6E>n almac<61>n asignado');
|
|
|
|
|
|
|
|
|
|
|
|
Comision.DataTable.Active := True;
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
procedure TfEditorComision.frViewFacturasComision1cxGridViewDataControllerSummaryAfterSummary(ASender: TcxDataSummary);
|
|
|
|
|
|
Var
|
|
|
|
|
|
AImporteTotal: Variant;
|
|
|
|
|
|
begin
|
|
|
|
|
|
inherited;
|
|
|
|
|
|
|
|
|
|
|
|
AImporteTotal := ASender.FooterSummaryValues[1];
|
|
|
|
|
|
|
|
|
|
|
|
if Assigned(FController) then
|
|
|
|
|
|
FController.AsignarImporteTotal(Comision, AImporteTotal);
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
destructor TfEditorComision.Destroy;
|
|
|
|
|
|
begin
|
|
|
|
|
|
// Utilizar mejor OnClose;
|
|
|
|
|
|
inherited;
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
procedure TfEditorComision.dsDataTableDataChange(Sender: TObject; Field: TField);
|
|
|
|
|
|
begin
|
|
|
|
|
|
inherited;
|
|
|
|
|
|
ActualizarEstadoEditor;
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
procedure TfEditorComision.actAnadirRecibosExecute(Sender: TObject);
|
|
|
|
|
|
begin
|
|
|
|
|
|
inherited;
|
|
|
|
|
|
// HayCambios := FController.ElegirRecibosCliente(Comision) OR HayCambios;
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
procedure TfEditorComision.actEliminarReciboExecute(Sender: TObject);
|
|
|
|
|
|
begin
|
|
|
|
|
|
inherited;
|
|
|
|
|
|
// FController.EliminarReciboCliente(Comision);
|
|
|
|
|
|
// HayCambios := True;
|
|
|
|
|
|
end;
|
|
|
|
|
|
{
|
|
|
|
|
|
procedure TfEditorComision.CerrarInterno;
|
|
|
|
|
|
begin
|
|
|
|
|
|
frViewRecibosComision1.OnViewModified := Nil;
|
|
|
|
|
|
inherited;
|
|
|
|
|
|
end;
|
|
|
|
|
|
}
|
|
|
|
|
|
constructor TfEditorComision.Create(AOwner: TComponent);
|
|
|
|
|
|
begin
|
|
|
|
|
|
inherited;
|
|
|
|
|
|
pgPaginas.ActivePageIndex := 0;
|
|
|
|
|
|
FViewComision := frViewComision1;
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
procedure TfEditorComision.CustomEditorClose(Sender: TObject;
|
|
|
|
|
|
var Action: TCloseAction);
|
|
|
|
|
|
begin
|
|
|
|
|
|
inherited;
|
|
|
|
|
|
dsDataTable.DataTable := NIL;
|
|
|
|
|
|
FViewComision := NIL;
|
|
|
|
|
|
FComision := NIL;
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
procedure TfEditorComision.EliminarInterno;
|
|
|
|
|
|
begin
|
|
|
|
|
|
if (Application.MessageBox('<27>Desea borrar esta liquidaci<63>n de comisiones?', 'Atenci<63>n', MB_YESNO) = IDYES) then
|
|
|
|
|
|
begin
|
|
|
|
|
|
inherited;
|
|
|
|
|
|
if not FController.Eliminar(FComision) then
|
|
|
|
|
|
actRefrescar.Execute;
|
|
|
|
|
|
end;
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
end.
|
|
|
|
|
|
|