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

📄 dmfrm.pas

📁 基于Interbase的图书管理系统
💻 PAS
📖 第 1 页 / 共 3 页
字号:
      Params[0].AsString:=Areaderid;
      Params[1].AsDateTime:=now;
      open;
      except
      end;
    end;
      dbasebook.Commit;
     case SPgoid.ParamByName('RVALUES').AsInteger of
     0:Aresult:=false;
     1:Aresult:=true;
     end;
 except
    dbasebook.Rollback;
    Aresult:=false;
    raise;
 end;
end;

procedure TDMbook.bigtypefirst;
begin
  Qrybigtype.First;
end;

procedure TDMbook.bookfirst;
begin
Qrybook.First;
end;

procedure TDMbook.readerfirst;
begin
Qryreader.First;
end;

procedure TDMbook.borrowfirst;
begin
Qryborrow.First;
end;

procedure TDMbook.renewalfirst;
begin
QryRenewal.First;
end;

procedure TDMbook.smalltypefirst;
begin
Qrysmalltype.First;
end;

procedure TDMbook.openborrowhistory;
begin
if Qryborrowhistory.Active then Qryborrowhistory.Close;
Qryborrowhistory.Open;
end;

procedure TDMbook.closeborrowhistory;
begin
if Qryborrowhistory.Active then Qryborrowhistory.Close;
qryborrowhistory.Filter:=emptystr;
qryborrowhistory.Filtered:=false;
end;

procedure TDMbook.closeReturnHistory;
begin
if Qryreturnhistory.Active then Qryreturnhistory.Close;
qryreturnhistory.Filter:=emptystr;
qryreturnhistory.Filtered:=false;
end;

procedure TDMbook.openReturnHistory;
begin
if Qryreturnhistory.Active then Qryreturnhistory.Close;
Qryreturnhistory.Open;
end;

procedure TDMbook.QryclosetimeCalcFields(DataSet: TDataSet);
begin
Qryclosetime['passcount']:=Qryclosetime['borrow_time']+Qryclosetime['renewal_time'];
end;

procedure TDMbook.closeClosetime;
begin
if Qryclosetime.Active then Qryclosetime.Close;
qryclosetime.Filter:=emptystr;
qryclosetime.Filtered:=false;
end;

procedure TDMbook.openClosetime;
begin
if Qryclosetime.Active then Qryclosetime.Close;
Qryclosetime.Open;
end;

procedure TDMbook.closeBooklose;
begin
if Qrybooklose.Active then Qrybooklose.Close;
qrybooklose.Filter:=emptystr;
qrybooklose.Filtered:=false;
end;

procedure TDMbook.openBooklose;
begin
if Qrybooklose.Active then Qrybooklose.Close;
Qrybooklose.Open;
end;

procedure TDMbook.clearBookLose(Adate:Tdatetime);
begin
 if qryclear.Active then qryclear.Active:=false;
try
 Qryclear.SQL.Clear;
 qryclear.SQL.Add('delete from booklose');
 qryclear.sql.Add('where booklose_date<:Adata');
 Qryclear.Prepare;
 Qryclear.ParamByName('Adata').AsDateTime:=Adate;
 qryclear.ExecSQL;
 messagedlg('清空成功!',mtInformation,[mbOK],0);
except
 messagedlg('清空失败!',mtError,[mbOK],0);
end;
end;

procedure TDMbook.clearBorrowHistory(Adate:Tdatetime);
begin
 if qryclear.Active then qryclear.Active:=false;
try
 Qryclear.SQL.Clear;
 qryclear.SQL.Add('delete from borrowhistory');
 qryclear.sql.Add('where borrow_date<:Adata');
 Qryclear.Prepare;
 Qryclear.ParamByName('Adata').AsDateTime:=Adate;
 qryclear.ExecSQL;
 messagedlg('清空成功!',mtInformation,[mbOK],0);
except
 messagedlg('清空失败!',mtError,[mbOK],0);
end;
end;

procedure TDMbook.clearReturnHistory(Adate:Tdatetime);
begin
 if qryclear.Active then qryclear.Active:=false;
 try
 Qryclear.SQL.Clear;
 qryclear.SQL.Add('delete from returnhistory');
 qryclear.sql.Add('where return_date<:Adata');
 Qryclear.Prepare;
 Qryclear.ParamByName('Adata').AsDateTime:=Adate;
 qryclear.ExecSQL;
  messagedlg('清空成功!',mtInformation,[mbOK],0);
