This repository has been archived on 2024-12-02. You can view files and clone it, but cannot push or open issues or pull requests.
AlonsoYSal_FactuGES/Modulos/Pagos/Cliente/uEditorPagos.pas

138 lines
3.8 KiB
ObjectPascal
Raw Blame History

unit uEditorPagos;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, uEditorBase, uEditorGrid, ToolWin, ComCtrls, JvExControls, JvComponent,
JvNavigationPane, uViewPagos, uBizPagos, ActnList, DBActns, uViewGrid,
Menus, uDataModuleBase, ImgList, PngImageList, TB2Dock, TB2Toolbar, TBX,
TB2Item, StdActns, TB2ExtItems, TBXExtItems, TB2MRU, DB, uDADataTable,
JvFormAutoSize, uDAScriptingProvider, uDACDSDataTable, JvAppStorage,
JvAppRegistryStorage, JvFormPlacement, ExtCtrls, uCustomView, uViewBase,
uViewBarraSeleccion, pngimage, JvComponentBase;
type
IEditorPagos = interface(IEditorGrid)
['{0BCA3B66-90C6-4BD6-8436-EC80462E9A9B}']
function GetPagos: IBizPagos;
procedure SetPagos(const Value: IBizPagos);
property Pagos: IBizPagos read GetPagos write SetPagos;
end;
TfEditorPagos = class(TfEditorGrid, IEditorPagos)
procedure actNuevoExecute(Sender: TObject);
procedure actModificarExecute(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure OnListaAnosChange(Sender: TObject; const Text: string);
private
FPagos: IBizPagos;
protected
function GetPagos: IBizPagos; virtual;
procedure SetPagos(const Value: IBizPagos); virtual;
procedure SetViewGrid(const Value: IViewGrid); override;
public
property Pagos: IBizPagos read GetPagos write SetPagos;
destructor Destroy; override;
end;
implementation
uses
uCustomEditor, uDataModulePagos, uEditorDBBase, uEditorUtils,
cxGrid, cxGridCustomTableView, uDBSelectionList;
//, uListaPagos;
// uEditorAlmacen;
{$R *.dfm}
{
****************************** TfEditorPagos *******************************
}
procedure TfEditorPagos.FormShow(Sender: TObject);
begin
ListaAnos := dmPagos.DarListaAnosPagos;
cbxListaAnos.OnChange := OnListaAnosChange; //OJO SIEMPRE ANTES DEL INHERITED
inherited;
if not Assigned(ViewGrid) then
raise Exception.Create('No hay ninguna vista asignada');
if not Assigned(Pagos) then
raise Exception.Create('No hay ning<6E>n Pago asignado');
// Pagos.DataTable.Active := True;
end;
function TfEditorPagos.GetPagos: IBizPagos;
begin
Result := FPagos;
end;
procedure TfEditorPagos.SetPagos(const Value: IBizPagos);
begin
FPagos := Value;
if Assigned(FPagos) then
begin
//Se guarda el where de la sentencia origen, por si el editor tiene filtros que
//afecten a este where y en un futuro se desea volver al where origen (filtro de a<>o))
WhereDataTable := FPagos.DataTable.Where.Clause;
dsDataTable.DataTable := FPagos.DataTable;
if Assigned(ViewGrid) then
(ViewGrid as IViewPagos).Pagos := Pagos;
end;
end;
procedure TfEditorPagos.actNuevoExecute(Sender: TObject);
begin
inherited;
Pagos.Insert;
Pagos.Show;
ViewGrid.RefreshGrid;
ViewGrid.SyncFocusedRecordsFromDataSet;
end;
procedure TfEditorPagos.actModificarExecute(Sender: TObject);
begin
inherited;
Pagos.Show;
ViewGrid.RefreshGrid;
ViewGrid.SyncFocusedRecordsFromDataSet;
end;
procedure TfEditorPagos.SetViewGrid(const Value: IViewGrid);
begin
inherited;
if Assigned(ViewGrid) and Assigned(Pagos) then
(ViewGrid as IViewPagos).Pagos := Pagos;
end;
destructor TfEditorPagos.Destroy;
begin
FPagos := NIL;
inherited;
end;
procedure TfEditorPagos.OnListaAnosChange(Sender: TObject; const Text: string);
var
aAux : ISelectedRowList;
begin
dmPagos.FiltrarAno(Pagos, WhereDataTable, Text);
if Pagos.DataTable.Active then
actRefrescar.Execute;
// Quitar las selecciones que hubiera anteriormente porque ya no valen
if Supports(Pagos, ISelectedRowList, aAux) then
if (aAux.SelectedRows.Count > 0) then
aAux.SelectedRows.Clear;
end;
end.