📄 renewalfrm.~pas
字号:
unit renewalfrm;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ButtonFrm, StdCtrls, Buttons, ExtCtrls, Mask, DBCtrls, ComCtrls,childfrm,
Menus;
type
TRenewalForm = 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;
Edday: TEdit;
Label9: TLabel;
Edispasstime: TEdit;
Label10: TLabel;
Edpassday: TEdit;
GroupBox6: TGroupBox;
Label11: TLabel;
Label12: TLabel;
DTPrenewal: TDateTimePicker;
Edrenewalday: TEdit;
GroupBox7: TGroupBox;
Label14: TLabel;
Label15: TLabel;
Label16: TLabel;
Label17: TLabel;
Eddate: TEdit;
DBE6: TDBEdit;
DBE7: TDBEdit;
DBE8: TDBEdit;
DBE9: TDBEdit;
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 BBtnRenewalClick(Sender: TObject);
procedure EdrenewaldayKeyPress(Sender: TObject; var Key: Char);
procedure FormShow(Sender: TObject);
procedure BBtnPrintClick(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
procedure clearDBEdit;
procedure clearedit;
{ Public declarations }
end;
var
RenewalForm: TRenewalForm;
implementation
uses dmfrm, prtborrowfrm;
{$R *.dfm}
var
tmpborrowlist2:Tstringlist;
tmpborrowdate:string;
procedure TRenewalForm.FormDestroy(Sender: TObject);
begin
inherited;
tmpborrowlist2.Free;
tmpborrowlist2:=nil;
RenewalForm:=nil;
end;
procedure TRenewalForm.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;
Eddate.Clear;
Edday.Clear;
Edispasstime.Clear;
Edpassday.Clear;
end;
procedure TRenewalForm.clearedit;
begin
DBE6.Clear;
DBE7.Clear;
DBE8.Clear;
DBE9.Clear;
Eddate.Clear;
Edday.Clear;
Edispasstime.Clear;
Edpassday.Clear;
Edbookid.Clear;
end;
procedure TRenewalForm.BtBreaderClick(Sender: TObject);
var
ii:integer;
tmpstr2: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);
tmpborrowlist2.Clear;
for ii:=0 to LBbook.Items.Count-1 do
begin
tmpstr2:=LBbook.Items.Strings[ii];
tmpstr2:=copy(tmpstr2,2,length(tmpstr2));
tmpstr2:=copy(tmpstr2,1,pos(']',tmpstr2)-1);
tmpborrowlist2.Add(tmpstr2);
end;
clearedit;
Edbookid.SetFocus;
end;
procedure TRenewalForm.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 TRenewalForm.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 tmpborrowlist2.IndexOf(dmbook.Qrybook['book_id'])=-1 then
begin
bookInformation('你没有借这本书,不能续借'+#13+'请初借这本书!');
clearEdit;
Edbookid.SetFocus;
exit;
end
else begin
LBbook.ItemIndex:=tmpborrowlist2.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);
Eddate.Text:=FormatDateTime('yyyy.mm.dd',StrToDateTime(Aborrowdate));
tmpborrowdate:=Aborrowdate;
Edday.Text:=Aborrowday;
if Aborrowdate=Emptystr then
begin
Edpassday.Text:=Emptystr;
bookInformation('借这本书时,没有输入初借日期!');
end
else begin
//start
if dmbook.comparedatemothed(StrToDateTime(Aborrowdate),DTPrenewal.DateTime)=1 then
begin
bookInformation('续借日期不能小于初借日期,'+#13+'系统日期有误,修改系统日期!');
clearedit;
Edbookid.SetFocus;
exit;
end;
Edpassday.Text:=inttostr(dmbook.passdaymothed(StrToDateTime(Aborrowdate),now,strtoint(Aborrowday)));
if strtoint(Edpassday.Text)>0 then
begin
Edispasstime.Text:='是';
bookInformation('告诉读者,他初借该书过期'+Edpassday.Text+'天');
end
else begin
Edispasstime.Text:='否';
Edpassday.Text:='0';
//end
end;
end;
dmbook.Qrybook.EnableControls;
if childfrm.checkusesdefaultday then Edrenewalday.ReadOnly:=true
else Edrenewalday.ReadOnly:=false;
Edrenewalday.SetFocus;
end;
procedure TRenewalForm.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 TRenewalForm.BBtnCancelClick(Sender: TObject);
begin
inherited;
clearDBEdit;
end;
procedure TRenewalForm.EdbookidEnter(Sender: TObject);
begin
inherited;
if (DBE2.Text=Emptystr)OR(DBE2.Text<>Edreaderid.Text) then
begin
bookInformation('请先输入借书证号并确认!');
Edreaderid.SetFocus;
exit;
end;
end;
procedure TRenewalForm.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 TRenewalForm.BBtnRenewalClick(Sender: TObject);
var
t1:integer;
Atempbool:boolean;
renwalint: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 Edrenewalday.Text=Emptystr then
begin
bookInformation('请输入续借借期!');
Edrenewalday.SetFocus;
exit;
end;
if Eddate.Text=Emptystr then
begin
bookInformation('输入了待续借书号,但没有确认!');
Edbookid.SetFocus;
exit;
end;
renwalint:=dmbook.comparedatemothed(StrToDateTime(tmpborrowdate),DTPrenewal.DateTime);
if renwalint=0 then
begin
bookInformation('他是今天初借的,现在不能续借,请过一天再续借.');
exit;
end;
if renwalint=1 then
begin
bookInformation('续借日期不能小于初借日期!'+#13+'修改续借日期,'+#13+'并且确认当前系统日期时间是否准确!');
// DTPrenewal.Enabled:=true;
// DTPrenewal.SetFocus;
exit;
end;
dmbook.isrenewaled(DBE2.Text,DBE6.Text,Atempbool);
if Atempbool then
begin
bookInformation('该书你已续借了一次,不能再续借了,请还书吧!');
clearedit;
Edbookid.SetFocus;
exit;
end;
if Edrenewalday.Text=Emptystr then t1:=0 else t1:=strtoint(Edrenewalday.Text);
try
dmbook.renewalbook(DBE2.Text,DBE6.Text,DTPrenewal.DateTime,t1);
except
bookError('续借图书失败!');
end;
clearedit;
Edreaderid.SetFocus;
end;
procedure TRenewalForm.EdrenewaldayKeyPress(Sender: TObject;
var Key: Char);
begin
inherited;
if key=#13 then BBtnRenewalClick(Sender)
else begin
if not(key in ['0'..'9',#8]) then
begin
key:=#0;
beep;
end;
end;
end;
procedure TRenewalForm.FormShow(Sender: TObject);
begin
inherited;
dmbook.closebook;
dmbook.closereader;
dmbook.openbook;
dmbook.openreader;
clearDBEdit;
end;
procedure TRenewalForm.BBtnPrintClick(Sender: TObject);
begin
inherited;
if not assigned(prtborrowForm) then
prtborrowForm:=TprtborrowForm.Create(Application);
try
prtborrowForm.RB3.Enabled:=false;
prtborrowForm.ShowModal;
finally
prtborrowForm.Free;
prtborrowForm:=nil;
end;
end;
procedure TRenewalForm.FormCreate(Sender: TObject);
begin
inherited;
tmpborrowlist2:=tstringlist.Create;
Edrenewalday.Text:=inttostr(childfrm.borrowbookday);
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -