192 lines
5.2 KiB
ObjectPascal
192 lines
5.2 KiB
ObjectPascal
|
|
unit uEditorAsientos;
|
|||
|
|
|
|||
|
|
interface
|
|||
|
|
|
|||
|
|
uses
|
|||
|
|
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
|
|||
|
|
Dialogs, uEditorGrid, Menus, DB, uDADataTable, JvAppStorage,
|
|||
|
|
JvAppRegistryStorage, JvComponent, JvFormPlacement, ImgList,
|
|||
|
|
PngImageList, StdActns, ActnList, ComCtrls, TB2ExtItems, TBXExtItems,
|
|||
|
|
TBX, TB2Item, TB2Dock, TB2Toolbar, ExtCtrls, JvExControls,
|
|||
|
|
JvNavigationPane, uBizAsientos, uViewGrid, JvComponentBase, pngimage;
|
|||
|
|
|
|||
|
|
type
|
|||
|
|
IEditorAsientos = interface(IEditorGrid)
|
|||
|
|
['{05667247-1AC6-4297-9B84-524A2AA3A04C}']
|
|||
|
|
function GetAsientos: IBizAsiento;
|
|||
|
|
procedure SetAsientos(const Value: IBizAsiento);
|
|||
|
|
property Asientos: IBizAsiento read GetAsientos write SetAsientos;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
TfEditorAsientos = class(TfEditorGrid, IEditorAsientos)
|
|||
|
|
actCerrarCaja: TAction;
|
|||
|
|
N3: TMenuItem;
|
|||
|
|
Cerrarcaja1: TMenuItem;
|
|||
|
|
actPuntear: TAction;
|
|||
|
|
TBXItem36: TTBXItem;
|
|||
|
|
TBXSubmenuItem2: TTBXSubmenuItem;
|
|||
|
|
TBXSeparatorItem16: TTBXSeparatorItem;
|
|||
|
|
TBXItem38: TTBXItem;
|
|||
|
|
TBXItem39: TTBXItem;
|
|||
|
|
procedure FormShow(Sender: TObject);
|
|||
|
|
procedure actNuevoExecute(Sender: TObject);
|
|||
|
|
procedure actModificarExecute(Sender: TObject);
|
|||
|
|
procedure actCerrarCajaExecute(Sender: TObject);
|
|||
|
|
procedure actEliminarExecute(Sender: TObject);
|
|||
|
|
procedure actCerrarCajaUpdate(Sender: TObject);
|
|||
|
|
procedure actNuevoUpdate(Sender: TObject);
|
|||
|
|
procedure actPuntearExecute(Sender: TObject);
|
|||
|
|
procedure actPuntearUpdate(Sender: TObject);
|
|||
|
|
private
|
|||
|
|
FAsientos: IBizAsiento;
|
|||
|
|
protected
|
|||
|
|
function GetAsientos: IBizAsiento; virtual;
|
|||
|
|
procedure SetAsientos(const Value: IBizAsiento); virtual;
|
|||
|
|
procedure SetViewGrid(const Value: IViewGrid); override;
|
|||
|
|
public
|
|||
|
|
property Asientos: IBizAsiento read GetAsientos write SetAsientos;
|
|||
|
|
constructor Create(AOwner: TComponent); override;
|
|||
|
|
destructor Destroy; override;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
var
|
|||
|
|
fEditorAsientos: TfEditorAsientos;
|
|||
|
|
|
|||
|
|
implementation
|
|||
|
|
|
|||
|
|
{$R *.dfm}
|
|||
|
|
{ TfEditorAsientos }
|
|||
|
|
|
|||
|
|
uses uViewAsientos;
|
|||
|
|
|
|||
|
|
constructor TfEditorAsientos.Create(AOwner: TComponent);
|
|||
|
|
begin
|
|||
|
|
inherited;
|
|||
|
|
ViewGrid := CreateView(TfrViewAsientos) as IViewAsientos;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
destructor TfEditorAsientos.Destroy;
|
|||
|
|
begin
|
|||
|
|
FAsientos := NIL;
|
|||
|
|
inherited;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfEditorAsientos.FormShow(Sender: TObject);
|
|||
|
|
begin
|
|||
|
|
inherited;
|
|||
|
|
|
|||
|
|
if not Assigned(ViewGrid) then
|
|||
|
|
raise Exception.Create('No hay ninguna vista asignada');
|
|||
|
|
|
|||
|
|
if not Assigned(Asientos) then
|
|||
|
|
raise Exception.Create('No hay ning<6E>n asiento asignado');
|
|||
|
|
|
|||
|
|
Asientos.DataTable.Active := True;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
function TfEditorAsientos.GetAsientos: IBizAsiento;
|
|||
|
|
begin
|
|||
|
|
Result := FAsientos;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfEditorAsientos.SetAsientos(const Value: IBizAsiento);
|
|||
|
|
begin
|
|||
|
|
FAsientos := Value;
|
|||
|
|
dsDataTable.DataTable := FAsientos.DataTable;
|
|||
|
|
if Assigned(ViewGrid) then
|
|||
|
|
(ViewGrid as IViewAsientos).Asientos := Asientos;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfEditorAsientos.SetViewGrid(const Value: IViewGrid);
|
|||
|
|
begin
|
|||
|
|
inherited;
|
|||
|
|
if Assigned(ViewGrid) and Assigned(Asientos) then
|
|||
|
|
(ViewGrid as IViewAsientos).Asientos := Asientos;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfEditorAsientos.actNuevoExecute(Sender: TObject);
|
|||
|
|
begin
|
|||
|
|
inherited;
|
|||
|
|
Asientos.Insert;
|
|||
|
|
Asientos.Show;
|
|||
|
|
ViewGrid.RefreshGrid;
|
|||
|
|
ViewGrid.SyncFocusedRecordsFromDataSet;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfEditorAsientos.actModificarExecute(Sender: TObject);
|
|||
|
|
begin
|
|||
|
|
inherited;
|
|||
|
|
Asientos.Show;
|
|||
|
|
ViewGrid.RefreshGrid;
|
|||
|
|
ViewGrid.SyncFocusedRecordsFromDataSet;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfEditorAsientos.actCerrarCajaExecute(Sender: TObject);
|
|||
|
|
var
|
|||
|
|
ACursor: TCursor;
|
|||
|
|
begin
|
|||
|
|
ACursor := Screen.Cursor;
|
|||
|
|
Screen.Cursor := crHourGlass;
|
|||
|
|
|
|||
|
|
ViewGrid.SyncFocusedRecordsFromGrid;
|
|||
|
|
Asientos.cerrarCaja;
|
|||
|
|
ViewGrid.RefreshGrid;
|
|||
|
|
ViewGrid.SyncFocusedRecordsFromDataSet;
|
|||
|
|
|
|||
|
|
Screen.Cursor := ACursor;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfEditorAsientos.actEliminarExecute(Sender: TObject);
|
|||
|
|
begin
|
|||
|
|
ViewGrid.SyncFocusedRecordsFromGrid;
|
|||
|
|
|
|||
|
|
if Asientos.PUNTEADO = CTE_NOPUNTEADO
|
|||
|
|
then inherited
|
|||
|
|
else if (Asientos.TIPOASIENTO = CTE_CIERRE)
|
|||
|
|
then Asientos.eliminarCierreCaja
|
|||
|
|
else raise Exception.Create('No se puede borrar un asiento que esta punteado por un cierre de caja');
|
|||
|
|
|
|||
|
|
ViewGrid.RefreshGrid;
|
|||
|
|
ViewGrid.SyncFocusedRecordsFromDataSet;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfEditorAsientos.actCerrarCajaUpdate(Sender: TObject);
|
|||
|
|
begin
|
|||
|
|
inherited;
|
|||
|
|
|
|||
|
|
if Assigned(dsDataTable.DataTable) then
|
|||
|
|
(Sender as TAction).Enabled := (not dsDataTable.DataTable.IsEmpty)
|
|||
|
|
and not (dsDataTable.DataTable.State = dsInsert)
|
|||
|
|
else
|
|||
|
|
(Sender as TAction).Enabled := False;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfEditorAsientos.actNuevoUpdate(Sender: TObject);
|
|||
|
|
begin
|
|||
|
|
inherited;
|
|||
|
|
(Sender as TAction).Enabled := Asientos.Cuenta.RecordCount <> 0;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfEditorAsientos.actPuntearExecute(Sender: TObject);
|
|||
|
|
begin
|
|||
|
|
inherited;
|
|||
|
|
|
|||
|
|
ViewGrid.SyncFocusedRecordsFromGrid;
|
|||
|
|
Asientos.puntearAsiento;
|
|||
|
|
ViewGrid.RefreshGrid;
|
|||
|
|
ViewGrid.SyncFocusedRecordsFromDataSet;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfEditorAsientos.actPuntearUpdate(Sender: TObject);
|
|||
|
|
begin
|
|||
|
|
inherited;
|
|||
|
|
|
|||
|
|
if Assigned(dsDataTable.DataTable) then
|
|||
|
|
(Sender as TAction).Enabled := (not dsDataTable.DataTable.IsEmpty)
|
|||
|
|
and not (dsDataTable.DataTable.State = dsInsert)
|
|||
|
|
else
|
|||
|
|
(Sender as TAction).Enabled := False;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
end.
|