<!--#include file="../check.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>
<title>商户后台 - 分组管理</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<link type="text/css" rel="stylesheet" href="/css/reset.css" />
<link type="text/css" rel="stylesheet" href="/css/main.css" />
<link type="text/css" rel="stylesheet" href="/css/template_vendor.css" />
<script type="text/javascript" src="/scripts/common.js"></script>
<script type="text/javascript" src="/scripts/nav.js"></script>
<script type="text/javascript" src="/scripts/footerdock.js"></script>
</head>
<body>
<!--#include file="top.asp"-->


<%

Nowpage=request.QueryString("page")


   set Rs1=GrateRs("select * from member where username like '"&trim(Session("Usr_UserName"))&"'",3)


Action = Request("cmd")
Select Case Action
	Case "Modify"
	    Call Modify()
	Case "Add"
	    Call Add()
	Case "Del"
	    Call Del()
	Case Else
	    Call Main()
End Select


Sub Del()
ID = (Request("ID"))
If ID = "" Then 
	Response.Write "<script>alert('缺少参数！');history.back();</script>"
	Response.End()
End If

	Set Res = GrateRs("Select * From L_fenzu Where ID="& Cint(ID) &"  and userid="&Rs1("id")&" ",3)
If Res.Eof And Res.Bof Then
	Response.Write "<script>alert('找不到相关信息！');history.back();</script>"
	Response.End()
End If


	set rs = GrateRs("select * from L_woool where fzid="& Cint(ID) &" ",3)
	do while not rs.eof


	set rsq = GrateRs("select * from L_jiangli where quid="& rs("ID") &" ",3)
	do while not rsq.eof

	rsq.delete
	rsq.update

		rsq.movenext
	Loop
	rsq.close
	set rsq = nothing

	rs.delete
	rs.update


		rs.movenext
	Loop
	rs.close
	set rs = nothing

	res.delete
	res.update
	set res=nothing






	response.Write("<script>alert('提示：删除成功！');window.location.href='Groups.asp'</script>")
end sub


%>


<%Sub Main()%>

	<div id="mainborder">
		<div id="main">
			
		<div>
			<div class="fl">
				<h3 class="bigico bigico_foldgroup">分组管理</h3>
			</div>
			<div class="fr" style="margin-top:20px">
				<ul style="list-style:none">
					<li class="ico_refresh fl"><a href="Groups.asp">刷新</a><span class="gray simsun"> ┊&nbsp; </span></li>
					<li class="ico_add fl"><a href="?cmd=Add">添加分组</a></li>
				</ul>
			</div>
			<div class="clear vspace"></div>
		</div>
		


			<div class="gridwrap">
				<table class="fixed grid">
					<thead>
						<th>顺序</th>
						<th width="160">分组名</th>
						<th width="70">包含分区</th>
						<th width="245">支付连接</th>
						<th width="100">创建时间</th>
						<th width="145" class="center">操作</th>
					</thead>
					








          <%
			  	Set Rs=GrateRs("select top 100 * from L_fenzu where userid="&Rs1("id")&" order by id desc",1)
						if rs.eof or rs.bof then
		%>
                                    
                                    
<tr>
<td colspan="6">暂无分组记录！</td>
</tr>




		<%else
		for i= 1 to rs.pagesize
		if rs.eof then
		exit for
		end if

		set urs = GrateRs("select count(*) as fzid from [L_woool] where fzid="&rs("id")&" and userid="&Rs1("id")&" ",1)
			  %>


							<tr>
								<td><%=i%></td>
								<td><%=rs("Name")%></td>
								<td><%=urs("fzid")%> 个</td>
								<td><a target="_blank" class="underline" title="支付链接" href="http://pay.6046.com/?g=<%=rs("id")%>">http://pay.6046.com/?g=<%=rs("id")%></a></td>
								<td><%=rs("time")%></td>
								<td class="center">
									<a href="Merchandises.asp?cmd=Add&fzid=<%=rs("id")%>">添加分区</a><span class="separator"> | </span>
							
									<a href="?cmd=Modify&id=<%=rs("id")%>">修改</a><span class="separator"> | </span>
									<a href="?cmd=Del&id=<%=rs("id")%>" onClick="return confirm('确定要删除此分组吗？确定后将删除此分组下的所有服务器,请慎重考虑！')">删除</a>
								</td>
							</tr>



          <%
	 Rs.movenext
next
	 %>		



						
						
				</table>
			</div>
	
		</div>
	</div>
</div>










      <%
end if
		%>







<%
End Sub

Sub Modify()
ID = (Request("ID"))
If ID = "" Then 
	Response.Write "<script>alert('缺少参数！');history.back();</script>"
	Response.End()
