unit filtros;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  Grids,Checa, StdCtrls, Buttons, ExtCtrls;

type
  TFormaFiltros = class(TForm)
    TablaFiltros: TStringGrid;
    BitBtn1: TBitBtn;
    BitBtn2: TBitBtn;
    Panel1: TPanel;
    Shape1: TShape;
    Bevel1: TBevel;
    Bevel2: TBevel;
    Bevel3: TBevel;
    Label1: TLabel;
    Label2: TLabel;
    Panel2: TPanel;
    procedure FormCreate(Sender: TObject);
    procedure BitBtn2Click(Sender: TObject);
    procedure BitBtn1Click(Sender: TObject);
    procedure Panel2Click(Sender: TObject);
    procedure Label2MouseDown(Sender: TObject; Button: TMouseButton;
      Shift: TShiftState; X, Y: Integer);
    procedure TablaFiltrosKeyDown(Sender: TObject; var Key: Word;
      Shift: TShiftState);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  FormaFiltros: TFormaFiltros;

procedure ponecampos(tabla:string);
function condiciones:string;

implementation

{$R *.DFM}

function condiciones:string;
var
i:integer;
aux:string;
begin
with FormaFiltros do
begin
aux:='';
for i:=1 to TablaFiltros.RowCount do
begin

{ShowMessage(TablaFiltros.Cells[2,i]);}
if TablaFiltros.Cells[2,i]<>'' then
begin
aux:=aux+TablaFiltros.Cells[0,i]+'*'+TablaFiltros.Cells[2,i]+'*'+TablaFiltros.Cells[3,i]+'*'+TablaFiltros.Cells[4,i]+'*';

end;

end;
condiciones:=aux;
end;
end;

procedure ponecampos(tabla:string);
var
inicio,fin,i,cuenta:integer;

begin
with FormaFiltros do
begin
inicio:=Trunc(rangoscampos(tabla)/1000);
fin:=rangoscampos(tabla)-(inicio*1000);
{ShowMessage(intToStr(inicio)+'  '+intToStr(fin));}
cuenta:=1;
TablaFiltros.RowCount:=2;
for i:=inicio to fin do
begin
TablaFiltros.Cells[0,cuenta]:=leecampos(i,1);
TablaFiltros.Cells[1,cuenta]:=leecampos(i,2);
TablaFiltros.Cells[2,cuenta]:='';
TablaFiltros.Cells[3,cuenta]:='';
TablaFiltros.Cells[4,cuenta]:=leecampos(i,3);;
TablaFiltros.RowCount:=TablaFiltros.RowCount+1;
if (leecampos(i,2)<>'')and (leecampos(i,2)<>'No Disponible') then
cuenta:=cuenta+1;
end;

end;
end;

procedure TFormaFiltros.FormCreate(Sender: TObject);
begin
TablaFiltros.ColWidths[0]:=1;
TablaFiltros.ColWidths[1]:=120;
TablaFiltros.ColWidths[2]:=60;
TablaFiltros.ColWidths[3]:=60;
TablaFiltros.ColWidths[4]:=1;

TablaFiltros.Cells[0,0]:='Clave';
TablaFiltros.Cells[1,0]:='Campo';
TablaFiltros.Cells[2,0]:='Condición';
TablaFiltros.Cells[3,0]:='Valor';
end;

procedure TFormaFiltros.BitBtn2Click(Sender: TObject);
begin
Tag:=0;
Close;
end;

procedure TFormaFiltros.BitBtn1Click(Sender: TObject);
begin
Tag:=1;
Close;
end;




procedure TFormaFiltros.Panel2Click(Sender: TObject);
begin
Close;
end;






procedure TFormaFiltros.Label2MouseDown(Sender: TObject;
  Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
ReleaseCapture;
SendMessage(FormaFiltros.Handle, WM_SYSCOMMAND, $F012, 0);

end;

procedure TFormaFiltros.TablaFiltrosKeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
{if key=13 then
TablaFiltros.}
end;


end.
