Diferencia entre revisiones de «TTprxSelectFromGridForm»

De Pragma Wiki
Ir a la navegación Ir a la búsqueda
Línea 26: Línea 26:


=Declaración=
=Declaración=
El form primero declara una clase que permite guardar las distintas sentencias SQL:
<pre>
<pre>
type
  TTprxSelectFromGridFormSentencia = class(TComponent)
  private
    FNombre: String;
    FComandos: TStringList;
  protected
  public
    property    Nombre: String read FNombre write FNombre;
    property    Comandos: TStringList read FComandos write FComandos;
  published
  end;
</pre>
Y la declaración finalmente es:
<pre>
type
  TTprxSelectFromGridForm = class(TTprxForm)
    ActionSELECCION_F5: TAction;
    Panel3: TPanel;
    Panel2: TPanel;
    SpeedButtonVERSENTENCIA: TSpeedButton;
    ButtonSELECCIONAR: TButton;
    ButtonCANCELAR: TButton;
    ComboBoxSENTENCIA: TComboBox;
    Panel1: TPanel;
    prxDBGridSELECCION: TfvsDBGrid;
    PanelPLANILLA: TPanel;
    GroupBox1: TGroupBox;
    Panel5: TPanel;
    Panel6: TPanel;
    Panel7: TPanel;
    Panel8: TPanel;
    Panel9: TPanel;
    prxStaticText1: TStaticText;
    EditPLANILLA: TEdit;
    Panel10: TPanel;
    Panel11: TPanel;
    prxStaticText2: TStaticText;
    Panel12: TPanel;
    Panel13: TPanel;
    StaticText2: TStaticText;
    OpenDialog1: TOpenDialog;
    ComboBoxHOJA: TComboBox;
    prxADODataSetExcel1: TprxADODataSetExcel;
    CheckBoxTODOS: TCheckBox;
    ButtonSELECCIONAR_PLANILLA: TButton;
    ButtonCARGAR_PLANILLA: TButton;
    ComboSetFocus: TAction;
    GrillaSetFocus: TAction;
    procedure FormShow(Sender: TObject);
    procedure ButtonSELECCIONARClick(Sender: TObject);
    procedure ButtonCANCELARClick(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure ComboBoxSENTENCIASelect(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure SpeedButtonVERSENTENCIAClick(Sender: TObject);
    procedure ActionSELECCION_F5Execute(Sender: TObject);
    procedure SpeedButtonPLANILLAClick(Sender: TObject);
    procedure EditPLANILLAExit(Sender: TObject);
    procedure SpeedButtonCARGARClick(Sender: TObject);
    procedure ComboSetFocusExecute(Sender: TObject);
    procedure GrillaSetFocusExecute(Sender: TObject);
    procedure FormProgresoClose(Sender: TObject);
    procedure prxDBGridSELECCIONMouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
    procedure prxDBGridSELECCIONKeyUp(Sender: TObject; var Key: Word; Shift: TShiftState);
    procedure CheckBoxTODOSClick(Sender: TObject);
  private
    FListo: Boolean;
    FSeleccionMultiple: Boolean;
    FImportarPlanilla: Boolean;
    FComando: String;


    FSentenciaDefecto: String;
    FCampoDefecto: String;
    FValorDefecto: String;
    FProgresoForm: TTprxProgresoForm;
    FSeleccionar: Boolean;
  protected
    Sentencias: array of TTprxSelectFromGridFormSentencia;
    SentenciasCount: Integer;
    procedure  SetComando(aValue: String);
    function    PanelPlanillaVisible: Boolean;
    procedure  SetSeleccionar(aValue: Boolean);
    procedure  ImprimirCantidadSeleccionada;
    property    Listo: Boolean read FListo write FListo;
    property    ProgresoForm: TTprxProgresoForm read FProgresoForm write FProgresoForm;
  public
    procedure  AgregarSentencia(aNombre: String; aSentencia: String); overload;
    procedure  AgregarSentencia(aNombre: String; aSentencia: TStringList); overload;
    procedure  Recorrer(aCall: TTprxSelectFromGridFormOnRecord);
    function    ComboBoxELEGIDO: String;
    property    SeleccionMultiple: Boolean read FSeleccionMultiple write FSeleccionMultiple;
    property    ImportarPlanilla: Boolean read FImportarPlanilla write FImportarPlanilla;
    property    SentenciaDefecto: String read FSentenciaDefecto write FSentenciaDefecto;
    property    CampoDefecto: String read FCampoDefecto write FCampoDefecto;
    property    ValorDefecto: String read FValorDefecto write FValorDefecto;
    property    Seleccionar: Boolean read FSeleccionar write SetSeleccionar;
  published
    property    Comando: String read FComando write SetComando;
  end;
</pre>
</pre>
=Implementación=
===procedure FormShow(Sender: TObject)===
Si el form tiene varias sentencias elige a la primera.
El form puede tener dos tipos de selección de registros:
*Simple: solo se puede elegir un registro.
*Múltiple: se pueden elegir varios registros a la vez.

Revisión del 20:32 28 may 2025

Descripción

El objeto TTprxSelectFromGridForm (Form para seleccionar valores.) permite seleccionar valores durante la edición de cualquier tabla. Normalmente se accede a este form presionando F5 sobre cualquier campo que tenga una clave foránea sobre otra tabla (por ejemplo: el campo cliente en una factura).

En su versión más sencilla ejecuta una sentencia SQL que completa la grilla con los registros producto del SQL y el usuario puede seleccionar un registro posicionándose sobre el mismo y picando el botón Seleccionar. Pero el form admite más de una sentencia.

Selección de valores.

Por ejemplo, Elegir sentencia SQL tiene tres elementos:

  • primitivo: el SQL trae los atributos primitivos.
  • clase: el SQL trae los atributos de tipo clase.
  • enumeraciones: el SQL trae los atributos de tipo enumeración.

(Ver Catalogos, tipos de datos disponibles).

Si el form contiene más de una sentencia, cuando cambiamos la sentencia en el combo se refrescan los resultados de la pantalla.

El form también permite importar datos de una planilla Excel, en ese caso habilita un panel superior para elegir la planilla (y hoja) de la computadora:

Importar datos de una planilla.

Identidad

  • Ancestro: TTprxForm
  • Carpeta: C:\DevelopPrx\classes
  • Archivo: prxSelectFromGridForm.PAS

Declaración

El form primero declara una clase que permite guardar las distintas sentencias SQL:

type
  TTprxSelectFromGridFormSentencia = class(TComponent)
  private
    FNombre: String;
    FComandos: TStringList;
  protected
  public
    property    Nombre: String read FNombre write FNombre;
    property    Comandos: TStringList read FComandos write FComandos;
  published
  end;

Y la declaración finalmente es:

type
  TTprxSelectFromGridForm = class(TTprxForm)
    ActionSELECCION_F5: TAction;
    Panel3: TPanel;
    Panel2: TPanel;
    SpeedButtonVERSENTENCIA: TSpeedButton;
    ButtonSELECCIONAR: TButton;
    ButtonCANCELAR: TButton;
    ComboBoxSENTENCIA: TComboBox;
    Panel1: TPanel;
    prxDBGridSELECCION: TfvsDBGrid;
    PanelPLANILLA: TPanel;
    GroupBox1: TGroupBox;
    Panel5: TPanel;
    Panel6: TPanel;
    Panel7: TPanel;
    Panel8: TPanel;
    Panel9: TPanel;
    prxStaticText1: TStaticText;
    EditPLANILLA: TEdit;
    Panel10: TPanel;
    Panel11: TPanel;
    prxStaticText2: TStaticText;
    Panel12: TPanel;
    Panel13: TPanel;
    StaticText2: TStaticText;
    OpenDialog1: TOpenDialog;
    ComboBoxHOJA: TComboBox;
    prxADODataSetExcel1: TprxADODataSetExcel;
    CheckBoxTODOS: TCheckBox;
    ButtonSELECCIONAR_PLANILLA: TButton;
    ButtonCARGAR_PLANILLA: TButton;
    ComboSetFocus: TAction;
    GrillaSetFocus: TAction;
    procedure FormShow(Sender: TObject);
    procedure ButtonSELECCIONARClick(Sender: TObject);
    procedure ButtonCANCELARClick(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure ComboBoxSENTENCIASelect(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure SpeedButtonVERSENTENCIAClick(Sender: TObject);
    procedure ActionSELECCION_F5Execute(Sender: TObject);
    procedure SpeedButtonPLANILLAClick(Sender: TObject);
    procedure EditPLANILLAExit(Sender: TObject);
    procedure SpeedButtonCARGARClick(Sender: TObject);
    procedure ComboSetFocusExecute(Sender: TObject);
    procedure GrillaSetFocusExecute(Sender: TObject);
    procedure FormProgresoClose(Sender: TObject);
    procedure prxDBGridSELECCIONMouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
    procedure prxDBGridSELECCIONKeyUp(Sender: TObject; var Key: Word; Shift: TShiftState);
    procedure CheckBoxTODOSClick(Sender: TObject);
  private
    FListo: Boolean;
    FSeleccionMultiple: Boolean;
    FImportarPlanilla: Boolean;
    FComando: String;

    FSentenciaDefecto: String;
    FCampoDefecto: String;
    FValorDefecto: String;
    FProgresoForm: TTprxProgresoForm;
    FSeleccionar: Boolean;
  protected
    Sentencias: array of TTprxSelectFromGridFormSentencia;
    SentenciasCount: Integer;

    procedure   SetComando(aValue: String);

    function    PanelPlanillaVisible: Boolean;

    procedure   SetSeleccionar(aValue: Boolean);

    procedure   ImprimirCantidadSeleccionada;

    property    Listo: Boolean read FListo write FListo;
    property    ProgresoForm: TTprxProgresoForm read FProgresoForm write FProgresoForm;
  public
    procedure   AgregarSentencia(aNombre: String; aSentencia: String); overload;
    procedure   AgregarSentencia(aNombre: String; aSentencia: TStringList); overload;
    procedure   Recorrer(aCall: TTprxSelectFromGridFormOnRecord);

    function    ComboBoxELEGIDO: String;

    property    SeleccionMultiple: Boolean read FSeleccionMultiple write FSeleccionMultiple;
    property    ImportarPlanilla: Boolean read FImportarPlanilla write FImportarPlanilla;

    property    SentenciaDefecto: String read FSentenciaDefecto write FSentenciaDefecto;
    property    CampoDefecto: String read FCampoDefecto write FCampoDefecto;
    property    ValorDefecto: String read FValorDefecto write FValorDefecto;
    property    Seleccionar: Boolean read FSeleccionar write SetSeleccionar;
  published
    property    Comando: String read FComando write SetComando;
  end;

Implementación

procedure FormShow(Sender: TObject)

Si el form tiene varias sentencias elige a la primera.

El form puede tener dos tipos de selección de registros:

  • Simple: solo se puede elegir un registro.
  • Múltiple: se pueden elegir varios registros a la vez.