infoquery.pas
上传用户:blmaxia
上传日期:2010-02-17
资源大小:657k
文件大小:7k
- unit infoquery;
- interface
- uses
- Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
- Dialogs, StdCtrls, ComCtrls, data;
- type
- Tqueryform = class(TForm)
- PageControl1: TPageControl;
- TabSheet1: TTabSheet;
- TabSheet2: TTabSheet;
- TabSheet3: TTabSheet;
- GroupBox1: TGroupBox;
- RadioButton1: TRadioButton;
- RadioButton2: TRadioButton;
- RadioButton3: TRadioButton;
- RadioButton4: TRadioButton;
- CheckBox1: TCheckBox;
- Label1: TLabel;
- Edit3: TEdit;
- Button1: TButton;
- Button2: TButton;
- ListView1: TListView;
- StaticText2: TStaticText;
- GroupBox2: TGroupBox;
- RadioButton5: TRadioButton;
- RadioButton6: TRadioButton;
- CheckBox2: TCheckBox;
- Label2: TLabel;
- Edit1: TEdit;
- Button3: TButton;
- ListView2: TListView;
- StaticText4: TStaticText;
- GroupBox3: TGroupBox;
- RadioButton7: TRadioButton;
- CheckBox3: TCheckBox;
- Label3: TLabel;
- Edit2: TEdit;
- Button4: TButton;
- ListView3: TListView;
- StaticText6: TStaticText;
- procedure RadioButton1Click(Sender: TObject);
- procedure RadioButton2Click(Sender: TObject);
- procedure RadioButton3Click(Sender: TObject);
- procedure RadioButton4Click(Sender: TObject);
- procedure Edit2KeyDown(Sender: TObject; var Key: Word;
- Shift: TShiftState);
- procedure Button4Click(Sender: TObject);
- procedure Button1Click(Sender: TObject);
- procedure Button3Click(Sender: TObject);
- procedure Button2Click(Sender: TObject);
- private
- { Private declarations }
- public
- { Public declarations }
- end;
- var
- queryform: Tqueryform;
- implementation
- {$R *.dfm}
- procedure Tqueryform.RadioButton1Click(Sender: TObject);
- begin
- edit3.Text :='';
- edit3.MaxLength:=10;
- end;
- procedure Tqueryform.RadioButton2Click(Sender: TObject);
- begin
- edit3.Text :='';
- edit3.MaxLength:=0;
- end;
- procedure Tqueryform.RadioButton3Click(Sender: TObject);
- begin
- edit3.Text :='';
- edit3.MaxLength:=0;
- end;
- procedure Tqueryform.RadioButton4Click(Sender: TObject);
- begin
- edit3.Text :='';
- edit3.MaxLength:=0;
- end;
- procedure Tqueryform.Edit2KeyDown(Sender: TObject; var Key: Word;
- Shift: TShiftState);
- begin
- if key=13 then
- button4click(sender);
- end;
- procedure Tqueryform.Button4Click(Sender: TObject);
- var
- content:string;
- begin
- try
- listview3.Items.Clear ;
- with datamoduleado.ADOQuery1 do
- begin
- content:=edit2.Text ;
- if checkbox3.Checked then
- content:='%'+content+'%';
- sql.Clear ;
- if radiobutton7.Checked then
- begin
- sql.Add('select lend.readerid ,name,sex,idcardno,outdate,code from lend,reader where lend.readerid like :readerid and reader.readerid=lend.readerid order by lend.readerid');
- parameters.ParamByName('readerid').Value :=content;
- end;
- open;
- while not eof do
- begin
- with listview3.Items.Add do
- begin
- caption:=fieldbyname('readerid').AsString ;
- subitems.add(fieldbyname('name').AsString );
- if fieldbyname('sex').AsString ='1' then
- subitems.add('女')
- else
- subitems.add('男');
- subitems.add(fieldbyname('code').AsString );
- subitems.add(fieldbyname('outdate').AsString );
- subitems.add(floattostr(date-fieldbyname('outdate').AsDateTime));
- subitems.add(fieldbyname('idcardno').AsString );
- if date-fieldbyname('outdate').AsDateTime >60 then
- subitems.Add(floattostr((date-fieldbyname('outdate').AsDateTime -60)*0.1))
- else
- subitems.add('0');
- end;
- next;
- end;
- statictext6.Caption :='共'+inttostr(recordcount)+'条记录';
- close;
- end;
- except
- messagedlg('查询失败',mterror,[mbok],0);
- end;
- end;
- procedure Tqueryform.Button1Click(Sender: TObject);
- begin
- close;
- end;
- procedure Tqueryform.Button3Click(Sender: TObject);
- var
- content:string;
- begin
- try
- listview2.Items.Clear ;
- with datamoduleado.ADOQuery1 do
- begin
- content:=edit1.Text ;
- if checkbox2.Checked then
- content:='%'+content+'%';
- sql.Clear ;
- if radiobutton5.Checked then
- begin
- sql.Add('select readerid,name,sex,idcardno from reader where readerid like :readerid ');
- parameters.ParamByName('readerid').Value :=content;
- end;
- if radiobutton6.Checked then
- begin
- sql.Add('select readerid,name,sex,idcardno from reader where name like :name ');
- parameters.ParamByName('name').Value :=content;
- end;
- open;
- while not eof do
- begin
- with listview2.Items.Add do
- begin
- caption:=fieldbyname('readerid').AsString ;
- subitems.add(fieldbyname('name').AsString );
- if fieldbyname('sex').AsString ='1' then
- subitems.add('女')
- else
- subitems.add('男');
- subitems.add(fieldbyname('idcardno').AsString );
- end;
- next;
- end;
- statictext4.Caption :='共'+inttostr(recordcount)+'条记录';
- close;
- end;
- except
- messagedlg('查询失败',mterror,[mbok],0);
- end;
- end;
- procedure Tqueryform.Button2Click(Sender: TObject);
- var
- content:string;
- begin
- try
- listview1.Items.Clear ;
- with datamoduleado.ADOQuery1 do
- begin
- content:=edit3.Text ;
- if checkbox1.Checked then
- content:='%'+content+'%';
- sql.Clear ;
- if radiobutton1.Checked then
- begin
- sql.Add('select code,name,author,press,outdate,cost,memo0 from book where code like :code ');
- parameters.ParamByName('code').Value :=content;
- end;
- if radiobutton2.Checked then
- begin
- sql.Add('select code,name,author,press,outdate,cost,memo0 from book where name like :name ');
- parameters.ParamByName('name').Value :=content;
- end;
- if radiobutton3.Checked then
- begin
- sql.Add('select code,name,author,press,outdate,cost,memo0 from book where press like :press ');
- parameters.ParamByName('press').Value :=content;
- end;
- if radiobutton4.Checked then
- begin
- sql.Add('select code,name,author,press,outdate,cost,memo0 from book where author like :author ');
- parameters.ParamByName('author').Value :=content;
- end;
- open;
- while not eof do
- begin
- with listview1.Items.Add do
- begin
- caption:=fieldbyname('code').AsString ;
- subitems.add(fieldbyname('name').AsString );
- subitems.add(fieldbyname('author').AsString );
- subitems.add(fieldbyname('press').AsString );
- subitems.add(fieldbyname('outdate').AsString );
- subitems.add(floattostr(fieldbyname('cost').AsFloat));
- subitems.add(fieldbyname('memo0').AsString );
- end;
- next;
- end;
- statictext2.Caption :='共'+inttostr(recordcount)+'条记录';
- close;
- end;
- except
- messagedlg('查询失败',mterror,[mbok],0);
- end;
- end;
- end.