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

📄 modifyrent.asp

📁 本程序是一款比较完善的图书租赁系统
💻 ASP
字号:
<%@ codePage="936" %>
<!--#include file="CONN.ASP"-->
<!--#include file="ChkErr.asp"-->
<!--#include file="ResultMsg.asp"-->
<%
If IsNumeric(Request("id"))=False Or Request("id")="" Then
	Response.Write GetErr(1)
	Response.End
End If

Sub ChkBooked()
	Dim objRS,strSQL
	Set objRS=Server.CreateObject("ADODB.RecordSet")
	'判断预订是否实现
	strSQL="SELECT TAC_ID_N FROM [Tenancy] WHERE TAC_ID_N="&Request("id")&" AND TAC_StartTime_D IS NULL AND TAC_UI_ID_FN="&Session("UserID")
	objRS.Open strSQL,objConn,1,3
	'若预订被实现,则输出错误信息
	If objRS.BOF Or objRS.EOF Then
		Response.Write "<br><br><br>"
		ResultMsg("此预订已经被实现或者不存在!")
		objRS.Close
		Set objRS=Nothing
		CloseDatabase
		Response.End
	End If
	objRS.Close
End Sub

Function ChkRent(ChkOption)
	Dim objRS,strSQL
	Set objRS=Server.CreateObject("ADODB.RecordSet")
	Select Case ChkOption
		Case "StartRent"
			strSQL="SELECT TAC_ID_N FROM [Tenancy] WHERE TAC_ID_N="&Request("id")&" AND TAC_StartTime_D IS NULL"
		Case "EndRent"
			strSQL="SELECT TAC_ID_N FROM [Tenancy] WHERE TAC_ID_N="&Request("id")&" AND TAC_StartTime_D IS NOT NULL AND TAC_EndTime_D IS NULL"
	End Select
	objRS.Open strSQL,objConn,1,3
	If Not objRS.BOF Or Not objRS.EOF Then
		ChkRent=True
	Else
		ChkRent=False
	End If
	objRS.Close
End Function

