📄 unit4.pas
字号:
unit Unit4;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ADODB, DB, Menus, StdCtrls, Grids, DBGrids, Buttons, ExtCtrls,
ToolWin, ComCtrls, jpeg;
type
TForm4 = class(TForm)
Image1: TImage;
CoolBar1: TCoolBar;
Panel1: TPanel;
SpeedButton5: TSpeedButton;
BitBtn1: TBitBtn;
BitBtn2: TBitBtn;
BitBtn3: TBitBtn;
StaticText1: TStaticText;
StaticText7: TStaticText;
Panel2: TPanel;
SpeedButton1: TSpeedButton;
SpeedButton2: TSpeedButton;
SpeedButton3: TSpeedButton;
SpeedButton4: TSpeedButton;
BitBtn4: TBitBtn;
BitBtn5: TBitBtn;
BitBtn6: TBitBtn;
BitBtn7: TBitBtn;
DBGrid1: TDBGrid;
StaticText2: TStaticText;
StaticText3: TStaticText;
StaticText4: TStaticText;
StaticText5: TStaticText;
StaticText6: TStaticText;
StaticText8: TStaticText;
RadioButton1: TRadioButton;
RadioButton2: TRadioButton;
Edit1: TEdit;
Edit2: TEdit;
Edit3: TEdit;
Edit4: TEdit;
Edit6: TEdit;
Edit7: TEdit;
MainMenu1: TMainMenu;
N1: TMenuItem;
N2: TMenuItem;
N3: TMenuItem;
N4: TMenuItem;
N5: TMenuItem;
N6: TMenuItem;
N7: TMenuItem;
N8: TMenuItem;
N12: TMenuItem;
N15: TMenuItem;
N9: TMenuItem;
N10: TMenuItem;
N11: TMenuItem;
N13: TMenuItem;
N14: TMenuItem;
ADOTable1: TADOTable;
DataSource1: TDataSource;
ADOQuery1: TADOQuery;
ADOQuery2: TADOQuery;
ADOTable2: TADOTable;
ADOQuery3: TADOQuery;
ADOTable3: TADOTable;
procedure BitBtn1Click(Sender: TObject);
procedure BitBtn2Click(Sender: TObject);
procedure BitBtn3Click(Sender: TObject);
procedure BitBtn4Click(Sender: TObject);
procedure BitBtn5Click(Sender: TObject);
procedure BitBtn6Click(Sender: TObject);
procedure BitBtn7Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form4: TForm4;
implementation
uses Unit1, Unit7,Unit5, Unit3, Unit10;
{$R *.dfm}
procedure TForm4.BitBtn6Click(Sender: TObject);
begin
StaticText7.Caption:='学生图书馆系统';
StaticText2.Caption:='书籍编号';
StaticText3.Caption:='书籍名称';
StaticText4.Caption:=' 作 者';
StaticText5.Caption:='出版社';
StaticText6.Caption:=' 价 格';
StaticText8.Caption:='书籍位置';
ADOQuery1.Close;
ADOQuery1.SQL.Clear; ADOQuery1.SQL.Add('select * from 学生借书信息表 where 学号 = ( select 学号 from 学生图书馆帐号表 where 帐号='''+form1.Edit1.Text+''')'); ADOQuery1.Open;
if ADOQuery1.Recordset.RecordCount=0 then
begin
application.MessageBox('所借的书已经全还!','提示',64);
end
end;
procedure TForm4.BitBtn4Click(Sender: TObject);
begin
StaticText7.Caption:='学生图书馆系统';
StaticText2.Caption:='书籍编号';
StaticText3.Caption:='书籍名称';
StaticText4.Caption:=' 作 者';
StaticText5.Caption:='出版社';
StaticText6.Caption:=' 价 格';
StaticText8.Caption:='书籍位置';
BitBtn5.Enabled:=true;
if RadioButton1.Checked then
begin
if Edit1.Text<>'' then
begin
ADOQuery1.Close;
ADOQuery1.SQL.Clear; ADOQuery1.SQL.Add('select * from 书籍信息表 where 书籍编号='''+Edit1.Text+''''); ADOQuery1.Open;
if ADOQuery1.Recordset.RecordCount=0 then
begin
application.MessageBox('该书籍不存在','提示',64);
end
else
begin
edit2.Text:=adoquery1.FieldByName('名称').AsString;
edit3.Text:=adoquery1.FieldByName('作者').AsString;
edit4.Text:=adoquery1.FieldByName('价格').AsString;
edit6.Text:=adoquery1.FieldByName('书籍位置').AsString;
edit7.Text:=adoquery1.FieldByName('出版社').AsString;
end
end
else
begin
if edit2.Text<>'' then
begin
ADOQuery1.Close;
ADOQuery1.SQL.Clear; ADOQuery1.SQL.Add('select * from 书籍信息表 where 名称='''+Edit2.Text+''''); ADOQuery1.Open;
if ADOQuery1.Recordset.RecordCount=0 then
begin
application.MessageBox('该书籍不存在','提示',64);
end
end
else
begin
application.MessageBox('请输入书籍编号或书籍名称!','提示',64);
end
end
end
else
begin
if RadioButton2.Checked then
begin
if edit2.Text<>'' then
begin
ADOQuery1.Close;
ADOQuery1.SQL.Clear; ADOQuery1.SQL.Add('select * from 书籍信息表 where 名称 like ''%'+Edit2.Text+'%'''); ADOQuery1.Open;
if ADOQuery1.Recordset.RecordCount=0 then
begin
application.MessageBox('该书籍不存在','提示',64);
end
end
end
else
begin
application.MessageBox('请选择查询条件','提示',64);
end
end
end;
procedure TForm4.BitBtn5Click(Sender: TObject);
var
s0:string;
begin
s0:='已借';
BitBtn5.Enabled:=false;
if (edit1.Text='') or (edit2.Text ='') then
begin
application.MessageBox('请查找书籍然后在借!','提示',64);
end
else
begin
ADOQuery1.Close;
ADOQuery1.SQL.Clear; ADOQuery1.SQL.Add('select * from 学生借书信息表 where 书籍编号='''+Edit1.Text+''''); ADOQuery1.Open;
ADOQuery2.Close;
ADOQuery2.SQL.Clear; ADOQuery2.SQL.Add('select * from 教师借书信息表 where 书籍编号='''+Edit1.Text+''''); ADOQuery2.Open;
if (ADOQuery1.Recordset.RecordCount=0) and(ADOQuery2.Recordset.RecordCount=0) then
begin
ADOQuery3.Close;
ADOQuery3.SQL.Clear; ADOQuery3.SQL.Add(' select * from 学生图书馆帐号表 where 帐号='''+form1.Edit1.Text+''''); ADOQuery3.Open;
adotable2.Append;
adotable2.FieldByName('学号').AsString:=adoquery3.FieldByName('学号').AsString;;
adotable2.FieldByName('姓名').AsString:=adoquery3.FieldByName('姓名').AsString;;
adotable2.FieldByName('书籍编号').AsString:=edit1.Text;
adotable2.FieldByName('名称').AsString:=edit2.Text;
adotable2.FieldByName('借书日期').AsDateTime:=Date();
adotable2.FieldByName('应归还日期').AsDateTime:=Date()+30;
adotable2.Post; ADOQuery1.Close; ADOQuery1.SQL.Clear; ADOQuery1.SQL.Add('update 书籍信息表 set 书籍位置='''+s0+''' where 书籍编号='''+Edit1.Text+''''); ADOQuery1.ExecSQL; application.MessageBox('借书成功成功!','提示',64)
end
else
begin
application.MessageBox('该书已经被借!','提示',64);
end
end
end;
procedure TForm4.BitBtn7Click(Sender: TObject);
begin
form3.Close;
end;
procedure TForm4.BitBtn1Click(Sender: TObject);
begin
BitBtn2.Enabled:=true;
StaticText7.Caption:='学生个人信息系统';
StaticText2.Caption:='学生学号';
StaticText3.Caption:='学生姓名';
StaticText4.Caption:='学生性别';
StaticText5.Caption:=' ';
edit7.Clear;
StaticText6.Caption:='出生日期';
StaticText8.Caption:='学生系别';
ADOQuery1.Close;
ADOQuery1.SQL.Clear;ADOQuery1.SQL.Add('select * from 学生信息表 where 学号=(select 学号 from 学生图书馆帐号表 where 帐号='''+form1.Edit1.Text+''')');ADOQuery1.Open;
edit1.Text:=adoquery1.FieldByName('学号').AsString;
edit2.Text:=adoquery1.FieldByName('姓名').AsString;
edit3.Text:=adoquery1.FieldByName('性别').AsString;
edit4.Text:=adoquery1.FieldByName('出生日期').AsString;
edit6.Text:=adoquery1.FieldByName('系别').AsString;
end;
procedure TForm4.BitBtn2Click(Sender: TObject);
begin
BitBtn2.Enabled:=false;
ADOQuery1.Close;
ADOQuery1.SQL.Clear;ADOQuery1.SQL.Add('update 学生信息表 set 姓名='''+edit2.Text+''',性别='''+edit3.Text+''',出生日期='''+edit4.Text+''',系别='''+edit6.Text+''' where 学号=(select 学号 from 学生图书馆帐号表 where 帐号='''+form1.Edit1.Text+''')');adoquery1.ExecSQL;
application.MessageBox('修改成功!','提示',64);
end;
procedure TForm4.BitBtn3Click(Sender: TObject);
begin
form7.show;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -