%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%> <% Dim MM_editAction MM_editAction = CStr(Request.ServerVariables("SCRIPT_NAME")) If (Request.QueryString <> "") Then MM_editAction = MM_editAction & "?" & Server.HTMLEncode(Request.QueryString) End If ' boolean to abort record edit Dim MM_abortEdit MM_abortEdit = false %> <% ' IIf implementation Function MM_IIf(condition, ifTrue, ifFalse) If condition = "" Then MM_IIf = ifFalse Else MM_IIf = ifTrue End If End Function %> <% If (CStr(Request("MM_update")) = "form1") Then If (Not MM_abortEdit) Then ' execute the update Dim MM_editCmd Set MM_editCmd = Server.CreateObject ("ADODB.Command") MM_editCmd.ActiveConnection = MM_theretreat_STRING MM_editCmd.CommandText = "UPDATE dbo.shop_basket_items SET qty = ? WHERE id = ?" MM_editCmd.Prepared = true MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param1", 5, 1, -1, MM_IIF(Request.Form("qty"), Request.Form("qty"), null)) ' adDouble MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param2", 5, 1, -1, MM_IIF(Request.Form("MM_recordId"), Request.Form("MM_recordId"), null)) ' adDouble MM_editCmd.Execute MM_editCmd.ActiveConnection.Close End If End If %> <% Dim Recordset1__mmid Recordset1__mmid = "0" If (session("basket_id") <> "") Then Recordset1__mmid = session("basket_id") End If %> <% Dim Recordset1 Dim Recordset1_cmd Dim Recordset1_numRows Set Recordset1_cmd = Server.CreateObject ("ADODB.Command") Recordset1_cmd.ActiveConnection = MM_theretreat_STRING Recordset1_cmd.CommandText = "SELECT * FROM dbo.shop_basket_items WHERE unid=? AND qty>0" Recordset1_cmd.Prepared = true Recordset1_cmd.Parameters.Append Recordset1_cmd.CreateParameter("param1", 200, 1, 255, Recordset1__mmid) ' adVarChar Set Recordset1 = Recordset1_cmd.Execute Recordset1_numRows = 0 %> <% Dim Recordset2__mmid Recordset2__mmid = "0" If (session("basket_id") <> "") Then Recordset2__mmid = session("basket_id") End If %> <% Dim Recordset2 Dim Recordset2_cmd Dim Recordset2_numRows Set Recordset2_cmd = Server.CreateObject ("ADODB.Command") Recordset2_cmd.ActiveConnection = MM_theretreat_STRING Recordset2_cmd.CommandText = "SELECT * FROM dbo.shop_basket_items WHERE unid=? AND qty>0" Recordset2_cmd.Prepared = true Recordset2_cmd.Parameters.Append Recordset2_cmd.CreateParameter("param1", 200, 1, 255, Recordset2__mmid) ' adVarChar Set Recordset2 = Recordset2_cmd.Execute Recordset2_numRows = 0 %> <% Dim Recordset3__mmid Recordset3__mmid = "0" If (session("basket_id") <> "") Then Recordset3__mmid = session("basket_id") End If %> <% Dim Recordset3 Dim Recordset3_cmd Dim Recordset3_numRows Set Recordset3_cmd = Server.CreateObject ("ADODB.Command") Recordset3_cmd.ActiveConnection = MM_theretreat_STRING Recordset3_cmd.CommandText = "SELECT Sum(product_price * qty) as tot FROM dbo.shop_basket_items WHERE unid=? AND qty>0 GROUP BY product_price, qty, unid ORDER BY product_price" Recordset3_cmd.Prepared = true Recordset3_cmd.Parameters.Append Recordset3_cmd.CreateParameter("param1", 200, 1, 255, Recordset3__mmid) ' adVarChar Set Recordset3 = Recordset3_cmd.Execute Recordset3_numRows = 0 %> <% Dim Repeat1__numRows Dim Repeat1__index Repeat1__numRows = -1 Repeat1__index = 0 Recordset1_numRows = Recordset1_numRows + Repeat1__numRows %> <% ' *** Recordset Stats, Move To Record, and Go To Record: declare stats variables Dim Recordset2_total Dim Recordset2_first Dim Recordset2_last ' set the record count Recordset2_total = Recordset2.RecordCount ' set the number of rows displayed on this page If (Recordset2_numRows < 0) Then Recordset2_numRows = Recordset2_total Elseif (Recordset2_numRows = 0) Then Recordset2_numRows = 1 End If ' set the first and last displayed record Recordset2_first = 1 Recordset2_last = Recordset2_first + Recordset2_numRows - 1 ' if we have the correct record count, check the other stats If (Recordset2_total <> -1) Then If (Recordset2_first > Recordset2_total) Then Recordset2_first = Recordset2_total End If If (Recordset2_last > Recordset2_total) Then Recordset2_last = Recordset2_total End If If (Recordset2_numRows > Recordset2_total) Then Recordset2_numRows = Recordset2_total End If End If %> <% ' *** Recordset Stats: if we don't know the record count, manually count them If (Recordset2_total = -1) Then ' count the total records by iterating through the recordset Recordset2_total=0 While (Not Recordset2.EOF) Recordset2_total = Recordset2_total + 1 Recordset2.MoveNext Wend ' reset the cursor to the beginning If (Recordset2.CursorType > 0) Then Recordset2.MoveFirst Else Recordset2.Requery End If ' set the number of rows displayed on this page If (Recordset2_numRows < 0 Or Recordset2_numRows > Recordset2_total) Then Recordset2_numRows = Recordset2_total End If ' set the first and last displayed record Recordset2_first = 1 Recordset2_last = Recordset2_first + Recordset2_numRows - 1 If (Recordset2_first > Recordset2_total) Then Recordset2_first = Recordset2_total End If If (Recordset2_last > Recordset2_total) Then Recordset2_last = Recordset2_total End If End If %>