《图书查询系统代码.docx》由会员分享,可在线阅读,更多相关《图书查询系统代码.docx(37页珍藏版)》请在三一办公上搜索。
1、图书查询系统代码1、主窗体代码 unit MainU; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, Buttons, ToolWin, ComCtrls,jpeg, Menus,DB, ADODB, ExtCtrls; type TMainF = class(TForm) MainMenu1: TMainMenu; N1: TMenuItem; N2: TMenuItem; N3: TMenuItem; N4: TMenu
2、Item; N5: TMenuItem; N6: TMenuItem; N7: TMenuItem; N8: TMenuItem; N9: TMenuItem; N10: TMenuItem; N11: TMenuItem; N12: TMenuItem; N13: TMenuItem; N14: TMenuItem; ToolBar1: TToolBar; BookQueryBitBtn1: TBitBtn; BitBtn2: TBitBtn; BitBtn3: TBitBtn; BitBtn4: TBitBtn; BitBtn5: TBitBtn; Image1: TImage; ADOC
3、onnection1: TADOConnection; ADOTable1: TADOTable; N15: TMenuItem; N16: TMenuItem; N17: TMenuItem; N18: TMenuItem; ToolBar2: TToolBar; BitBtn1: TBitBtn; BitBtn6: TBitBtn; BitBtn7: TBitBtn; procedure FormCreate(Sender: TObject); procedure N13Click(Sender: TObject); procedure N3Click(Sender: TObject);
4、procedure N14Click(Sender: TObject); procedure BitBtn2Click(Sender: TObject); procedure BookQueryBitBtn1Click(Sender: TObject); procedure N2Click(Sender: TObject); procedure N4Click(Sender: TObject); procedure N5Click(Sender: TObject); procedure N10Click(Sender: TObject); procedure N11Click(Sender:
5、TObject); procedure N6Click(Sender: TObject); procedure BitBtn3Click(Sender: TObject); procedure BitBtn4Click(Sender: TObject); procedure BitBtn5Click(Sender: TObject); procedure N7Click(Sender: TObject); procedure N16Click(Sender: TObject); procedure N17Click(Sender: TObject); procedure N18Click(Se
6、nder: TObject); procedure BitBtn1Click(Sender: TObject); procedure BitBtn6Click(Sender: TObject); procedure BitBtn7Click(Sender: TObject); procedure Formclose(Sender: TObject); private Private declarations public Logined:Boolean; Public declarations end; var MainF: TMainF; MyPath:String; const MyPas
7、sW=1111; implementation uses ReaderQuery,BookQuery,kucun,HelpForm,JieHuanQuery,About,QD,UserQueryForm; $R *.dfm procedure TMainF.FormCreate(Sender: TObject); begin dengluU, MyPath:=ExtractFilePath(ParamStr(0); ShortDateFormat:=yyyy/mm/dd; MainF.ToolBar1.Visible:=false; MainF.ToolBar2.Visible:=false;
8、 MainF.N15.Enabled:=false; end; procedure TMainF.N13Click(Sender: TObject); /单击该按钮,显示对应窗体 begin application.Initialize; denglu:=tdenglu.Create(application); denglu.Show; end; procedure TMainF.N3Click(Sender: TObject); /单击该按钮,显示对应窗体 begin application.Initialize; ReaderQueryForm:=TReaderQueryForm.Crea
9、te(application); ReaderQueryForm.Show; end; procedure TMainF.N14Click(Sender: TObject); begin if messagedlg(真的要退出系统吗?,mtconfirmation,mbYes,mbNo,0)=mryes then close; adotable1.Open; adotable1.last; adotable1.edit; adotable1.FieldByName(downtime).AsDateTime:=now; adotable1.Post; adotable1.Close; end;
10、/单击该按钮,显示对应窗体 procedure TMainF.Formclose(Sender: TObject); /关闭主窗体 begin adotable1.Open; adotable1.last; adotable1.edit; adotable1.FieldByName(downtime).AsDateTime:=now; adotable1.Post; adotable1.Close; 才 end; procedure TMainF.BitBtn2Click(Sender: TObject); /单击该按钮,显示对应窗体 begin application.Initialize;
11、 ReaderQueryForm:=TReaderQueryForm.Create(application); ReaderQueryForm.Show; end; procedure TMainF.BookQueryBitBtn1Click(Sender: TObject); /单击该按钮,显示对应窗体 begin application.Initialize; BookQueryForm:=TBookQueryForm.Create(application); BookQueryForm.Show; end; procedure TMainF.N2Click(Sender: TObject
12、); /单击该按钮,显示对应窗体 begin application.Initialize; BookQueryForm:=TBookQueryForm.Create(application); BookQueryForm.Show; end; procedure TMainF.N4Click(Sender: TObject); /单击该按钮,显示对应窗体 begin application.Initialize; UserQuery:=TUserQuery.Create(application); UserQuery.Show; end; procedure TMainF.N5Click(S
13、ender: TObject); /单击该按钮,显示对应窗体 begin application.Initialize; kucunQuery:=TKucunQuery.Create(application); KucunQuery.Show; end; procedure TMainF.N10Click(Sender: TObject); /单击该按钮,显示对应窗体 begin application.Initialize; AboutForm:=TAboutForm.Create(application); AboutForm.Show; end; procedure TMainF.N11
14、Click(Sender: TObject); /单击该按钮,显示对应窗体 begin application.Initialize; help:=Thelp.Create(application); help.Show; end; procedure TMainF.N6Click(Sender: TObject); /单击该按钮,显示对应窗体 begin application.Initialize; JHQuery:=TJHQuery.Create(application); JHQuery.Show; end; procedure TMainF.BitBtn3Click(Sender:
15、TObject); /单击该按钮,显示对应窗体 begin application.Initialize; UserQuery:=TUserQuery.Create(application); UserQuery.Show; end; procedure TMainF.BitBtn4Click(Sender: TObject); /单击该按钮,显示对应窗体 begin application.Initialize; kucunQuery:=TKucunQuery.Create(application); KucunQuery.Show; end; procedure TMainF.BitBtn
16、5Click(Sender: TObject); /单击该按钮,显示对应窗体 begin application.Initialize; JHQuery:=TJHQuery.Create(application); JHQuery.Show; end; procedure TMainF.N7Click(Sender: TObject); begin if messagedlg(真的要退出查询系统吗?,mtconfirmation,mbYes,mbNo,0)=mryes then Close; mainf.ADOTable1.Open; mainf.ADOTable1.last; mainf.A
17、DOTable1.edit; mainf.ADOTable1.FieldByName(downtime).AsDateTime:=now; mainf.ADOTable1.Post; mainf.ADOTable1.Close; end; /对用户表进行操作,将用户退出系统的时间加入表中 procedure TMainF.N16Click(Sender: TObject); /单击该按钮,显示对应窗体 begin application.Initialize; BookQueryForm:=TBookQueryForm.Create(application); BookQueryForm.Sh
18、ow; end; procedure TMainF.N17Click(Sender: TObject); begin application.Initialize; ReaderQueryForm:=TReaderQueryForm.Create(application); /单击该按钮,显示对应窗体 ReaderQueryForm.Show; end; procedure TMainF.N18Click(Sender: TObject); /单击该按钮,显示对应窗体 begin application.Initialize; JHQuery:=TJHQuery.Create(applicat
19、ion); JHQuery.Show; end; procedure TMainF.BitBtn1Click(Sender: TObject); /单击该按钮,显示对应窗体 begin application.Initialize; BookQueryForm:=TBookQueryForm.Create(application); BookQueryForm.Show; end; procedure TMainF.BitBtn6Click(Sender: TObject); begin application.Initialize; kucunQuery:=TKucunQuery.Creat
20、e(application); KucunQuery.Show; end; procedure TMainF.BitBtn7Click(Sender: TObject); /单击该按钮,显示对应窗体 begin application.Initialize; JHQuery:=TJHQuery.Create(application); JHQuery.Show; end; end. 2、图书查询代码 unit BookQuery; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls,
21、 Forms, Dialogs, StdCtrls, ComCtrls, Buttons; type TBookQueryForm = class(TForm) PageControl1: TPageControl; TabSheet1: TTabSheet; GroupBox1: TGroupBox; RadioButton1: TRadioButton; RadioButton2: TRadioButton; RadioButton3: TRadioButton; RadioButton4: TRadioButton; RadioButton5: TRadioButton; GroupBo
22、x2: TGroupBox; Label1: TLabel; Edit1: TEdit; CheckBox1: TCheckBox; BitBtn1: TBitBtn; GroupBox3: TGroupBox; ListView1: TListView; BitBtn2: TBitBtn; StaticText1: TStaticText; procedure BitBtn1Click(Sender: TObject); procedure RadioButton1Click(Sender: TObject); procedure RadioButton2Click(Sender: TObj
23、ect); procedure RadioButton3Click(Sender: TObject); procedure RadioButton4Click(Sender: TObject); procedure RadioButton5Click(Sender: TObject); procedure Edit1KeyPress(Sender: TObject; var Key: Char); procedure Edit1KeyDown(Sender: TObject; var Key: Word; Shift: TShiftState); procedure BitBtn2Click(
24、Sender: TObject); private Private declarations public Public declarations end; var BookQueryForm: TBookQueryForm; implementation uses datamodule; $R *.dfm procedure TBookQueryForm.BitBtn1Click(Sender: TObject); var Content : string; begin try ListView1.Items.Clear; with DataModuleADO.ADOQuery1 do be
25、gin if ( not RadioButton1.Checked) and (not RadioButton2.Checked) and( not RadioButton3.Checked) and (not RadioButton4.Checked ) and( not RadioButton5.Checked ) or (not checkbox1.Checked) or (edit1.Text =) and (not checkbox1.Checked) then begin showMessage(查询条件未选择!或者查询内容为空); edit1.SetFocus; edit1.Se
26、lectAll; exit; end; Content:=Edit1.Text; if CheckBox1.Checked then Content := %+Content +%; close; SQL.Clear; if RadioButton1.Checked then begin SQL.Add(select * from book where bookcode like :bookcode); Parameters.ParamByName(bookcode).value := Content; end; if RadioButton2.Checked then begin SQL.A
27、dd(select * from book where bookname like :bookname); Parameters.ParamByName(bookname).value := Content; end; if RadioButton3.Checked then begin SQL.Add(select * from book where author like :author); Parameters.ParamByName(author).value := Content; end; if RadioButton4.Checked then begin SQL.Add(sel
28、ect * from book where bookman like :bookman); Parameters.ParamByName(bookman).value := Content; end; if RadioButton5.Checked then begin SQL.Add(select * from book where bookkind like :bookkind); Parameters.ParamByName(bookkind).value := Content; end; Open; while not Eof do begin with ListView1.Items
29、.Add do begin Caption := FieldByName(bookcode).AsString; SubItems.Add(FieldByName(bookname).AsString); SubItems.Add(FieldByName(author).AsString); SubItems.Add(FieldByName(bookman).AsString); SubItems.Add(FieldByName(bookkind).AsString); SubItems.Add(FieldByName(bookprice).AsString); SubItems.Add(Fi
30、eldByName(bookproduceday).AsString); SubItems.Add(FieldByName(booklast).AsString); end; Next; end; StaticText1.Caption:= 共+IntToStr(RecordCount)+条记录; Close; end; except MessageDlg(查询失败,mtError,mbok,0); end; end; procedure TBookQueryForm.Edit1KeyPress(Sender: TObject; var Key: Char); begin if length(
31、edit1.text)20 then begin messagedlg(已经超出范围!,mtwarning,mbok,0); edit1.SetFocus; exit; end ; end; procedure TBookQueryForm.RadioButton1Click(Sender: TObject); begin Edit1.Text := ; Edit1.MaxLength := 10; end; procedure TBookQueryForm.RadioButton2Click(Sender: TObject); begin Edit1.Text := ; Edit1.MaxL
32、ength := 0; end; procedure TBookQueryForm.RadioButton3Click(Sender: TObject); begin Edit1.Text := ; Edit1.MaxLength := 0; end; procedure TBookQueryForm.RadioButton4Click(Sender: TObject); begin Edit1.Text := ; Edit1.MaxLength := 0; end; procedure TBookQueryForm.RadioButton5Click(Sender: TObject); be
33、gin Edit1.Text := ; Edit1.MaxLength := 10; end; procedure TBookQueryForm.Edit1KeyDown(Sender: TObject; var Key: Word;Shift: TShiftState); begin if Key =13 then BitBtn1Click(Sender); end; procedure TBookQueryForm.BitBtn2Click(Sender: TObject); begin close; end; end. 3、读者查询代码 unit ReaderQuery; interfa
34、ce uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, ComCtrls, StdCtrls, Buttons,ADODB, DB, Grids, DBGrids; type TReaderQueryForm = class(TForm) PageControl1: TPageControl; TabSheet1: TTabSheet; GroupBox1: TGroupBox; RadioButton1: TRadioButton; RadioButton2: TR
35、adioButton; RadioButton3: TRadioButton; RadioButton4: TRadioButton; GroupBox2: TGroupBox; Label1: TLabel; Edit1: TEdit; CheckBox1: TCheckBox; BitBtn1: TBitBtn; GroupBox3: TGroupBox; BitBtn2: TBitBtn; StaticText1: TStaticText; ListView1: TListView; procedure RadioButton1Click(Sender: TObject); proced
36、ure RadioButton2Click(Sender: TObject); procedure RadioButton3Click(Sender: TObject); procedure RadioButton4Click(Sender: TObject); procedure RadioButton5Click(Sender: TObject); procedure BitBtn1Click(Sender: TObject); procedure Edit1KeyPress(Sender: TObject; var Key: Char); procedure Edit1KeyDown(S
37、ender: TObject; var Key: Word; Shift: TShiftState); procedure BitBtn2Click(Sender: TObject); private Private declarations public Public declarations end; var ReaderQueryForm: TReaderQueryForm; implementation uses datamodule; $R *.dfm procedure TReaderQueryForm.RadioButton1Click(Sender: TObject); /给文
38、本框赋空值,并限制用户最大输入字符长度 begin Edit1.Text := ; Edit1.MaxLength := 10; end; procedure TReaderQueryForm.RadioButton2Click(Sender: TObject); /给文本框赋空值 begin Edit1.Text := ; Edit1.MaxLength := 0; end; procedure TReaderQueryForm.RadioButton3Click(Sender: TObject); begin Edit1.Text := ; Edit1.MaxLength := 0; en
39、d; procedure TReaderQueryForm.RadioButton4Click(Sender: TObject); begin Edit1.Text := ; Edit1.MaxLength := 0; end; procedure TReaderQueryForm.RadioButton5Click(Sender: TObject); begin Edit1.Text := ; /限制用户输入的最大字符长度 Edit1.MaxLength := 10; end; procedure TReaderQueryForm.Edit1KeyDown(Sender: TObject;
40、var Key: TShiftState); begin if Key =13 then /判断用户是否输入结束 BitBtn1Click(Sender); end; procedure TReaderQueryForm.BitBtn1Click(Sender: TObject); var Content : string; begin try ListView1.Items.Clear; with DataModuleADO.ADOQuery1 do begin if ( not RadioButton1.Checked) and (not RadioButton2.Checked) /异常
41、处理 and( not RadioButton3.Checked) and (not RadioButton4.Checked) and (not checkbox1.Checked) or (edit1.Text =) and (not checkbox1.Checked) then begin showMessage(查询条件未选择!或者查询内容为空); Word;Shift: exit; end; begin Content:=Edit1.Text; if CheckBox1.Checked then Content := %+Content +%; Close; SQL.Clear; if RadioButton1.Checked then /查询相关的关键字 begin SQL.Add(select * from yonghu where usercode like :usercode); Parameters.ParamByName(usercode).value := Content; end; if RadioButton2.Checked then begin SQL.Add(select * from yonghu where username like :username); Parameters.ParamBy
链接地址:https://www.31ppt.com/p-3377647.html