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

📄 frmloanu.pas

📁 图书借阅管理系统含源代码
💻 PAS
📖 第 1 页 / 共 2 页
字号:
unit frmLoanU;

interface

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

type
  TfrmLoan = class(TForm)
    GroupBox1: TGroupBox;
    Label1: TLabel;
    edLeaseNO: TEdit;
    btnLeaseNo: TBitBtn;
    Label2: TLabel;
    edName: TEdit;
    Label3: TLabel;
    edIDCard: TEdit;
    Label4: TLabel;
    edBalance: TEdit;
    Label5: TLabel;
    dtBagMoTim: TDateTimePicker;
    Panel1: TPanel;
    imgPhoto: TImage;
    GroupBox2: TGroupBox;
    Label6: TLabel;
    edBookNo: TEdit;
    btnBookNo: TBitBtn;
    Label7: TLabel;
    edTitle: TEdit;
    Label8: TLabel;
    edAuthor: TEdit;
    Label9: TLabel;
    edBoConName: TEdit;
    Label10: TLabel;
    edLoanDate: TEdit;
    Label11: TLabel;
    edLoan: TEdit;
    Panel2: TPanel;
    imgPic: TImage;
    btnClose: TBitBtn;
    btnLoan: TBitBtn;
    procedure btnCloseClick(Sender: TObject);
    procedure FormShow(Sender: TObject);
    procedure btnLeaseNoClick(Sender: TObject);
    procedure btnLoanClick(Sender: TObject);
    procedure edLeaseNOExit(Sender: TObject);
    procedure btnBookNoClick(Sender: TObject);
    procedure edBookNoExit(Sender: TObject);
  private
    { Private declarations }
    procedure ClsText();
  public
    { Public declarations }
    procedure Loan(Loan:Boolean);
  end;

var
  frmLoan: TfrmLoan;

implementation

uses DMU;

{$R *.dfm}
var
  LoanBoo:Boolean;

procedure TfrmLoan.btnCloseClick(Sender: TObject);
begin
  Close;
end;

procedure TfrmLoan.Loan(Loan: Boolean);
begin
  if Loan then
  begin
    frmLoan.Caption:='借书';
    btnLoan.Caption:='借出(&L)';
  end
  else
  begin
    frmLoan.Caption:='还书';
    btnLoan.Caption:='归还(&R)';
  end;
  LoanBoo:=Loan;
end;

procedure TfrmLoan.FormShow(Sender: TObject);
begin
  if LoanBoo then
  begin
    edLeaseNo.SetFocus;
    edLeaseNo.ReadOnly:=False;
    edLeaseNo.Color:=clWindow;
  end
  else
  begin
    edBookNo.SetFocus;
    edLeaseNo.ReadOnly:=True;
    edLeaseNo.Color:=clScrollBar;
  end;
  ClsText();
end;

procedure TfrmLoan.btnLeaseNoClick(Sender: TObject);
var
  f:file of Byte;
  TempPic:String;
begin
  TempPic:=ExtractFilePath(Application.ExeName)+'temp.jpg';
  Dm.adoTemp.Close;
  Dm.adoTemp.SQL.Clear;
  Dm.adoTemp.SQL.Text:='Select * from Reader where LeaseNo='+QuotedStr(edLeaseNo.Text);
  Dm.adoTemp.Open;
  if Dm.adoTemp.RecordCount=0 then
  begin
    MessageBox(0,Pchar('找不到借书证为:“'+edLeaseNo.Text+'”的用户。'),'提示',MB_OK+MB_ICONEXCLAMATION+MB_TASKMODAL);
    edLeaseNo.SetFocus;
    edLeaseNo.Clear;
    exit;
  end;
  edName.Text:=Dm.adoTemp.FieldByName('Name').AsString;
  edIDCard.Text:=Dm.adoTemp.FieldByName('IDCard').AsString;
  edBalance.Text:=Dm.adoTemp.FieldByName('Balance').AsString;
  if Dm.adoTemp.FieldByName('BagMonth').AsString='0' then
  begin
    dtBagMoTim.Visible:=True;
    dtBagMoTim.Date:=Dm.adoTemp.FieldByName('BagMoTim').AsDateTime;
  end
  else
    dtBagMoTim.Visible:=False;
