仓酷云

 找回密码
 立即注册
搜索
热搜: 活动 交友 discuz
查看: 3233|回复: 19
打印 上一主题 下一主题

[学习教程] ASP网页编程之完全的会见统计法式(二 法式篇)

[复制链接]
灵魂腐蚀 该用户已被删除
跳转到指定楼层
楼主
发表于 2015-2-3 23:31:50 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有帐号?立即注册

x
对用户来说可预见费用、节约费用,可以做到花少钱办大事。由于省去了购买软件和硬件等的前期费用,用户可以租用较高级的应用软件。ASP的收费是根据软件的类型、客制化程度、用户数量、服务期限来定的,对客户来说这笔费用是可以预见的。方便于客户应用软件的升级。   请人人在转载和利用的时分  保存这条信息
*/
/* dbcn.asp
   创立数据库毗连的 公用法式
*/
<%
  function OpenConn()
     '创立数据库毗连
     dim ConnStr
     dim uid
     dim pwd
     dim db
     uid="BBC"
     pwd="BBC"
     db="BBC"
     Softserver="Softdepserver"
     Set Conn = Server.CreateObject("ADODB.Connection")
     ConnStr="Provider=SQLOLEDB.1;UID=" & uid & ";PWD=" & pwd & ";database=" & db & ";server=" & Softserver & ""
     
     Conn.Open ConnStr
     
     set OpenConn=Conn
  end function
  
  function OpenRst()
     '创立数据库纪录集
     set Rst=Server.CreateObject ("ADODB.Recordset")
     set OpenRst=Rst
  end function
%>
/*
  staticFunc
  统计法式所需求用到的函数库
*/
<!--#include file="dbcn.asp"-->
<%
   set conn=openConn()
   set rst=openRst()
   sub WriteDateTable(intStart,intEnd,strArray,ccount)
      '生成统计表
      %>
        <table border=1 width=100%>
           <%for i= intStart to intEnd%>
              <tr>
              <td width=30%><%=strArray(i)%></td>
              <td width=60%>
              <%
                 if rst.eof then
                    setbar 0,ccount
                 else
                    if rst(1)=i then
                       setbar rst(3),ccount
               if not rst.eof then rst.movenext
                    else
                       setbar 0,ccount
                    end if
                 end if
              %>
              </td>
          </tr>        
           <%next%>
        </table>
      <%
   end sub
%>
<%
   sub setBar(num,ccount)
     '生成统计条
     if ccount=0 then
        percent=0
     else
       percent=cInt(num/ccount*10000)/100
     end if   
     strGif="http://edu.cnzz.cn/NewsInfo/bar.gif"
     %>
       <img src="<%=strGif%>" width="<%=percent+5%>" height=10><font color=red><%=percent%>%</font>
     <td align=center>
       <%=num%>
     </td>
    <%
   end sub
%>
<%
   sub writeDayStatic(userid)
    '生成日统计
   i=0
   dim strArray(100)
   for i=0 to 23
      strArray(i)= cStr(i) & "点--" & cstr(i+1) & "点"
   next
   i=0
   set rst=openRst()
   strSQL="select sum(num) as ccount from dateStatic where userid='" & userid & "'"
   rst.open strSQL,conn,3,3
   if isnull(Rst("ccount")) then
     ccount=0
   else
     ccount=Rst("ccount")
   end if
   strSQL="select * from dateStatic where userid='" & userid & "' order by hourid"
   set rst=openRst()
   rst.open strSQL,conn,3,3
%>
会见总数<%=ccount%>
<table border=1 width=100%>
    <tr height=100%>
       <td width=50%><% WriteDateTable 0, 11, strArray ,ccount %></td>
       <td width=50%><%WriteDateTable 12, 23, strArray ,ccount %></td>
    </tr>