Select Case Request("action")
	'显示确认取消预订的页面
	Case "CancelBooked"
		'若预订没有实现则可以取消
		ChkBooked()
		Response.Write "<form action=modifyRent.asp><br><br><br>"
		ResultMsg("您确定取消对租赁号为&nbsp;<b><a href=disprent.asp?id="&Request("id")&"><font color=red>"&Request("id")&"</font></a></b>&nbsp;么的预订?")
		Response.Write "<p align=center><input type=submit value=确定>&nbsp;<input type=button value=关闭 onclick=vbscript:window.close()></p>"
		Response.Write "<input type=hidden name=action value=ReadyToCancel><input type=hidden name=id value="&Request("id")&">"
		Response.Write "</form>"
		
	Case "ReadyToCancel"
		'取消预订
		ChkBooked()
		strSQL="DELETE FROM [Tenancy] WHERE TAC_ID_N="&Request("id")
		objConn.Execute(strSQL)
		Response.Write "<br><br><br>"
		ResultMsg("您的预订已被取消!")
		
	Case "CtrRent"
		%><!--#include file="ChkAdmin.asp"--><%
		'显示租赁选项
		Response.Write "<link href=style.css rel=stylesheet type=text/css>"
		Response.Write "<br><br><br><br><br>"
		Response.Write "<form action=modifyRent.asp>"
		Response.Write "<p align=center>对预订号为<b><font color=red>"&Request("id")&"</font></b>的预订:"
		Response.Write "<input type=radio name=action value=StartRent>起租&nbsp;<input type=radio name=action value=ConfirmEndRent>结算"
		Response.Write "<br><input type=submit value=确认>&nbsp;<input type=button value=返回 onclick=javascript:history.go(-1)></p>"
		Response.Write "<input type=hidden name=id value="&Request("id")&">"
		Response.Write "</form>"
		
	Case "StartRent"
		%><!--#include file="ChkAdmin.asp"--><%
		Set objRS=Server.CreateObject("ADODB.RecordSet")
		'判断用户是否有超期未还的影片
		strSQL="SELECT TAC_ID_N FROM [Tenancy] WHERE TAC_UI_ID_FN="&Session("UserID")&" AND TAC_Timeout_B=True AND TAC_EndTime_D IS NULL"
		objRS.Open strSQL,objConn,1,3
			If Not objRS.BOF Or Not objRS.EOF Then
				Response.Write "<br><br><br>"
				ResultMsg("此用户还有影片未归还!请归还影片后再作预订!")
				CloseDatabase
				Response.End
			End If
		objRS.Close
		
		'更新租赁信息
		If ChkRent("StartRent")=False Then
			Response.Write "<br><br><br>"
			ResultMsg("所要起租的预订不存在或者已经起租!")
			CloseDatabase
			Response.End
		End If
		strSQL="UPDATE [Tenancy] SET TAC_StartTime_D='"&Now()&"',TAC_Status_N=3 WHERE TAC_ID_N="&Request("id")
		objConn.Execute(strSQL)
		'读取影片信息
		strSQL="SELECT VI_ID_N,VI_VS_ID_FN,VI_RentCount_N,TAC_UI_ID_FN FROM [Tenancy],[VideoInfo] WHERE TAC_VI_ID_FN=VI_ID_N AND TAC_ID_N="&Request("id")
		objRS.Open strSQL,objConn,1,3
		Dim tmpVSID
		tmpVSID=objRS("VI_VS_ID_FN")
		tmpUID=objRS("TAC_UI_ID_FN")
		'更新影片信息
		strSQL="UPDATE [VideoInfo] SET VI_Status_N=3,VI_RentCount_N="&objRS("VI_RentCount_N")+1&" WHERE VI_ID_N="&objRS("VI_ID_N")
		objConn.Execute(strSQL)
		objRS.Close
		'更新影片类型的租赁计数
		strSQL="SELECT VS_ID_N,VS_RentCount_N FROM [VideoStyle] WHERE VS_ID_N="&tmpVSID
		objRS.Open strSQL,objConn,1,3
		strSQL="UPDATE [VideoStyle] SET VS_RentCount_N="&objRS("VS_RentCount_N")+1&" WHERE VS_ID_N="&objRS("VS_ID_N")
		objConn.Execute(strSQL)
		objRS.Close
		'更新用户租赁计数
		strSQL="SELECT UI_RentCount_N FROM [UserInfo] WHERE UI_ID_N="&tmpUID
		objRS.Open strSQL,objConn,1,3
		strSQL="UPDATE [UserInfo] SET UI_RentCount_N="&objRS("UI_RentCount_N")+1&" WHERE UI_ID_N="&tmpUID
		objConn.Execute(strSQL)
		objRS.Close
		Response.Write "<br><br><br>"
		ResultMsg("预订已成功起租!")
		
	Case "ConfirmEndRent"
		%><!--#include file="ChkAdmin.asp"--><%
		'显示确认结算的页面
		If ChkRent("EndRent")=False Then
			Response.Write "<br><br><br>"
			ResultMsg("所要结算的预订不存在或者已结算!")
			CloseDatabase
			Response.End
		End If
		Response.Write "<link href=style.css rel=stylesheet type=text/css>"
		Response.Write "<br><br><br><br><br>"
		Response.Write "<form action=modifyrent.asp>"
		Response.Write "<p align=center>是否要结算预订号为&nbsp;<b><font color=red>"&Request("id")&"</font></b>&nbsp;的租赁?"
		Response.Write "<br><input type=submit value=结算>&nbsp;<input type=button value=返回 onclick=javascript:history.go(-1)>"
		Response.Write "<input type=hidden name=action value=EndRent><input type=hidden name=id value="&Request("id")&">"
		Response.Write "</p></form>"
		
	Case "EndRent"
		%><!--#include file="ChkAdmin.asp"--><%
		'结算
		If ChkRent("EndRent")=False Then
			Response.Write "<br><br><br>"
			ResultMsg("所要结算的预订不存在或者已结算!")
			CloseDatabase
			Response.End
		End If
		'读取影片的租价信息,计算租价
		strSQL="SELECT VI_ID_N,VI_VS_ID_FN,TAC_UI_ID_FN,UI_CerRank_N,UI_RentCount_N,PMT_Price_N,PMT_Deposit_N,PMT_LateFee_N,TAC_Lease_N,TAC_StartTime_D,TAC_TimeOut_B FROM [Payment],[VideoInfo],[Tenancy],[UserInfo] WHERE TAC_VI_ID_FN=VI_ID_N AND TAC_UI_ID_FN=UI_ID_N AND VI_PMT_ID_FN=PMT_ID_N AND TAC_ID_N="&Request("id")
		Set objRS=Server.CreateObject("ADODB.RecordSet")
		objRS.Open strSQL,objConn,1,3
		'计算超期天数
		Dim tmpTimeout
		If IsNull(objRS("TAC_StartTime_D"))=False Then
			tmpTimeout=DateDiff("d",DateAdd("d",objRS("TAC_Lease_N"),objRS("TAC_StartTime_D")),Now())
			If tmpTimeout<=0 Then
				tmpTimeout=0
			End If
		Else
			tmpTimeout=0
		End If
		'获取并判断用户租金
		Dim tmpUserPayment
		If IsNull(objRS("TAC_StartTime_D"))<>True Then
			If objRS("TAC_TimeOut_B")=True Then
				tmpUserPayment=objRS("PMT_Price_N")*DateDiff("d",objRS("TAC_StartTime_D"),Now())+objRS("PMT_LateFee_N")*tmpTimeout
			Else
				tmpUserPayment=objRS("PMT_Price_N")*objRS("TAC_Lease_N")
			End If
		Else
			tmpUserPayment=0
		End If
		Dim tmpVID,tmpUID,tmpUserRentCount
		tmpVID=objRS("VI_ID_N")
		tmpUID=objRS("TAC_UI_ID_FN")
		tmpUserRentCount=objRS("UI_RentCount_N")
		objRS.Close
		'更新租赁记录
		strSQL="UPDATE [Tenancy] SET TAC_Return_B=True,TAC_EndTime_D='"&Now()&"',TAC_UserPayment_N='"&tmpUserPayment&"',TAC_Status_N=1 WHERE TAC_ID_N="&Request("id")
		objConn.Execute(strSQL)
		'更新影片记录
		strSQL="UPDATE [VideoInfo] SET VI_Status_N=1 WHERE VI_ID_N="&tmpVID
		objConn.Execute(strSQL)
		'更新用户信用记录
		strSQL="UPDATE [UserInfo] SET UI_RentCount_N="&tmpUserRentCount+1&" WHERE UI_ID_N="&tmpUID
		objConn.Execute(strSQL)
		Response.Write "<br><br><br>"
		ResultMsg("预订已成功结算!")
	Case Else
		Response.Write GetErr(1)
		Response.End
End Select
Set objRS=Nothing
CloseDatabase
%>

⌨️ 快捷键说明

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