unit UBuscarBimExt;

interface

uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
  Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Data.DB, Vcl.StdCtrls, Vcl.Buttons,
  Data.Win.ADODB, Vcl.Grids, Vcl.DBGrids;

type
  TFBuscarBimestreExt = class(TForm)
    DBGrid1: TDBGrid;
    QBimestres: TADOQuery;
    QBimestresIdBimestre: TAutoIncField;
    QBimestresAnio: TSmallintField;
    QBimestresFecha_elab: TDateTimeField;
    QBimestresBimestre: TWordField;
    QBimestresObservaciones: TWideStringField;
    QBimestresNomMes: TStringField;
    DSBimestres: TDataSource;
    CBMes: TComboBox;
    BitBtn2: TBitBtn;
    BitBtn1: TBitBtn;
    CBAnio: TComboBox;
    Label2: TLabel;
    Label1: TLabel;
    procedure CBAnioChange(Sender: TObject);
    procedure FormCreate(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  FBuscarBimestreExt: TFBuscarBimestreExt;

implementation

{$R *.dfm}

uses Udm;

procedure buscar(anio : string; mes:string; elquery:TAdoQuery);
var
  txtBus : string;
  begin
    begin
       elquery.Active:= false;
       txtbus:= 'Select * from BimestresExt where Anio = ' + anio + ' and Bimestre = ' + mes;
       elquery.SQL.Clear;
       elquery.SQL.Add(txtbus);
       elquery.Active:= true;
    end;
  end;



procedure TFBuscarBimestreExt.CBAnioChange(Sender: TObject);
 var
   val : integer;
begin
val :=  CBMes.ItemIndex + 1;
if val = 0 then
   inc(val);
  buscar(CBAnio.Text, inttostr(val), QBimestres);
end;

procedure TFBuscarBimestreExt.FormCreate(Sender: TObject);
begin
 CBAnio.Text:= CBAnio.Items[0];
 CBMes.Text:= CBMes.Items[0]
end;

end.
