<%@ codepage ="936" %>
  <% 
	data_path="../../" 'ACC连接数据库路径，对SQL无效
	numid="23"
	dir="../err.asp" 
 %>
 <!--#include file="../../conn/conn.asp"-->
<!--#include file="../../inc/safe.asp"-->
<!--#include file="../../inc/FileSystem.asp"-->
<!--#include file="../rolecheck.asp"-->

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<LINK href="../css/style.css" rel=stylesheet type=text/css>
<script language="javascript">
function checkmodi()
{
  if(document.formmoid.class_1_name.value.replace(/^\s+|\s+$/g,'')=="")
 {
   alert("您必须输入大类名称!");
   document.formmoid.class_1_name.focus();
   return false;
 } 
 if(document.formmoid.orderid_1.value.replace(/^\s+|\s+$/g,'')=="")
 {
   alert("您必须输入排序号!");
   document.formmoid.orderid_1.focus();
   return false;
 }
}
</script>
</head>
<%
dim body
call main()

set rs=nothing
conn.close
set conn=nothing
sub main()
%>
 <table width="98%" border="0" cellspacing="0" cellpadding="0"  align=center class="tableBorder"> 
  <tr> 
     <th height=25 colspan="2" class="tableHeaderText">专项商机类别管理 </th> 
   </tr> 
  <tr> 
     <td colspan="2"  height="20" ><font color="#666666">温馨提示：①类别直接与发布的信息相关联，删除类别可能会影响到以前发布的专项商机信息。</font> </td> 
   </tr> 
  <tr> 
     <td width="12%" height=25 class="forumRowHighlight"> <B>操作选项</B></td> 
     <td width="88%" class="forumRowHighlight"><a href="index.asp">管理专项商机</a>  | <a href="type.asp">管理商机类别</a> | <a href="class_ok.asp?action=add_class_1">添加专项类别</a> | [<a href="javascript:location.reload()">刷新页面</a>]</td> 
   </tr> 
</table> 
<font color="<%=TableContentColor%>"> 
<%
           if request("action") ="add_class_1" then 
              call add_class_1()
           elseif request("action")="add_class_1_ok" then
              call add_class_1_ok()
           elseif request("action")="edit_class_1" then
              call edit_class_1()
           elseif request("action")="savedit_1" then
              call savedit_1()
           elseif request("action")="del_class_1" then
              call del_class_1()
           else
              call linkinfo()
           end if
           %> 
 <%=body%> 
</font> 
<%
end sub
sub add_class_1()
%> 
<SCRIPT language=javascript>
function FORM1_onsubmit()
{
 if(document.FORM1.class_name.value.length<1)
 {
   alert("您必须输入大类名称!");
   document.FORM1.class_name.focus();
   return false;
 } 
 if(document.FORM1.orderid.value.length<1)
 {
   alert("您必须输入排序号!");
   document.FORM1.orderid.focus();
   return false;
 }
}

</SCRIPT> 
  <TABLE width=100% border="0" align="center" cellPadding=3 cellSpacing=1 class="tableBorder"> 
   <FORM name=FORM1 onSubmit="return FORM1_onsubmit()" action=class_ok.asp?action=add_class_1_ok&LogName=103 method=post> 
 <TR> 
      <Th colSpan=2 height="28" class="tableHeaderText">添加专项商机类别</Th> 
    </TR> 
    <TR> 
      <TD width=38% height=25 align=right class="forumRowHighlight">要添加的类别名称：</TD> 
      <TD width=62% height=40 class="forumRowHighlight">
	  <INPUT maxLength=16 size=35 name=class_name onBlur="this.value=this.value.replace(/\s/igm,'')">
	  
	  排序号:
  <input type="text" name="orderid"  value="0" maxlength="5" onKeyUp="value=value.replace(/[^\d]/g,'') " size=5   tonbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/[^\d]/g,''))">	  </TD> 
    </TR> 
    <TR> 
      <TD colSpan=2 height="27" align=center class="forumRowHighlight"> <INPUT type=submit value='确 定 添 加' name=Submit2> </TD> 
    </TR> </FORM>
  </TABLE> 
 
<%
end sub
sub edit_class_1()
    set rs=server.createobject("adodb.recordset")
    sqltext="select * from Yixiang_vipinfo_class where typeid="+Cstr(request("id"))
    rs.open sqltext,conn,1,1
