FactuGES2/Source/Modulos/Contabilidad/Views/uEditorAsiento.pas
2008-01-02 19:45:32 +00:00

240 lines
6.7 KiB
ObjectPascal
Raw Blame History

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;
frViewApuntes1: TfrViewApuntes;
dxLayoutControl1Group_Root: TdxLayoutGroup;
dxLayoutControl1: TdxLayoutControl;
dxLayoutControl1Item1: TdxLayoutItem;
edtOrden: TcxDBSpinEdit;
dxLayoutControl1Item2: TdxLayoutItem;
edtFecha: TcxDBDateEdit;
dxLayoutControl1Item3: TdxLayoutItem;
dxLayoutControl1Group2: TdxLayoutGroup;
dxLayoutControl1Group3: TdxLayoutGroup;
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 := 'Nueva Asiento - ' + AppFactuGES.EmpresaActiva.NOMBRE + ' - ' + AppFactuGES.EjercicioActivo.NOMBRE
else
FTitulo := 'Asiento' + ' ' + IntToStr(Asiento.ORDEN) + ' - ' + AppFactuGES.EmpresaActiva.NOMBRE + ' - ' + AppFactuGES.EjercicioActivo.NOMBRE;
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 almac<61>n asignado');
Asiento.DataTable.Active := True;
//Muy importante ya que pone el numero de orden del apunte al maximo valor existente
//tiene que ser aqui porque es cuando la tabla esta filtrada por el asiento
Asiento.Apuntes.SetNumOrden;
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>Desea borrar esta Asiento?', 'Atenci<63>n', MB_YESNO) = IDYES) then
begin
inherited;
if not FController.Eliminar(FAsiento) then
actRefrescar.Execute;
end;
end;
end.