📄 returnfrm.~pas
字号:
unit returnfrm;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ButtonFrm, StdCtrls, Buttons, ExtCtrls, Mask, DBCtrls, ComCtrls,
Menus;
type
TReturnForm = class(Tbuttonform)
GroupBox1: TGroupBox;
Splitter1: TSplitter;
GroupBox2: TGroupBox;
Panel1: TPanel;
Label1: TLabel;
Edreaderid: TEdit;
BtBreader: TBitBtn;
GroupBox3: TGroupBox;
GroupBox4: TGroupBox;
Panel2: TPanel;
Label2: TLabel;
Edbookid: TEdit;
BtBbook: TBitBtn;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
Label6: TLabel;
LBbook: TListBox;
DBE1: TDBEdit;
DBE2: TDBEdit;
DBE3: TDBEdit;
DBE4: TDBEdit;
Label13: TLabel;
DBE5: TDBEdit;
GroupBox5: TGroupBox;
Label7: TLabel;
Label8: TLabel;
EdBorrowday: TEdit;
Label10: TLabel;
EdBorrowpass: TEdit;
GroupBox6: TGroupBox;
Label11: TLabel;
DTPreturn: TDateTimePicker;
GroupBox7: TGroupBox;
Label14: TLabel;
Label15: TLabel;
Label16: TLabel;
Label17: TLabel;
EdBorrowdate: TEdit;
DBE6: TDBEdit;
DBE7: TDBEdit;
DBE8: TDBEdit;
DBE9: TDBEdit;
Label9: TLabel;
Label12: TLabel;
Label18: TLabel;
EdRenewalpass: TEdit;
EdRenewalday: TEdit;
EdRenewaldate: TEdit;
Label22: TLabel;
Label23: TLabel;
procedure FormDestroy(Sender: TObject);
procedure BtBreaderClick(Sender: TObject);
procedure EdreaderidKeyPress(Sender: TObject; var Key: Char);
procedure BtBbookClick(Sender: TObject);
procedure EdbookidKeyPress(Sender: TObject; var Key: Char);
procedure BBtnCancelClick(Sender: TObject);
procedure EdbookidEnter(Sender: TObject);
procedure LBbookClick(Sender: TObject);
procedure BBtnReturnClick(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure BBtnPrintClick(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
procedure clearDBEdit;
procedure clearedit;
{ Public declarations }
end;
var
ReturnForm: TReturnForm;
implementation
uses dmfrm, prtborrowfrm;
{$R *.dfm}
var
tmpborrowlist3:Tstringlist;
tmpborowdate,tmprenawdate:string;
procedure TReturnForm.FormDestroy(Sender: TObject);
begin
inherited;
tmpborrowlist3.Free;
tmpborrowlist3:=nil;
ReturnForm:=nil;
end;
procedure TReturnForm.clearDBEdit;
begin
Edreaderid.Clear;
Edbookid.Clear;
DBE1.Clear;
DBE2.Clear;
DBE3.Clear;
DBE4.Clear;
DBE5.Clear;
DBE6.Clear;
DBE7.Clear;
DBE8.Clear;
DBE9.Clear;
LBbook.Clear;
EdBorrowdate.Clear;
EdBorrowday.Clear;
EdBorrowpass.Clear;
EdRenewalday.Clear;
EdRenewalpass.Clear;
EdRenewaldate.Clear;
end;
procedure TReturnForm.clearedit;
begin
DBE6.Clear;
DBE7.Clear;
DBE8.Clear;
DBE9.Clear;
EdBorrowdate.Clear;
EdBorrowday.Clear;
EdBorrowpass.Clear;
EdRenewaldate.Clear;
EdRenewalday.Clear;
EdRenewalpass.Clear;
Edbookid.Clear;
end;
procedure TReturnForm.BtBreaderClick(Sender: TObject);
var
iii:integer;
tmpstr3:string;
begin
inherited;
if Edreaderid.Text=Emptystr then
begin
bookInformation('请输入借书证号!');
Edreaderid.SetFocus;
Edreaderid.Clear;
exit;
end;
dmbook.readerfirst;
if not dmbook.Qryreader.Locate('reader_id',Edreaderid.Text,[]) then
begin
clearDBEdit;
bookInformation('输入借书证号在数据库中不存在!');
Edreaderid.SetFocus;
exit;
end;
//dmbook.Qryreader.EnableControls;
LBbook.Items.text:=dmbook.getborrowedbook(Edreaderid.Text);
tmpborrowlist3.Clear;
for iii:=0 to LBbook.Items.Count-1 do
begin
tmpstr3:=LBbook.Items.Strings[iii];
tmpstr3:=copy(tmpstr3,2,length(tmpstr3));
tmpstr3:=copy(tmpstr3,1,pos(']',tmpstr3)-1);
tmpborrowlist3.Add(tmpstr3);
end;
clearEdit;
Edbookid.SetFocus;
end;
procedure TReturnForm.EdreaderidKeyPress(Sender: TObject; var Key: Char);
begin
inherited;
if key=#13 then
begin
if TEdit(Sender)=Edreaderid then BtBreaderClick(Sender);
// if TEdit(Sender)=Edbookid then BtBbook.SetFocus;
end
else begin
if not(key in ['0'..'9',#8]) then
begin
key:=#0;
beep;
end;
end;
end;
procedure TReturnForm.BtBbookClick(Sender: TObject);
var
Aborrowdate,Aborrowday,Arenewaldate,Arenewalday:string;
begin
inherited;
if Edbookid.Text=Emptystr then
begin
bookInformation('请输入待还书书号!');
Edbookid.SetFocus;
Edbookid.Clear;
exit;
end;
dmbook.bookfirst;
if not dmbook.Qrybook.Locate('book_id',Edbookid.Text,[]) then
begin
bookInformation('该书号不存在,或输入有误!');
Edbookid.SetFocus;
Edbookid.Clear;
exit;
end
else begin
//if LBbook.Items.IndexOf('['+dmbook.Qrybook['book_id']+']'+dmbook.Qrybook['book_name'])=-1 then
if tmpborrowlist3.IndexOf(dmbook.Qrybook['book_id'])=-1 then
begin
bookInformation('你没有借这本书,不能还书'+#13+'请初借这本书!');
clearEdit;
Edbookid.SetFocus;
exit;
end
else begin
LBbook.ItemIndex:=tmpborrowlist3.IndexOf(dmbook.Qrybook['book_id']);
// LBbook.ItemIndex:=LBbook.Items.IndexOf('['+dmbook.Qrybook['book_id']+']'+dmbook.Qrybook['book_name']);
end;
end;
DMbook.getborrowdateday(DBE2.Text,Edbookid.Text,Aborrowdate,Aborrowday,Arenewaldate,Arenewalday);
EdBorrowdate.Text:=FormatDateTime('yyyy.mm.dd',StrToDateTime(Aborrowdate));
tmpborowdate:=Aborrowdate;
EdBorrowday.Text:=Aborrowday;
EdRenewaldate.Text:=Arenewaldate;
tmprenawdate:=Arenewaldate;
EdRenewalday.Text:=Arenewalday;
if Arenewaldate=Emptystr then
begin
if dmbook.comparedatemothed(StrToDateTime(Aborrowdate),DTPreturn.DateTime)=1 then
begin
bookInformation('他没有续借该书,'+#13+'还书日期不能小于初借日期,'+#13+'系统日期有误,修改系统日期!');
clearedit;
Edbookid.SetFocus;
// DTPrenewal.Enabled:=true;
// DTPrenewal.SetFocus;
exit;
end;
EdBorrowpass.Text:=inttostr(dmbook.passdaymothed(StrToDateTime(Aborrowdate),now,strtoint(Aborrowday)));
if strtoint(EdBorrowpass.Text)<0 then EdBorrowpass.Text:='0';
EdRenewalpass.Text:=Emptystr;
end
else begin
EdRenewaldate.Text:=FormatDateTime('yyyy.mm.dd',StrToDateTime(Arenewaldate));
if dmbook.comparedatemothed(StrToDateTime(ARenewaldate),DTPreturn.DateTime)=1 then
begin
bookInformation('他续借了该书,'+#13+'还书日期不能小于续借日期,'+#13+'系统日期有误,修改系统日期!');
clearedit;
Edbookid.SetFocus;
// DTPrenewal.Enabled:=true;
// DTPrenewal.SetFocus;
exit;
end;
EdBorrowpass.Text:=inttostr(dmbook.passdaymothed(StrToDateTime(Aborrowdate),StrToDateTime(Arenewaldate),strtoint(Aborrowday)));
EdRenewalpass.Text:=inttostr(dmbook.passdaymothed(StrToDateTime(Arenewaldate),now,strtoint(Arenewalday)));
if strtoint(EdBorrowpass.Text)<0 then EdBorrowpass.Text:='0';
if strtoint(EdRenewalpass.Text)<0 then EdRenewalpass.Text:='0';
end;
if (EdBorrowpass.Text<>'0')and(EdBorrowpass.text<>emptystr) then
begin
if (EdRenewalpass.Text<>'0')and(EdRenewalpass.Text<>emptystr) then
bookInformation('告诉读者:'+#13+'他初借过期'+EdBorrowpass.Text+'天,'+#13+'他续借过期'+EdRenewalpass.Text+'天.')
else bookInformation('告诉读者:'+#13+'他初借过期'+EdBorrowpass.Text+'天.');
end
else begin
if (EdRenewalpass.Text<>'0')and(EdRenewalpass.Text<>emptystr) then
bookInformation('告诉读者:'+#13+'他续借过期'+EdRenewalpass.Text+'天.');
end;
dmbook.Qrybook.EnableControls;
//DTPreturn.SetFocus;
end;
procedure TReturnForm.EdbookidKeyPress(Sender: TObject; var Key: Char);
begin
inherited;
if key=#13 then BtBbookClick(Sender);
if not(key in ['a'..'z','A'..'Z','0'..'9','-',#8]) then
begin
key:=#0;
beep;
end;
if (key in ['a'..'z']) then key:=chr(ord(key)-32);
end;
procedure TReturnForm.BBtnCancelClick(Sender: TObject);
begin
inherited;
clearDBEdit;
end;
procedure TReturnForm.EdbookidEnter(Sender: TObject);
begin
inherited;
if (DBE2.Text=Emptystr)OR(DBE2.Text<>Edreaderid.Text) then
begin
bookInformation('请先输入借书证号并确认!');
Edreaderid.SetFocus;
exit;
end;
end;
procedure TReturnForm.LBbookClick(Sender: TObject);
var
tmpstring:string;
begin
inherited;
tmpstring:=LBbook.Items.Strings[LBbook.ItemIndex];
tmpstring:=copy(tmpstring,2,length(tmpstring));
tmpstring:=copy(tmpstring,1,pos(']',tmpstring)-1);
Edbookid.Text:=tmpstring;
BtBbookClick(Sender);
end;
procedure TReturnForm.BBtnReturnClick(Sender: TObject);
var
t1,t2:string;
t3,t4,t5,t6:integer;
t7,t8,t9:Tdatetime;
bowint,renwint:integer;
begin
inherited;
if Edreaderid.Text=Emptystr then
begin
bookInformation('请输入借书证号!');
Edreaderid.SetFocus;
exit;
end;
if Edbookid.Text=Emptystr then
begin
bookInformation('请输入待还书书号!');
Edbookid.SetFocus;
exit;
end;
if EdBorrowdate.Text=Emptystr then
begin
bookInformation('输入了待续借书号,但没有确认!');
Edbookid.SetFocus;
exit;
end;
if EdRenewaldate.Text=Emptystr then
begin
bowint:=dmbook.comparedatemothed(StrToDateTime(tmpborowdate),DTPreturn.DateTime);
if bowint=0 then
begin
bookInformation('他是今天初借的,现在不能还,请过一天再还.');
exit;
end;
if bowint=1 then
begin
bookInformation('他没有续借该书,'+#13+'还书日期不能小于初借日期,'+#13+'系统日期有误,修改系统日期!');
clearedit;
Edbookid.SetFocus;
// DTPrenewal.Enabled:=true;
// DTPrenewal.SetFocus;
exit;
end;
end
else begin
renwint:=dmbook.comparedatemothed(StrToDateTime(tmprenawdate),DTPreturn.DateTime);
if renwint=0 then
begin
bookInformation('他是今天续借的,现在不能还,请过一天再还.');
exit;
end;
if renwint=1 then
begin
bookInformation('他续借了该书,'+#13+'还书日期不能小于续借日期,'+#13+'系统日期有误,修改系统日期!');
clearedit;
Edbookid.SetFocus;
// DTPrenewal.Enabled:=true;
// DTPrenewal.SetFocus;
exit;
end;
end;
t1:=Edreaderid.Text;
t2:=Edbookid.Text;
if EdBorrowday.Text=Emptystr then t3:=0 else t3:=strtoint(EdBorrowday.Text);
if EdBorrowpass.Text=Emptystr then t4:=0 else t4:=strtoint(EdBorrowpass.Text);
if EdRenewalday.Text=Emptystr then t5:=0 else t5:=strtoint(EdRenewalday.Text);
if EdRenewalpass.Text=Emptystr then t6:=0 else t6:=strtoint(EdRenewalpass.Text);
t7:=StrToDateTime(tmpborowdate);
try
t8:=StrToDateTime(tmprenawdate);
except
t8:=t7;
end;
t9:=DTPreturn.DateTime;
try
//还书 -------待写代码---
dmbook.returnbook(t1,t2,t3,t4,t5,t6,t7,t8,t9);
LBbook.Items.Delete(LBbook.ItemIndex);
except
bookError('续借图书失败!');
end;
clearedit;
Edreaderid.SetFocus;
end;
procedure TReturnForm.FormShow(Sender: TObject);
begin
inherited;
dmbook.closebook;
dmbook.closereader;
dmbook.openbook;
dmbook.openreader;
clearDBEdit;
end;
procedure TReturnForm.BBtnPrintClick(Sender: TObject);
begin
inherited;
if not assigned(prtborrowForm) then
prtborrowForm:=TprtborrowForm.Create(Application);
try
prtborrowForm.RB1.Enabled:=false;
prtborrowForm.RB2.Enabled:=false;
prtborrowForm.ShowModal;
finally
prtborrowForm.Free;
prtborrowForm:=nil;
end;
end;
procedure TReturnForm.FormCreate(Sender: TObject);
begin
inherited;
tmpborrowlist3:=Tstringlist.Create;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -