<!-- #include file="../conn.asp" -->
<!-- #include file="../const.asp" -->

<%call chksunzom()
chk=requestA("chk")
bbid=requestA("gid")

if instr(quanxs,"x3t")<=0 then call sunzomqx()

sql="select * from sz_bb where id="&bbid&""  
set rs1 =server.createobject("ADODB.RecordSet")	
rs1.open sql,conn,1,3
if not rs1.eof then
bbname=rs1("bbname"):bblx=chk0(rs1("bblx")):ysxx=rs1("ysxx"):yfxx=rs1("yfxx"):ssxx=rs1("ssxx"):sfxx=rs1("sfxx")
end if
rs1.close:set rs1=nothing

if Cntshu(ysxx,"[#]")>0 then
ysxxs=split(ysxx,"[#]")
for qq=1 to Cntshu(ysxx,"[#]")
ysmx=split(ysxxs(qq),"|")
ysmxid=ysmx(0)

yszds0=split(ysmx(1),",")
for zz1=1 to Cntshu(ysmx(1),",")
'if conn.execute("select zdhz from MX_zd where ChannelID="&ysmxid&" and FieldName='"&yszds0(zz1)&"' and CharIndex(zdhz,'ltj',1)>0").bof then yszds=yszds0(zz1)
next
yszds=conn.execute("select FieldName,ChannelID,zdhz from SZ_zd where ChannelID="&ysmxid&" and instr(zdhz,'ltj')>0 ")(0)  'CharIndex(zdhz,'ltj',1)>0

ysmxdat=cdatx("mxdat","SZ_mx","where id="&ysmxid&"")
yshe=yshe+CDbl(chk0(conn.execute("select sum("&yszds&") from "&ysmxdat&"")(0)))
next
end if

if Cntshu(yfxx,"[#]")>0 then
yfxxs=split(yfxx,"[#]")
for qq1=1 to Cntshu(yfxx,"[#]")
yfmx=split(yfxxs(qq1),"|")
yfmxid=yfmx(0)
yfzds=conn.execute("select FieldName from SZ_zd where ChannelID="&yfmxid&" and instr(zdhz,'ltj')>0 ")(0)   'split(yfmx(1),",")(1)
yfmxdat=cdatx("mxdat","SZ_mx","where id="&yfmxid&"")
yfhe=yfhe+CDbl(chk0(conn.execute("select sum("&yfzds&") from "&yfmxdat&"")(0)))
next
end if

if Cntshu(ssxx,"[#]")>0 then
ssxxs=split(ssxx,"[#]")
for qq2=1 to Cntshu(ssxx,"[#]")
ssmx=split(ssxxs(qq2),"|")
ssmxid=ssmx(0)
sszds=conn.execute("select FieldName from SZ_zd where ChannelID="&ssmxid&" and instr(zdhz,'ltj')>0 ")(0)   'split(ssmx(1),",")(1)
ssmxdat=cdatx("mxdat","SZ_mx","where id="&ssmxid&"")
sshe=sshe+CDbl(chk0(conn.execute("select sum("&sszds&") from "&ssmxdat&"")(0)))
next
end if


if Cntshu(sfxx,"[#]")>0 then
sfxxs=split(sfxx,"[#]")
for qq3=1 to Cntshu(sfxx,"[#]")
sfmx=split(sfxxs(qq3),"|")
sfmxid=sfmx(0)
sfzds=conn.execute("select FieldName from SZ_zd where ChannelID="&sfmxid&" and instr(zdhz,'ltj')>0 ")(0)    'split(sfmx(1),",")(1)
sfmxdat=cdatx("mxdat","SZ_mx","where id="&sfmxid&"")
sfhe=sfhe+CDbl(chk0(conn.execute("select sum("&sfzds&") from "&sfmxdat&"")(0)))
next
end if

'Response.Write (""&yszds&"<br>"&ysmxdat&""):Response.end

%> 
<html>
<head>
<title><%=dianming%> - <%=bbname%></title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link href="../images/sunzom.css" rel="stylesheet" type="text/css">
</HEAD>
<BODY>
<div>
<h2 align="center"><%=bbname%></h2>

<table cellpadding="7" cellspacing="0" border="1" width="100%" bordercolor="#666666" bgcolor="#FFFFFF" style="border-collapse: collapse">
		
		<tr>
    <td align="right">
    
<font size="4">应收账款：</font></td>
    <td><font size="4"><%=formatnumber(yshe,2)%>元</font></td>
    <td align="right"><font size="4">实收账款：</font></td>
    <td><font size="4"><%=formatnumber(sshe,2)%>元</font></td>
  </tr>  

		<tr>
    <td align="right"><font size="4">应付账款：
    
　</font></td>
    <td><font size="4"><%=formatnumber(yfhe,2)%>元</font></td>
    <td align="right"><font size="4">实付账款：</font></td>
    <td><font size="4"><%=formatnumber(sfhe,2)%>元</font></td>
  </tr>  

		<tr>
    <td align="right"><font size="4">营业利润：</font></td>
    <td><font size="4"><%=formatnumber((yshe-yfhe),2)%>元</font></td>
    <td align="right"><font size="4">实际利润：</font></td>
    <td><font size="4"><%=formatnumber((sshe-sfhe),2)%>元</font></td>
  </tr>  

  <tr>
    <td align="center" colspan="4">营业利润=应收总额-应付总额；实际利润=实收总额-实付总额</td>
  </tr>
  </table></div>
</body>
</html>