</table>
<%
end sub
%>
<%
   sub writeWeekStatic(userid)
   '生成周统计   
   i=0
   dim strArray(7)
   strArray(0)="日曜日"
   strArray(1)="礼拜一"
   strArray(2)="礼拜二"
   strArray(3)="礼拜三"
   strArray(4)="木曜日"
   strArray(5)="礼拜五"
   strArray(6)="礼拜六"
   i=0
   strSQL="select sum(num) as ccount from weekStatic where userid='" & userid & "'"
   set rst=openRst()
   rst.open strSQL,conn,3,3
   if isnull(Rst("ccount")) then
     ccount=0
   else
     ccount=Rst("ccount")
   end if
   strSQL="select * from WeekStatic where userid='" & userid & "' order by dayid"
   set rst=openRst()
   rst.open strSQL,conn,3,3
   %>
   会见总数<%=ccount%>
     <table border=1 width=100%>
       <tr height=100%>
          <td width=100%><% WriteDateTable 0, 6, strArray ,ccount %></td>
       </tr>
    </table>
   <%
   end sub
%>
<%
   sub writeMonthStatic(userid)
   '生成月统计
   i=0
   dim strArray(32)
   for i=1 to  31
     strArray(i)=cStr(i) & "日"
   next
   i=0
   strSQL="select sum(num) as ccount from MonthStatic where userid='" & userid & "'"
   set rst=openRst()
   rst.open strSQL,conn,3,3
   if isnull(Rst("ccount")) then
     ccount=0
   else
     ccount=Rst("ccount")
   end if
   strSQL="select * from MonthStatic where userid='" & userid & "' order by dayid"
   set rst=openRst()
   rst.open strSQL,conn,3,3
   %>
   会见总数<%=ccount%>
     <table border=1 width=100%>
       <tr height=100%>
          <td width=50%><% WriteDateTable 1, 16, strArray ,ccount %></td>
          <td width=50%><% WriteDateTable 17, 31, strArray ,ccount %></td>
       </tr>
    </table>
   <%
   end sub
%>
<%
   sub writeYearStatic(userid)
   i=0
   dim strArray(13)
   for i=1 to  12
     strArray(i)=cStr(i) & "月"
   next
   i=0
   strSQL="select sum(num) as ccount from YearStatic where userid='" & userid & "'"
   set rst=openRst()
   rst.open strSQL,conn,3,3
   if isnull(Rst("ccount")) then
     ccount=0
   else
     ccount=Rst("ccount")
   end if
   strSQL="select * from YearStatic where userid='" & userid & "' order by monthid"
   set rst=openRst()
   rst.open strSQL,conn,3,3
   %>
   会见总数<%=ccount%>
     <table border=1 width=100%>
       <tr height=100%>
          <td width=50%><% WriteDateTable 1, 6, strArray ,ccount %></td>
          <td width=50%><% WriteDateTable 7, 12, strArray ,ccount %></td>
       </tr>
    </table>
   <%
   end sub
%>
<%
   sub WriteRecentInfo(userid)
      '显示会见者的阅读器散布
      StrSQL="select top 10 * from accessstat where userid='" & userid & "' order by VisitTime desc"
      set rst=openRst()
      Rst.open StrSQL,Conn,3,1
      %>
      <table border=1 width=100%  align=center cellSpacing=1 cellPadding=1>
          <tr>
             <td width=5% align=center>序 号</td>
             <td width=20% align=center>来访工夫</td>                 
             <td width=15% align=center>IP地址</td>
             <td width=15% align=center>所用操作体系</td>
             <td width=15% align=center>所用阅读器类型</td>
             <td width=30% align=center>阅读的上一页</td>
             <td width=0%></td>
          </tr>
         <% for i=1 to Rst.RecordCount %>                  
              <tr>
                 <td width=5% align=center><%=i%></td>
                 <td width=20% align=center><%=Rst("VisitTime")%></td>                                                              
                 <td width=15% align=center><%=Rst("IPAddr")%></td>
                 <td width=15% align=center><%=Rst("UseSystem")%></td>
                 <td width=15% align=center><%=Rst("BrowserType")%></td>   
                 <td width=30% align=center><a HREF=<%=Rst("LastPage")%>><%Response.Write Rst("LastPage")%></a></td>
                 <td width=0%></td>
               </tr>
               <% Rst.MoveNext%>              
     <% Next %>
      </table>   
<%
   end sub