%> 
<form name=formmoid action="class_ok.asp?action=savedit_1&LogName=104" method=post  onSubmit="return checkmodi()"> 
  <input type=hidden name=id value="<%=Cstr(request("id"))%>"> 
  <table width="100%" border="0" align="center" cellpadding="3" cellspacing="1" class="tableBorder"> 
    <TR> 
      <Th colSpan=2 height="28" class="tableHeaderText">修改专项商机类别</Th> 
    </TR> 
    <tr> 
      <td width="40%" height="40" align=right class="forumRowHighlight">要修改的类别名称：</td> 
      <td width="60%" class="forumRowHighlight">
	   <input name="class_1_name" type="text" value="<%=rs("type")%>" size='35' maxlength="16"  onBlur="this.value=this.value.replace(/\s/igm,'')">
	    排序号:
  <input type="text" name="orderid_1"  value="<%=rs("orderid")%>" maxlength="5" onKeyUp="value=value.replace(/[^\d]/g,'') " size=5   tonbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/[^\d]/g,''))"> 
      </td> 
    </tr> 
    <tr> 
      <td height="30" colspan="2" class="forumRowHighlight" align="center"> <input type="submit" name="Submit" value="确 定 修 改"> </td> 
    </tr> 
  </table> 
</form> 
<%
rs.close
set rs=nothing
end sub
sub savedit_1()
    set rs= server.createobject ("adodb.recordset")
    sql = "select * from Yixiang_vipinfo_class where typeid="+Replace_Text(request("id"))
    rs.Open sql,conn,1,3
    
	if rs.eof and rs.bof then
       body=body+"<br>"+"错误，数据库操作错误，没有找到此条信息。"
    else
       rs("type")=Replace_Text(Request.Form ("class_1_name"))
	   orderid_1=Replace_Text(request.Form("orderid_1"))
	   if not isnumeric(orderid_1) then
	   orderid_1=0
	   end if
	   rs("orderid")=orderid_1
        rs.Update
	   typeid =rs("typeid")
   
    end if 
response.write"<br><table cellpadding=2 cellspacing=1 border=0 width=100% class=tableBorder align=center>"
response.write"<TR>"
response.write"<TH class=tableHeaderText colSpan=2 height=25>专项商机类别管理</TH>"
response.write"</TR><tr><td height=85 valign=top class=forumRow align=center>"

	   Set RsVip=Server.CreateObject("Adodb.Recordset")
	   	SqlVip="Select * from yixiang_vipinfo Where viptype="&typeid&" "
		RsVip.Open SqlVip,Conn,1,3
	   		IF NOt  RsVip.Eof Then 
				ID1=RsVip("vipinfo_id")
					RsVip.Movelast
				ID2=RsVip("vipinfo_id")
			end if
	   		RsVip.Close
			Set RsVip=Nothing
	%>
	
	<script language="javascript">
function return_ok(Content)
{
//弹出确认对话框,为真则生成当前分类信息
var i=confirm(Content);
if(i)
{
document.write("<iframe src='../../manage/makehtml/vipinfo/makelist.asp?all=all'  scrolling='no' height=90 width='100%' frameborder='0'></iframe><br><br>")
document.write("<iframe src='../../manage/makehtml/vipinfo/makedetail.asp?all=update&id1=<%=ID1%>&id2=<%=ID2%>'  scrolling='no' height=90 width='100%' frameborder='0'></iframe><br><br>")
}
else
{
	document.write("分类修改成功");
}
}
</script>

	<%   

Response.Write  "<div align=center><br><br><script>return_ok('您是否需要生成当前分类信息?')</script></div></td></tr>"
response.write"<tr align=center><td height=30 class=forumRowHighlight><a href='type.asp'>&lt;&lt; 返回上一页</a></td>"
response.write"</tr>"
response.write"</table>"
end sub

