【正文】
into Manager values (managerId,password,Name,Level ,Phone,Email,Birthday,sex) set able=1 endENDif error0 or rowcount = 0 rollback transaction。88888839。3) 借閱書(shū)籍:ALTER PROCEDURE [dbo].[Proc_Borrow]ReaderId varchar(50),BookId varchar(50),state int outputASBEGIN if (select balance from Reader where sReaderId=ReaderId)0 set state=0 有欠款,不可借 else begin declare BorrowId varchar(50) set BorrowId=ReaderId+39。+BookId+cast(GETDATE() as varchar(10)) insert into [dbo].Borrowed values(BorrowId,ReaderId,BookId,GETDATE(),GETDATE()+30,null,0) update Book set iState=0 where sBookId=BookId set state=1 endENDif error0 or rowcount = 0 rollback transaction。5) 檢查書(shū)目狀態(tài):ALTER PROCEDURE [dbo].[Proc_Checkbook]bookId varchar(50),bookState int,pages int=nullASBEGIN if bookState=2 缺頁(yè) begin update Borrowed set Fine_ticket=Fine_ticket+ (select fnum from FineKind where iFineKind=2)*pages where sBookId= (select top(1) sBookId from Borrowed where sBookId=bookId order by Return_Date desc) update Book set iState=1 where sBookId=bookId end else if bookState=4 遺失 begin update Borrowed set Fine_ticket=Fine_ticket+ (select fnum from FineKind where iFineKind=4)*(select fPrice from Book where sBookId=bookId) where sBookId= (select top(1) sBookId from Borrowed where sBookId=bookId order by Return_Date desc) update Book set iState=4 where sBookId=bookId endEND if error0 or rowcount = 0 rollback transaction。日期39。7) 登錄:ALTER PROCEDURE [dbo].[Proc_LogIn] id varchar(50),password varchar(50),pos int output,name varchar(50) outputASBEGINIF pos = 0 BEGIN if exists(select * from Reader where sReaderId = id and sPassword = password and Lend_able=1) select name = Name from Reader where sReaderId = id and sPassword = password else set pos = 1 END ELSE BEGIN if exists(select * from Manager where sManagerId = id and sPassword = password) select pos=iLevel,name = Name from Manager where sManagerId = id and sPassword = password /* 設(shè)置pos的值,當(dāng)顯示管理員界面時(shí)根據(jù)級(jí)別不同而設(shè)置管理員可進(jìn)行的操作*/ else set pos = 1 END END else set pos = 1 END END if error0 or rowcount = 0 rollback transaction。9) 下訂單:ALTER PROCEDURE [dbo].[Proc_MakeOrder]bookname varchar(30),press varchar(20)=null,order_num int ,orderstaffId varchar(20),state int=null outputASBEGIN declare orderid varchar(30) set orderid=bookname+39。+cast(GETDATE()as varchar(10)) if exists(select *from [order] where sOrderId=orderid) set state=0 else begin insert into [dbo].[Order] values(orderid,bookname,press,order_num,GETDATE(),orderstaffId) set state=1 endEND if error0 or rowcount = 0 rollback transaction。 11) 充值:ALTER PROCEDURE [dbo].[Proc_paydebt]sReaderId varchar(30),money floatASBEGIN declare tmp float select tmp=balance from Reader where sReaderId=sReaderId if tmp is null update Reader set balance=money where sReaderId=sReaderId else update Reader set balance=balance+money where sReaderId=sReaderIdENDif error0 or rowcount = 0 rollback transaction。13) 還書(shū):ALTER PROCEDURE [dbo].[Proc_Return]bookId varchar(50)ASBEGIN declare balance float if GETDATE()(select DeadLine from Borrowed where sBookId=bookId and Return_Date=null) begin declare tmp float declare deadline date select deadline=deadline from Borrowed where sBookId=bookId and Return_Date=null該書(shū)的應(yīng)還日期 select tmp=fNum from FineKind where iFineKind=1 set tmp=tmp*CAST((GETDATE()deadline)as int) update Borrowed set Fine_ticket=tmp where sBookId=bookId update Reader set balance=balancetmp where sReaderId= (select top(1) sReaderId from Borrowed where sBookId=bookId order by DeadLine desc) end update Borrowed set Return_date =GETDATE() where sBookId=bookId 設(shè)置還書(shū)日期 update Book set iState=1 where sBookId=bookIdENDif error0 or rowcount = 0 rollback transaction。select sbookId as 圖書(shū)編號(hào), sBookName as 圖書(shū)名稱(chēng), sAuthor as 作者,