(四)自己动手,做一个属于自己的疫情填报收集表

第3章 主要程序编写的代码

  1. 前言
  2. 第1章 在win10下配置asp的运行环境
  3. 第2章 系统需求分析
  4. 第3章 主要程序编写的代码
  5. 结语

  在页面设计的程序中,本人觉得主要有下面几个方面的代码需记录下来。

3.1显示未填报的学生名单的SQL语句

select * from xs where xsclass='"&session("jsclass")&"' and not exists(select * from xsq where xs.xsno=xsq.xsno and xstimeid="&ymdnum&" and xsclass='"&session("jsclass")&"')

  //表示通过学生学号查找xs和xsq两个表的某个班的学生在某一天不存在的学生数据。
  //xs表是学生基本信息表,xsq表是存储学生每天填报的数据。Xs.xsno=xsq.xsno是对xs表中的xsno(学生学号)跟xsq表中的xsno进行配对,并将没有配对上的学生找出来。

3.2统计填报数据代码

rs.open"select * from xsq where xstimeid="&ymdnum&"",conn,1,1
	if not(rs.eof or rs.bof) then
			xsnum1=0   ‘初始化各个变量
			xsnum2=0
……
			xsnum9=0
			xsnum10=0
		do while not rs.eof   ‘逐条计算各项数据的和
		if trim(rs("xsdress"))="A" then
			      xsnum1=xsnum1+1
		else
			      xsnum2=xsnum2+1
		end if			   
		……
		  		if trim(rs("xsq4"))="A" then
			      xsnum9=xsnum9+1
		else
			      xsnum10=xsnum10+1
		end if			   
		rs.movenext
			loop
		else
			xsnum1=0
			xsnum2=0
		    ……
			xsnum9=0
			xsnum10=0		
	end if

3.3导出Excel报名的代码

  主要的代码如下所示,导出的是Excel格式的报表。代码比较简单,大家百度一下也是可以找到的。

Response.AddHeader "Content-Disposition","attachment;filename="&ymdnum&"-"&jsclass&"-未填报健康数据的学生名单.xls"  ‘导出的文件名称
Response.ContentType = "application/vnd.ms-excel"  ‘以excel的格式导出
	    rs.open"select * from xs where not exists(select * from xsq where xs.xsno=xsq.xsno and xstimeid="&ymdnum&")",conn,1,1
if not(rs.eof or rs.bof) then
response.write "<table width=""100%"" border=""1"" >"  
response.write "<tr>"
response.write "<th width=""40%""><b>学号</b></th>"
response.write "<th width=""30%""><b>姓名</b></th>"
response.write "<th width=""30%""><b>年级</b></th>"
response.write "<th width=""30%""><b>班别</b></th>"
response.write "<th width=""30%""><b>是否填报</b></th>"
response.write "</tr>"
do while not rs.eof
response.write "<tr>"
response.write "<td width=""40%"">"&trim(rs("xsno"))&"</td>"
response.write "<td width=""30%"">"&trim(rs("xsname"))&"</td>"
response.write "<td width=""30%"">"&trim(rs("xsglass"))&"</td>"
response.write "<td width=""30%"">"&trim(rs("xsclass"))&"</td>"
response.write "<td width=""30%"">否</td>"
response.write "</tr>"
rs.movenext
loop
response.write "</table>"
end if
rs.close
set rs=nothing

结语

  本案的架构比较简单,所使用的也不是现在流行的编程语言,但是比较实用,而且在很多教育单位,使用的服务器都比较落后,安装的操作系统可能也不是现在最新的。在这样的情况下,本着只要能实现需求就行的想法开发的这个数据上报系统,经过一个多星期的运行,应付每天2000多条的数据上报,还是显得绰绰有余。现在使用本系统,可以很潇洒地动动手指,就可将一天的数据统计导出来,直接转发给学校疫情指挥部,自己也终于从数据搬运工和校对工中解放出来了。

  最后形成的上报表如图所示。
图5.1

发布了5 篇原创文章 · 获赞 4 · 访问量 161

猜你喜欢

转载自blog.csdn.net/ydr888/article/details/105003807