//===============读取相片===========
  DeleteFile(TempPic);
  TblobField(DM.adoTemp.FieldByName('Photo')).SaveToFile(TempPic);
  AssignFile(f,TempPic);
  Reset(f);
  if FileSize(f)=0 then
  begin
    imgPhoto.Picture.LoadFromFile(ExtractFilePath(Application.ExeName)+'\noPic.jpg');
    CloseFile(f);
  end
  else
  begin
    CloseFile(f);
    imgPhoto.Picture.LoadFromFile(TempPic);
  end;
  imgPhoto.Visible:=True;
  DeleteFile(TempPic);
//===========================
  Dm.adoTemp.Close;
end;

procedure TfrmLoan.ClsText;
begin
  edLeaseNo.Clear;
  edName.Clear;
  edIDCard.Clear;
  edBalance.Clear;
  edBookNo.Clear;
  edTitle.Clear;
  edAuthor.Clear;
  edBoConName.Clear;
  edLoanDate.Clear;
  edLoan.Clear;
  imgPic.Visible:=False;
  imgPhoto.Visible:=False;
end;

procedure TfrmLoan.btnLoanClick(Sender: TObject);
var
  MaxLoanHow:integer;
  MaxArrearage,LoanCost,OverstepTermHire,OverstepTermHire2:Single;
  myDate1,myDate2,myDate3,myDate4,myDate5:integer;
  Money,Money1,Money2,Money3,Money4,Money5:Single;
  Str:String;
begin

//==========================
  btnLeaseNo.Click;
  btnBookNo.Click;
  if (edLeaseNo.Text='') or (edBookNo.Text='')then
  begin
    MessageBox(0,Pchar('借书证号和图书号不能为空。'),'提示',MB_OK+MB_ICONEXCLAMATION+MB_TASKMODAL);
    exit;
  end;
//========读取借阅设置======
  Dm.adoTemp.Close;
  Dm.adoTemp.SQL.Clear;
  Dm.adoTemp.SQL.Text:='Select * from LoanOption';
  DM.adoTemp.Open;
  MaxArrearage:=StrToFloat(Dm.adoTemp.FieldByname('MaxArrearage').AsString);
  LoanCost:=StrToFloat(Dm.adoTemp.FieldByName('LoanCost').AsString);
  OverstepTermHire:=StrToFloat(Dm.adoTemp.FieldByName('OverstepTermHire').AsString);
  OverstepTermHire2:=StrToFloat(Dm.adoTemp.FieldByName('OverstepTermHire2').AsString);
  MaxLoanHow:=StrToInt(Dm.adoTemp.FieldByName('MaxLoanHow').AsString);
  Dm.adoTemp.Close;

//=========================
  if LoanBoo then
  begin//借书
//---------判断借书条件-----------------
    DM.adoLoan.close;
    Dm.adoLoan.SQL.Clear;
    Dm.adoLoan.SQL.Text:='select * from Book where BookNo='+QuotedStr(edBookNo.Text);
    Dm.adoLoan.Open;
    if Dm.adoLoan.FieldByName('Loan').AsString='1'then
    begin
      MessageBox(0,Pchar('借出失败!'+Chr(13)+'图书号为:“'+edBookNo.Text+'的图书已被借出,本次借书行动被终止。'),'提示',MB_OK+MB_ICONSTOP+MB_TASKMODAL);
      Dm.adoLoan.Close;
      exit;
    end;

    Dm.adoLoan.Close;
    Dm.adoLoan.SQL.Clear;
    Dm.adoLoan.SQL.Text:='select * from Loan where LeaseNo='+QuotedStr(edLeaseNo.Text);
    Dm.adoLoan.Open;

    if Dm.adoLoan.RecordCount>=MaxLoanHow then
    begin
      MessageBox(0,Pchar('借出失败!'+Chr(13)+'借书证为:“'+edLeaseNo.Text+'的用户所借的书已经超出最大借出'+IntToStr(MaxLoanHow)+'本的规定,本次借书行动被终止。'),'提示',MB_OK+MB_ICONSTOP+MB_TASKMODAL);
      Dm.adoLoan.Close;
      exit;
    end;

    Dm.adoLoan.Close;
    Dm.adoLoan.SQL.Clear;
    Dm.adoLoan.SQL.Text:='select * from Reader where LeaseNo='+QuotedStr(edLeaseNo.Text);
    Dm.adoLoan.Open;

    if Dm.adoLoan.FieldByName('PressGold').AsString=''then
    begin
      MessageBox(0,Pchar('借出失败!'+Chr(13)+'借书证为:“'+edLeaseNo.Text+'的用户尚未充值,本次借书行动被终止。'),'提示',MB_OK+MB_ICONSTOP+MB_TASKMODAL);
      Dm.adoLoan.Close;
      exit;
    end;

⌨️ 快捷键说明

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