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

📄 borrowbook.~pas

📁 蛮不错的图书管理系统,大家可以载着试试看啊
💻 ~PAS
字号:
unit borrowbook;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, Buttons, ComCtrls, jpeg, ExtCtrls, DB, DBTables;

type
  Tborrowbookfrm = class(TForm)
    Panel1: TPanel;
    Image1: TImage;
    PageControl1: TPageControl;
    TabSheet1: TTabSheet;
    TabSheet2: TTabSheet;
    GroupBox1: TGroupBox;
    ListView1: TListView;
    GroupBox2: TGroupBox;
    r1: TRadioButton;
    r2: TRadioButton;
    Label1: TLabel;
    e1: TEdit;
    b1: TBitBtn;
    GroupBox3: TGroupBox;
    ListView2: TListView;
    BitBtn1: TBitBtn;
    q1: TQuery;
    b2: TBitBtn;
    b4: TBitBtn;
    procedure BitBtn1Click(Sender: TObject);
    procedure TabSheet1Show(Sender: TObject);
    procedure b1Click(Sender: TObject);
    procedure b2Click(Sender: TObject);

    procedure b4Click(Sender: TObject);
    procedure Button1Click(Sender: TObject);
    private
    { Private declarations }
    procedure listbooks;
    procedure borrowcheck(var l:TListView);
    procedure borrow (var bno:string);
    procedure toview(var q:Tquery; list:TListView; flg:integer);
  public
    { Public declarations }
  end;

var
  borrowbookfrm: Tborrowbookfrm;

implementation
    uses gl,main1,extimebook;
{$R *.dfm}

procedure Tborrowbookfrm.listbooks;
begin
 q1.Close;
 q1.sql.Clear;
 q1.sql.add('select * from book_info order by 借阅次数 desc');
 q1.Open;
 toview(q1,listview1,1);
 q1.close;
end;

procedure Tborrowbookfrm.toview(var q:Tquery; list:Tlistview;flg:integer);
begin
   q.First;
  while not q.Eof do
    begin
      with list.Items.Add do
       begin
          caption:=q.fieldbyname('图书编号').AsString;
          SubItems.add(q.FieldByName('书名').AsString);
          SubItems.Add(q.FieldByName('作者').AsString);
          SubItems.Add(q.FieldByName('出版社').AsString);
        if flg=1 then
          SubItems.Add(q.FieldByName('借阅次数').AsString)
        else
          SubItems.Add(q.FieldByName('类别').AsString);
        if gf.isborrowed(caption)  then  SubItems.Add('是') else  SubItems.Add('否');
      end;
    q.next;
  end;

end;



procedure Tborrowbookfrm.BitBtn1Click(Sender: TObject);
begin
close;
end;

procedure Tborrowbookfrm.TabSheet1Show(Sender: TObject);
begin
  listview1.Items.Clear;
  listbooks;
end;

procedure Tborrowbookfrm.b1Click(Sender: TObject);
begin
   q1.Close;
   q1.SQL.Clear;
   if e1.text='' then
    q1.SQL.Add('select * from book_info ')
   else
   begin
    if r1.Checked then
      begin
      q1.SQL.Add('select * from book_info where 图书编号 like :no ');
      q1.ParamByName('no').AsString:='%'+e1.Text+'%';
      end;
    if r2.Checked then
      begin
      q1.SQL.Add('select * from book_info where 书名 like :name ');
      q1.ParamByName('name').AsString:='%'+e1.Text+'%';
      end;
   end;
   q1.Open;
   listview2.Items.Clear;
   toview (q1,listview2,0);
   q1.Close;
end;

procedure Tborrowbookfrm.borrowcheck(var l:TListView);
var ch:integer;
    bno,bout:string;

begin

   if  l.Items.Count=0 then exit;
   if  l.selected=nil   then
      begin
         showmessage('你要借阅那本书?');

       //exit;
      end
    else
      begin

   bno:=l.Selected.Caption;
   bout:=l.Selected.SubItems[4];
   if bout='是' then
      begin
        messagedlg('这本书已全部借出',mtinformation,[mbyes],0);

        exit;

      end;
   if exbook_num=0 then

      if  main.Query1.RecordCount<p_books then
        begin
          if  messagedlg('确认要借出这本书吗?',mtinformation,[mbyes,mbno],0)=mrno then  exit;
          borrow(bno);
        end
      else
         begin
          messagedlg('你借的图书已满!',mtinformation,[mbyes],0);

          exit;

         end;
   if exbook_num>0 then
      begin
        ch:=messagedlg('您现在有'+inttostr(exbook_num)+'本书超时,如果你想继续借书请先还书!'+chr(13)+chr(13)+chr(10)+'现在就还书吗?',mtinformation,[mbyes,mbno],0);
        if ch=mrno then    exit
        else extimebookfrm.ShowModal;
        if exbook_num=0 then
          begin
          if  messagedlg('确认要借出这本书吗?',mtinformation,[mbyes,mbno],0)=mrno then  exit;
          borrow(bno);
          end
        else
          begin
          messagedlg('你还有欠书!',mtinformation,[mbyes],0);
          exit;
          end;
      end;
  messagedlg('借书成功!',mtinformation,[mbyes],0);
  l.Selected.SubItems[4]:='是';
  end;
end;

procedure Tborrowbookfrm.borrow (var bno:string);
begin

 q1.SQL.Clear;
 q1.SQL.Add('insert into borrow_info (图书编号,图书卡号,借出时间)'+ 'values(:bno,:cno,:dat)');
 q1.ParamByName('bno').AsString:=bno;
 q1.ParamByName('cno').AsString:=userno;
 q1.ParamByName('dat').AsDatetime:=date;
 q1.ExecSQL;
 q1.close;
 q1.SQl.Clear;
 q1.SQL.Add('update book_info set 借阅次数=借阅次数+1'+'  where 图书编号=:b');
 q1.ParamByName('b').AsString:=bno;
 q1.ExecSQL;
 q1.Close;
 main.listbookinfo;
end;

procedure Tborrowbookfrm.b2Click(Sender: TObject);
begin
borrowcheck(listview1);
end;



procedure Tborrowbookfrm.b4Click(Sender: TObject);
begin
// if ti=1 then
 //begin
 //hot:=userno;
 //ti:=2 ;
// end;
 //tipfrm.ShowModal;
 //if userno=hot then   messagedlg('请选择用户!',mtinformation,[mbyes],0)
// else
// begin

 borrowcheck(listview2);
 
end;

procedure Tborrowbookfrm.Button1Click(Sender: TObject);
begin
 if  listview1.selected=nil   then
 begin


messagedlg('你要借阅那本书?',mtinformation,[mbyes],0);
  exit;
    end;
end;

end.

⌨️ 快捷键说明

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