%>
<%
   sub WriteBrowserInfo(userid)
      Set Rst=OpenRst()
      strSQL="select count(*) as VisitCount from AccessStat where userid='" & userid & "'"
      Rst.open strSQL,Conn,3,1
      TotalVisit=rst(0)
      StrSQL="select BrowserType,count(BrowserType) as visitcount from AccessStat where userid='" & userid & "' group by BrowserType order by VisitCount desc"
      Set Rst=OpenRst()
      Rst.open StrSQL,Conn,3,1
      %>   
      <table border=1 width=100%  align=center cellSpacing=1 cellPadding=1>
          <tr>
             <td width=5% align=center>序 号</td>
             <td width=15% align=center>所用阅读器类型</td>                 
             <td width=40% align=center>会见比例尺暗示</td>
             <td width=15% align=center>会见次数</td>
             <td width=5%></td>
          </tr>
          <%for i=1 to     Rst.RecordCount %>
             <tr>
                <td width=5% align=center><%=i%></td>
                <td width=15% align=center><%=Rst("BrowserType")%></td>
                <!--
                <td width=15% align=center><%=Rst("VisitCount")%></td>                                                      
                <td width=10% align=center><%=FormatNumber(CInt(Rst("VisitCount")/TotalVisit*10000)/100,true,true)%>%</td>
                 <td width=40% align=left><img src=http://edu.cnzz.cn/NewsInfo/bar.gif width=<%=(Rst("VisitCount")/TotalVisit)*300%> height=10></td>
                -->
                <td><%setbar Rst("VisitCount"),TotalVisit %></td>
                <td width=5% ></td>
             </tr>
         <%Rst.MoveNext%>
          <% Next %>   
          </table>
<%   
   end sub
%>
<%
   sub InsertData(userid)
      '处置阅读者信息
      ExecUserInfo userid
      '处置日统计
      ExecDayStatic userid
      '处置周统计
      ExecWeekStatic userid
      '处置月统计
      ExecMonthStatic userid
      '处置年统计
      ExecYearStatic userid
   end sub
%>
<%
   sub ExecUserInfo(userid)
      '处置阅读者信息
      strRet=Request.ServerVariables("HTTP_USER_AGENT")
      strArray=split(strRet,"(")
      strRet=left(strArray(1),len(strArray(1))-1)
      strArray=split(strRet,";")
      strBrowserName=strArray(1)       '阅读器
      strUseSystem=strArray(2)         '用户操作体系  
      strPrPage=Request.ServerVariables("HTTP_REFERER")     '从何而来
      if strPrPage="" then
         strPrPage="http://" & Request.ServerVariables("SERVER_NAME") & Request.ServerVariables("SCRIPT_NAME")
      end if
      strIPAddr=Request.ServerVariables ("REMOTE_ADDR")        '用户IP地址
      strSQL="insert into AccessStat(UserID,VisitTime,IPAddr,UseSystem,BrowserType,LastPage) "
      strSQL=strSQL & "values ('" & trim(userid) & "',getDate(),'" & trim(strIPAddr) & "','"
      strSQL=strSQL & trim(strUseSystem) & "','" & trim(strBrowserName) & "','" & trim(strPrPage) & "')"
      conn.execute strSQL
   end sub
%>
<%
   sub ExecDayStatic(userid)
      '处置逐日的小时数据
      strSQL="select * from DateStatic where dateid=datepart(dy,getdate()) and userid='" & userid & "'"
      set rst=openrst()
      rst.open strSQL,conn,3,3
      if rst.eof and rst.bof then
         strSQL="delete from DateStatic where userid='" & userid & "'"
         conn.execute strSQL
         for i=0 to 23
            strSQL="insert into DateStatic values(datepart(dy,getdate())," & cStr(i) & ",'" & userid & "',0)"
            conn.execute strSQL
         next
      end if
      strSQL="update datestatic set num=num + 1 where dateid=datepart(dy,getdate()) and hourid= datepart(hh,getdate()) and userid='" & userid & "'"
      conn.execute strSQL      
   end sub
%>
<%
   sub ExecWeekStatic(userid)
     '处置每周的日数据
     strSQL="select * from WeekStatic where weekid=datepart(ww,getdate()) and userid='" & userid & "'"
     set rst=openRst()
     rst.open strSQL,conn,3,3
     if rst.eof and rst.bof then
        strSQL="delete from WeekStatic  where userid='" & userid & "'"
        conn.execute strSQL
        for i=0 to 6
           strSQL="insert into WeekStatic values(datepart(ww,getdate())," & cStr(i) & ",'" & userid & "',0)"
           conn.execute strSQL
        next
     end if
     strSQL="update weekstatic set num=num + 1 where weekid=datepart(ww,getdate()) and dayid+1= datepart(dw,getdate())  and userid='" & userid & "'"
     conn.execute strSQL
  end sub
%>
<%
   sub ExecMonthStatic(userid)
      '处置每个月的日数据
      strSQL="select * from MonthStatic where monthid=datepart(mm,getdate()) and userid='" & userid & "'"
      set rst=openRst()
      rst.open strSQL,conn,3,3
      if rst.eof and rst.bof then
         strSQL="delete from MonthStatic  where userid='" & userid & "'"
         conn.execute strSQL
         for i=1 to 31
            strSQL="insert into MonthStatic values(datepart(mm,getdate())," & cStr(i) & ",'" & userid & "',0)"
            conn.execute strSQL
         next
      end if
      strSQL="update monthstatic set num=num + 1 where monthid=datepart(mm,getdate()) and dayid= datepart(dd,getdate())"
      conn.execute strSQL
   end sub
%>
<%
   sub ExecYearStatic(userid)
     '处置每一年的月数据
     strSQL="select * from YearStatic where yearid=datepart(yy,getdate()) and userid='" & userid & "'"
      set rst=openRst()
      rst.open strSQL,conn,3,3
      if rst.eof and rst.bof then
         strSQL="delete from YearStatic where userid='" & userid & "'"
         conn.execute strSQL
         for i=1 to 12
            strSQL="insert into YearStatic values(datepart(yy,getdate())," & cStr(i) & ",'" & userid & "',0)"
            conn.execute strSQL
         next
      end if
      strSQL="update YearStatic set num=num + 1 where Yearid=datepart(yy,getdate()) and Monthid= datepart(mm,getdate()) and userid='" & userid & "'"
      conn.execute strSQL
   end sub
%>
SQL Server是基于服务器端的中型的数据库,可以适合大容量数据的应用,在功能上管理上也要比Access要强得多。在处理海量数据的效率,后台开发的灵活性,可扩展性等方面强大。
透明 该用户已被删除
沙发
发表于 2015-2-4 01:06:58 | 只看该作者
虽然ASP也有很多网络教程。但是这些都不系统。都是半路出家,只是从一个例子告诉你怎么用。不会深入讨论,更不会将没有出现在例子里的方法都一一列举出来。
再现理想 该用户已被删除
板凳
发表于 2015-2-7 11:02:44 | 只看该作者
我想问如何掌握学习节奏(先学什么再学什么)最好详细点?
愤怒的大鸟 该用户已被删除
地板
发表于 2015-2-11 12:50:37 | 只看该作者
ASP.Net和ASP的最大区别在于编程思维的转换,而不仅仅在于功能的增强。ASP使用VBS/JS这样的脚本语言混合html来编程,而那些脚本语言属于弱类型、面向结构的编程语言,而非面向对象,这就明显产生以下几个问题:
蒙在股里 该用户已被删除
5#
发表于 2015-3-2 12:22:16 | 只看该作者
还有如何才能在最短的时间内学完?我每天可以有效学习2小时,双休日4小时。
小妖女 该用户已被删除
6#
发表于 2015-3-11 03:36:23 | 只看该作者
你可以通过继承已有的对象最大限度保护你以前的投资。并且C#和C++、Java一样提供了完善的调试/纠错体系。
若相依 该用户已被删除
7#
发表于 2015-3-17 19:20:55 | 只看该作者
ASP也是这几种脚本语言中最简单易学的开发语言。但ASP也是这几种语言中唯一的一个不能很好支持跨平台的语言。  因为ASP脚本语言非常简单,因此其代码也简单易懂,结合HTML代码,可快速地完成网站的应用程序。
灵魂腐蚀 该用户已被删除
8#
 楼主| 发表于 2015-3-20 23:43:29 | 只看该作者
