admin_shoppingcart.asp

来自「江西旅行网整站源码下载 希望对大家有用 经过测试 安全可用」· ASP 代码 · 共 184 行

ASP
184
字号
<%@language=vbscript codepage=936 %>
<%
Option Explicit
Response.buffer = True
Const PurviewLevel = 0
Const PurviewLevel_Channel = 0
Const PurviewLevel_Others = "ShoppingCart"
%>
<!--#include file="../Conn.asp"-->
<!--#include file="../Inc/Function.asp"-->
<!--#include file="Admin_ChkPurview.asp"-->
<%
Dim PE_DatePart_D, PE_DatePart_Y, PE_DatePart_M, PE_DatePart_W
If SystemDatabaseType = "SQL" Then
    PE_True = "1"
    PE_False = "0"
    PE_Now = "GetDate()"
    PE_DatePart_D = "d"
    PE_DatePart_Y = "yyyy"
    PE_DatePart_M = "m"
    PE_DatePart_W = "ww"
Else
    PE_True = "True"
    PE_False = "False"
    PE_Now = "Now()"
    PE_DatePart_D = "'d'"
    PE_DatePart_Y = "'yyyy'"
    PE_DatePart_M = "'m'"
    PE_DatePart_W = "'ww'"
End If
%>
<html>
<head>
<Title>购物车</Title>
<meta http-equiv='Content-Type' content='text/html; charset=gb2312' />
<link href='Admin_Style.css' rel='stylesheet' type='text/css'>
</head>
<body>
<table width='100%' border='0' align='center' cellpadding='2' cellspacing='1' class='border'>
  <tr class='topbg'> 
    <td height='22' colspan='10'><table width='100%'><tr class='topbg'><td align='center'><b>购物车管理</b></td><td width='60' align='right'><a href='http://go.powereasy.net/go.aspx?UrlID=10047' target='_blank'><img src='images/help.gif' border='0'></a></td></tr></table></td>
  </tr>
  <tr class='tdbg' height='30'>
<form name='form1' action='Admin_ShoppingCart.asp' method='get'><td>快速查找:
<select size=1 name='SearchType' onChange='javascript:submit()'>
<option value='0' selected>所有购物车记录</option>
<option value='1'>今天的购物车记录</option>
<option value='2'>本周的购物车记录</option>
<option value='3'>本月的购物车记录</option>
</select>&nbsp;&nbsp;<a href='Admin_ShoppingCart.asp'>购物车管理首页</a></td></form>
<form name='myform' method='post' action='Admin_ShoppingCart.asp' onsubmit="return confirm('确实要删除指定的购物车记录吗?')"><td>
如果购物车明细记录太多,影响了系统性能,可以删除一定时间段前的记录以加快速度。<br>
时间范围:<input type='radio' name='DatepartType' value='0'>1天前&nbsp;&nbsp;<input type='radio' name='DatepartType' value='1'>1个星期前&nbsp;&nbsp;<input type='radio' name='DatepartType' value='2'>1个月前&nbsp;&nbsp;<input type='radio' name='DatepartType' value='3' checked>3个月前
&nbsp;&nbsp;<input type='submit' name='submit1' value='删除记录'>
<input type='hidden' name='Action' value='Clear'>
</td></form>
  </tr>
</table>
<%
Select Case Action
Case "Clear"
    Call Clear()
Case Else
    Call Main()
End Select


