unit uViewFiltroBase; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, cxMaskEdit, cxDropDownEdit, cxCalendar, dxLayoutControl, cxContainer, cxEdit, cxTextEdit, dxLayoutLookAndFeels, cxControls, StdCtrls, Buttons, cxRadioGroup, TBXDkPanels, TB2ExtItems, TBXExtItems, TBX, TB2Item, TB2Dock, TB2Toolbar, ActnList, ImgList, PngImageList, uViewBase; type IViewFiltroBase = interface(IViewBase) ['{0D0EA630-BF93-4BA1-93C2-FD5A5B0CBEED}'] function GetFiltrosChange: TNotifyEvent; procedure SetFiltrosChange(const Value: TNotifyEvent); property OnFiltrosChange: TNotifyEvent read GetFiltrosChange write SetFiltrosChange; function GetVerFiltros: Boolean; procedure SetVerFiltros(const Value: Boolean); property VerFiltros: Boolean read GetVerFiltros write SetVerFiltros; function GetTexto: String; procedure SetTexto(const Value: String); property Texto: String read GetTexto write SetTexto; function GetTexto2: String; procedure SetTexto2(const Value: String); property Texto2: String read GetTexto2 write SetTexto2; end; TfrViewFiltroBase = class(TfrViewBase, IViewFiltroBase) dxLayoutControl1Group_Root: TdxLayoutGroup; dxLayoutControl1: TdxLayoutControl; dxLayoutLookAndFeelList1: TdxLayoutLookAndFeelList; dxLayoutControl1Item1: TdxLayoutItem; txtFiltroTodo: TcxTextEdit; dxLayoutControl1Item2: TdxLayoutItem; edtFechaIniFiltro: TcxDateEdit; dxLayoutControl1Item3: TdxLayoutItem; edtFechaFinFiltro: TcxDateEdit; dxLayoutControl1Group1: TdxLayoutGroup; TBXDockablePanel1: TTBXDockablePanel; ActionList1: TActionList; actQuitarFiltro: TAction; PngImageList: TPngImageList; tbxBotones: TTBXToolbar; TBXItem2: TTBXItem; TBXAlignmentPanel1: TTBXAlignmentPanel; dxLayoutControl1Item4: TdxLayoutItem; txtFiltroTodo2: TcxTextEdit; dxLayoutControl1Group2: TdxLayoutGroup; procedure OnCamposFiltroChange(Sender: TObject); procedure actQuitarFiltroExecute(Sender: TObject); private FOnFiltrosChange: TNotifyEvent; function GetFiltrosChange: TNotifyEvent; procedure SetFiltrosChange(const Value: TNotifyEvent); function GetVerFiltros: Boolean; procedure SetVerFiltros(const Value: Boolean); function GetTexto: String; procedure SetTexto(const Value: String); function GetTexto2: String; procedure SetTexto2(const Value: String); protected procedure LimpiarCampos; virtual; function ValidarCampos: Boolean; virtual; function GetModified: Boolean; override; public property OnFiltrosChange: TNotifyEvent read GetFiltrosChange write SetFiltrosChange; property VerFiltros: Boolean read GetVerFiltros write SetVerFiltros; property Texto: String read GetTexto write SetTexto; property Texto2: String read GetTexto2 write SetTexto2; end; implementation {$R *.dfm} uses uDialogUtils; { TfrViewFiltroBase } function TfrViewFiltroBase.GetFiltrosChange: TNotifyEvent; begin Result := FOnFiltrosChange; end; function TfrViewFiltroBase.GetModified: Boolean; begin Result := False; end; procedure TfrViewFiltroBase.SetFiltrosChange(const Value: TNotifyEvent); begin FOnFiltrosChange := Value; end; function TfrViewFiltroBase.GetVerFiltros: Boolean; begin Result := Self.Visible; end; procedure TfrViewFiltroBase.SetVerFiltros(const Value: Boolean); begin Self.Visible := Value; if not Self.Visible then actQuitarFiltro.Execute; end; procedure TfrViewFiltroBase.LimpiarCampos; begin txtFiltroTodo.Clear; // txtFiltroTodo2.Clear; edtFechaIniFiltro.Clear; edtFechaFinFiltro.Clear; end; procedure TfrViewFiltroBase.OnCamposFiltroChange(Sender: TObject); begin if ValidarCampos then if Assigned(FOnFiltrosChange) then FOnFiltrosChange(Sender); end; function TfrViewFiltroBase.ValidarCampos: Boolean; begin Result := True; if not VarIsNull(edtFechaIniFiltro.EditValue) and not VarIsNull(edtFechaFinFiltro.EditValue) then begin if (edtFechaIniFiltro.EditValue > edtFechaFinFiltro.EditValue) then begin ShowWarningMessage('La fecha de inicio debe ser anterior a la fecha final'); edtFechaIniFiltro.SetFocus; Result := False; end end; end; procedure TfrViewFiltroBase.actQuitarFiltroExecute(Sender: TObject); begin LimpiarCampos; if Assigned(FOnFiltrosChange) then FOnFiltrosChange(Sender); end; function TfrViewFiltroBase.GetTexto: String; begin Result := txtFiltroTodo.Text; end; function TfrViewFiltroBase.GetTexto2: String; begin // Result := txtFiltroTodo2.Text; end; procedure TfrViewFiltroBase.SetTexto(const Value: String); begin txtFiltroTodo.Text := Value; end; procedure TfrViewFiltroBase.SetTexto2(const Value: String); begin txtFiltroTodo.Text := Value; end; end.