git-svn-id: https://192.168.0.254/svn/Proyectos.AlonsoYSal_FactuGES2/trunk@6 40301925-124e-1c4e-b97d-170ad7a8785b
245 lines
6.9 KiB
ObjectPascal
245 lines
6.9 KiB
ObjectPascal
unit uEditorAsiento;
|
||
|
||
interface
|
||
|
||
uses
|
||
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
|
||
Dialogs, uEditorDBItem, ToolWin, ComCtrls, JvExControls, JvComponent,
|
||
uBizAsientos, 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,
|
||
|
||
uIEditorAsiento, uAsientosController, JvExComCtrls,
|
||
JvStatusBar, dxLayoutLookAndFeels, uDAInterfaces, uViewDetallesGenerico,
|
||
uViewApuntes, cxDropDownEdit, cxCalendar, cxDBEdit, dxLayoutControl,
|
||
cxContainer, cxEdit, cxTextEdit, cxMaskEdit, cxSpinEdit, cxControls, DBCtrls,
|
||
dxGDIPlusClasses;
|
||
|
||
type
|
||
TfEditorAsiento = class(TfEditorDBItem, IEditorAsiento)
|
||
dxLayoutLookAndFeelList1: TdxLayoutLookAndFeelList;
|
||
dxLayoutOfficeLookAndFeel1: TdxLayoutOfficeLookAndFeel;
|
||
dxLayoutControl1Group_Root: TdxLayoutGroup;
|
||
dxLayoutControl1: TdxLayoutControl;
|
||
lcOrden: TdxLayoutItem;
|
||
edtOrden: TcxDBSpinEdit;
|
||
dxLayoutControl1Item2: TdxLayoutItem;
|
||
edtFecha: TcxDBDateEdit;
|
||
dxLayoutControl1Group2: TdxLayoutGroup;
|
||
dxLayoutControl1Group3: TdxLayoutGroup;
|
||
dxLayoutControl1Item1: TdxLayoutItem;
|
||
frViewApuntes1: TfrViewApuntes;
|
||
procedure FormShow(Sender: TObject);
|
||
procedure dsDataTableDataChange(Sender: TObject; Field: TField);
|
||
procedure CustomEditorClose(Sender: TObject; var Action: TCloseAction);
|
||
protected
|
||
FController : IAsientosController;
|
||
FAsiento: IBizAsiento;
|
||
// FViewAsiento : IViewAsiento;
|
||
|
||
function GetController : IAsientosController;
|
||
procedure SetController (const Value : IAsientosController); virtual;
|
||
function GetAsiento: IBizAsiento; virtual;
|
||
procedure SetAsiento(const Value: IBizAsiento); virtual;
|
||
// function GetViewAsiento: IViewAsiento;
|
||
// procedure SetViewAsiento(const Value: IViewAsiento);
|
||
// property ViewAsiento: IViewAsiento read GetViewAsiento write SetViewAsiento;
|
||
|
||
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 Asiento: IBizAsiento read GetAsiento write SetAsiento;
|
||
constructor Create(AOwner: TComponent); override;
|
||
destructor Destroy; override;
|
||
end;
|
||
|
||
implementation
|
||
|
||
{$R *.dfm}
|
||
|
||
uses
|
||
uCustomEditor, uDataModuleBase, uFactuGES_App;
|
||
|
||
function ShowEditorAsiento (ABizObject : TDADataTableRules): TModalResult;
|
||
var
|
||
AEditor: TfEditorAsiento;
|
||
begin
|
||
AEditor := TfEditorAsiento.Create(Application);
|
||
try
|
||
AEditor.Asiento := (ABizObject as IBizAsiento);
|
||
Result := AEditor.ShowModal;
|
||
finally
|
||
AEditor.Release;
|
||
end;
|
||
end;
|
||
|
||
{
|
||
******************************* TfEditorAsiento *******************************
|
||
}
|
||
function TfEditorAsiento.GetAsiento: IBizAsiento;
|
||
begin
|
||
Result := FAsiento;
|
||
end;
|
||
|
||
function TfEditorAsiento.GetController: IAsientosController;
|
||
begin
|
||
Result := FController;
|
||
end;
|
||
|
||
{
|
||
function TfEditorAsiento.GetViewAsiento: IViewAsiento;
|
||
begin
|
||
Result := FViewAsiento;
|
||
end;
|
||
}
|
||
|
||
procedure TfEditorAsiento.GuardarInterno;
|
||
begin
|
||
inherited;
|
||
FController.Guardar(FAsiento);
|
||
Modified := False;
|
||
end;
|
||
|
||
procedure TfEditorAsiento.PonerTitulos(const ATitulo: string);
|
||
var
|
||
FTitulo : String;
|
||
begin
|
||
if Assigned(Asiento) then
|
||
begin
|
||
if Asiento.EsNuevo then
|
||
FTitulo := 'Nuevo asiento - ' + AppFactuGES.EmpresaActiva.NOMBRE + ' - ' + AppFactuGES.EjercicioActivo.NOMBRE + ' (' + AppFactuGES.EjercicioActivo.ESTADO + ')'
|
||
else
|
||
FTitulo := 'Asiento' + ' ' + IntToStr(Asiento.ORDEN) + ' - ' + AppFactuGES.EmpresaActiva.NOMBRE + ' - ' + AppFactuGES.EjercicioActivo.NOMBRE + ' (' + AppFactuGES.EjercicioActivo.ESTADO + ')';
|
||
end;
|
||
|
||
inherited PonerTitulos(FTitulo);
|
||
end;
|
||
|
||
procedure TfEditorAsiento.SetAsiento(const Value: IBizAsiento);
|
||
begin
|
||
FAsiento := Value;
|
||
|
||
if Assigned(FAsiento) then
|
||
begin
|
||
dsDataTable.DataTable := FAsiento.DataTable;
|
||
frViewApuntes1.Apuntes := FAsiento.Apuntes
|
||
end
|
||
else
|
||
begin
|
||
dsDataTable.DataTable := Nil;
|
||
frViewApuntes1.Apuntes := Nil;
|
||
end;
|
||
|
||
// if Assigned(FViewAsiento) and Assigned(Asiento) then
|
||
// FViewAsiento.Asiento := Asiento;
|
||
end;
|
||
|
||
procedure TfEditorAsiento.SetController(const Value: IAsientosController);
|
||
begin
|
||
FController := Value;
|
||
// if Assigned(ViewAsiento) then
|
||
// ViewAsiento.Controller := FController;
|
||
end;
|
||
|
||
{
|
||
procedure TfEditorAsiento.SetViewAsiento(const Value: IViewAsiento);
|
||
begin
|
||
FViewAsiento := Value;
|
||
|
||
if Assigned(FViewAsiento) and Assigned(Asiento) then
|
||
FViewAsiento.Asiento := Asiento;
|
||
end;
|
||
}
|
||
|
||
procedure TfEditorAsiento.FormShow(Sender: TObject);
|
||
begin
|
||
inherited;
|
||
|
||
// if not Assigned(FViewAsiento) then
|
||
// raise Exception.Create('No hay ninguna vista asignada');
|
||
|
||
if not Assigned(Asiento) then
|
||
raise Exception.Create('No hay ning<6E>n asiento asignado');
|
||
|
||
Asiento.DataTable.Active := True;
|
||
|
||
//Al insertar el orden se asigna automaticamente en el servidor, luego se podr<64> modificar
|
||
if Asiento.EsNuevo then
|
||
lcOrden.Visible := False
|
||
else
|
||
lcOrden.Visible := True;
|
||
|
||
//En el caso de tener apuntes el asiento nos posicionaremos siempre el la columna concepto del ultimo apunte
|
||
frViewApuntes1.GotoLast;
|
||
end;
|
||
|
||
destructor TfEditorAsiento.Destroy;
|
||
begin
|
||
// Utilizar mejor OnClose;
|
||
inherited;
|
||
end;
|
||
|
||
{
|
||
procedure TfEditorAsiento.AsignarVista;
|
||
var
|
||
AViewAsiento: TfrViewAsiento;
|
||
begin
|
||
AViewAsiento := TfrViewAsiento.create(Self);
|
||
with AViewAsiento do
|
||
begin
|
||
Parent := pagGeneral;
|
||
Align := alClient;
|
||
// dxLayoutControlAsiento.LookAndFeel := dxLayoutOfficeLookAndFeel1;
|
||
end;
|
||
ViewAsiento := AViewAsiento;
|
||
end;
|
||
}
|
||
|
||
constructor TfEditorAsiento.Create(AOwner: TComponent);
|
||
begin
|
||
inherited;
|
||
pgPaginas.ActivePageIndex := 0;
|
||
// AsignarVista;
|
||
end;
|
||
|
||
procedure TfEditorAsiento.CustomEditorClose(Sender: TObject; var Action: TCloseAction);
|
||
begin
|
||
inherited;
|
||
dsDataTable.DataTable := NIL;
|
||
// FViewAsiento := NIL;
|
||
FAsiento := NIL;
|
||
end;
|
||
|
||
procedure TfEditorAsiento.dsDataTableDataChange(Sender: TObject; Field: TField);
|
||
begin
|
||
inherited;
|
||
{
|
||
if Assigned(FAsiento) and (not (FAsiento.DataTable.Fetching) or
|
||
not (FAsiento.DataTable.Opening) or not (FAsiento.DataTable.Closing)) then
|
||
PonerTitulos;
|
||
}
|
||
end;
|
||
|
||
procedure TfEditorAsiento.EliminarInterno;
|
||
begin
|
||
if (Application.MessageBox('<27>Est<73> seguro que desea borrar este asiento?', 'Atenci<63>n', MB_YESNO) = IDYES) then
|
||
begin
|
||
inherited;
|
||
if not FController.Eliminar(FAsiento) then
|
||
actRefrescar.Execute;
|
||
end;
|
||
end;
|
||
|
||
end.
|
||
|