except
 messagedlg('清空失败!',mtError,[mbOK],0);
end;
end;

procedure TDMbook.clearReaderQuit(Adate:Tdatetime);
begin
 if qryclear.Active then qryclear.Active:=false;
try
 Qryclear.SQL.Clear;
 qryclear.SQL.Add('delete from readerquit');
 qryclear.sql.Add('where reader_quitdate<:Adata');
 Qryclear.Prepare;
 Qryclear.ParamByName('Adata').AsDateTime:=Adate;
 qryclear.ExecSQL;
  messagedlg('清空成功!',mtInformation,[mbOK],0);
except
 messagedlg('清空失败!',mtError,[mbOK],0);
end;
end;

procedure TDMbook.clearCloseTime(Adate: Tdatetime);
var
sqltemp:string;
begin
closeClosetime;
sqltemp:=Qryclosetime.SQL.Text;
Qryclosetime.SQL.Clear;
try
 try
  Qryclosetime.SQL.Add('DELETE FROM TIMECLOSE');
  Qryclosetime.sql.Add('where return_date<:Adata');
  Qryclosetime.Prepare;
  Qryclosetime.ParamByName('Adata').AsDateTime:=Adate;
  Qryclosetime.ExecSQL;
  messagedlg('清空成功!',mtInformation,[mbOK],0);
 finally
  closeClosetime;
  Qryclosetime.SQL.Text:=sqltemp;
  openClosetime;
 end;
except
  messagedlg('清空失败!',mtError,[mbOK],0);
end;

end;

procedure TDMbook.closeQrymaster;
begin
qrymaster.Close;
end;

procedure TDMbook.openQrymaster;
begin
qrymaster.Open;
end;

procedure TDMbook.closeQryTypemaster;
begin
qrytypemaster.Close;
end;

procedure TDMbook.openQryTypemaster;
begin
qrytypemaster.Open;
end;

procedure TDMbook.closeQryReaderQuit;
begin
QryReaderQuit.Close;
end;

procedure TDMbook.OpenQryReaderQuit;
begin
QryReaderQuit.Open;
end;

procedure TDMbook.bookaccept;
begin
try
Dbasebook.ApplyUpdates([qrybook]);
except
  messagedlg('保存数据失败!',mtError,[mbOK],0);
  qrybook.CancelUpdates; 
end;
end;

procedure TDMbook.bookcancel;
begin
qrybook.CancelUpdates;
end;

procedure TDMbook.bookdelete;
begin
qrybook.Delete;
end;

procedure TDMbook.bookedit;
begin
qrybook.Edit;
end;

procedure TDMbook.bookinsert;
begin
qrybook.Insert;
end;

procedure TDMbook.booklast;
begin
qrybook.Last;
end;

procedure TDMbook.booknext;
begin
qrybook.Next;
end;

procedure TDMbook.bookprior;
begin
qrybook.Prior;
end;

procedure TDMbook.bookpost;
begin
qrybook.Post;
end;

function TDMbook.bookfind(Abook_id:string):boolean;
begin
Result:=qrybook.Locate('book_id',Abook_id,[]);
end;

function TDMbook.IsFirst(Astate: string):boolean;
begin
 Result:=false;
 if Astate='book' then Result := qrybook.Bof;
 if Astate='reader' then Result := qryreader.Bof;
end;

function TDMbook.IsLast(Astate: string):boolean;
begin
  Result:=false;
 if Astate='book' then Result := qrybook.Eof;
 if Astate='reader' then Result := qryreader.Eof;
end;

procedure TDMbook.readeraccept;
begin
 try
Dbasebook.ApplyUpdates([qryreader]);
except
  messagedlg('保存数据失败!',mtError,[mbOK],0);
  qryreader.CancelUpdates; 
end;
end;

procedure TDMbook.readercancel;
begin
 qryreader.CancelUpdates; 
end;

procedure TDMbook.readerdelete;
begin
qryreader.Delete;
end;

procedure TDMbook.readeredit;
begin
 qryreader.Edit;
end;

function TDMbook.readerfind(Adatefield,Astring:string):boolean;
begin
Result:=qryreader.Locate(Adatefield,Astring,[]);
end;

procedure TDMbook.readerinsert;
begin
qryreader.Insert;
end;

procedure TDMbook.readerlast;
begin
qryreader.Last;
end;

procedure TDMbook.readernext;
begin
qryreader.Next;
end;

procedure TDMbook.readerpost;
begin
qryreader.Post;
end;

