<!-- #include file="../conn.asp" -->
<!-- #include file="../cls_main.asp" -->
<!-- #include file="../cls_Mesky_showPage.asp" -->
<% MyDbPath = "../"
dim obj
set obj = New admin_operation
	call obj.AspInit()
set obj = nothing

Class admin_operation
	
	Private Mesky
	Private Sub Class_Initialize()
		Set Mesky = New Cls_Main
	End Sub
	Private Sub Class_Terminate()
		Set Mesky = Nothing
	End Sub
	Public Sub AspInit()
		Response.Write "<HTML>" & vbCrLf
		Response.Write "<HEAD>" & vbCrLf
		Response.Write "<TITLE>业务管理</TITLE>" & vbCrLf
		Response.Write "<META http-equiv=Content-Type content=""text/html; charset=gb2312"">" & vbCrLf
		Response.Write "<LINK href=""admin.css"" type=text/css rel=stylesheet>" & vbCrLf
		Response.Write "</HEAD>" & vbCrLf
		Response.Write "<BODY leftmargin=""1"" topmargin=""1"">" & vbCrLf
			If Mesky.adminName = "" Then
				Mesky.strMsg = "<li>非法操作：登录超时或你没有以管理员身份登录系统，<a href=""../admin_login.asp"" target=_top>点此进入管理员登录界面</a>。"
				Call Mesky.SystemMsg
			Else
				Call Main
			End If
		Response.Write "</BODY>" & vbCrLf
		Response.Write "</HTML>" & vbCrLf
	
	End Sub
	Private Sub Main()
		Select Case Request("action")
		Case "Batch_Auditing"
			Call Batch_Auditing
		Case "Auditing"
			Call Auditing
		Case Else
			Call showList
		End Select
	End Sub
	Private Sub Batch_Auditing()
		Dim sID, arrID, i
		sID = Request("ID")
		If sID = "" Then
			Mesky.strMsg = "请选择要操作的业务订单。"
			Call Mesky.SystemMsg
		Else
			arrID = Split(sID, ",")
			For i = 0 To UBound(arrID)
				Operation (CLng(arrID(i)))
			Next
			Mesky.strMsg = "批量业务审核操作完成。"
			Call Mesky.SystemMsg
		End If
	End Sub
	Private Sub Auditing()
		Call Operation(CLng(Request("ID")))
		Mesky.strMsg = "单个业务审核操作完成。"
		Call Mesky.SystemMsg
	End Sub
	Private Sub Operation(ID)
		Dim Rs
		Set Rs = Mesky.Execute("select ID,Moneys,Points,Months,UserName,isAuditing from Mesky_Operation where ID = " & ID)
		If Rs.BOF And Rs.EOF Then
			Set Rs = Nothing
			Exit Sub
		Else
			If Rs(5) Then
				Set Rs = Nothing
				Exit Sub
			Else
				If Rs(2) > 0 Then Mesky.Execute ("update Mesky_User set Points = Points + " & Rs(2) & " where UserName = '" & Rs(4) & "'")
				If Rs(3) > 0 Then Mesky.Execute ("update Mesky_User set VipEndDate = DateAdd(m, " & Rs(3) & ", VipEndDate) where UserName = '" & Rs(4) & "'")
				Mesky.Execute ("update Mesky_Operation set isAuditing = 1 where ID = " & ID)
			End If
		End If
		Set Rs = Nothing
	End Sub
	Private Sub showList()
	
		Dim sColumn, showPageRs, strSQL, Rs, i, currentPage
		If Trim(Request.QueryString("Page")) = "" Then
			currentPage = 1
		Else
			currentPage = Trim(Request.QueryString("Page"))
		End If
		sColumn = "ID,ProductID,ProductName,Moneys,Points,Months,UserName,DateAndTime,isAuditing"
		Response.Write " <fieldset><legend>业务管理：</legend>" & vbCrLf
		Response.Write "      <table width=""100%"" border=""0"" align=""center"" cellpadding=""3"" cellspacing=""1"">" & vbCrLf
		Response.Write "        <tr height=""21""> " & vbCrLf
		Response.Write "          <td background=""../images/menubg.gif"">选择</td>" & vbCrLf
		Response.Write "          <td background=""../images/menubg.gif"">产品名称</td>" & vbCrLf
		Response.Write "          <td background=""../images/menubg.gif"">金额</td>" & vbCrLf
		Response.Write "          <td background=""../images/menubg.gif"">积分点</td>" & vbCrLf
		Response.Write "          <td background=""../images/menubg.gif"">时长</td>" & vbCrLf
		Response.Write "          <td background=""../images/menubg.gif"">业务提交时间</td>" & vbCrLf
		Response.Write "          <td background=""../images/menubg.gif"">用户</td>" & vbCrLf
		Response.Write "          <td background=""../images/menubg.gif"">审核</td>" & vbCrLf
		Response.Write "          <td background=""../images/menubg.gif"">管理操作</td>" & vbCrLf
		Response.Write "        </tr>" & vbCrLf
		Response.Write "        <SCRIPT language = ""JavaScript"">" & vbCrLf
		Response.Write "function SelectAll() {" & vbCrLf
		Response.Write "    for (var i=0;i<document.myform.selSpecialID.length;i++) {" & vbCrLf
		Response.Write "        var e=document.myform.selSpecialID[i];" & vbCrLf
		Response.Write "        e.checked=!e.checked;" & vbCrLf
		Response.Write "    }" & vbCrLf
		Response.Write "}" & vbCrLf
		Response.Write "</script>" & vbCrLf
		Response.Write "        <form name=""myform"" method=""post"" action="""">" & vbCrLf
	
		Set showPageRs = New cls_Mesky_showPage '创建对象
			If IsSqlDataBase = 1 Then
				showPageRs.DbType = "MSSQL_SP"
			Else
				showPageRs.DbType = "AC"
			End If
			'数据库类型,AC为access,MSSQL为sqlserver2000,MSSQL_SP为存储过程版,MYSQL为mysql,PGSQL为PostgreSql
			showPageRs.RecType = 0
			'取记录总数方法(0执行count,1自写sql语句取,2固定值)
			showPageRs.RecSql = 0
			'如果RecType＝1则=取记录sql语句，如果是2=数值，等于0=""
			showPageRs.RecTerm = 2
			'取从记录条件是否有变化(0无变化,1有变化,2不设置cookies也就是及时统计，适用于搜索时候)
			showPageRs.CookieName = "admin_cms_special" '如果RecTerm＝2,cookiesname="",否则写cookiesname
			showPageRs.Order = 0              '排序(0顺序1降序),注意要和下面sql里面主键ID的排序对应
			showPageRs.PageSize = 30          '每页记录条数
			showPageRs.currentPage = currentPage
			showPageRs.sql = sColumn & "$Mesky_Operation$$ID$ID" '字段,表,条件(不需要where),排序(不需要需要ORDER BY),主键ID
		Dim iRecCount, sqlRs
		iRecCount = showPageRs.RecCount() '记录总数
	   
		If iRecCount < 1 Then
			Response.Write "<tr bgcolor=""#FCFCFC""><td colspan=""9"">Sorry！没有找到任何记录。</td></tr>"
		Else
			'Set sqlRs = showPageRs.ResultSet()  '返回ResultSet
			Rs = showPageRs.ResultSet()  '返回ResultSet
			For i = 0 To UBound(Rs, 2)
			' sColumn = "ID,ProductID,ProductName,Moneys,Points,Months,UserName,DateAndTime,isAuditing"
				If (i + 1) Mod 2 = 0 Then
				Response.Write "          <tr class=""tdbg2""> " & vbCrLf
				Else
				Response.Write "          <tr class=""tdbg3""> " & vbCrLf
				End If
				Response.Write "            <td >"
				If Not Rs(8, i) Then
				Response.Write "<input name=""ID"" type=""checkbox"" value=""" & Rs(0, i) & """>"
				End If
				Response.Write "            </td>" & vbCrLf
				Response.Write "            <td><a href=""User_BuyPoints.asp?action=buy&id=" & Rs(1, i) & """ target=""_blank"">" & Rs(2, i) & "</a></td>" & vbCrLf
				Response.Write "            <td>￥ " & Rs(3, i) & " 元</td>" & vbCrLf
				Response.Write "            <td>" & Rs(4, i) & " 点</td>" & vbCrLf
				Response.Write "            <td>" & Rs(5, i) & " 月</td>" & vbCrLf
				Response.Write "            <td>" & Mesky.FormatMyDate(Rs(7, i), "{Y}-{m}-{d} {h}:{mi}") & "</td>" & vbCrLf
				Response.Write "            <td>" & Rs(6, i) & "</td>" & vbCrLf
				If Rs(8, i) Then
				Response.Write "            <td><b><font color=red>√</font></b></td>" & vbCrLf
				Response.Write "            <td></td>" & vbCrLf
				Else
				Response.Write "            <td><b><font color=red>×</font></b></td>" & vbCrLf
				Response.Write "            <td><a href=""?action=Auditing&ID=" & Rs(0, i) & """>审核</a></td>" & vbCrLf
				End If
				Response.Write "          </tr>" & vbCrLf
			Next
			Rs = Null
			'Set sqlRs = Nothing
		End If
		
		Response.Write "          <tr> " & vbCrLf
		Response.Write "            <td colspan=""9"" class=""tdbg2""><a href=""javascript:SelectAll()"">选择</a> " & vbCrLf
		Response.Write "              管理选项: " & vbCrLf
		Response.Write "              <input type=""radio"" name=""action"" value=""Batch_Auditing""> <font color=""#FF0000"">批量审核</font> " & vbCrLf
		Response.Write "              <input type=""submit"" name=""Submit3"" value=""执行操作"" onclick=""{if(confirm('您确定执行的操作吗?')){this.document.myform.submit();return true;}return false;}""> " & vbCrLf
		Response.Write "          </tr>" & vbCrLf
		Response.Write "        </form>" & vbCrLf
		If iRecCount > 0 Then
			Response.Write "<tr bgcolor=""#FFFFFF""><td colspan=""9"">" & showPageRs.showPage("?Page={$pages}" & q) & "</td></tr>"
		End If
		Response.Write "      </table></fieldset>" & vbCrLf
		Set showPageRs = Nothing
		
	End Sub
	Public Sub OnEndPage()
		Response.Write Mesky.CopyRight
	End Sub ' OnEndPage

End Class %>