牙签学技术

一根牙签的业余爱好
  博客园 :: 首页 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理

[ASP.NET]显示IP-Repeater

Posted on 2008-07-25 14:23 『牙签』 阅读(13) 评论(0)  编辑 收藏 所属分类: ASP.NET 1.0
<%@ Import NameSpace="System.Data" %>

<%@ Import NameSpace="System.Data.oledb" %>

<%@ Import NameSpace="DatabaseNamespace" %>

<%@ Import NameSpace="System.Data.sqlclient" %>

<%@ Page Inherits="ScontentCodeBehind" src="MyCodeBehind.vb" %>

<html>

<head>

<style>

    body 
{

    font
: normal 62.5% "Lucida Sans Unicode",sans-serif;

    font-size
:12px;

    color
:#CCCCCC;

    margin
: 0;

    
}


    td
{

    font-family
:宋体;

    font-size
:12px;

    line-height
:20px;

    
}


    a
{

    color
:#cccccc;

    font-size
:12px;

    font-family
:仿宋;

    text-decoration
:none



    
}


    a:hover
{

    color
:#feb206;

    font-size
:12px;

    font-family
:仿宋;

    text-decoration
:underline;

    
}




.STYLE1 
{color: #FFFFFF}

.STYLE2 
{color: #CC3300}

.STYLE3 
{color: #000000}

.STYLE4 
{

    font-family
: "黑体";

    font-size
: 14px;

    color
: #000000;

}


</style>



<script runat="server">

    public PNID as string

    public PID as string

    sub page_load(o as object,e as eventargs)



        dim conpubs as sqlconnection

        dim cmdselectcount as sqlcommand



        conpubs
=new sqlconnection ("server=webserver;database=net0575New;uid=sa;pwd=0.123456789;")

        conpubs.open()

        cmdselectcount
=new sqlcommand("select count(*) from shopip where shopid='"& request.querystring("id"&"'",conpubs)

        IPList.text
=cmdSelectcount.executescalar()

        conpubs.close()





        dim conpubs2 as sqlconnection

        dim cmdselectcount2 as sqlcommand



        conpubs2
=new sqlconnection ("server=webserver;database=net0575New;uid=sa;pwd=0.123456789;")

        conpubs2.open()

        cmdselectcount2
=new sqlcommand("select count(*) from shopip where shopid='"& request.querystring("id"&"' and convert(varchar,year(iptime)) + convert(varchar,month(iptime)) + convert(varchar,day(iptime)) =convert(varchar,year(getdate())) + convert(varchar,month(getdate())) + convert(varchar,day(getdate()))",conpubs2)

        TDIPList.text
=cmdSelectcount2.executescalar()

        conpubs2.close()





        dim conpubs3 as sqlconnection

        dim cmdselectcount3 as sqlcommand



        conpubs3
=new sqlconnection ("server=webserver;database=net0575New;uid=sa;pwd=0.123456789;")

        conpubs3.open()

        cmdselectcount3
=new sqlcommand("select count(*) from shopip where shopid='"& request.querystring("id"&"' and convert(varchar,year(iptime)) + convert(varchar,month(iptime)) + convert(varchar,day(iptime)) =convert(varchar,year(getdate()-1)) + convert(varchar,month(getdate()-1)) + convert(varchar,day(getdate()-1))",conpubs3)

        YDIPList.text
=cmdSelectcount3.executescalar()

        conpubs3.close()





        Dim sqlstr as string

        sqlstr
="select * from ShopIP where shopid='"& request.querystring("id"&"' order by IPtime desc"

        RepeatDataBind (sqlstr)



        dim obj as 
new DatabaseDo

        obj.connstr
=ConfigurationSettings.AppSettings("connstr").ToString()

        dim ds as dataset

        sqlstr
="select top 1 * from notes where sid='" & request.querystring("id"& "'"

            ds
=obj.getdataset(sqlstr)

            
if ds.tables(0).rows.count>=1 then

                PNID
=ds.tables(0).rows(0).item("nid")

            
else

                PNID
=0

            end 
if



        sqlstr
="select top 1 * from product  where sid='" & request.querystring("id"& "'"

            ds
=obj.getdataset(sqlstr)

            
if ds.tables(0).rows.count>=1 then

                PID
=ds.tables(0).rows(0).item("pid")

            end 
if

    end sub



    sub RepeatDataBind(sqlstr as string)

        dim myconn as OleDbConnection

        dim ds as 
new dataset

        dim connstr as string

        connstr
=ConfigurationSettings.AppSettings("Connstr")



        myconn
=new oleDbconnection(connstr)

        dim dbRead as oledbDataadapter

        dbread
=new oledbdataadapter(sqlstr,myconn)

        

        dbread.fill(ds,
"shopip")

        dim objPage as 
new pagedDataSource

        objPage.Datasource
=ds.tables("shopip").defaultview

        objpage.allowpaging
=true

        objpage.pagesize
=18

    

        dim curPage as integer

        
if request.queryString("page")<> "" then

            curPage
=Convert.Toint32(request.queryString("Page"))

        
else

            curPage
=1

        end 
if

        objpage.currentpageindex
=curpage-1

        

        messagesPage.text
=curPage.Tostring() + "/" +  objpage.pageCount.tostring()

        
if not objpage.isfirstpage then

            upLink.navigateUrl
=request.CurrentExecutionfilepath+"?id=" & _

            request.querystring(
"id"& "&page=" + Convert.tostring(curpage-1)

        end 
if

        
if not objpage.islastpage then

            downLink.navigateUrl
=request.CurrentExecutionfilepath+"?id=" & _

            request.querystring(
"id"& "&page=" + Convert.tostring(curpage+1)

        end 
if

        msglist.datasource
=objpage

        msglist.databind()

    end sub

</script>



</head>

<body bgcolor="#28292b">

    
<TABLE width="100%" cellpadding="0" cellspacing="0" height="100%" valign=top>

        
<TR>

            
<TD width="30%" valign="top" style="font-size:18px">

                
<table width="100%" valign=top>

                    
<td>

                          
<font style="font-size:14px;color:#ffffff"><b>IP访问记录:</b></font><p>

                                浏览次数:
<asp:label id="IPList" runat="server" /><br>

                                今日浏览:
<asp:label id="TDIPList" runat="server" /><br>

                                昨日浏览:
<asp:label id="YDIPList" runat="server" />

                    
</td>

                
</table>

            
</TD>



            
<TD width="3" bgcolor="#000000">

            
</TD>



            
<TD valign="top">

                
<table width=100% valign=top>

                    
<tr>

                        
<td colspan=2 align=right>

                            
<href="cont.aspx?id=<%=request.querystring("id")%>" target="cont">

                            · 本店首页
</a>  

                            
<href="Product.aspx?id=<%=request.querystring("id")%>&pid=<%= PID%>" target="cont">

                            · 产品介绍
</a>  

                            
<href="Notes.aspx?id=<%=request.querystring("id")%>&nid=<%= PNID%>" target="cont">

                            · 通知公告
</a>  

                            
<href="msgbook.aspx?id=<%=request.querystring("id")%>" target="cont">

                            · 顾客留言
</a>  

                            
<href="IPShow.aspx?id=<%=request.querystring("id")%>" target="cont">

                            · 查看访问
</a>    

                        
</td>

                    
</tr>

                    
<tr>

                        
<td class="tdbg">

                        
</td>

                    
</tr>

                    
<tr>

                      
<td align=center valign="top">

                      
<TABLE width="90%" border="0" cellpadding="0" cellspacing="0">

                        
<tr>

                            
<td height=25 colspan="2" background="../Image/msgbg.gif">   <span class="STYLE4">=IP历史访问记录=</span></td>

                        
</tr>

                        
<asp:Repeater ID="msglist" runat="server">

                        
<ItemTemplate>

                        
<tr>

                            
<td width="34%" align="center" valign=top bgcolor="#E3E3E3">

                                
<span class="STYLE1"><span class="STYLE2"><%# DataBinder.Eval(Container.Dataitem,"IPname"%></span></span></td>

                            
<td width="66%" align="left" valign=middle bgcolor="#E3E3E3"><span class="STYLE3"><%# DataBinder.Eval(Container.Dataitem,"IPTime"%> </span></td>

                        
</tr>

                        
<tr>

                            
<td colspan="2" align="center" height=1 valign=top bgcolor="#999999"></td>

                        
</tr>

                        
</ItemTemplate>

                        
<AlternatingItemTemplate>

                        
<tr>

                            
<td align="center" valign=top bgcolor="#FFFFFF"><span class="STYLE1">