<!--#include file="../../p_inc/Include_func.asp"-->
<!--#include file="../inc/public.asp"-->
<!--#include file="../inc/openconn.asp"-->
<!--#include file="function.asp"-->
<%

select case Request.QueryString("action")
case "new"
	call new_()
case "submit"

	n_id=request.Form("n_id")
	n_title=trim(request.Form("n_title"))
	n_name=trim(request.Form("n_name"))
	n_contact=trim(request.Form("n_contact"))
	n_num=trim(request.Form("n_num"))
	n_period=request.Form("n_period")
	n_ip=trim(request.Form("n_ip"))
	n_view=trim(request.Form("n_view"))
	n_date=trim(request.Form("n_date"))
	n_url=trim(request.Form("n_url"))
	
	if n_title="" then
	response.Write ErrMsg("请输入网吧名称")
	elseif n_ip="" then
	response.Write ErrMsg("请输入IP地址")
	end if
	
	set rs=server.CreateObject("adodb.recordset")
	rs.open "select * from p3t_netbar where n_id="&n_id,conn,1,3
	if rs.eof and rs.bof then
	rs.addnew
	end if
	rs("n_title")=n_title
	rs("n_name")=n_name
	rs("n_contact")=n_contact
	rs("n_num")=n_num
	rs("n_period")=n_period
	rs("n_ip")=n_ip
	rs("n_view")=n_view
	rs("n_date")=n_date
	rs("n_url")=n_url
	rs.update
	rs.close
	set rs=nothing
	
	p3t "<script>alert('操作成功');parent.location.reload();</script>"
	p3t_end
	
case "del"
	
	n_id=request.QueryString("n_id")
	if n_id="" then n_id=request.QueryString("val")
	conn.execute("delete from p3t_netbar where n_id in ("&n_id&")")	
	p3t "<script>parent.location.reload();</script>"
	p3t_end
	
case "zero"
	
	n_id=request.QueryString("n_id")
	if n_id="" then n_id=request.QueryString("val")
	conn.execute("update p3t_netbar set n_view=0 where n_id in ("&n_id&")")	
	p3t "<script>parent.location.reload();</script>"
	p3t_end
	
case else
	call main_()
end select
footer()

sub main_()
%>
<script type="text/javascript" src="jquery.min.js"></script>
<script type="text/javascript">
$(function(){
	$("table tr").hover(function(){
		$(this).addClass("hover");
	},function(){
		$(this).removeClass("hover");
	});
});
function checkAll(){
	$("table input:checkbox").each(function(){
		this.checked = !this.checked; 
	});
}
function edit(){
	var val = $("table input:checkbox:checked").map(function(data){return this.value}).get().join(",");
	if (val == "")
		alert("请至少选择一条信息");
	else if (val.split(",").length > 1)
		alert("请选择一条信息");
	else
		location.href = "?action=new&val=" + val;
}
function del(){
	var val = $("table input:checkbox:checked").map(function(data){return this.value}).get().join(",");
	if (val == "")
		alert("请至少选择一条信息");
	else
		if(confirm("您确定要删除这 " + val.split(",").length + " 条信息吗？"))yukiiak.location.href = "?action=del&val=" + val;
}
</script>
<LINK href="../css/style.css" rel=stylesheet type=text/css> 
<body marginheight=0 marginwidth=0 leftmargin=0>

<TABLE border=0 cellPadding=0 cellSpacing=0 width="100%">
<TD align="center">
<TABLE width=100% border="0" cellPadding=2 cellSpacing=1 class="tableBorder">
  <tr> 
     <th height=25 colspan="2" align:center>网吧联盟信息管理</th> 
  </tr>

<div class="main_body">
	<table cellspacing="1">
<br>
<p>
<a>操作选项：</a>
    <a href="?action=new"><img src="btn_add.gif" />添加</a> |
    <a href="javascript:edit()"><img src="btn_edit.gif" />编辑</a> |
    <a href="javascript:del()"><img src="btn_del.gif" />删除</a>
</p>

      <tr>
        <th width="20"><input type="checkbox" onclick="checkAll()" title="全选/反选" /></th>
        <th width="120">网吧名称</th>
        <th width="80">法人代表</th>
        <th width="100">联系方式</th>
        <th width="80">机器台数</th>
        <th width="80">合作期限</th>
        <th>IP地址</th>
        <th width="70">浏览次数</th>
        <th width="70">提交时间</th>
        <th width="120">主页地址</th>
        <th width="120">基本操作</th>
      </tr>
