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

📄 untreturn.~pas

📁 资料室图书借阅管理系统
💻 ~PAS
📖 第 1 页 / 共 2 页
字号:
unit untreturn;

interface

uses
  Classes, SysUtils, IWAppForm, IWApplication, IWTypes, IWGrids, IWDBGrids,
  IWCompButton, IWCompEdit, Controls, IWVCLBaseControl, IWBaseControl,
  IWControl, IWCompLabel, IWCompRadioButton, IWCompListbox, Forms, untframe,
  IWHTMLControls, IWExtCtrls, DB, ADODB,graphics, Menus, IWBaseHTMLControl;

type
  Tfrmreturn = class(TIWAppForm)
    IWLabel1: TIWLabel;
    IWLabel2: TIWLabel;
    IWEdit1: TIWEdit;
    IWLabel3: TIWLabel;
    IWEdit2: TIWEdit;
    IWButton1: TIWButton;
    IWDBGrid1: TIWDBGrid;
    IWFrame11: TIWFrame1;
    IWLabel4: TIWLabel;
    IWLabel6: TIWLabel;
    IWButton2: TIWButton;
    IWRadioGroup1: TIWRadioGroup;
    IWHRule1: TIWHRule;
    IWHRule2: TIWHRule;
    IWComboBox1: TIWComboBox;
    ADOQuery1: TADOQuery;
    DataSource1: TDataSource;
    IWLabel5: TIWLabel;
    IWDBGrid2: TIWDBGrid;
    ADOQuery2: TADOQuery;
    DataSource2: TDataSource;
    ADOQuery3: TADOQuery;
    IWListbox1: TIWListbox;
    procedure IWButton2Click(Sender: TObject);
    procedure IWButton1Click(Sender: TObject);
    procedure IWDBGrid1RenderCell(ACell: TIWGridCell; const ARow,
      AColumn: Integer);
    procedure IWAppFormCreate(Sender: TObject);
    //procedure IWAppFormCreate(Sender: TObject);
   // procedure IWDBGrid1HTMLTag(ASender: TObject; ATag: TIWHTMLTag);
   // procedure IWAppFormCreate(Sender: TObject);
    //procedure IWAppFormCreate(Sender: TObject);
    //procedure IWButton3Click(Sender: TObject);
  public
  end;

implementation

uses ServerController,DateUtils,tempuntmain,untguest,untlog, unqkbasic;

{$R *.dfm}
var
  tempuser:string;
  tempname:string;
  tempid:string;
  m, h,j,k,q:integer;
procedure Tfrmreturn.IWButton2Click(Sender: TObject);
var
  //t:string;
  tempadostr:string;
  tempadostr2,tempadostr3:string;
  expirebook:integer;
  expiredate:integer;
