<%@language=vbscript codepage=936 %>
<%
Option Explicit
%>
<!--#include file="../conn.asp"-->
<%
Dim ProductID
Dim rs,iStocks
ProductID = Trim(request("ProductID"))
If IsNumeric(ProductID) then
	ProductID=Clng(ProductID)
else
	ProductID=0
end if
If ProductID > 0 Then
	Set rs = Conn.Execute("select Stocks,OrderNum from PE_Product where ProductID=" & ProductID & "")
	If rs.BOF And rs.EOF Then
		iStocks=0
	else
		iStocks=rs(0)-rs(1)
		if iStocks<0 then iStocks=0
	End If
	rs.close
	set rs=nothing
else
	iStocks=0
End If

Response.Write "document.write('" & iStocks & "');"
Call CloseConn
%>