<!-- #include file="const.asp" -->
<!-- #include file="admin_judge.asp" -->
<!-- #include file="Page_cls.asp"-->
<!-- #include file="admin_function.asp"-->
<!-- #include file="../public/public.asp"-->
<%
url = cstr(request.servervariables("script_name"))
shop_url = replace(url,"admin/news.asp","")
call admintop()
Select Case request("action")
	Case "dete" : del()
	Case "updt" : update()
	Case "adclass" : add()
	Case "adclass_ok" : add_ok()
	Case "edit" : edit()
	Case "edit_ok" : edit_ok()
	Case Else
		 main()
End Select

Sub add_ok
  c_paixu=request("c_paixu")
  c_show = request("show")
	If IsNumeric(c_paixu)=False Then c_paixu=0
  set rs=server.CreateObject("adodb.recordset")
  rs.Open "select * from t_news_class", conn, 1, 3
  rs.AddNew
	For LangT = 1 To TotalLang
		rs("c_name" & LanguageTxt(LangT))=trim(safereplace(request("c_name" & LanguageTxt(LangT))))
	Next
  rs("c_paixu")=c_paixu
  rs("c_show")=c_show
  rs.Update
  rs.Close:set rs=Nothing
  m_t="文章类别管理"
  m_s="·数据添加成功！"
  m_u="news.asp"
	m_time="2"
  Call Up_mes(m_t,m_s,0,m_u,0,0,m_time,1)
End Sub

Sub edit_ok
	id=Safereplace(trim(request("id")))
  c_paixu=request("c_paixu")
  c_show=request("show")
	If IsNumeric(c_paixu)=False Then c_paixu=0
  set rs=server.CreateObject("adodb.recordset")
  rs.Open "select * from t_news_class where c_id = "& id &"", conn, 1, 3
	For LangT = 1 To TotalLang
		rs("c_name" & LanguageTxt(LangT))=trim(safereplace(request("c_name" & LanguageTxt(LangT))))
	Next
  rs("c_paixu")=c_paixu
  rs("c_show")=c_show
  rs.Update
  rs.Close:set rs=Nothing
  m_t="文章类别管理"
  m_s="·数据更新成功！"
  m_u="news.asp"
	m_time="2"
  Call Up_mes(m_t,m_s,0,m_u,0,0,m_time,1)
End Sub

Sub update
	c_id=Replace(Safereplace(trim(request("m_id")))," ","")
	c_paixu=Replace(Safereplace(trim(request("c_paixu")))," ","")
	If UBound(Split(c_id,",")) = 0 Then
    set rs=server.CreateObject("adodb.recordset")
    rs.open "select * from t_news_class where c_id=" &c_id, conn, 1, 3
            rs("c_paixu")=c_paixu
    rs.update
    rs.close:set rs=Nothing
	Else
		For i = 0 To UBound(Split(c_id,","))
	    set rs=server.CreateObject("adodb.recordset")
	    rs.open "select * from t_news_class where c_id=" &Split(c_id,",")(i), conn, 1, 3
	    rs("c_paixu")=Split(c_paixu,",")(i)
	    rs.update
	    rs.close:set rs=Nothing
		Next
	End If
  m_t="文章类别管理"
  m_s="·数据更新成功！"
  m_u="?page=" & request("page")& "&keyword=" & request("keyword")& "&Lang="& request("lang")
	m_time="2"
  Call Up_mes(m_t,m_s,0,m_u,0,0,m_time,1)
End Sub

Sub del
  del_id= Replace(safereplace(Trim(request("id"))),"，",",")
	If Right(del_id,1) = "," Then del_id = Left(del_id,Len(del_id)-1)
  if del_id="" then
    response.write"<SCRIPT language=JavaScript>alert('请选择您要删除的条目！');javascript:history.go(-1)</SCRIPT>"
    response.end
  end if
  conn.execute "delete from t_news_class where c_id in("&del_id&")"
  m_t="文章类别管理"
  m_s="·数据删除成功！"
  m_u="?page=" & request("page")& "&keyword=" & request("keyword")& "&Lang="& request("lang")
  m_time="2"
  Call Up_mes(m_t,m_s,0,m_u,0,0,m_time,1)
End Sub

Sub add()
%>
<script language="JavaScript" type="text/JavaScript">
function CheckForm(theform)
{
    if (!isEmpty(theform.c_name,'请填写名称！')) return false;
}
</script>
<script language=JavaScript src="../js/dialog.js"></script>
<%
  page_name = "添加文章"
%>
<!-- #include file="welcome_head.asp" -->
<table width="99%" border="0" cellspacing="0" cellpadding="3" class="classtable">
<form name="form2" method="post" action="?action=adclass_ok" onSubmit="return CheckForm(this);">
<tr>
	<td height="30" align="left" class="classhead"><input name="submit" type="image" src="../images/bt_app.gif" value=" 提交 " title=" 提交 " align="absmiddle">&nbsp;<input type="image" src="../images/bt_res.gif" border="0" title=" 重填 " onclick="reset();return false;" align="absmiddle"></td>
	<td class="classhead" align="right">
	<%=QuickMenu("","")%>
	</td>
 </tr>
