This repository has been archived on 2024-11-28. You can view files and clone it, but cannot push or open issues or pull requests.
LuisLeon_FactuGES2/Source/Modulos/Contactos/Views/uViewAgenteObjetivosFacturas.pas

136 lines
4.2 KiB
ObjectPascal
Raw Blame History

unit uViewAgenteObjetivosFacturas;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, uViewDetallesGenerico, cxStyles, cxCustomData, cxGraphics, cxFilter,
cxData, cxDataStorage, cxEdit, DB, cxDBData, ActnList, ImgList, PngImageList,
uDAInterfaces, uDADataTable, ComCtrls, ToolWin, cxGridLevel,
cxGridCustomTableView, cxGridTableView, cxGridDBTableView, cxClasses,
cxControls, cxGridCustomView, cxGrid, cxSpinEdit, cxCurrencyEdit, TB2ExtItems,
TBXExtItems, TB2Item, TB2Dock, TB2Toolbar, TBX, uAgentesController;
type
TfrViewAgenteObjetivosFacturas = class(TfrViewDetallesGenerico)
cxGridViewID_AGENTE: TcxGridDBColumn;
cxGridViewANO: TcxGridDBColumn;
cxGridViewMES: TcxGridDBColumn;
cxGridViewUNIDADES_OBJETIVO: TcxGridDBColumn;
cxGridViewIMPORTE_OBJETIVO: TcxGridDBColumn;
cxGridViewDESCRIPCION: TcxGridDBColumn;
tbxFiltro: TTBXToolbar;
lblAno: TTBXLabelItem;
cbxListaAnos: TTBXComboBoxItem;
procedure OnListaAnosChange(Sender: TObject; const Text: string);
procedure CustomViewShow(Sender: TObject);
procedure CustomViewDestroy(Sender: TObject);
protected
FListaAnos: TStringList;
FController : IAgentesController;
function GetListaAnos: TStringList;
procedure SetListaAnos(const Value: TStringList);
function GetController : IAgentesController; virtual;
procedure SetController (const Value : IAgentesController); virtual;
public
property Controller : IAgentesController read GetController write SetController;
property ListaAnos: TStringList read GetListaAnos write SetListaAnos;
procedure Refrescar;
end;
implementation
{$R *.dfm}
uses schContactosClient_Intf;
{ TfrViewAgenteObjetivosFacturas }
procedure TfrViewAgenteObjetivosFacturas.CustomViewDestroy(Sender: TObject);
begin
FController := NIL;
if Assigned(FListaAnos) then
FlistaAnos.Free;
inherited;
end;
procedure TfrViewAgenteObjetivosFacturas.CustomViewShow(Sender: TObject);
begin
cbxListaAnos.OnChange := OnListaAnosChange; //OJO SIEMPRE ANTES DEL INHERITED
inherited;
cbxListaAnos.ItemIndex := 0;
end;
function TfrViewAgenteObjetivosFacturas.GetController: IAgentesController;
begin
Result := FController;
end;
function TfrViewAgenteObjetivosFacturas.GetListaAnos: TStringList;
begin
Result := FListaAnos;
end;
procedure TfrViewAgenteObjetivosFacturas.OnListaAnosChange(Sender: TObject; const Text: string);
begin
dsDetalles.DataTable.Filter := 'ANO = ''' + Text + '''';
dsDetalles.DataTable.Filtered :=True;
end;
procedure TfrViewAgenteObjetivosFacturas.Refrescar;
begin
//Volvemos a cargar los a<>os de los objetivos
if Assigned(FController) then
ListaAnos := FController.DarListaAnosObjetivosFacturasAgente(dsDetalles.DataTable.FieldByName(fld_Agentes_Objetivos_facturasID_AGENTE).AsInteger);
cbxListaAnos.ItemIndex := 0;
end;
procedure TfrViewAgenteObjetivosFacturas.SetController(const Value: IAgentesController);
begin
FController := Value;
if Assigned(FController) then
ListaAnos := FController.DarListaAnosObjetivosFacturasAgente(dsDetalles.DataTable.FieldByName(fld_Agentes_Objetivos_facturasID_AGENTE).AsInteger);
end;
procedure TfrViewAgenteObjetivosFacturas.SetListaAnos(const Value: TStringList);
var
i: Integer;
AStringAnterior: String;
begin
AStringAnterior := '';
if Assigned(FListaAnos) and (FListaAnos.Count > 0) then
begin
AStringAnterior := FListaAnos.ValueFromIndex[cbxListaAnos.ItemIndex];
FListaAnos.Free;
end;
//Se asigna el nuevo TStringList
FListaAnos := Value;
if Assigned(FListaAnos) then
begin
cbxListaAnos.Strings.BeginUpdate;
cbxListaAnos.Strings.Clear;
for i := 0 to FListaAnos.Count - 1 do
cbxListaAnos.Strings.Append(FListaAnos.Names[i]);
//Se posiciona en el elemento que habia anteriormente
if Length(AStringAnterior) > 0 then
begin
if FListaAnos.IndexOfName(AStringAnterior) <> -1 then
cbxListaAnos.ItemIndex := FListaAnos.IndexOfName(AStringAnterior)
else
cbxListaAnos.ItemIndex := 0;
end;
cbxListaAnos.Strings.EndUpdate;
end;
end;
end.