git-svn-id: https://192.168.0.254/svn/Proyectos.AlonsoYSal_FactuGES/trunk@5 9a1d36f3-7752-2d40-8ccb-50eb49674c68
170 lines
4.8 KiB
ObjectPascal
170 lines
4.8 KiB
ObjectPascal
unit uEditorCuentas;
|
||
|
||
interface
|
||
|
||
uses
|
||
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
|
||
Dialogs, uEditorBase, uEditorGrid, ToolWin, ComCtrls, JvExControls, JvComponent,
|
||
JvNavigationPane, ActnList, DBActns, uViewGrid, Menus, ImgList, PngImageList,
|
||
TB2Dock, TB2Toolbar, TBX, TB2Item, StdActns, TB2ExtItems, TBXExtItems,
|
||
TB2MRU, DB, uDADataTable, JvFormAutoSize, uDAScriptingProvider, uDACDSDataTable,
|
||
JvAppStorage, JvAppRegistryStorage, JvFormPlacement, ExtCtrls, uCustomView,
|
||
uViewBase, uViewBarraSeleccion, pngimage,
|
||
|
||
uViewCuentas, uBizCuentas, JvComponentBase;
|
||
|
||
type
|
||
IEditorCuentas = interface(IEditorGrid)
|
||
['{F1DCDA99-2E02-43FC-A2D0-43BF7C3C1FD1}']
|
||
function GetCuentas: IBizCuenta;
|
||
procedure SetCuentas(const Value: IBizCuenta);
|
||
property Cuentas: IBizCuenta read GetCuentas write SetCuentas;
|
||
|
||
function GetSelectionBarVisible: Boolean;
|
||
procedure SetSelectionBarVisible(const Value: Boolean);
|
||
property SelectionBarVisible : Boolean read GetSelectionBarVisible write
|
||
SetSelectionBarVisible;
|
||
end;
|
||
|
||
TfEditorCuentas = class(TfEditorGrid, IEditorCuentas)
|
||
frViewBarraSeleccion: TfrViewBarraSeleccion;
|
||
procedure FormShow(Sender: TObject);
|
||
procedure actNuevoExecute(Sender: TObject);
|
||
procedure actModificarExecute(Sender: TObject);
|
||
procedure actEliminarExecute(Sender: TObject);
|
||
procedure frViewBarraSeleccionactSeleccionarExecute(Sender: TObject);
|
||
private
|
||
FCuentas: IBizCuenta;
|
||
protected
|
||
function GetCuentas: IBizCuenta; virtual;
|
||
procedure SetCuentas(const Value: IBizCuenta); virtual;
|
||
procedure SetViewGrid(const Value: IViewGrid); override;
|
||
function GetSelectionBarVisible: Boolean; virtual;
|
||
procedure SetSelectionBarVisible(const Value: Boolean); virtual;
|
||
public
|
||
property SelectionBarVisible : Boolean read GetSelectionBarVisible write
|
||
SetSelectionBarVisible;
|
||
property Cuentas: IBizCuenta read GetCuentas write SetCuentas;
|
||
constructor Create(AOwner: TComponent); override;
|
||
destructor Destroy; override;
|
||
end;
|
||
|
||
implementation
|
||
|
||
uses
|
||
uEditorUtils, uDataModuleCuentas;
|
||
|
||
{$R *.dfm}
|
||
|
||
function ShowEditorCuentas (ABizObject : TDADataTableRules): TModalResult;
|
||
var
|
||
AEditor: TfEditorCuentas;
|
||
begin
|
||
AEditor := TfEditorCuentas.Create(Application);
|
||
try
|
||
AEditor.Cuentas := (ABizObject as IBizCuenta);
|
||
Result := AEditor.ShowModal;
|
||
finally
|
||
AEditor.Release;
|
||
end;
|
||
end;
|
||
|
||
{
|
||
****************************** TfEditorCuentas *******************************
|
||
}
|
||
procedure TfEditorCuentas.FormShow(Sender: TObject);
|
||
begin
|
||
inherited;
|
||
|
||
if not Assigned(ViewGrid) then
|
||
raise Exception.Create('No hay ninguna vista asignada');
|
||
|
||
if not Assigned(Cuentas) then
|
||
raise Exception.Create('No hay ning<6E>n Cuenta asignado');
|
||
|
||
Cuentas.DataTable.Active := True;
|
||
end;
|
||
|
||
function TfEditorCuentas.GetCuentas: IBizCuenta;
|
||
begin
|
||
Result := FCuentas;
|
||
end;
|
||
|
||
procedure TfEditorCuentas.SetCuentas(const Value: IBizCuenta);
|
||
begin
|
||
FCuentas := Value;
|
||
dsDataTable.DataTable := FCuentas.DataTable;
|
||
if Assigned(ViewGrid) then
|
||
(ViewGrid as IViewCuentas).Cuentas := Cuentas;
|
||
end;
|
||
|
||
procedure TfEditorCuentas.actNuevoExecute(Sender: TObject);
|
||
begin
|
||
inherited;
|
||
Cuentas.Insert;
|
||
Cuentas.Show;
|
||
ViewGrid.RefreshGrid;
|
||
ViewGrid.SyncFocusedRecordsFromDataSet;
|
||
end;
|
||
|
||
procedure TfEditorCuentas.actModificarExecute(Sender: TObject);
|
||
begin
|
||
inherited;
|
||
Cuentas.Show;
|
||
ViewGrid.RefreshGrid;
|
||
ViewGrid.SyncFocusedRecordsFromDataSet;
|
||
end;
|
||
|
||
procedure TfEditorCuentas.SetViewGrid(const Value: IViewGrid);
|
||
begin
|
||
inherited;
|
||
if Assigned(ViewGrid) and Assigned(Cuentas) then
|
||
(ViewGrid as IViewCuentas).Cuentas := Cuentas;
|
||
end;
|
||
|
||
destructor TfEditorCuentas.Destroy;
|
||
begin
|
||
FCuentas := NIL;
|
||
inherited;
|
||
end;
|
||
|
||
function TfEditorCuentas.GetSelectionBarVisible: Boolean;
|
||
begin
|
||
Result := frViewBarraSeleccion.Visible
|
||
end;
|
||
|
||
procedure TfEditorCuentas.SetSelectionBarVisible(const Value: Boolean);
|
||
begin
|
||
frViewBarraSeleccion.Visible := True;
|
||
ViewGrid.OnDblClick := frViewBarraSeleccion.actSeleccionar.OnExecute;
|
||
end;
|
||
|
||
procedure TfEditorCuentas.frViewBarraSeleccionactSeleccionarExecute(
|
||
Sender: TObject);
|
||
begin
|
||
inherited;
|
||
ViewGrid.SyncFocusedRecordsFromGrid;
|
||
ModalResult := mrOK;
|
||
end;
|
||
|
||
constructor TfEditorCuentas.Create(AOwner: TComponent);
|
||
begin
|
||
inherited;
|
||
ViewGrid := CreateView(TfrViewCuentas) as IViewCuentas;
|
||
end;
|
||
|
||
procedure TfEditorCuentas.actEliminarExecute(Sender: TObject);
|
||
begin
|
||
if (Application.MessageBox('<27>Est<73> seguro que desea borrar esta cuenta?'+#10#13+'(Se borrar<61>n todos sus asientos)', 'Atenci<63>n', MB_YESNO) = IDYES) then
|
||
begin
|
||
inherited;
|
||
ViewGrid.RefreshGrid;
|
||
end;
|
||
end;
|
||
|
||
initialization
|
||
RegisterEditor(IBizCuenta, ShowEditorCuentas, etItems);
|
||
|
||
end.
|
||
|