procedure TDMbook.readerprior;
begin
qryreader.Prior;
end;

procedure TDMbook.CountBookDataFromWhere(Atype,Awhere: string);
var
  tmpStr:string;
begin
  tmpStr:='';
  QryStatisticBook.Close;
  QryStatisticBook.SQL.Clear;
  if Atype='BOOKCOUNT' then
     tmpStr:='select sum(book_number) as bookcount from book';
  if Atype='BIG' then
     tmpStr:='select book_bigtype,book_bigname from bookbigtype order by book_bigtype';
  if Atype='BIGSMALL' then
     begin
       tmpStr:='select book_type,book_smallname,book_bigtype from booksmalltype where book_bigtype='+'"'+Awhere+'"';
       tmpStr:=tmpStr+' order by book_type';
     end;
  if Atype='BIGBOOKCOUNT' then
     tmpStr:='select sum(book_number) as bigbookcount from book where book_id like '+'"'+Awhere+'%"';
  if Atype='BIGBOOK' then
    begin
      tmpStr:='select book_id,book_name,book_publish,book_pubdate,book_number,book_price,book_date ';
      tmpStr:=tmpStr+'from book where book_id like '+'"'+Awhere+'%"';
      tmpStr:=tmpStr+' order by book_id';
    end;
  if Atype='BIGSMALLBOOKCOUNT' then
     tmpStr:='select sum(book_number) as bigsmallbookcount from book where book_id like '+'"'+Awhere+'%"';
  if Atype='BIGSMALLBOOK' then
    begin
      tmpStr:='select book_id,book_name,book_publish,book_pubdate,book_number,book_price,book_date ';
      tmpStr:=tmpStr+'from book where book_id like '+'"'+Awhere+'%"';
      tmpStr:=tmpStr+' order by book_id';
    end;
  //  showmessage(tmpStr);
  QryStatisticBook.SQL.Text:=tmpStr;
  QryStatisticBook.Prepare;
  QryStatisticBook.Open;
end;

procedure TDMbook.CountAllCount(AString:TStrings);
begin
  if (glbBigTypeCount=0)or(glbSmallTypeCount=0) then DMbook.openbooktypedb;
  CountBookDataFromWhere('BOOKCOUNT','');
  glbBookCount:=QryStatisticBook.FieldByName('bookcount').AsInteger;
  Qrybigtype.First;
  Astring.Clear;
  while not Qrybigtype.Eof do
     begin
      AString.Add(Qrybigtype.FieldValues['BOOK_BIGTYPE']+'='+Qrybigtype.FieldValues['BOOK_BIGNAME']);
      Qrybigtype.Next;
     end;
end;


procedure TDMbook.CountBigCount(Awhere:string;var AsmalltypeCount, AbigBookcount: string;
  Astring: TStrings);
var
  tmpStr:string;
begin
  CountBookDataFromWhere('BIGBOOKCOUNT',Awhere);
  AbigBookcount:=QryStatisticBook.FieldByName('bigbookcount').AsString;
  if AbigBookCount='' then AbigBookCount:='0';
  CountBookDataFromWhere('BIGSMALL',Awhere);
  AsmalltypeCount:=inttostr(QryStatisticBook.RecordCount);
  QryStatisticBook.First;
  tmpStr:='';
  Astring.Clear;
  while not QryStatisticBook.Eof do
  begin
     Astring.Add(QryStatisticBook.FieldValues['BOOK_TYPE']+'='+QryStatisticBook.FieldValues['BOOK_SMALLNAME']);
     QryStatisticBook.Next;
  end;
end;

procedure TDMbook.closeCountData;
begin
   QryStatisticBook.Close;
   QryStatisticReader.Close;
   QryStatisticBorrow.Close;
end;

procedure TDMbook.CountReaderDataFromWhere(Atype, Awhere: string);
var
  tmpStr:string;
begin
  tmpStr:='';
  QryStatisticReader.Close;
  QryStatisticReader.SQL.Clear;
  if Atype='READERCOUNT' then
    tmpStr:='select count(*) as readercount from reader';
  if Atype='READERDATA' then
    tmpStr:='select reader_id,reader_no,reader_name,reader_dept,reader_dodate from reader order by reader_id';
  if Atype='READERQUITCOUNT' then
    tmpStr:='select count(*) as readerquitcount from readerquit';
  if Atype='READERQUITDATA' then
    tmpStr:='select reader_id,reader_no,reader_name,reader_dept,reader_dodate,reader_quitdate from readerquit order by reader_id';
  QryStatisticReader.SQL.Text:=tmpStr;
  QryStatisticReader.Prepare;
  QryStatisticReader.Open;
