205 lines
5.6 KiB
ObjectPascal
205 lines
5.6 KiB
ObjectPascal
|
|
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,
|
|||
|
|
JvEnterTab;
|
|||
|
|
|
|||
|
|
type
|
|||
|
|
TfEditorComision = class(TfEditorDBItem, IEditorComision)
|
|||
|
|
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
|
|||
|
|
FTitulo := 'Comisi<73>n' + ' - ' + Comision.Descripcion;
|
|||
|
|
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
|
|||
|
|
FViewComision.Comision := Comision;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfEditorComision.SetController(const Value: IComisionesController);
|
|||
|
|
begin
|
|||
|
|
FController := Value;
|
|||
|
|
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;
|
|||
|
|
var
|
|||
|
|
AViewComision: TfrViewComision;
|
|||
|
|
begin
|
|||
|
|
AViewComision := TfrViewComision.create(Self);
|
|||
|
|
with AViewComision do
|
|||
|
|
begin
|
|||
|
|
Parent := pagGeneral;
|
|||
|
|
Align := alClient;
|
|||
|
|
// dxLayoutControlComision.LookAndFeel := dmBase.dxLayoutSkinLookAndFeel;
|
|||
|
|
end;
|
|||
|
|
ViewComision := AViewComision;
|
|||
|
|
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;
|
|||
|
|
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.
|
|||
|
|
|