End If


Set Res = GrateRs("Select * From L_fenzu Where ID="& Cint(ID) &" and userid="&Rs1("id")&" ",3)
If Res.Eof And Res.Bof Then
	Response.Write "<script>alert('找不到相关信息！');history.back();</script>"
	Response.End()
End If

    If Request("Update") = "OK" Then
	    Name = Request("Name")


		If Name = "" Then 
			Response.Write "<script>alert('请输入分组名称！');history.back();</script>"
			Response.End()
		End If	
		
		 Res("Name") = Name
		 Res.Update

		Set Res = Nothing




		Response.Write "<script>alert('修改成功!');location.href='Groups.asp';</script>"
		Response.End()
	End IF
%>




<script type="text/javascript">
function SetBank(bank)
{document.getElementById("BankBox").value=bank;}

 function $d(obj){
           
           return document.getElementById(obj);
        }
function f_sub()
   {

	if( $d("Name").value == "" )
	{
		alert( "请输入分组名!" );
		
		return false;		
	}	
	else
	{
	    return true;
	}
  }
</script>





	<div id="mainborder">
		<div id="main">
			
		<h3 class="bigico bigico_foldgroup">修改分组</h3>
		<div class="vspace"></div>
		
		<div class="shrink">
			<form name="form1" method="post" action="" id="form1">
			<input name="action" value="edit" type="hidden" />
			<input name="ID" type="hidden" id="ID" value="<%=Res("ID")%>">
			<input name="Update" type="hidden"  id="Update" value="OK">




				<table cellpadding="5" cellspacing="0">
					<tr>
						<td width="140" valign="top">分组名:</td>
						<td><input name="Name" type="text" maxlength="24" id="Name" value="<%=Res("Name")%>" style="width:180px;" />
							<div class="lb"></div>
							<span class="t3">任意输入一个分组名称，用来容易识别分组记录信息。</span></td>
					</tr>
					<tr>
						<td></td>
						<td><input name="save" type="submit" id="save" value="添加"  onclick="return f_sub();" style="width:70px" class="button" />
							<input type="button" value="返回" style="width:70px" class="button" onclick="javascript:history.back();" />
							&nbsp; &nbsp;
							<span id="testing" class="t2"></span>
						</td>
					</tr>
				</table>
			</form>
			<div class="vspace"></div>

		</div>
	
		</div>
	</div>
</div>
</body>
</html>




 



<%
Set Res = Nothing
End Sub


Sub Add()
    If Request("Update") = "OK" Then
	    Name = Request("Name")


		If Name = "" Then 
			Response.Write "<script>alert('请输入分组名称！');history.back();</script>"
			Response.End()
		End If
		




		Set Res = GrateRs("Select * From L_fenzu Where ID is null ",3)

				
		Res.Addnew
		Res("Name") = Name
		Res("UserID") = Rs1("id")
		Res("Time") = Now
		Res.Update
		Set Res = Nothing
		



		Response.Write "<script>alert('添加成功!');location.href='Groups.asp';</script>"
		Response.End()
	End IF
%>


<script type="text/javascript">
function SetBank(bank)
{document.getElementById("BankBox").value=bank;}

 function $d(obj){
           
           return document.getElementById(obj);
        }
function f_sub()
   {

	if( $d("Name").value == "" )
	{
		alert( "请输入分组名!" );
		
		return false;		
	}	
	else
	{
	    return true;
	}
  }
</script>



	<div id="mainborder">
		<div id="main">
			
		<h3 class="bigico bigico_foldgroup">添加分组</h3>
		<div class="vspace"></div>
		
		<div class="shrink">
			<form name="form1" method="post" action="" id="form1">
			<input name="action" value="edit" type="hidden" />
			<input name="Update" type="hidden" id="Update" value="OK">


				<table cellpadding="5" cellspacing="0">
					<tr>
						<td width="140" valign="top">分组名:</td>
						<td><input name="Name" type="text" maxlength="24" id="Name"  style="width:180px;" />
							<div class="lb"></div>
							<span class="t3">任意输入一个分组名称，用来容易识别分组记录信息。</span></td>
					</tr>
					<tr>
						<td></td>
						<td><input name="save" type="submit" id="save" value="添加"  onclick="return f_sub();" style="width:70px" class="button" />
							<input type="button" value="返回" style="width:70px" class="button" onclick="javascript:history.back();" />
							&nbsp; &nbsp;
							<span id="testing" class="t2"></span>
						</td>
					</tr>
				</table>
			</form>
			<div class="vspace"></div>

		</div>
	
		</div>
	</div>
</div>
</body>
</html>









<%
Set Res = Nothing
End Sub
%>


