正在装载数据……
<%@ Language=VBScript %>
<%Option Explicit%>
<!-- #include file="../../inc/config.asp" -->
<!-- #include file="../../inc/check.asp" -->
<!-- #include file="../../inc/public.asp" -->
<!-- #include file="../../inc/vbconn.asp" -->
<!-- #include file="../../inc/Report.asp" -->
<%
'********************************************************************
' Description:
'
' Author:
'
' Date:
'********************************************************************
'Call Check(8,1)
Dim rs,rs1,ttl,sql
Dim mydat,fdt,sdt,edt,tim
Dim provide,cls,stime1,stime2,num1,mon1,prc1,mon2,mon3,mon4,area,cdt
dim zsum,zmon,zsumber,zmoney,xmoney,dzmoney,cmoney,sqmoney,tmoney,leixing
Set rs=Server.CreateObject("ADODB.Recordset")
rs.ActiveConnection=conn
rs.CursorType=adOpenForwardOnly
rs.LockType=adLockReadOnly
ttl=Application("Sys_Co_Name")&"水泥包装发货日报表"
stime1=Cdate(getForm("stime1","str",""))
stime2=Cdate(getForm("stime2","str",""))
leixing=getform("leixing","str","")
area=getform("area","str","")
If Len(area)>0 Then cdt=cdt&" and a.fid='"&area&"' "
'品种数组
%>
<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
<LINK rel="stylesheet" type="text/css" href="../../css/main.css">
<LINK rel="stylesheet" type="text/css" href="../../css/scdd.css">
<SCRIPT LANGUAGE=javascript src='../../js/Report.js'></SCRIPT>
<title><%=ttl%></title>
</HEAD>
<BODY>
<h2 align=center><%=ttl%></h2>
<TABLE WIDTH=80% BORDER=0 CELLSPACING=0 CELLPADDING=0>
<TR>
<TD width="10%" NOWRAP align=left> 单位:吨</TD>
<TD width="10%" NOWRAP align=right><%=stime1%>至<%=stime2%> </TD>
</TR>
</table>
<%
response.write ("<TABLE cellSpacing=0 cellPadding=0 width='80%' class=pTable>")
response.write ("<tr>")
response.write ("<td nowrap width='5%' >生产线</td>")
response.write ("<td nowrap width='9%' >水泥品种</td>")
response.write ("<td nowrap width='9%' >外销数量</td>")
response.write ("<td nowrap width='9%' >自用数量</td>")
response.write ("<td nowrap width='9%' >总计数量</td>")
response.write ("<td nowrap width='9%' >本月累计</td>")
response.write ("</tr>")
dim myarray1,row1,i
sql="select distinct a.fid,a.area from X_site a join x_sell b on a.fid=b.area "
sql=sql&" where a.del=0 and b.stime between '"&stime1&"' and '"&stime2 &"' " &cdt
sql=sql&" order by a.area "
rs.open sql
if not rs.eof then
myarray1=rs.getrows()
Else
myarray1=""
End If
If IsArray(myarray1) then
row1=ubound(myarray1,2)
else
row1=-1
end if
rs.close
For i=0 To row1
Dim myarray2,row2,j
sql="select distinct(x.name),a.grup from x_sell a left join X_material x on a.mtr=x.fid where a.area='"&myarray1(0,i)&"' and a.stime between '"&stime1&"' and '"&stime2 &"' "
rs.open sql
If Not rs.eof Then
myarray2=rs.getrows()
Else
myarray2=""
End If
If IsArray(myarray2) Then
row2=UBound(myarray2,2)
Else
row2=-1
End If
rs.close
response.write "<tr>"
response.write "<td width='5%' align=center rowspan='"&row2+1&"'> "&myarray1(1,i)&"</td>"
For j=0 To row2
response.write ("<td nowrap width='6%' align=center> "&myarray2(0,j)&"</td>")
sql="select isnull(sum(a.number),0) as number1 from P_Organi p join x_sell a on p.fid=a.customer where p.leixing='1' and a.stime between '"&stime1&"' and '"&stime2 &"'and a.grup='"&myarray2(1,j)&"' and a.area='"&myarray1(0,i)&"'"
rs.open sql
If Not rs.eof Then
Dim number1 '定义外销数量
number1=CDbl(rs("number1"))
End If
rs.close
response.write ("<td nowrap width='6%' align=center> "&formatnum2(number1,2)&"</td>")
sql="select isnull(sum(a.number),0) as number2 from P_Organi p join x_sell a on p.fid=a.customer where p.leixing='2' and a.stime between '"&stime1&"' and '"&stime2 &"'and a.grup='"&myarray2(1,j)&"' and a.area='"&myarray1(0,i)&"'"
rs.open sql
If Not rs.eof Then
Dim number2 '定义自用数量
number2=CDbl(rs("number2"))
End If
rs.close
response.write ("<td nowrap width='6%' align=center> "&formatnum2(number2,2)&"</td>")
Dim number3'定义总计数量
number3=number3+number1+number2
response.write ("<td nowrap width='6%' align=center>"&formatnum2(number3,2)&"</td>")
number3=0
sql="select isnull(sum(a.number),0) as number4 from P_Organi p join x_sell a on p.fid=a.customer where a.stime between '"&year(stime2)&"-"&month(stime2)&"-1' and '"&stime2 &"'and a.grup='"&myarray2(1,j)&"' and a.area='"&myarray1(0,i)&"'"
rs.open sql
If Not rs.eof Then
Dim number4'定义本月累计
number4=CDbl(rs("number4"))
End If
rs.close
response.write ("<td nowrap width='6%' align=center> "&formatnum2(number4,2)&"</td>")
response.write ("</tr>")
Next
response.write "<td width='20%' align=center colspan=2> 包装当日发出量</td>"
sql="select isnull(sum(a.number),0) as number5 from P_Organi p join x_sell a on p.fid=a.customer join X_material x on a.mtr=x.fid where a.stime between '"&stime1&"' and '"&stime2 &"' and a.area='"&myarray1(0,i)&"' and x.cls='1000000000000005' "
rs.open sql
If Not rs.eof Then
Dim number5'定义包装当日发出量
number5=CDbl(rs("number5"))
End If
rs.close
response.write "<td width='20%' align=center colspan=4> "&formatnum2(number5,2)&"</td>"
response.write ("<tr>")
response.write "<td width='20%' align=center colspan=2 > 散装当日发出量</td>"
sql="select isnull(sum(a.number),0) as number6 from P_Organi p join x_sell a on p.fid=a.customer join X_material x on a.mtr=x.fid where a.stime between '"&stime1&"' and '"&stime2 &"' and a.area='"&myarray1(0,i)&"' and x.cls='1000000000000006' "
rs.open sql
If Not rs.eof Then
Dim number6'定义散装当日发出量
number6=CDbl(rs("number6"))
End If
rs.close
response.write "<td width='20%' align=center colspan=4 > "&formatnum2(number6,2)&"</td>"
response.write ("</tr>")
Dim tol'定义合计数量
tol=tol+number5+number6
Next
response.write ("<tr bgcolor='yellow'>")
response.write "<td width='20%' align=left colspan=2 > 合计</td>"
response.write "<td width='20%' align=center colspan=4 > "&formatnum2(tol,2)&"</td>"
response.write ("</tr>")
response.write("<br><TABLE WIDTH='100%' BORDER=0 CELLSPACING=0 CELLPADDING=0>")
response.write("<br><TR><TD NOWRAP WIDTH='80%'> </TD><TD NOWRAP WIDTH='20%'>填表:" & Session("name") & "</TD></TR>")
response.write("</TABLE>")
%>
</BODY>
</HTML>
<!-- #include file="../../inc/vbdonn.asp" -->
本文来源:http://blog.csdn.net/xsl3378/archive/2007/07/06/1681050.aspx