<!--#include file="function.asp"-->
<%
checkLogin()

header("基本信息 &gt; 我的网址管理")
select case Request.QueryString("action")
case "new"
	call new_()
case "submit"

	wc_id=request.Form("wc_id")
	wc_title=request.Form("wc_title")
	wc_url=request.Form("wc_url")
	wc_bak=request.Form("wc_bak")
	
	if wc_title="" then
	response.Write ErrMsg("请输入网址标题")
	elseif wc_url="" then
	response.Write ErrMsg("请输入网址链接")
	end if
	
	set rs=server.CreateObject("adodb.recordset")
	rs.open "select * from p3t_website_custom where wc_id="&wc_id,conn,1,3
	if not rs.eof then
	rs("wc_title")=wc_title
	rs("wc_url")=wc_url
	rs("wc_bak")=wc_bak
	rs.update
	end if
	rs.close
	set rs=nothing
	
	p3t "<script>alert('操作成功');parent.location.href='?';</script>"
	p3t_end
case else
	call main_()
end select
footer()

sub main_()
%>
<script type="text/javascript" src="images/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>
<div class="main_ctrl">
	<p><a>操作选项：</a>
    <a href="javascript:edit()"><img src="images/btn_edit.gif" />编辑</a>
    </p>
</div>
<div class="main_body">
	<table cellspacing="1">
      <tr>
        <th width="20"><input type="checkbox" onclick="checkAll()" title="全选/反选" /></th>
        <th width="100">网址标题</th>
        <th>网址链接</th>
        <th>备注</th>
        <th width="100">基本操作</th>
      </tr>
<%
set rs=server.createobject("adodb.recordset")
sql="select * from p3t_website_custom order by wc_id asc"
rs.open sql,conn,1,1
if rs.eof then 
p3t "<tr><td class=""center"" colspan=""10"">暂无信息</td></tr>"
else
PageSize=14
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="wc_id" type="checkbox" value="<%=rs("wc_id")%>" /></td>
        <td><%=rs("wc_title")%></td>
        <td><%=rs("wc_url")%></td>
        <td><%=rs("wc_bak")%></td>
        <td class="center">
        	<a href="?action=new&wc_id=<%=rs("wc_id")%>">编辑</a>
        </td>
      </tr>
<%
i=i+1
if i=PageSize Then Exit Do  
rs.movenext
LOOP
end if
rs.close
set rs=nothing
%>
    </table>
    <div class="pager"><%=pages%></div>
</div>
<%
end sub
sub new_()
wc_id=request.QueryString("wc_id")
if wc_id="" then wc_id=request.QueryString("val")
if wc_id="" or isnumeric(wc_id)=false then wc_id=0
if wc_id<>0 then
set rs=conn.execute("select * from p3t_website_custom where wc_id="&wc_id)
if not rs.eof then
wc_title=rs("wc_title")
wc_url=rs("wc_url")
wc_bak=rs("wc_bak")
end if
set rs=nothing
end if
%>
<div class="main_ctrl">
	<p><a>操作选项：</a>
    <a href="javascript:history.back()"><img src="images/btn_list.gif" />返回列表</a>
    </p>
</div>
<div class="main_body">
	<table cellspacing="1">
    <form name="form1" action="?action=submit" method="post" target="yukiiak">
      <tr>
        <th colspan="2" class="left"><%if wc_id=0 then p3t "新建" else p3t "编辑ID："&wc_id%></th>
      </tr>
      <tr>
        <td width="100" class="right">网址标题</td>
        <td><input type="text" name="wc_title" class="input" size="40" value="<%=wc_title%>" /></td>
      </tr>
      <tr>
        <td class="right">网址链接</td>
        <td><input type="text" name="wc_url" class="input" size="40" value="<%=wc_url%>" /></td>
      </tr>
      <tr>
        <td class="right">备注</td>
        <td><textarea name="wc_bak" cols="60" rows="4" class="input"><%=wc_bak%></textarea></td>
      </tr>
      <tr>
        <td></td>
        <td>
			<input name="wc_id" type="hidden" value="<%=wc_id%>">
        	<input type="submit" name="submit" class="button" value=" 提 交 " />
        </td>
      </tr>
    </form>
    </table>
</div>
<%
end sub
%>