<tr>
   <td class="classtop" colspan="2" height="30">文章添加</td></tr>
<tr>
<td class="classbg" colspan="2">
<ul id="tablist">
   <%For LangT = 1 To TotalLang%>
   <li<%If LangT = 1 Then response.write(" class=""selected""") End If%>><a rel="tcontent<%= LangT %>" style="CURSOR:hand;"><%= LanguageName(LangT) %></a></li>
   <%Next%>
</ul>
<div id="tabcontentcontainer">
<%For LangT = 1 To TotalLang%>
   <div id="tcontent<%= LangT %>" class="tabcontent">
   <table cellspacing="0" cellpadding="4" width="100%" border="0" id="classtable_<%= LangT %>">
<tr class="classtd">
<td width="15%" class="classtd">输入名称：</td>
<td width="85%" class="classtd">
<input type="text" name="c_name<%= LanguageTxt(LangT) %>" size="20" class="form">
<input type="radio" name="show" value="1" style="border:0;" checked>网店新闻<input type="radio" name="show" value="2" style="border:0;" >通用信息
</td>
</tr>
	</table>
	</div>
	<script>tdshow("classtable_<%= LangT %>");</script>
<%Next%>
</div>
<script>showtabcontent("tablist")</script>
<ul id="tablistmain">
   <li class="selected"><a rel="">通用信息</a></li>
</ul>
<div id="tabcontentcontainer">
<table cellspacing="0" cellpadding="4" width="100%" border="0" id="classtable">
<tr class="classtd">
<td width="15%" class="classtd">排序序号：</td>
<td width="85%" class="classtd">
<input type="text" name="c_paixu" size="5" value="1" class="form">
</td>
</tr>
</table>
<script>tdshow("classtable");</script>
</div>
</td>
</tr>
<tr class="classfooter">
  <td height="30" colspan="2" align="left" class="classfooter"><input name="submit" type="image" src="../images/bt_app.gif" value=" 提交 " title=" 提交 " align="absmiddle">&nbsp;<input type="image" src="../images/bt_res.gif" border="0" title=" 重填 " onclick="reset();return false;" align="absmiddle"></td>
 </tr>
</form>
</table>
<!-- #include file="welcome_footer.asp" -->
<%
End Sub

Sub edit()
Id = checknum(request("id"),0)
sql = "select * from t_news_class where c_id = "& id &""
set Rs = conn.execute(sql)
if Not (rs.eof and rs.bof) then
%>
<script language="JavaScript" type="text/JavaScript">
function CheckForm(theform)
{
    if (!isEmpty(theform.c_name,'请填写名称！')) return false;
}
</script>
<script language=JavaScript src="../js/dialog.js"></script>
<%
  page_name = "文章编辑"
%>
<!-- #include file="welcome_head.asp" -->
<table width="99%" border="0" cellspacing="0" cellpadding="3" class="classtable">
<form name="form1" method="post" action="?action=edit_ok" onSubmit="return CheckForm(this);">
<tr>
	<td height="30" align="left" class="classhead"><input name="submit" type="image" src="../images/bt_app.gif" value=" 提交 " title=" 提交 " align="absmiddle">&nbsp;<input type="image" src="../images/bt_res.gif" border="0" title=" 重填 " onclick="reset();return false;" align="absmiddle"><input type="hidden" name="id" value="<%=id%>"></td>
	<td class="classhead" align="right">
	<%=QuickMenu("","")%>
	</td>
 </tr>
<tr>
   <td class="classtop" colspan="2" height="30">文章编辑</td></tr>
<tr>
<td class="classbg" colspan="2">
<ul id="tablist">
   <%For LangT = 1 To TotalLang%>
   <li<%If LangT = 1 Then response.write(" class=""selected""") End If%>><a rel="tcontent<%= LangT %>" style="CURSOR:hand;"><%= LanguageName(LangT) %></a></li>
   <%Next%>
</ul>
<div id="tabcontentcontainer">
<%For LangT = 1 To TotalLang%>
   <div id="tcontent<%= LangT %>" class="tabcontent">
   <table cellspacing="0" cellpadding="4" width="100%" border="0" id="classtable_<%= LangT %>">
<tr class="classtd">
<td width="15%" class="classtd">输入名称：</td>
<td width="85%" class="classtd">
<input type="text" name="c_name<%= LanguageTxt(LangT) %>" value="<%= rs("c_name"& LanguageTxt(LangT)) %>" size="20" class="form">
<input type="radio" name="show" value="1" style="border:0;" <% lookup rs("c_show"& LanguageTxt(LangT)),"1","checked","" %>>网店新闻
<input type="radio" name="show" value="2" style="border:0;" <% lookup rs("c_show"& LanguageTxt(LangT)),"2","checked","" %>>通用信息
</td>
</tr>
	</table>
	</div>
	<script>tdshow("classtable_<%= LangT %>");</script>