<%
set rs=server.createobject("adodb.recordset")
sql="select * from p3t_netbar order by n_id desc"
rs.open sql,conn,1,1
if rs.eof then 
p3t "<tr><td class=""center"" colspan=""10"">暂无信息</td></tr>"
else
PageSize=10
NowPage=Request.QueryString("Page")
If NowPage="" Then:NowPage=1:Else:NowPage=Int(NowPage):End If
rs.PageSize=PageSize
rs.AbsolutePage=NowPage
i=0:PageList=0
'分页
pages=getPages(rs,NowPage,PageSize,PageList,"?")
do while not rs.eof
%>
      <tr>
        <td class="center"><input name="n_id" type="checkbox" value="<%=rs("n_id")%>" /></td>
        <td align="center"><%=rs("n_title")%></td>
        <td><%=rs("n_name")%></td>
        <td align="center"><%=rs("n_contact")%></td>
        <td align="center"><%=rs("n_num")%></td>
        <td align="center"><%=rs("n_period")%></td>
        <td><%=rs("n_ip")%></td>
        <td align="center"><%=rs("n_view")%></td>
        <td align="center"><%=rs("n_date")%></td>
        <td align="center"><%=rs("n_url")%></td>
        <td class="center">
        	<a href="?action=zero&n_id=<%=rs("n_id")%>" target="yukiiak">归零</a> |
        	<a href="?action=new&n_id=<%=rs("n_id")%>">编辑</a> |
            <a href="javascript:;" onclick="if(confirm('您确定要删除这条信息吗？'))yukiiak.location.href = '?action=del&n_id=<%=rs("n_id")%>';">删除</a>
        </td>
      </tr>
<%
i=i+1
if i=PageSize Then Exit Do  
rs.movenext
LOOP
end if
rs.close
set rs=nothing
%>
</table>
<br>
<br>
<br>
    <div class="pager"><%=pages%></div>
</div>
<%
end sub
sub new_()
n_id=request.QueryString("n_id")
if n_id="" then n_id=request.QueryString("val")
if n_id="" or isnumeric(n_id)=false then n_id=0
if n_id<>0 then
set rs=conn.execute("select * from p3t_netbar where n_id="&n_id)
if not rs.eof then
n_title=rs("n_title")
n_name=rs("n_name")
n_contact=rs("n_contact")
n_num=rs("n_num")
n_period=rs("n_period")
n_ip=rs("n_ip")
n_view=rs("n_view")
n_date=rs("n_date")
n_url=rs("n_url")
end if
set rs=nothing
end if
%>
<LINK href="../css/style.css" rel=stylesheet type=text/css> 
<body marginheight=0 marginwidth=0 leftmargin=0>

<TABLE border=0 cellPadding=0 cellSpacing=0 width="100%">
<TD align="center">
<TABLE width=100% border="0" cellPadding=2 cellSpacing=1 class="tableBorder">
  <tr> 
     <th height=25 colspan="2" align:center>网吧联盟信息管理</th> 
  </tr>
<div class="main_body">
	<table cellspacing="1">
    <form name="form1" action="?action=submit" method="post"  target="yukiiak">
<br>
      <tr>
        <th colspan="2" class="left"><%if n_id=0 then p3t "新建" else p3t "编辑ID："&n_id%></th>
      </tr>
      <tr>
        <td width="100" class="right">网吧名称</td>
        <td><input type="text" name="n_title" class="input" size="40" value="<%=n_title%>" /></td>
      </tr>
      <tr>
        <td class="right">法人代表</td>
        <td><input type="text" name="n_name" class="input" size="40" value="<%=n_name%>" /></td>
      </tr>
      <tr>
        <td class="right">联系方式</td>
        <td><input type="text" name="n_contact" class="input" size="40" value="<%=n_contact%>" /></td>
      </tr>
      <tr>
        <td class="right">网吧机器台数</td>
        <td><input type="text" name="n_num" class="input" size="10" value="<%=n_num%>" /> 台</td>
      </tr>
      <tr>
        <td class="right">IP地址</td>
        <td><input type="text" name="n_ip" class="input" size="40" value="<%=n_ip%>" /> IP格式：124.115.21.238</td>
      </tr>
      <tr>
        <td class="right">提交时间</td>
        <td><input type="text" name="n_date" class="input" size="40" value="<%=n_date%>" /> IP格式：124.115.21.238</td>
      </tr>
 <tr>
        <td class="right">浏览次数</td>
        <td><input type="text" name="n_view" class="input" size="40" value="<%=n_view%>" /></td>
      </tr>
<tr>
        <td class="right">主页地址</td>
        <td><input type="text" name="n_url" class="input" size="40" value="<%=n_url%>" /></td>
      </tr>
      <tr>
        <td class="right">合作期限</td>
        <td>
		<label><input type="radio" name="n_period" value="一季度"<%if n_period="一季度" then p3t " checked"%> />一季度</label> &nbsp;
		<label><input type="radio" name="n_period" value="半年"<%if n_period="半年" then p3t " checked"%> />半年</label> &nbsp;
		<label><input type="radio" name="n_period" value="一年"<%if n_period="一年" then p3t " checked"%> />一年</label>
		</td>
      </tr>
      <tr>
        <td></td>
        <td>
			<input name="n_id" type="hidden" value="<%=n_id%>">
        	<input type="submit" name="submit" class="button" value=" 提 交 " />    <a href="javascript:history.back()"><img src="images/btn_list.gif" />返回列表</a>
        </td>
      </tr>
    </form>
    </table>
    </table>
</div>
<%
end sub
%>