我的代码:
<!--#include file="conn/conn.asp"-->
<%
sj = Request.form("sj")
n1 = Request.form("n1")
y1 = Request.form("y1")
r1 = Request.form("r1")
n2 = Request.form("n2")
y2 = Request.form("y2")
hw1 = Request.form("hw1")
hw2 = Request.form("hw2")
if sj="br" then
date1=date()
date2=date()
n1=year(date())
else
if sj="by" then
n1=year(date())
y1=month(date())
date1=dateserial(n1,y1,1)
if y1=12 then
date2=dateserial(n1,y1,31)
else
date2=dateserial(n1,y1,datediff("d",dateserial(n1,y1,1),dateserial(n1,y1+1,1)))
end if
else
if sj="bn" then
n1=year(date())
date1=dateserial(n1,1,1)
date2=dateserial(n1,12,31)
else
date1=dateserial(n1,y1,r1)
date2=dateserial(n2,y2,r2)
end if
end if
end if
%>
<%
if hw1="0000" then
hwlb1="开始粉种 "
else
hwcx1="SELECT cInvName FROM inventory WHERE inventory.cInvCode='"&hw1&"'"
set hwcx1=conn.execute(hwcx1)
if not hwCX1.eof then
hwlb1=hwcx1("cInvName")
hwcx1.close
else
tt="T"
end if
end if
if hw2="9999" then
hwlb2="所有粉种"
else
hwcx2="SELECT cInvName FROM inventory WHERE inventory.cInvCode='"&hw2&"'"
set hwcx2=conn.execute(hwcx2)
if not hwCX2.eof then
hwlb2=hwcx2("cInvName")
hwcx2.close
else
tt="T"
end if
end if
%>
<title>查询面粉现存量</title>
<p align="center"><font face="黑体" size="4" color="#FF0000">收发存汇总表</font><font face="黑体" size="2" color="#FF0000">(面粉查询)</font></p>
<div align="center">
<center>
<table border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#C0C0C0" id="AutoNumber1">
<tr>
<td align="center"><font size="2" color="#008080">
<b>仓库名称</b></font></td>
<td align="center"><b><font color="#008080" size="2">产品名称</font></b></td>
<td align="center"><font size="2" color="#008080">
<b>期初结存数量</b></font></td>
<td align="center"><font size="2" color="#008080">
<b>入库数量</b></font></td>
<td align="center"><font size="2" color="#008080"><b>出库数量</b></font></td>
<td align="center"><font size="2" color="#008080"><b>期末结存数量</b></font></td>
</tr>
<%
SSql="SELECT cInvCode as code,Inventory.cInvCCode as code1,Inventory.cInvName as name, Inventory.cInvStd as norm,Inventory.cdefwarehouse as depot FROM Inventory WHERE cinvccode='0901' or cinvccode='0902' or cinvccode='0903' or cinvccode='0907' or cinvccode='0908' order by Inventory.cInvCode "
Set rs = Server.CreateObject("ADODB.Recordset")
rs.Open SSql,conn,3,1
if not rs.eof then
rs.movefirst
do while not rs.eof
bm1=trim(rs.Fields("code").value)
ck1=trim(rs.Fields("depot").value)
tt1="SELECT isnull(SUM(b.iQuantity),0) AS sl FROM RdRecord a left jOIN RdRecords b ON a.ID = b.ID WHERE (a.cVouchType = '34') AND (a.cWhCode = '301') and b.cinvcode='"&bm1&"' "
set nn1=conn.execute(tt1)
qcsl=nn1("sl").value
tt4="SELECT isnull(SUM(b.iQuantity),0) AS cc FROM RdRecord a left jOIN RdRecords b ON a.ID = b.ID WHERE (a.cVouchType = '10') AND (a.cWhCode = '301') AND (b.cinvcode = '"&bm1&"') "
set nn02=conn.execute(tt4)
ccsl=nn02("cc").value
tt5="SELECT isnull(SUM(b.iQuantity),0) AS ck FROM RdRecord a left jOIN RdRecords b ON a.ID = b.ID WHERE (a.bRdFlag = '0') AND (a.cVouchType = '09' or a.cVouchType = '32') AND (a.cWhCode = '301') and (b.cinvcode='"&bm1&"') "
set nn002=conn.execute(tt5)
ccck=nn002("ck").value
tt="SELECT cInvname as cname FROM Inventory WHERE cinvcode='"&bm1&"' "
set nn1=conn.execute(tt)
aa1=nn1("cname").value
qm=csng(sl)+(cc)-(ck)
tt6="SELECT isnull(SUM(b.iQuantity),0) AS qm FROM RdRecord a left jOIN RdRecords b ON a.ID = b.ID WHERE (a.bRdFlag = '0') AND (a.cVouchType = '09' or a.cVouchType = '32') AND (a.cWhCode = '301') AND (b.cinvcode = '"&bm1&"') "
set nn02=conn.execute(tt6)
ccsl=nn02("qm").value
tt3="SELECT count(*) as jl FROM Warehouse WHERE cwhcode='"&ck1&"' "
set nn01=conn.execute(tt3)
jl=nn01("jl").value
if jl=0 then
aa2="面粉厂"
else
tt2="SELECT cwhname as depot FROM Warehouse WHERE cwhcode='"&ck1&"' "
set nn01=conn.execute(tt2)
aa2=nn01("depot").value
end if
%>