<%Next%>
</div>
<script>showtabcontent("tablist")</script>
<ul id="tablistmain">
   <li class="selected"><a rel="">通用信息</a></li>
</ul>
<div id="tabcontentcontainer">
<table cellspacing="0" cellpadding="4" width="100%" border="0" id="classtable">
<tr class="classtd">
<td width="15%" class="classtd">排序序号：</td>
<td width="85%" class="classtd">
<input type="text" name="c_paixu" value="<%=rs("c_paixu")%>" size="5" value="1" class="form">
</td>
</tr>
</table>
</div>
<script>tdshow("classtable");</script>
</td>
</tr>
<tr class="classfooter">
  <td height="30" colspan="2" align="left" class="classfooter"><input name="submit" type="image" src="../images/bt_app.gif" value=" 提交 " title=" 提交 " align="absmiddle">&nbsp;<input type="image" src="../images/bt_res.gif" border="0" title=" 重填 " onclick="reset();return false;" align="absmiddle"></td>
 </tr>
</form>
</table>
<!-- #include file="welcome_footer.asp" -->
<%
End If
rs.close : Set rs = Nothing
End Sub

Sub main
	page=checknum(request("page"),1)
	keyword=safereplace(Trim(request("keyword")))
	lang = safereplace(request("lang"))
	If lang = "" Then lang = LanguageTxt(0)
	Dim ors
	Set ors=new Cls_vbsPage
	Set ors.Conn=conn
	With ors
	.PageSize=15
	.PageName="Page"
	If IsSqlDataBase = 0 Then
		.DbType="AC"
	Else
		.DbType="MSSQL"
	End If
	.RecType=-1
	.Pkey="c_id"
	.Field="c_id,c_name"& lang &",c_paixu"
	.Table="t_news_class"
	sql = "1=1"
	If keyword <> "" Then sql = sql &" and (c_name"& lang &" like '%"& keyword &"%')"
	.Condition=sql
	.OrderBy="c_paixu asc,c_id desc"
	End With
	DataCount=ors.RecCount()
	DataList=ors.ResultSet()
%>
<%
  page_name = "文章类别管理"
%>
<!-- #include file="welcome_head.asp" -->
<table width="99%" width="90%" border="0" cellspacing="0" cellpadding="3" id="classtable" class="classtable">
<tbody>
<form name="form1" method="post" action="?action=updt">
<tr>
  <td colspan="2" height="30" align="left" class="classhead">
   <input name="submit" type="image" src="../images/bt_app.gif" value=" 提交 " title=" 提交 " align="absmiddle">
   <input type="image" border="0" title=" 删除 " onclick="location.href='javascript:todel();';return false;" src="../images/bt_delete.gif" align="absmiddle">
	 <input type="image" border="0" title=" 新建 " onclick="location.href='?action=adclass';return false;" src="../images/bt_add.gif" align="absmiddle">
	 <input name="page" type="hidden" value=<%=page%>>
	 <input name="keyword" type="hidden" value="<%=keyword%>">
	 <input name="lang" type="hidden" value="<%=lang%>">
	 <input name="l_type" type="hidden" value="">
	 <input name="sort_id" type="hidden" value="">
  </td>
 </tr>
<tr>
<td class="classtop" width="5%" height="30" title="全选" style="cursor:pointer;" onclick="location.href='javascript:selectall();';return false;">选择</td>
<td class="classtop" width="20%">名称</td>
<td class="classtop" width="55%">&nbsp;</td>
<td class="classtop" width="10%">序号</td>
<td class="classtop" width="10%">操作</td>
</tr>
<%
If DataCount >0 Then
		For i = 0 To Ubound(DataList,2)
%>
<tr class="classrow">
<td height="30" class="classrow"><input name="id" style="border:0;" type="checkbox" value="<%=DataList(0,i)%>"><input name="m_id" type="hidden" value="<%=DataList(0,i)%>"></td>
<td colspan="2" class="classrow"><%=DataList(1,i)%></td>
<td class="classrow"><input name="c_paixu" type="text" id="p_paixu" value=<%=DataList(2,i)%> size="3" class="form"></td>
<td class="classrow"><a href="?action=edit&id=<%=DataList(0,i)%>"><img src="../images/icon_edit.gif" width="16" height="16" title=" 编辑 " border="0"></a></td>
</tr>
<%
     Next
End If
%>
<tr class="classrow">
<td height="30" colspan="5" class="classrow">
<strong>友情提示：通用信息类的文章为系统内容，请勿删除，可以编辑！</strong>
</td>
</tr>
</form>
</table>
<script>tdshow("classtable");</script>
<!-- #include file="welcome_footer.asp" -->
<%End Sub%>