⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 unit3.pas

📁 用DELPHI来编写的图书管理系统
💻 PAS
字号:
unit Unit3;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, jpeg, ExtCtrls, Buttons, ADODB, DB, Mask, DBCtrls,
  ToolWin, ComCtrls, Menus, Grids, DBGrids;

type
  TForm3 = class(TForm)
    Image1: TImage;
    MainMenu1: TMainMenu;
    N1: TMenuItem;
    N2: TMenuItem;
    N3: TMenuItem;
    N4: TMenuItem;
    N5: TMenuItem;
    N6: TMenuItem;
    N7: TMenuItem;
    N8: TMenuItem;
    N9: TMenuItem;
    N10: TMenuItem;
    N11: TMenuItem;
    N12: TMenuItem;
    N13: TMenuItem;
    N14: TMenuItem;
    ADOTable1: TADOTable;
    DataSource1: TDataSource;
    CoolBar1: TCoolBar;
    Panel1: TPanel;
    BitBtn1: TBitBtn;
    BitBtn2: TBitBtn;
    BitBtn3: TBitBtn;
    StaticText1: TStaticText;
    Panel2: TPanel;
    SpeedButton1: TSpeedButton;
    BitBtn4: TBitBtn;
    SpeedButton2: TSpeedButton;
    BitBtn5: TBitBtn;
    SpeedButton3: TSpeedButton;
    BitBtn6: TBitBtn;
    SpeedButton4: TSpeedButton;
    DBGrid1: TDBGrid;
    StaticText2: TStaticText;
    StaticText3: TStaticText;
    StaticText4: TStaticText;
    StaticText5: TStaticText;
    StaticText6: TStaticText;
    StaticText8: TStaticText;
    N15: TMenuItem;
    RadioButton1: TRadioButton;
    RadioButton2: TRadioButton;
    BitBtn7: TBitBtn;
    ADOQuery1: TADOQuery;
    Edit1: TEdit;
    Edit2: TEdit;
    Edit3: TEdit;
    Edit4: TEdit;
    Edit6: TEdit;
    Edit7: TEdit;
    ADOQuery2: TADOQuery;
    ADOTable2: TADOTable;
    ADOQuery3: TADOQuery;
    SpeedButton5: TSpeedButton;
    StaticText7: TStaticText;
    ADOTable3: TADOTable;
    procedure BitBtn6Click(Sender: TObject);
    procedure BitBtn4Click(Sender: TObject);
    procedure BitBtn5Click(Sender: TObject);
    procedure BitBtn7Click(Sender: TObject);
    procedure BitBtn1Click(Sender: TObject);
    procedure BitBtn2Click(Sender: TObject);
    procedure BitBtn3Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form3: TForm3;


implementation

uses Unit5, Unit4, Unit10, Unit1, Unit7;

{$R *.dfm}

procedure TForm3.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 TForm3.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 TForm3.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 TForm3.BitBtn7Click(Sender: TObject);
begin
form3.Close;
end;

procedure TForm3.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 TForm3.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 TForm3.BitBtn3Click(Sender: TObject);
begin
form7.show;
end;

end.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -