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

 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title></title>
<LINK href="../css/style.css" rel=stylesheet type=text/css>
<script language="javascript">
function ischeckg()
{
var strn=document.modiform.gradename.value;
 	if(strn.replace(/^\s+|\s+$/g,'')=="")
  {
   alert("请输入等级名称！");
   document.modiform.gradename.focus();
   return false;
  }	
}

function showgrade(obj)
{
 if(obj.value==1)
 {
 document.all("deldiv").style.display="none";
 document.delform.isall.value=0;
 }
  else if(obj.value==2)
 {
 document.all("deldiv").style.display="none";
  document.delform.isall.value=0;
  }
  else if(obj.value==3)
 {
 document.all("deldiv").style.display="";
  document.delform.isall.value=1;
  }
 }
 function isdeltrue()
 {
   var isok=confirm("你确定要执行此操作！");
  if(isok)
  {
  if( document.delform.isall.value=="1")
  {
    if(document.delform.delkind.options[document.delform.delkind.options.selectedIndex].value=="no")
   {
   alert("对不起！目前没有用于等级转换的等级!");
    return false;
  }
   }
  else
  {
   return true ;
   }
  }
  else
  {
   return false;
  }
 }
</script>
   </head>
   <%
    
	'删除等级 start^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
	gaction=Replace_Text(request("gaction"))
 	gid=Replace_Text(request("gid"))
	 roleid=Replace_Text(request("roleid"))
	delbtn=Replace_Text(request("delbtn"))
	delall=Replace_Text(request("delall"))
	delkind=Replace_Text(request("delkind"))
 	if delbtn<>"" then
	'①.只删除该会员不删除其相关信息  start 1 
	if delall="1" then
	conn.execute "delete from Websen_corporation where gradeid="&roleid
	set rsdel=server.CreateObject("adodb.recordset")
	sqldel="select * from Websen_vipgrade where id="&gid
	rsdel.open sqldel,conn,1,3
	if not rsdel.eof then 
	rsdel.delete
 	rsdel.close
	response.Redirect("grademanage.asp")
	end if
	end if
	'^^^^^^^^end 1 ^^^^^^^^^^^^^^^^^^^^^^^^^^^
	
	'②.删除该等级下的所有会员及属于该会员所有相关信息  start 2 
	if delall="2" then 
   '删除数据库中信息===========================================
	set rsall=server.CreateObject("adodb.recordset")
	sqlall="select  id,[user] from Websen_corporation where gradeid="&roleid
	rsall.open sqlall,conn,1,3
	 if not rsall.eof then 
 	 do while not rsall.eof 
     conn.execute "delete from Websen_Info where  Gsid="&rsall("id") '删除该会员的供求信息  
     conn.execute "delete from Websen_productshow  where  Gsid="&rsall("id") '删除该会员的产品信息
	 conn.execute "delete from Websen_memberRelation where [user]='"&rsall("user")&"' or SecUser='"&rsall("user")&"'"  '删除该会员的商业伙伴 
	 conn.execute "delete from Websen_work where Gsid="&rsall("id")  '删除该会员的招聘信息
	 conn.execute "delete from Websen_productclass where gsid="&rsall("id") '删除该会员的产品大类
     conn.execute "delete from Websen_productclass_1 where gsid="&rsall("id") '删除该会员的产品小类
	 conn.execute "delete from Websen_getprice where mycid="&rsall("id")&"  or  sendcid="&rsall("id")'删除该会员留言信息
	 conn.execute "delete from Websen_getprice1 where mycid="&rsall("id")&"  or  sendcid="&rsall("id")'删除该会员留言信息
	 conn.execute "delete from Websen_files where  userid="&rsall("id")   ' 删除该会员上传的图片
	 conn.execute "delete from Websen_expo where gsid="&rsall("id") '删除该会员的展会信息
	 conn.execute "delete from Websen_emailorder where gsid="&rsall("id")'删除该会员的订阅的商机
	 conn.execute "delete from Websen_trustadv where bprid="&rsall("id")&" or pjrid="&rsall("id") '删除该会员评价信息
	 conn.execute "delete from Websen_book where gsid="&rsall("id") '删除该会员有关的反馈评价信息
	 conn.execute "delete from Websen_bizre where gsid="&rsall("id") '删除该会员有关的证书信息
	 
	  '删除会员的相关文件---------------------------------------------
	  call FSO_Del(HOPE_InstallDir&"Vipcom/"&rsall("user"))
 	  call FileDel(HOPE_InstallDir&"Ptcom/"&rsall("user")&".html")
      rsall.delete 	 
	 '---------------------------------------------------------------
      rsall.movenext 
	 loop
	 rsall.close
   	 end if
	 '================================================================
 	 conn.execute "delete  from Websen_vipgrade where id="&gid  '删除该等级
	 response.Redirect("grademanage.asp")
    end if
 	' ^^^^^^^^^^^^^^^end   2^^^^^^^^^^^^^^^^^^^^^^ 
	'③.不删除该等级下的会员，将该等级下的所有会员转换到其它等级下   start 3 
	if delall="3" then 
	if delkind<>"no" and delkind<>""  then
	set rsk=server.CreateObject("adodb.recordset")
	sqlk="select * from Websen_corporation where gradeid="&roleid
	rsk.open sqlk,conn,1,3
	if not rsk.eof  then 
	do while not rsk.eof 
	rsk("gradeid")=delkind
	rsk.update
	rsk.movenext 
	loop
	rsk.close
 	end if
    conn.execute "delete  from Websen_vipgrade where id="&gid  '删除该等级
    response.Redirect("grademanage.asp")
   	end if
 	end if
 	'^^^^^end  3^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 	end if
 

'^^^ end ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   
   %>
 <body>
<table width="98%" border="0" cellspacing="0" cellpadding="0" align=center class="tableBorder">
<tr> 
<th width="100%" height=25 class="tableHeaderText">会员等级信息删除管理</th>
</tr>
<tr>
<td class="forumRowHighlight"> <B>注意： </B><BR> 
①.<font color="red">等级ID</font>是会员直属某类等级的直接<font color=red>关联值</font>，关系整个系统的所有会员的一切信息，请不要随意<font  color="red">删除</font>，否则将造成严重后果！ 
<br />
②.删除某个等级时,请注意选择所要删除的内容范围！ 
</td>
</tr>
<tr>
<td class="forumRowHighlight">★<a href="grademanage.asp">等级列表</a>
</td>
</tr>
</table>
<table border="1" cellpadding="0"  bordercolor="#ADE0FD"  cellspacing="0" width="98%" align="center">
<tr>
  <td>
  <table border="0" cellpadding="0"     cellspacing="0" width="100%" align="center">

<%
 if gaction="del" then 
	if gid<>"" then
	set rsdel=server.CreateObject("adodb.recordset")
	sqldel="select * from Websen_vipgrade where id="&gid
	rsdel.open sqldel,conn,1,3
	if not rsdel.eof then 
  %>
   <tr><td height="25"  bgcolor="#E8E8E8">
   &nbsp;&nbsp;<b>你要删除的等级名称是: <font color="red"><%=rsdel("gradename")%></font>,等级ID值是：<font color="#CC3300"><%=rsdel("roleid")%></font></b>&nbsp;&nbsp;&nbsp;&nbsp;<a href="#" onClick="javascript:history.back(-1);">取消删除</a>
  </td></tr> 
  <%
  delgradename=rsdel("gradename")
  	rsdel.close
	end if
 	end if
	end if
   %>
<form name="delform"  method="post" action="" onSubmit="return isdeltrue();">
<tr>
  <td><br />请选择删除等级[<font color="#CF5C3A"><%=delgradename%></font>]操作的类型:<br />
  &nbsp;<input type="radio" name="delall" value="1"   onclick="showgrade(this);" />只删除该等级下的所有会员而不删除属于该会员的相关信息<br />&nbsp;<input type="radio" name="delall" value="2" checked="checked" onClick="showgrade(this);"  />删除该等级下的所有会员及属于该会员所有相关信息<br />&nbsp;<input type="radio" name="delall" value="3"  onclick="showgrade(this);" />不删除该等级下的会员，将该等级下的所有会员转换到其它等级下<input type="radio" style="display:none" name="isall"   value="0"/>  </td>
</tr>
<tr><td   height="43"  >
<div id="deldiv" style="display:none; background-color:#F7F7F7; height:35"><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;请选择要将[<font color="#006699"><%=delgradename%></font>]下的所有会员转换到的等级：
<select size="1"  name="delkind"   >
<%
set rsk=server.CreateObject("adodb.recordset")
sqlk="select * from Websen_vipgrade where id<>"&gid&" order by roleid"
rsk.open sqlk,conn,1,1
if rsk.eof then 
%>
<option  value="no">无任何等级</option>
<%
end if
if not rsk.eof then
do while not rsk.eof 
%>
<option  value="<%=rsk("roleid")%>"><%=rsk("gradename")%></option>
 <%
rsk.movenext 
loop
rsk.close
end if
 %>
</select><br /><br />
</div>
</td></tr>
	<tr><td  height="30" align="center"><input type="submit" name="delbtn" value="执行删除" /></td></tr>
 </form>
</table>
 </td>
</tr></table>
</body>
</html>
