Diferencia entre revisiones de «TpAUX CLASE SUBTOTAL unit»

De Pragma Wiki
Ir a la navegación Ir a la búsqueda
Sin resumen de edición
Línea 55: Línea 55:
   end;
   end;
</pre>
</pre>
=Implementación=
===function ExecuteDataset(aDataSet: TprxADODataSetEdit; aTableName: String): Boolean===
Este Execute lo llama cada clase detalle de la clase de la función '''Execute'''. Retorna True si define subtotales.
===function Execute(aMasterDS: TprxADODataSet): Boolean===
Similar anterior pero llamado por un master.
=Modo de uso=
Habitualmente el auxiliar se usa de la siguiente manera (ejemplo tomado de [[TTfvsDBClientFrameGridConsultas]].fvsDBGridResultadoGetPopupOptions):
<pre>
prxADOClientDM.pAUX_CLASE_SELECCION_CRITERIOS_unit.DataSet      := DataSource.DataSet; // QueryRESULTADO;
prxADOClientDM.pAUX_CLASE_SELECCION_CRITERIOS_unit.Clase        := TprxADODataSetEdit(TprxADOQuery(QueryRESULTADO).MasterDataSet).ppTableName;
</pre>
Primero asignamos las propiedades:
*'''Dataset''' que se asigna al dataset de la pantalla que llama al auxiliar.
*'''Clase''' se inicializa al nombre de la tabla del componente que está llamando al auxiliar.
Si '''Exexute''' retorna True (indicando que se ha definido un SQL para la selección de criterios) toma ese SQL y agrega la opción '''Definir criterios...''' al menú local:
<pre>
if prxADOClientDM.pAUX_CLASE_SELECCION_CRITERIOS_unit.Execute then
  begin
  SQL_Criterios := prxADOClientDM.pAUX_CLASE_SELECCION_CRITERIOS_unit.SQL_COMANDO.Text;
  aPopupMenu.OptionAdd('Definir criterios...', True, 'magnifier_zoom_in', AbrirFormCriterios);
  aPopupMenu.OptionAddSeparator;
  end;
</pre>
'''AbrirFormCriterios''' es una función local que se ocupa de abrir el form [[TTprxCriteriosConsultasForm]] de criterios, aplicar el SQL del auxiliar y administrar la selección de valores:
<pre>
procedure TTfvsDBClientFrameGridConsultas.AbrirFormCriterios(Sender: TObject);
var
  vF: TTprxCriteriosConsultasForm;
begin
  if Assigned(CriteriosForm) = False then
    CriteriosForm := TTprxCriteriosConsultasForm.Create(Self);
  CriteriosForm.GUID := TprxADODataSetEdit(DataSource.DataSet).GUID;
  CriteriosForm.SQL  := SQL_Criterios;
  CriteriosForm.ShowModal;
  CriteriosForm.Release;
  CriteriosForm := nil;
  SQLEjecutar(Sender);
  fvsDBGridResultado.WidthJustify;
end;
</pre>
=Usos=
Este auxiliar lo usa:

Revisión del 17:34 22 may 2025

Descripción

El objeto TpAUX_CLASE_SUBTOTAL_unit (Subtotales desde detalles en edición de clases) procesa los auxiliares de tipo SUBTOTAL, ver detalles en DEV AUXILIARES/SUBTOTAL.

Identidad

  • Ancestro: TComponent
  • Carpeta: C:\DevelopPrx\pPRAGMA
  • Archivo: pAUX_CLASE_SUBTOTAL_unit.pas

Declaración

type
  TpAUX_CLASE_SUBTOTAL_item = record
    Dataset: TprxADODataSet;
    Parser: Tfva_parser_fbn;
    Campo: String;
    Calculo: String;
    Regla: String;
    ModoSubtotal: String;
    UsaMaster: Boolean;
    Valor: Variant;
  end;