用户端的浏览器不需要提供任何别的支持,这样大提高了用户与服务器之间的交互的速度。
柔情似水 该用户已被删除
9#
发表于 2015-3-23 23:46:44 | 只看该作者
它可通过内置的组件实现更强大的功能,如使用A-DO可以轻松地访问数据库。
冷月葬花魂 该用户已被删除
10#
发表于 2015-4-12 11:05:05 | 只看该作者
最近在学asp,不要问我为什么不直接学.net,因为公司网站是asp做的所以有这个需要,卖了本书asp入门到精通,对里面的六大内置对象老是记不住,还有很多属性和方法看的头晕。
分手快乐 该用户已被删除
11#
发表于 2015-4-13 07:56:22 | 只看该作者
尽管MS自己讲C#内核中更多的象VC,但实际上我还是认为它和Java更象一些吧。首先它是面向对象的编程语言,而不是一种脚本,所以它具有面向对象编程语言的一切特性,比如封装性、继承性、多态性等等,这就解决了刚才谈到的ASP的那些弱点。
admin 该用户已被删除
12#
发表于 2015-4-17 10:20:06 | 只看该作者
ASP(ActiveServerPages)是Microsfot公司1996年11月推出的WEB应用程序开发技术,它既不是一种程序语言,也不是一种开发工具,而是一种技术框架,不须使用微软的产品就能编写它的代码,能产生和执行动态、交互式、高效率的站占服务器的应用程序。
精灵巫婆 该用户已被删除
13#
发表于 2015-4-23 08:07:03 | 只看该作者
代码逻辑混乱,难于管理:由于ASP是脚本语言混合html编程,所以你很难看清代码的逻辑关系,并且随着程序的复杂性增加,使得代码的管理十分困难,甚至超出一个程序员所能达到的管理能力,从而造成出错或这样那样的问题。
兰色精灵 该用户已被删除
14#
发表于 2015-6-13 03:19:58 | 只看该作者
尽管MS自己讲C#内核中更多的象VC,但实际上我还是认为它和Java更象一些吧。首先它是面向对象的编程语言,而不是一种脚本,所以它具有面向对象编程语言的一切特性,比如封装性、继承性、多态性等等,这就解决了刚才谈到的ASP的那些弱点。
若天明 该用户已被删除
15#
发表于 2015-6-14 20:42:03 | 只看该作者
Server:这个表示的服务器,操作服务器的一些东西使用这个,如Server.Mappath转换服务器路径,Server.CreateObject实例化一个组件
变相怪杰 该用户已被删除
16#
发表于 2015-7-4 04:37:46 | 只看该作者
下面简单介绍一下我学习ASP的方法,希望对想学习ASP的朋友有所帮助...
莫相离 该用户已被删除
17#
发表于 2015-7-17 14:28:58 | 只看该作者
尽管MS自己讲C#内核中更多的象VC,但实际上我还是认为它和Java更象一些吧。首先它是面向对象的编程语言,而不是一种脚本,所以它具有面向对象编程语言的一切特性,比如封装性、继承性、多态性等等,这就解决了刚才谈到的ASP的那些弱点。
爱飞 该用户已被删除
18#
发表于 2015-7-18 22:11:45 | 只看该作者
封装性使得代码逻辑清晰,易于管理,并且应用到ASP.Net上就可以使业务逻辑和Html页面分离,这样无论页面原型如何改变,业务逻辑代码都不必做任何改动;继承性和多态性使得代码的可重用性大大提高。
小魔女 该用户已被删除
19#
发表于 2015-7-29 12:47:09 | 只看该作者
ASP主要是用好六个对象,其实最主要的是用好其中两个:response和request,就可以随心所欲地控制网页变换和响应用户动作了。
飘灵儿 该用户已被删除
20#
发表于 2015-10-14 12:24:46 | 只看该作者
如何更好的使自己的东西看上去很不错等等。其实这些都不是问题的实质,我们可以在实践中不断提升自己,不断充实自己。
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|Archiver|手机版|仓酷云 鄂ICP备14007578号-2

GMT+8, 2024-4-26 16:57

Powered by Discuz! X3.2

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表