<%@ Page Language="VB" runat="server" %>
<%@ Import Namespace="system.data.sqlclient" %>
<%@ Import Namespace="system.data" %>
<script runat="server">
dim conn as sqlconnection
dim cmd as sqlcommand
dim sqlconn as string=configurationsettings.appsettings("sqlconn")
Dim Pagesize,Pagecount,RecordNum,CurrentPage as integer
Sub Page_Load(Src As Object, E As EventArgs)
If Not IsPostBack Then
page1()
CurrentPage=0
LinkButton1.Enabled=false
LinkButton2.Enabled=false
LinkButton3.Enabled=false
LinkButton4.Enabled=false
pagesize2.text=CurrentPage+1
DataBind()
else
DataBind1()
End If
End Sub
sub DataBind()
if request.cookies("admininf") is nothing then
response.Redirect("adminlogin.aspx")
response.end
else
dim adid=request.Cookies("admininf").values("adminid")
conn=new sqlconnection(sqlconn)
conn.open
cmd=new sqlcommand("select * from admin where id="+adid,conn)
dim rs as sqldatareader=cmd.executereader
if rs.read() then
lable.text=rs("username")+"管理员.您可以对汕头房产信息进行管理工作!"
end if
rs.close
conn.close
lable1.text="现在时间:"+formatdatetime(now,1)
end if
end sub
sub DataBind1()
Dim StartIndex as integer
StartIndex = CurrentPage*PageSize
select case house.selectedvalue
case "出租信息管理"
conn=new sqlconnection(sqlconn)
conn.open
cmd=new sqlcommand("select * from housetab order by id desc ",conn)
dim rs as sqldatareader=cmd.executereader
if not rs.read then
vteip.text="友情提示:暂无数据!"
else
rs.close
dim da as sqldataAdapter=new sqldataAdapter(cmd)
dim ds as dataset =new dataset
da.fill(ds,StartIndex,PageSize,"cztab")
datalist1.datasource=ds.tables("cztab")
if(CurrentPage=(PageCount-1)) then
LinkButton1.enabled=true
LinkButton2.Enabled =true
LinkButton3.enabled=false
LinkButton4.Enabled =false
elseif(CurrentPage=0) then
LinkButton1.enabled=false
LinkButton2.Enabled =false
LinkButton3.enabled=true
LinkButton4.Enabled =true
elseif (CurrentPage<>0 and CurrentPage<>(PageCount-1))
LinkButton1.enabled=true
LinkButton2.Enabled =true
LinkButton3.enabled=true
LinkButton4.Enabled =true
end if
datalist1.databind
end if
conn.close
case "求租信息管理"
response.Write("求租信息管理")
case "出售信息管理"
case "求购信息管理"
end select
end sub
sub page1()
Pagesize=15
pagesize1.text=pagesize
conn=new sqlconnection(sqlconn)
try
conn.open
cmd=new sqlcommand("select count(*) as id from housetab ",conn)
Dim dr as sqlDataReader
dr=cmd.executereader
Dim intCount as integer
if dr.Read() then
intCount =dr("id")
else
intCount = 0
end if
dr.Close()'查询有多少条记录
RecordNum=intcount
lnum1.text=RecordNum
if recordnum mod pagesize=0 then '计算可以分为多少页
PageCount = RecordNum/PageSize
countpage1.text=pagecount
else
PageCount = RecordNum/PageSize +1
countpage1.text=pagecount
end if
ViewState(PageCount) = PageCount
finally
conn.close
end try
end sub
sub page_onclick(s as object,e as Commandeventargs)
CurrentPage = ViewState("PageIndex")
PageCount = ViewState(PageCount)
Dim cmd1 as string = e.CommandName
select case cmd1
case "top"
CurrentPage=0
case "next"
if CurrentPage<(PageCount-1) then CurrentPage+=1
case "prev"
if CurrentPage>0 then CurrentPage-=1
case "end"
CurrentPage=PageCount-1
case "goto"
if page2.value>pagecount then
response.Write("<script>alert('输入的页码不对!');"+"</"+"script>")
else
CurrentPage=page2.value-1
end if
end select
ViewState("PageIndex") =CurrentPage
pagesize2.text=CurrentPage+1
page2.value=CurrentPage+1
DataBind1()
end sub
Sub boundclickon(Src As Object, E As DataListItemEventArgs)
dim del as LinkButton
If (e.Item.ItemType = ListItemType.AlternatingItem Or e.Item.ItemType = ListItemType.Item) Then
CType(e.Item.FindControl("del"), LinkButton).Attributes.Add("onclick", "return confirm('您真的要删除第" & (e.Item.ItemIndex + 1).ToString() & " 行吗?')")
end if
end sub
</script>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>汕头房产管理</title>
<style type="text/css">
<!--
body,td,th {
font-size: 12px;
color: #000000;
font-family: 宋体;
}
body {
background-color: #F6F6F6;
}
tr.listitem1 td
{
border-left:solid 1px #BBBBBB;
border-bottom:solid 1px #BBBBBB;
background-color:#FFFFFF;
padding:1px 1px 1px 1px;
text-indent:1px;
}
tr.listitem2 td
{
border-left:solid 1px #BBBBBB;
border-bottom:solid 1px #BBBBBB;
background-color:#F6F6F6;
padding:1px 1px 1px 1px;
text-indent:1px;
}
tr.over td
{
border-left:dashed 1px #BBBBBB;
border-bottom:dashed 1px #BBBBBB;
background-color:#FFF0B5;
padding:1px 1px 1px 1px;
text-indent:3px;
}
-->
</style></head>
<body>
<form method="post" id="form1" runat="server">
<table width="98%" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td width="47%" height="36" valign="bottom" style="BORDER-BOTTOM: #74ad3a 1px dotted">您好.
<asp:Label ForeColor="#FF0000" ID="lable" runat="server" /></td>
<td width="53%" valign="bottom" style="BORDER-BOTTOM: #74ad3a 1px dotted">
<div align="right">
<asp:Label ID="lable1" runat="server" /></div></td>
</tr>
<tr>
<td height="32" background="images/bj.jpg">
<asp:DropDownList AutoPostBack="true" BackColor="#0099CC" ForeColor="#FFFFFF" ID="house" runat="server">
<asp:ListItem Selected="true" >请选择管理类型</asp:ListItem>
<asp:ListItem >出租信息管理</asp:ListItem>
<asp:ListItem >求租信息管理</asp:ListItem>
<asp:ListItem >出售信息管理</asp:ListItem>
<asp:ListItem >求购信息管理</asp:ListItem>
</asp:DropDownList></td>
<td height="32" background="images/bj.jpg"><asp:Label ID="vteip" runat="server" /></td>
</tr>
<tr>
<td height="37" colspan="2">
<asp:DataList ID="datalist1" RepeatDirection="Vertical" runat="server" Width="100%" OnItemDataBound="boundclickon" allowcustompaging="true">
<headertemplate>
<table width="100%" height="28" border="0" cellpadding="0" cellspacing="0" bgcolor="#CCCCCC">
<tr>
<td width="14%" height="13"><div align="center">房屋类型</div></td>
<td width="13%"><div align="center">发布区域</div></td>
<td width="20%"><div align="center">出租位置</div></td>
<td width="18%"><div align="center">发布租金</div></td>
<td width="17%"><div align="center">发布时间</div></td>
<td width="18%"><div align="center">管理员操作管理 </div></td>
</tr>
</table>
</headertemplate>
<itemtemplate>
<table width="100%" height="20" border="0" cellpadding="0" cellspacing="0">
<tr class="listitem1" οnmοuseοver="this.className='over'" οnmοuseοut="this.className='listitem1'">
<td width="4%" height="13"><div align="center">■</div></td>
<td width="10%"><%# databinder.Eval(container.dataitem,"houselx")%></td>
<td width="13%"><div align="center"><%# databinder.Eval(container.dataitem,"houseqy")%></div></td>
<td width="20%"><div align="center"><%# databinder.Eval(container.dataitem,"housewz")%></div></td>
<td width="18%"><div align="center">
<strong><font color="#FF0000"><%# databinder.Eval(container.dataitem,"housemaney")%></font></strong>元</div></td>
<td width="17%"><div align="center"><%# databinder.Eval(container.dataitem,"addtime")%></div></td>
<td width="18%"><div align="center"><asp:LinkButton ID="del" runat="server" Text="删除"></asp:LinkButton></div></td>
</tr>
</table>
</itemtemplate>
<alternatingitemtemplate>
<table width="100%" height="20" border="0" cellpadding="0" cellspacing="0">
<tr class="listitem2" οnmοuseοver="this.className='over'" οnmοuseοut="this.className='listitem2'">
<td width="4%" height="13"><div align="center"><img src="images/2.gif" width="17" height="17"></div></td>
<td width="10%" bgcolor="#FFFFFF"><%# databinder.Eval(container.dataitem,"houselx")%></td>
<td width="13%" bgcolor="#FFFFFF"><div align="center"><%# databinder.Eval(container.dataitem,"houseqy")%></div></td>
<td width="20%" bgcolor="#FFFFFF"><div align="center"><%# databinder.Eval(container.dataitem,"housewz")%></div></td>
<td width="18%" bgcolor="#FFFFFF"><div align="center">
<strong><font color="#FF0000"><%# databinder.Eval(container.dataitem,"housemaney")%></font></strong>元</div></td>
<td width="17%" bgcolor="#FFFFFF"><div align="center"><%# databinder.Eval(container.dataitem,"addtime")%></div></td>
<td width="18%" bgcolor="#FFFFFF"><div align="center">
<asp:LinkButton ID="del" runat="server" Text="删除"></asp:LinkButton>
</div></td>
</tr>
</table>
</alternatingitemtemplate>
</asp:DataList></td>
</tr>
</table>
<p>
<asp:Label ID="pagesize1" runat="server" />
条记录/页 共有(
<asp:Label ID="lnum1" runat="server" />
)条记录 共(
<asp:Label ID="countpage1" runat="server" />
)页
<asp:LinkButton ID="LinkButton1" CommandName="top" runat="server" Text="首页" OnCommand="page_onclick"></asp:LinkButton>
<asp:LinkButton ID="LinkButton2" CommandName="prev" runat="server" Text="上一页" OnCommand="page_onclick"></asp:LinkButton>
<asp:LinkButton ID="LinkButton3" CommandName="next" runat="server" Text="下一页" OnCommand="page_onclick"></asp:LinkButton>
<asp:LinkButton ID="LinkButton4" commandname="end" runat="server" Text="末页" OnCommand="page_onclick"></asp:LinkButton>
当前页为第(
<asp:Label ID="pagesize2" runat="server" />
)页 跳到
<input name="textfield" type="text" id="page2" size="1" maxlength="3" width="3px" runat="server" onKeyPress="return regInput(this,/^[0-9]*$/,String.fromCharCode(event.keyCode))" οnpaste="return regInput(this,/^[0-9]*$/,window.clipboardData.getData('Text'))" οndrοp="return regInput(this,/^[0-9]*$/,event.dataTransfer.getData('Text'))" style="ime-mode:disabled; width:30px; height:20px">
页
<asp:Button ID="Button1" CommandName="goto" Text="GO" runat="server" OnCommand="page_onclick"/></p>
</form>
</body>
</html>