begin

  tempuser:=trim(iwedit2.Text);
  case iwcombobox1.ItemIndex of
    0: begin

          tempname:=tempuser;
          adoquery2.Close;
          adoquery2.SQL.Clear;
          adoquery2.SQL.Add(' SELECT user11.UserId as 用户编号, user11.username as 用户名称, user11.departID as 部门编号, user11.sex as 姓别, user11.address as 住址, user11.telNum as 电话, user11.MobileNum as 手机, user11.zipcode as 邮编,  '+
              ' user11.FaxNum as 传真, user11.Email as Email,  user11.memo as 备注 FROM  user11   '+
              ' where user11.username='+quotedstr(tempuser));
         adoquery2.Open;

         if  adoquery2.RecordCount>1 then
               begin
                 webapplication.ShowMessage('存在多个用户,请使用读者编号再次查询!');
                 iwdbgrid2.Visible:=true;
                 iwlistbox1.Visible:=false;
                 adoquery1.Close;
               end
         else
         if  adoquery2.RecordCount=0 then
         begin
             webapplication.ShowMessage('不存在此用户名,请正确输入!');
             adoquery2.Close;
         end
         else          //adoquery2.recordcount=1
         begin
           //iwdbgrid1.Visible:=true;
           iwdbgrid2.Visible:=false;

           tempid:=adoquery2.Lookup('用户名称',tempuser,'用户编号');
           adoquery2.Close;

          adoquery1.Close;
          adoquery1.SQL.Clear;
          adoquery1.SQL.Add('SELECT  borrowreturn.BookID as 书号, book.Name as 书名, borrowreturn.journalid as 期刊号, JournalDetail.JournalBasicID as 期刊名, borrowreturn.userId as 用户编号, borrowreturn.username as 用户名称, '+
          ' borrowreturn.borrowDate as 借书日期, borrowreturn.MEmo as 备注'+
              ' FROM JournalDetail INNER JOIN (book INNER JOIN borrowreturn ON book.BookID = borrowreturn.BookID) ON JournalDetail.ID = borrowreturn.journalid'+
              ' where borrowreturn.username='+quotedstr(tempuser)+' ORDER BY borrowreturn.borrowDate DESC');
          adoquery1.Open;
          adoquery1.First;
          k:=adoquery1.RecordCount;

          if K<>0 then
          begin
             iwlistbox1.Items.Clear;
             iwlistbox1.Visible:=true;
          end;

          while not adoquery1.Eof do
          begin
             tempadostr:=adoquery1.fieldbyname('借书日期').AsString;

             expirebook:=DaysBetween(strtodatetime(tempadostr),Now);
             if expirebook>dqstr then
                     begin
                        expiredate:=expirebook-dqstr;
                        tempadostr2:= adoquery1.fieldbyname('书号').AsString;
                        tempadostr3:= adoquery1.fieldbyname('期刊号').AsString;
                                if trim(tempadostr2)='' then
                                begin
                                   // webapplication.ShowMessage(tempadostr2+inttostr(expiredate));
                                   iwlistbox1.Items.Add(tempadostr3+'以超期'+inttostr(expiredate)+'天!');
                                end
                                else
                                begin
                                   iwlistbox1.Items.Add(tempadostr2+'以超期'+inttostr(expiredate)+'天!');
                                end;    //end if
                     end
               else
               //if expirebook<dqstr then
               begin
                expiredate:=dqstr-expirebook;
                tempadostr2:= adoquery1.fieldbyname('书号').AsString;
                tempadostr3:= adoquery1.fieldbyname('期刊号').AsString;
                      if trim(tempadostr2)='' then
                      begin
                        iwlistbox1.Items.Add (tempadostr3+'还有'+inttostr(expiredate)+'天到期!');
                        end
                     else
                     begin
                     iwlistbox1.Items.Add(tempadostr2+'还有'+inttostr(expiredate)+'天到期!');
                     end;
                end;   //end if
                adoquery1.Next;
         end;   //end while
          adoquery1.First;
         end ; //end ifelse

       end;  //end 0

    1:  begin
          iwlistbox1.Visible:=false;
          adoquery1.Close;
          adoquery1.SQL.Clear;
         adoquery1.SQL.Add('SELECT   borrowreturn.BookID as 书号, book.Name as 书名, borrowreturn.journalid as 期刊号, JournalDetail.JournalBasicID as 期刊名, borrowreturn.userId as 用户编号, borrowreturn.username as 用户名称,  '+
              ' borrowreturn.borrowDate as 借书日期, borrowreturn.MEmo as 备注'+
              ' FROM JournalDetail INNER JOIN (book INNER JOIN borrowreturn ON book.BookID = borrowreturn.BookID) ON JournalDetail.ID = borrowreturn.journalid'+
              ' where borrowreturn.userId='+quotedstr(tempuser)+' ORDER BY borrowreturn.borrowDate DESC');
          adoquery1.Open;
           k:=adoquery1.RecordCount ;
          if  k<>0 then
          begin
          iwlistbox1.Items.Clear;
          iwlistbox1.Visible:=true;
          tempid:=tempuser;
          tempname:=adoquery1.Lookup ('用户编号',tempid,'用户名称');
          iwdbgrid2.Visible:=false;
          adoquery2.Close;
          iwdbgrid1.Visible:=true;

          adoquery1.First;

          while not adoquery1.Eof do
          begin
             tempadostr:=adoquery1.fieldbyname('借书日期').AsString;

             expirebook:=DaysBetween(strtodatetime(tempadostr),Now);
             if expirebook>dqstr then
             begin
                expiredate:=expirebook-dqstr;
                tempadostr2:= adoquery1.fieldbyname('书号').AsString;
                tempadostr3:= adoquery1.fieldbyname('期刊号').AsString;
                if trim(tempadostr2)='' then
                        begin
                           // webapplication.ShowMessage(tempadostr2+inttostr(expiredate));
                             iwlistbox1.Items.Add(tempadostr3+'以超期'+inttostr(expiredate)+'天!');
                        end
                        else
                        begin
                            iwlistbox1.Items.Add(tempadostr2+'以超期'+inttostr(expiredate)+'天!');
                            end;
                end
                 else
                         //if expirebook<dqstr then
                         begin
                          expiredate:=dqstr-expirebook;
                          tempadostr2:= adoquery1.fieldbyname('书号').AsString;
                          tempadostr3:= adoquery1.fieldbyname('期刊号').AsString;
                          if trim(tempadostr2)='' then
                          begin
                            iwlistbox1.Items.Add (tempadostr3+'还有'+inttostr(expiredate)+'天到期!');
                            end
                         else
                         begin
                         iwlistbox1.Items.Add(tempadostr2+'还有'+inttostr(expiredate)+'天到期!');
                         end;
             end;
             adoquery1.Next;
          end;
          adoquery1.First;
     end //end if
     else
     begin
        adoquery3.Close;
        adoquery3.SQL.Clear;
        adoquery3.SQL.add('SELECT user11.UserId, user11.username FROM user11');
        adoquery3.Open;
        if   adoquery3.RecordCount=0 then
        begin
               webapplication.ShowMessage('找不到此用户号,请正确输入');
               adoquery3.Close;
        end
        else
        begin
           tempid:=tempuser;
          tempname:=adoquery3.Lookup ('userId',tempid,'username');
          adoquery3.Close;

          iwdbgrid2.Visible:=false;
          iwdbgrid1.Visible:=true;
        end;

     end;  //end ifelse

     end;    //end case1
  end;
 end;

