<!--#include file="../../../inc/AspCms_MainClass.asp" -->
<%
CheckAdmin("AspCms_Key.asp")

dim action : action=getForm("action", "get")
dim LinkType,LinkText,LinkDesc,ImageURL,LinkOrder,LinkStatus,LinkTet,LinkURL,ID,color


Select case action
	case "del" : delLinks
	case "add" : addLinks
	case "edit" : editLinks
	case "on" : onOff "on", "KeySetting", "ID", "KStatus", "", getPageName()
	case "off" : onOff "off", "KeySetting", "ID", "KStatus", "", getPageName()
	
End Select

Sub getContent
	ID = getForm("id","get")
	Dim rsObj 	: Set rsObj=Conn.Exec("select Color,Keywords,Url,OrderNum,KStatus,AddTime,Keywordsa,EditTime from {prefix}KeySetting where ID="&ID,"r1")
	if isnul(ID) then alertMsgAndGo "ID不能为空","-1"	
	color=rsObj(0)
	LinkText=rsObj(1)
	LinkURL=rsObj(2)
	LinkOrder=rsObj(3)
	LinkStatus=rsObj(4)
	LinkTet=rsObj(6)
	rsObj.close	:	Set rsObj = nothing
End Sub

Sub editLinks
	ID=getForm("LinkID","post")
	color=getForm("color","post")	
	LinkText=getForm("LinkText","post")	
	LinkDesc=getForm("LinkDesc","post")	
	ImageURL =getForm("ImageURL","post")	
	LinkOrder=getForm("LinkOrder","post")
	LinkTet=getForm("LinkTet","post")
	LinkStatus=getCheck(getForm("LinkStatus","post"))
	LinkURL=getForm("LinkURL","post")	

	if isnul(LinkText) then alertMsgAndGo "网站名称不能为空","-1"
	if isnul(LinkURL) then alertMsgAndGo "链接地址不能为空","-1"		
	if not isurl(LinkURL) then alertMsgAndGo "链接地址不正确","-1"	
	if isnul(LinkStatus) then LinkStatus=0
	'die "update {prefix}KeySetting set color="&color&",Keywords='"&LinkText&"',OrderNum="&LinkOrder&",Keywordsa='"&LinkTet&"',KStatus="&LinkStatus&",Url='"&LinkURL&"' where ID="&ID
	conn.Exec "update {prefix}KeySetting set color='"&color&"',Keywords='"&LinkText&"',Url='"&LinkURL&"',OrderNum="&LinkOrder&",KStatus="&LinkStatus&",Keywordsa='"&LinkTet&"' where ID="&ID,"exe"
	
	alertMsgAndGo "修改成功","AspCms_Key.asp"
End Sub

Sub addLinks 	
	color=getForm("color","post")	
	LinkText=getForm("LinkText","post")
	LinkDesc=getForm("LinkDesc","post")	
	ImageURL =getForm("ImageURL","post")	
	LinkOrder=getForm("LinkOrder","post")
	LinkTet=getForm("LinkTet","post")
	LinkStatus=getCheck(getForm("LinkStatus","post"))
	LinkURL=getForm("LinkUrl","post")	

	if isnul(LinkText) then alertMsgAndGo "网站名称不能为空","-1"
	if isnul(LinkURL) then alertMsgAndGo "链接地址不能为空","-1"		
	if not isurl(LinkURL) then alertMsgAndGo "链接地址不正确","-1"
	'if LinkType and isnul(ImageURL) then alertMsgAndGo "图片地址不能为空","-1"
	conn.Exec "insert into {prefix}KeySetting(Color,Keywords,Url,OrderNum,KStatus,Keywordsa,AddTime,EditTime) values('"&color&"','"&LinkText&"','"&LinkUrl&"','"&LinkOrder&"','"&LinkStatus&"','"&LinkTet&"','"&now()&"','"&now()&"')","exe"		
	alertMsgAndGo "添加成功","AspCms_Key.asp"
End Sub	

Sub KeyList
	Dim rsObj	:	Set rsObj=conn.Exec("select Id, Keywords,Url,Color,OrderNum,KStatus,Keywordsa,AddTime,EditTime from {prefix}KeySetting Order by OrderNum Asc,Id","r1")
	If rsObj.Eof Then 
		echo"<tr bgcolor=""#FFFFFF"" align=""center"">"&vbcrlf& _
			"<td colspan=""7"">没有数据</td>"&vbcrlf& _
		  "</tr>"&vbcrlf
	Else
		Do while not rsObj.Eof 
		Dim linkDisplay,linktype
		 echo"<tr class=list>"&vbcrlf& _
			"<TD align=middle height=26><INPUT type=checkbox value="""&rsObj(0)&""" name=""id""></TD>"&vbcrlf& _
			"<td>"&rsObj(0)&"</td>"&vbcrlf& _
			"<td>"&rsObj(1)&"</td>"&vbcrlf& _
			"<td>"&rsObj(2)&"</td>"&vbcrlf& _
			"<td>"&rsObj(6)&"</td>"&vbcrlf& _
			"<td>"&rsObj(4)&"</td>"&vbcrlf& _
			"<td>"&rsObj(3)&"</td>"&vbcrlf& _
			"<TD>"&getStr(rsObj(5),"<a href=""?action=off&id="&rsObj(0)&""" title=""启用""><IMG src=""../../images/toolbar_ok.gif""></a>","<a href=""?action=on&id="&rsObj(0)&""" title=""禁用"" ><IMG src=""../../images/toolbar_no.gif""></a>")&"</TD>"&vbcrlf& _
			"<td><a href=""AspCms_KeyEdit.asp?id="&rsObj(0)&""" class=""txt_C1"">修改</a> | <a href=""?action=del&id="&rsObj(0)&""" class=""txt_C1"" onClick=""return confirm('确定要删除吗')"">删除</a></td>"&vbcrlf& _
		  "</tr>"&vbcrlf
		  rsObj.MoveNext
		Loop
	End If
	rsObj.close	:	Set rsObj = nothing
End Sub

Sub delLinks 
	id=getForm("id","both")
	if isnul(id) then alertMsgAndGo "请选择要删除的内容","-1"

	conn.Exec "Delete * from {prefix}KeySetting where ID in("&id&")" ,"exe"
'	alertMsgAndGo "删除成功","AspCms_Key.asp"	
	response.Redirect("AspCms_Key.asp")
End Sub 

%>