end;

procedure TDMbook.CountBorrowDataFromWhere(Atype: string; Awhere: Tdatetime);
var
  tmpStr:string;
  tyear,tmonth,tday:word;
begin
  tmpStr:='';
  QryStatisticBorrow.Close;
  QryStatisticBorrow.SQL.Clear;
    //
  DecodeDate(Awhere,tyear,tmonth,tday);
  if Atype='BORROWCOUNT' then
    tmpStr:='select sum(borrow_number) as borrowcount from borrowbooks';
  if Atype='BORROWBOOK' then
    tmpStr:='select book_id,book_name,borrow_date,borrow_day from borrowitems order by book_id';
  if Atype='CURBORROWCOUNT' then
    begin
      tmpStr:='select count(*) as curborrowcount from borrowitems where';
      tmpStr:=tmpStr+' (extract(year from borrow_date)='+'"'+inttostr(tyear)+'")';
      tmpStr:=tmpStr+' and (extract(month from borrow_date)='+'"'+inttostr(tmonth)+'")';
      tmpStr:=tmpStr+' and (extract(day from borrow_date)='+'"'+inttostr(tday)+'")';
    end;
  if Atype='CURBORROWBOOK' then
    begin
      tmpStr:='select book_id,book_name,borrow_date,borrow_day from borrowitems where';
      tmpStr:=tmpStr+' (extract(year from borrow_date)='+'"'+inttostr(tyear)+'")';
      tmpStr:=tmpStr+' and (extract(month from borrow_date)='+'"'+inttostr(tmonth)+'")';
      tmpStr:=tmpStr+' and (extract(day from borrow_date)='+'"'+inttostr(tday)+'")';
      tmpStr:=tmpStr+' order by book_id';
    end;
  if Atype='RETURNCOUNT' then
    tmpStr:='select count(*) as returncount from returnhistory';
  if Atype='RETURNBOOK' then
    begin
      tmpStr:='select a.book_id,b.book_name,a.return_date from returnhistory a,book b';
      tmpStr:=tmpStr+' where a.book_id=b.book_id order by book_id';
    end;
  if Atype='CURRETURNCOUNT' then
    begin
      tmpStr:='select count(*) as curreturncount from returnhistory where';
      tmpStr:=tmpStr+' (extract(year from return_date)='+'"'+inttostr(tyear)+'")';
      tmpStr:=tmpStr+' and (extract(month from return_date)='+'"'+inttostr(tmonth)+'")';
      tmpStr:=tmpStr+' and (extract(day from return_date)='+'"'+inttostr(tday)+'")';
    end;
  if Atype='CURRETURNBOOK' then
    begin
      tmpStr:='select a.book_id,b.book_name,a.return_date from returnhistory a,book b ';
      tmpStr:=tmpStr+'where (a.book_id=b.book_id)';
      tmpStr:=tmpStr+' and (extract(year from return_date)='+'"'+inttostr(tyear)+'")';
      tmpStr:=tmpStr+' and (extract(month from return_date)='+'"'+inttostr(tmonth)+'")';
      tmpStr:=tmpStr+' and (extract(day from return_date)='+'"'+inttostr(tday)+'")';
      tmpStr:=tmpStr+' order by book_id';
    end;
  QryStatisticBorrow.SQL.Text:=tmpStr;
  QryStatisticBorrow.Prepare;
  QryStatisticBorrow.Open;
end;

procedure TDMbook.CounteachBorrowDataFromWhere(Atype, Awhere: string);
var
  tmpStr:string;
begin
  tmpStr:='';
  QryStatisticBorrow.Close;
  QryStatisticBorrow.SQL.Clear;
  if Atype='BORROWBOOK' then
    tmpStr:='select book_id,book_name,borrow_date,borrow_day from borrowitems '+Awhere+' order by book_id';
  if Atype='RETURNBOOK' then
    begin
      tmpStr:='select a.book_id,b.book_name,a.return_date from returnhistory a,book b ';
      tmpStr:=tmpStr+Awhere+' and (a.book_id=b.book_id) order by book_id';
    end;
  QryStatisticBorrow.SQL.Text:=tmpStr;
  QryStatisticBorrow.Prepare;
  QryStatisticBorrow.Open;
end;

end.

⌨️ 快捷键说明

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