procedure Tfrmreturn.IWButton1Click(Sender: TObject);
var
   str1,str2,str3:string;
   tempstr:string;   //在库
   tempint:integer;

   tempadostr:string;
  tempadostr2,tempadostr3:string;
  expirebook:integer;
  expiredate:integer;
begin
   tempstr:='在库';
   str1:=copy(iwedit1.Text,0,1);
   tempint:=strtoint(str1);
  // webapplication.ShowMessage(str1);

  if tempuser='' then
  begin
    webapplication.ShowMessage('请先查询读者信息');
  end
  else
  begin
      iwdbgrid1.DataSource:=nil;
   case iwradiogroup1.ItemIndex  of
       0:begin

          adoquery1.Close;
          adoquery1.SQL.Clear;
          adoquery1.SQL.Add('SELECT  borrowreturn.BookID as 书号, book.Name as 书名, borrowreturn.journalid as 期刊号, JournalDetail.JournalBasicID as 期刊名, borrowreturn.userId as 用户编号, borrowreturn.username as 用户名称, '+
          ' borrowreturn.borrowDate as 借书日期, borrowreturn.MEmo as 备注 '+
              ' FROM book INNER JOIN (JournalDetail INNER JOIN borrowreturn ON JournalDetail.ID = borrowreturn.journalid) ON book.BookID = borrowreturn.BookID'+
              ' where borrowreturn.Booktype='+quotedstr(tempstr));
          adoquery1.Open;

         case tempint of
            1:begin
              if adoquery1.Locate('书号',trim(iwedit1.Text),[]) then

              begin
                str2:='借出';
                str3:=datetimetostr(now);

                adoquery1.Close;

                adoquery1.SQL.Clear;
                adoquery1.SQL.Add('SELECT * FROM borrowreturn ');
                adoquery1.Open;

                adoquery1.Locate('BookID',trim(iwedit1.Text),[]);
                adoquery1.Edit;

                adoquery1.FieldByName('username').AsString:=tempname;
                adoquery1.FieldByName('userId').AsString:=tempid;
                adoquery1.FieldByName('Booktype').AsString:=str2;
                adoquery1.FieldByName('borrowDate').AsString:=str3;
                adoquery1.Post;
                adoquery1.Refresh;
                adoquery1.Close;
                  h:=h+1;
                  iwlistbox1.Items.Add(trim(iwedit1.Text)+'还有'+inttostr(dqstr)+'天到期!');
                  iwdbgrid1.Visible:=true;
              end  //end if
              else
              begin
                webapplication.ShowMessage('书号输入错误,请重新输入');
               // adoquery1.EnableControls;
              end;
               adoquery1.Close;
               adoquery1.SQL.Clear;

              adoquery1.SQL.Add('SELECT   borrowreturn.BookID as 书号, book.Name as 书名, borrowreturn.journalid as 期刊号, JournalDetail.JournalBasicID as 期刊名, borrowreturn.userId as 用户编号, borrowreturn.username as 用户名称, '+
              ' borrowreturn.borrowDate as 借书日期, borrowreturn.MEmo as 备注'+
              ' FROM JournalDetail INNER JOIN (book INNER JOIN borrowreturn ON book.BookID = borrowreturn.BookID) ON JournalDetail.ID = borrowreturn.journalid '+
              ' where borrowreturn.username='+quotedstr(tempname)+' ORDER BY borrowreturn.borrowDate DESC');
          adoquery1.Open;
         
          iwdbgrid1.DataSource:=datasource1;

             end;    //end case 01

           2:begin

           if adoquery1.Locate('期刊号',trim(iwedit1.Text),[]) then

              begin
                str2:='借出';
                str3:=datetimetostr(now);

                adoquery1.Close;

                adoquery1.SQL.Clear;
                adoquery1.SQL.Add('SELECT * FROM borrowreturn ');
                adoquery1.Open;

                adoquery1.Locate('journalid',trim(iwedit1.Text),[]);
                adoquery1.Edit;

                adoquery1.FieldByName('username').AsString:=tempname;
                adoquery1.FieldByName('userId').AsString:=tempid;
                adoquery1.FieldByName('Booktype').AsString:=str2;
                adoquery1.FieldByName('borrowDate').AsString:=str3;
                adoquery1.Post;
                adoquery1.Refresh;
                adoquery1.Close;
                 h:=h+1;
                  iwlistbox1.Items.Add(trim(iwedit1.Text)+'还有'+inttostr(dqstr)+'天到期!');
                  iwdbgrid1.Visible:=true;
              end  //end if

⌨️ 快捷键说明

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