sub del_class_1()
			'删除当前分类
			Filename=HOPE_InstallDir&"vipinfo/"&Cstr(request("id"))&".html"
			Call FileDel(FileName) '删除当前ID的页面文件
			
			FIlePath=HOPE_InstallDir&"vipinfo/" '文件所在位置
			Call Del_Page(FIlePath,Cstr(request("id")))   '方法四:删除分页文件
			
		Set RsInfo=Server.CreateObject("Adodb.Recordset")
			SqlInfo="Select * From yixiang_vipinfo Where viptype="&Cstr(request("id"))&""
			RsInfo.Open SqlInfo,Conn,1,1
			do WHile NOt RsInfo.Eof
					TID=RsInfo("viptype")
					ClassID=RsInfo("vipinfo_id")
				Filename=HOPE_InstallDir&"UploadFile/"&RsInfo("picture")
				if RsInfo("picture")<>"nopicture.gif" then
				Call FileDel(FileName) '删除大类ID里所有页面文件的图片
				end if
				Filename=HOPE_InstallDir&"vipinfo/offerdetail/"&TID&"-"&ClassID&".html"
				Call FileDel(FileName) '删除大类ID里所有的页面文件
				
				if	RsInfo.Eof Then Exit Do
				RsInfo.MoveNext
			Loop

			Conn.Execute("Delete From yixiang_vipinfo Where viptype="&Cstr(request("id"))&"")
			
    set rs=server.createobject("adodb.recordset")
    sqltext="delete from Yixiang_vipinfo_class where typeid="&Cstr(request("id"))
	rs.open sqltext,conn,3,3
response.write"<br><table cellpadding=2 cellspacing=1 border=0 width=100% class=tableBorder align=center>"
response.write"<TR>"
response.write"<TH class=tableHeaderText colSpan=2 height=25>专项商机类别管理</TH>"
response.write"<TR><tr><td height=85 valign=top class=forumRow>"
Response.write "<div align=center>"
%>


	<script language="javascript">
function Del_Save(Content)
{
//弹出确认对话框,为真则生成当前分类信息
var i=confirm(Content);
if(i)
{
document.write("<iframe src='../../manage/makehtml/vipinfo/makelist.asp?all=all'  scrolling='no' height=90 width='100%' frameborder='0'></iframe><br><br>")
}
else
{
	document.write("分类修改成功");
}
}
</script>

<%
Response.Write  "<div align=center><br><br><script>Del_Save('您是否需要生成当前分类信息?')</script></div></td></tr>"
Response.write "</div></td></tr>"
response.write"<tr align=center><td height=30 class=forumRowHighlight><a href='type.asp'>&lt;&lt; 返回上一页</a></td>"
response.write"</tr>"
response.write"</table><br>"    

end sub



sub add_class_1_ok()

    set rs=server.createobject("adodb.recordset")
    sqltext="select * from Yixiang_vipinfo_class where type='"&Replace_Text(request.form("class_name"))&"'"
    rs.open sqltext,conn,1,1
    '查找数据库，检查大类是否已经存在
    if rs.recordcount >= 1 then 
       if rs("type")=Replace_Text(request.form("class_name")) then
          response.write"<SCRIPT language=JavaScript>alert('此类别已经存在，请选用其它名称！');"
          response.write"this.location.href='class_ok.asp?action=add_class_1';</SCRIPT>"
       end if
    else
       set rs=server.createobject("adodb.recordset")
       sqltext="select * from Yixiang_vipinfo_class"
       rs.open sqltext,conn,3,3
       rs.addnew
       rs("type")=Replace_Text(request.form("class_name"))
	   orderid=Replace_Text(request.form("orderid"))
	   if not isnumeric(orderid) then
	   orderid=0
	   end if
	   rs("orderid")=orderid
       rs.update
		
response.write"<br><table cellpadding=2 cellspacing=1 border=0 width=100% class=tableBorder align=center>"
response.write"<TR>"
response.write"<TH class=tableHeaderText colSpan=2 height=25>专项商机类别管理</TH>"
response.write"<TR><tr><td height=85 valign=top class=forumRow>"
		
Response.write("<iframe src='../../manage/makehtml/vipinfo/makelist.asp?all=all'  scrolling='no' height=90 width='100%' frameborder='0'></iframe>")
Response.write "<div align=center><br><br>添加专项商机类别成功！</div></td></tr>"
response.write"<tr align=center><td height=30 class=forumRowHighlight><a href='type.asp'>&lt;&lt; 返回上一页</a></td>"
response.write"</tr>"
response.write"</table>"
end if
end sub
%> 
<!--#include file="../copy.asp" --> 