Sub Main
    Dim MaxPerPage,TotalPut,CurrentPage,strFileName,i
    Dim sql,Querysql,SearchType,rsCart
    MaxPerPage=PE_Clng(Trim(Request("MaxPerPage")))
    CurrentPage=PE_Clng(Trim(Request("Page")))
    SearchType=PE_Clng(Trim(Request("SearchType")))
    if MaxPerPage<=0 then MaxPerPage=20
    if CurrentPage<=0 then CurrentPage=1
    strFileName="Admin_ShoppingCart.asp"
    sql = "select top " & MaxPerPage & " P.ProductID,P.ProductName,P.Unit,P.Price,C.CartID,C.Quantity,C.UpdateTime from PE_ShoppingCarts C inner join PE_Product P on P.ProductID=C.ProductID"
    Querysql = Querysql & " where 1=1 "
    Response.Write "<br><table width='100%'><tr><td align='left'><img src='images/img_u.gif' align='absmiddle'>您现在的位置:<a href='Admin_ShoppingCart.asp'>购物车管理</a>&nbsp;&gt;&gt;&nbsp;"
    Select Case SearchType
        Case 0
            Response.Write "所有购物车记录"
        Case 1
            Querysql = Querysql & " and datediff(" & PE_DatePart_D & ",C.UpdateTime," & PE_Now & ")<1"
            Response.Write "今天的购物车记录"
        Case 2
            Querysql = Querysql & " and datediff(" & PE_DatePart_W & ",C.UpdateTime," & PE_Now & ")<1"
            Response.Write "本周的购物车记录"
        Case 3
            Querysql = Querysql & " and datediff(" & PE_DatePart_M & ",C.UpdateTime," & PE_Now & ")<1"
            Response.Write "本月的购物车记录"
        Case Else
            FoundErr = True
            ErrMsg = ErrMsg & "<li>错误的参数!</li>"
    End Select

    totalPut = PE_CLng(Conn.Execute("select Count(*) from PE_ShoppingCarts C " & Querysql)(0))
    If CurrentPage < 1 Then
        CurrentPage = 1
    End If
    If (CurrentPage - 1) * MaxPerPage > totalPut Then
        If (totalPut Mod MaxPerPage) = 0 Then
            CurrentPage = totalPut \ MaxPerPage
        Else
            CurrentPage = totalPut \ MaxPerPage + 1
        End If
    End If
    If CurrentPage > 1 Then
        Querysql = Querysql & " and C.CartItemID < (select min(CartItemID) from (select top " & ((CurrentPage - 1) * MaxPerPage) & " C.CartItemID from PE_ShoppingCarts C " & Querysql & " order by C.CartItemID desc) as QueryCartItemID) "
    End If
    sql = sql & Querysql & " order by C.CartItemID desc"

    Response.Write "</td></tr></table>"
    If FoundErr = True Then Exit Sub
    
    Response.Write "<table width='100%' border='0' align='center' cellpadding='2' cellspacing='1' class='border'>"
    Response.Write "  <tr class='title' height='22' align='center'>"
    Response.Write "    <td width='120'><b>时间</b></td>"
    Response.Write "    <td><b>购物车ID</b></td>"
    Response.Write "    <td><b>商 品 名 称</b></td>"
    Response.Write "    <td width='40'><b>单位</b></td>"
    Response.Write "    <td width='80'><b>价格</b></td>"
    Response.Write "    <td width='50'><b>数量</b></td>"
    Response.Write "  </tr>"
    
    Set rsCart = Server.CreateObject("Adodb.RecordSet")
    rsCart.Open sql, Conn, 1, 1
    If rsCart.BOF And rsCart.EOF Then
        totalPut = 0
        Response.Write "<tr class='tdbg' height='50'><td colspan='20' align='center'>没有任何购物车记录!</td></tr>"
    Else
        Do While Not rsCart.EOF            
            Response.Write "  <tr class='tdbg' onmouseout=""this.className='tdbg'"" onmouseover=""this.className='tdbgmouseover'"">"
            Response.Write "    <td width='120' align='center'>" & rsCart("UpdateTime") & "</td>"
            Response.Write "    <td>" & rsCart("CartID") & "</td>"
            Response.Write "    <td>" & rsCart("ProductName") & "</td>"
            Response.Write "    <td width='40' align=center>" & rsCart("Unit") & "</td>"
            Response.Write "    <td width='80' align=center>" & FormatNumber(rsCart("Price"), 2, vbTrue, vbFalse, vbTrue) & "</td>"
            Response.Write "    <td width='50' align='center'>" & rsCart("Quantity") & "</td>"
            Response.Write "  </tr>"
            
            i = i + 1
            If i >= MaxPerPage Then Exit Do
            rsCart.MoveNext
        Loop
    End If
    rsCart.Close
    Set rsCart = Nothing
    
    Response.Write ShowPage(strFileName, totalPut, MaxPerPage, CurrentPage, True, True, "条购物车记录", True)
End Sub

Sub Clear()
    Dim DatepartType, TempDate, strDatepart
    DatepartType = PE_CLng(Trim(Request("DatepartType")))
    Select Case DatepartType
    Case 0
        TempDate = DateAdd("D", -1, Date)
        strDatepart = "1天前"
    Case 1
        TempDate = DateAdd("D", -7, Date)
        strDatepart = "1个星期前"
    Case 2
        TempDate = DateAdd("M", -1, Date)
        strDatepart = "1个月前"
    Case 3
        TempDate = DateAdd("M", -3, Date)
        strDatepart = "3个月前"
    End Select
    If SystemDatabaseType = "SQL" Then
        Conn.Execute ("delete from PE_ShoppingCarts where UpdateTime<'" & TempDate & "'")
    Else
        Conn.Execute ("delete from PE_ShoppingCarts where UpdateTime<#" & TempDate & "#")
    End If
    Call WriteSuccessMsg("成功删除了 " & strDatepart & " 的记录!", "Admin_ShoppingCart.asp")

End Sub
%>
</body>
</html>

<%
%>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?