type
  TpAUX_CLASE_SUBTOTAL_unit = class(TComponent)
  private
    FQuery: TprxADOQuery;

    FSQL_CALCULO: TStringList;
    FSQL_REGLA: TStringList;
    FTag_MODOSUBTOTAL: String;
    FTag_USAMASTERDS: Boolean;
    FItems: TStringList;
  protected
    Reglas: array[0..13] of TpAUX_CLASE_SUBTOTAL_item;
    ReglasCount: Integer;

    property    SQL_CALCULO: TStringList read FSQL_CALCULO write FSQL_CALCULO;
    property    SQL_REGLA: TStringList read FSQL_REGLA write FSQL_REGLA;
    property    Tag_MODOSUBTOTAL: String read FTag_MODOSUBTOTAL write FTag_MODOSUBTOTAL;
    property    Tag_USAMASTERDS: Boolean read FTag_USAMASTERDS write FTag_USAMASTERDS;

    function    ExecuteDataset(aDataSet: TprxADODataSetEdit; aTableName: String): Boolean;
  public
    constructor Create(AOwner: TComponent); override;
    destructor  Destroy; override;

    function    Execute(aMasterDS: TprxADODataSet): Boolean;

    property    Query: TprxADOQuery read FQuery write FQuery;

    property    Items: TStringList read FItems;
  published
  end;

Implementación

function ExecuteDataset(aDataSet: TprxADODataSetEdit; aTableName: String): Boolean

Este Execute lo llama cada clase detalle de la clase de la función Execute. Retorna True si define subtotales.

function Execute(aMasterDS: TprxADODataSet): Boolean

Similar anterior pero llamado por un master.

Modo de uso

Habitualmente el auxiliar se usa de la siguiente manera (ejemplo tomado de TTfvsDBClientFrameGridConsultas.fvsDBGridResultadoGetPopupOptions):

prxADOClientDM.pAUX_CLASE_SELECCION_CRITERIOS_unit.DataSet       := DataSource.DataSet; // QueryRESULTADO;
prxADOClientDM.pAUX_CLASE_SELECCION_CRITERIOS_unit.Clase         := TprxADODataSetEdit(TprxADOQuery(QueryRESULTADO).MasterDataSet).ppTableName;

Primero asignamos las propiedades:

  • Dataset que se asigna al dataset de la pantalla que llama al auxiliar.
  • Clase se inicializa al nombre de la tabla del componente que está llamando al auxiliar.

Si Exexute retorna True (indicando que se ha definido un SQL para la selección de criterios) toma ese SQL y agrega la opción Definir criterios... al menú local:

if prxADOClientDM.pAUX_CLASE_SELECCION_CRITERIOS_unit.Execute then
   begin
   SQL_Criterios := prxADOClientDM.pAUX_CLASE_SELECCION_CRITERIOS_unit.SQL_COMANDO.Text;

   aPopupMenu.OptionAdd('Definir criterios...', True, 'magnifier_zoom_in', AbrirFormCriterios);
   aPopupMenu.OptionAddSeparator;
   end;

AbrirFormCriterios es una función local que se ocupa de abrir el form TTprxCriteriosConsultasForm de criterios, aplicar el SQL del auxiliar y administrar la selección de valores:

procedure TTfvsDBClientFrameGridConsultas.AbrirFormCriterios(Sender: TObject);
var
  vF: TTprxCriteriosConsultasForm;
begin
  if Assigned(CriteriosForm) = False then
     CriteriosForm := TTprxCriteriosConsultasForm.Create(Self);

  CriteriosForm.GUID := TprxADODataSetEdit(DataSource.DataSet).GUID;
  CriteriosForm.SQL  := SQL_Criterios;
  CriteriosForm.ShowModal;
  CriteriosForm.Release;

  CriteriosForm := nil;

  SQLEjecutar(Sender);
  fvsDBGridResultado.WidthJustify;
end;

Usos

Este auxiliar lo usa: