2010-05-05 17:10:12 +00:00
|
|
|
|
unit uEditorComision;
|
|
|
|
|
|
|
|
|
|
|
|
interface
|
|
|
|
|
|
|
|
|
|
|
|
uses
|
|
|
|
|
|
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
|
|
|
|
|
|
Dialogs, uEditorDBItem, ToolWin, ComCtrls, JvExControls, JvComponent,
|
|
|
|
|
|
uViewComision, uBizComisiones, JvNavigationPane, ActnList,
|
|
|
|
|
|
uEditorBase, StdActns, TB2Dock, TB2Toolbar, SpTBXItem, ImgList, PngImageList,
|
|
|
|
|
|
TB2Item, uEditorItem, DB, uDADataTable, uEditorDBBase, JvFormAutoSize,
|
|
|
|
|
|
uDAScriptingProvider, uDACDSDataTable, StdCtrls, pngimage, ExtCtrls,
|
|
|
|
|
|
SpTBXDkPanels, JvButton, AppEvnts, uCustomView, uViewBase, uDMBase,
|
|
|
|
|
|
JvAppStorage, JvAppRegistryStorage, JvFormPlacement, JvComponentBase,
|
|
|
|
|
|
|
|
|
|
|
|
uIEditorComision, uComisionesController, JvExComCtrls,
|
|
|
|
|
|
JvStatusBar, dxLayoutLookAndFeels, uDAInterfaces, cxGraphics, cxControls,
|
|
|
|
|
|
cxLookAndFeels, cxLookAndFeelPainters, cxContainer, cxEdit, cxLabel,
|
2010-07-01 14:34:24 +00:00
|
|
|
|
JvEnterTab, uViewDetallesGenerico, uViewFacturasComision, Grids, DBGrids;
|
2010-05-05 17:10:12 +00:00
|
|
|
|
|
|
|
|
|
|
type
|
|
|
|
|
|
TfEditorComision = class(TfEditorDBItem, IEditorComision)
|
2010-06-13 17:44:56 +00:00
|
|
|
|
frViewComision1: TfrViewComision;
|
|
|
|
|
|
frViewFacturasComision1: TfrViewFacturasComision;
|
2010-05-05 17:10:12 +00:00
|
|
|
|
procedure FormShow(Sender: TObject);
|
|
|
|
|
|
procedure dsDataTableDataChange(Sender: TObject; Field: TField);
|
|
|
|
|
|
procedure CustomEditorClose(Sender: TObject; var Action: TCloseAction);
|
|
|
|
|
|
protected
|
|
|
|
|
|
FController : IComisionesController;
|
|
|
|
|
|
FComision: IBizComision;
|
|
|
|
|
|
FViewComision : IViewComision;
|
|
|
|
|
|
|
|
|
|
|
|
function GetController : IComisionesController;
|
|
|
|
|
|
procedure SetController (const Value : IComisionesController); virtual;
|
|
|
|
|
|
function GetComision: IBizComision; virtual;
|
|
|
|
|
|
procedure SetComision(const Value: IBizComision); virtual;
|
|
|
|
|
|
function GetViewComision: IViewComision;
|
|
|
|
|
|
procedure SetViewComision(const Value: IViewComision);
|
|
|
|
|
|
property ViewComision: IViewComision read GetViewComision write SetViewComision;
|
|
|
|
|
|
|
|
|
|
|
|
procedure GuardarInterno; override;
|
|
|
|
|
|
procedure EliminarInterno; override;
|
|
|
|
|
|
|
|
|
|
|
|
procedure PonerTitulos(const ATitulo: string = ''); override;
|
|
|
|
|
|
|
|
|
|
|
|
//Si queremos crear otra vista para el editor heredado solo tendriamos que
|
|
|
|
|
|
//sobreescribir este metodo
|
|
|
|
|
|
procedure AsignarVista; virtual;
|
|
|
|
|
|
|
|
|
|
|
|
public
|
|
|
|
|
|
property Comision: IBizComision read GetComision write SetComision;
|
|
|
|
|
|
constructor Create(AOwner: TComponent); override;
|
|
|
|
|
|
destructor Destroy; override;
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
implementation
|
|
|
|
|
|
|
|
|
|
|
|
{$R *.dfm}
|
|
|
|
|
|
|
|
|
|
|
|
uses
|
|
|
|
|
|
uCustomEditor, uDataModuleComisiones, uDataModuleBase;
|
|
|
|
|
|
|
|
|
|
|
|
function ShowEditorComision (ABizObject : TDADataTableRules): TModalResult;
|
|
|
|
|
|
var
|
|
|
|
|
|
AEditor: TfEditorComision;
|
|
|
|
|
|
begin
|
|
|
|
|
|
AEditor := TfEditorComision.Create(Application);
|
|
|
|
|
|
try
|
|
|
|
|
|
AEditor.Comision := (ABizObject as IBizComision);
|
|
|
|
|
|
Result := AEditor.ShowModal;
|
|
|
|
|
|
finally
|
|
|
|
|
|
AEditor.Release;
|
|
|
|
|
|
end;
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
******************************* TfEditorComision *******************************
|
|
|
|
|
|
}
|
|
|
|
|
|
function TfEditorComision.GetComision: IBizComision;
|
|
|
|
|
|
begin
|
|
|
|
|
|
Result := FComision;
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
function TfEditorComision.GetController: IComisionesController;
|
|
|
|
|
|
begin
|
|
|
|
|
|
Result := FController;
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
function TfEditorComision.GetViewComision: IViewComision;
|
|
|
|
|
|
begin
|
|
|
|
|
|
Result := FViewComision;
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
procedure TfEditorComision.GuardarInterno;
|
|
|
|
|
|
begin
|
|
|
|
|
|
inherited;
|
|
|
|
|
|
FController.Guardar(FComision);
|
|
|
|
|
|
Modified := False;
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
procedure TfEditorComision.PonerTitulos(const ATitulo: string);
|
|
|
|
|
|
var
|
|
|
|
|
|
FTitulo : String;
|
|
|
|
|
|
begin
|
|
|
|
|
|
if Assigned(Comision) then
|
|
|
|
|
|
begin
|
|
|
|
|
|
if Comision.EsNuevo then
|
|
|
|
|
|
FTitulo := 'Nueva comisi<73>n'
|
|
|
|
|
|
else
|
2010-06-13 17:44:56 +00:00
|
|
|
|
FTitulo := 'Comisi<73>n' + ' - ' + Comision.AGENTE;
|
2010-05-05 17:10:12 +00:00
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
inherited PonerTitulos(FTitulo);
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
procedure TfEditorComision.SetComision(const Value: IBizComision);
|
|
|
|
|
|
begin
|
|
|
|
|
|
FComision := Value;
|
|
|
|
|
|
dsDataTable.DataTable := FComision.DataTable;
|
|
|
|
|
|
|
|
|
|
|
|
if Assigned(FViewComision) and Assigned(Comision) then
|
2010-06-13 17:44:56 +00:00
|
|
|
|
begin
|
2010-05-05 17:10:12 +00:00
|
|
|
|
FViewComision.Comision := Comision;
|
2010-06-13 17:44:56 +00:00
|
|
|
|
frViewFacturasComision1.Comision := Comision;
|
|
|
|
|
|
end
|
|
|
|
|
|
else
|
|
|
|
|
|
begin
|
|
|
|
|
|
FViewComision.Comision := Nil;
|
|
|
|
|
|
frViewFacturasComision1.Comision := Nil;
|
|
|
|
|
|
end
|
2010-05-05 17:10:12 +00:00
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
procedure TfEditorComision.SetController(const Value: IComisionesController);
|
|
|
|
|
|
begin
|
|
|
|
|
|
FController := Value;
|
2010-06-13 17:44:56 +00:00
|
|
|
|
if Assigned(FController) then
|
|
|
|
|
|
begin
|
|
|
|
|
|
frViewFacturasComision1.Controller := FController;
|
|
|
|
|
|
end;
|
2010-05-05 17:10:12 +00:00
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
procedure TfEditorComision.SetViewComision(const Value: IViewComision);
|
|
|
|
|
|
begin
|
|
|
|
|
|
FViewComision := Value;
|
|
|
|
|
|
|
|
|
|
|
|
if Assigned(FViewComision) and Assigned(Comision) then
|
|
|
|
|
|
FViewComision.Comision := Comision;
|
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
|
|
|
|
destructor TfEditorComision.Destroy;
|
|
|
|
|
|
begin
|
|
|
|
|
|
// Utilizar mejor OnClose;
|
|
|
|
|
|
inherited;
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
procedure TfEditorComision.AsignarVista;
|
|
|
|
|
|
begin
|
2010-06-13 17:44:56 +00:00
|
|
|
|
ViewComision := frViewComision1;
|
2010-05-05 17:10:12 +00:00
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
constructor TfEditorComision.Create(AOwner: TComponent);
|
|
|
|
|
|
begin
|
|
|
|
|
|
inherited;
|
|
|
|
|
|
pgPaginas.ActivePageIndex := 0;
|
|
|
|
|
|
AsignarVista;
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
procedure TfEditorComision.CustomEditorClose(Sender: TObject;
|
|
|
|
|
|
var Action: TCloseAction);
|
|
|
|
|
|
begin
|
|
|
|
|
|
inherited;
|
|
|
|
|
|
dsDataTable.DataTable := NIL;
|
|
|
|
|
|
FViewComision := NIL;
|
|
|
|
|
|
FComision := NIL;
|
2010-06-13 17:44:56 +00:00
|
|
|
|
FController := Nil;
|
2010-05-05 17:10:12 +00:00
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
procedure TfEditorComision.dsDataTableDataChange(Sender: TObject;
|
|
|
|
|
|
Field: TField);
|
|
|
|
|
|
begin
|
|
|
|
|
|
inherited;
|
|
|
|
|
|
if Assigned(FComision) and (not (FComision.DataTable.Fetching) or
|
|
|
|
|
|
not (FComision.DataTable.Opening) or not (FComision.DataTable.Closing)) then
|
|
|
|
|
|
PonerTitulos;
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
procedure TfEditorComision.EliminarInterno;
|
|
|
|
|
|
begin
|
|
|
|
|
|
if (Application.MessageBox('<27>Desea borrar esta comision?', 'Atenci<63>n', MB_YESNO) = IDYES) then
|
|
|
|
|
|
begin
|
|
|
|
|
|
inherited;
|
|
|
|
|
|
if not FController.Eliminar(FComision) then
|
|
|
|
|
|
actRefrescar.Execute;
|
|
|
|
|
|
end;
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
end.
|
|
|
|
|
|
|