<% Response.expires = 0 Response.expiresabsolute = Now() - 1 Response.addHeader "pragma", "no-cache" Response.addHeader "cache-control", "private" Response.CacheControl = "no-cache" %> <% ewCurSec = 0 ' Initialise ' User levels Const ewAllowAdd = 1 Const ewAllowDelete = 2 Const ewAllowEdit = 4 Const ewAllowView = 8 Const ewAllowList = 8 Const ewAllowReport = 8 Const ewAllowSearch = 8 Const ewAllowAdmin = 16 %> <% If Session("design-desk-shop-DAT_status") <> "login" Then Response.Redirect "login.asp" Else ' Restore Security Table - created in Login arrSecurity = Session("ewSecurity") ' Get Current Table Security sTmp1 = -1 For sTmp = 1 to UBound(arrSecurity, 2) If arrSecurity(0, sTmp) = "accessories" Then sTmp1 = sTmp Exit For End If Next ewCurLvl = Session("design-desk-shop-DAT_status_UserLevel") If IsNumeric(ewCurLvl) And sTmp1 <> -1 Then If ewCurLvl = -1 Then ' System Administrator ewCurSec = 31 ElseIf ewCurLvl > 0 and ewCurLvl <= 1 Then ewCurSec = arrSecurity(ewCurLvl, sTmp1) End If End If If (ewCurSec And ewAllowdelete) <> ewAllowdelete Then Response.Redirect "accessorieslist.asp" End If %> <% ' Initialize common variables x_Part_No = Null x_Sale = Null x_Special = Null x_Category = Null x_Product_Name = Null x_Preferred_Supplier = Null x_Image_Prefix = Null x_ImageSuffix = Null x_Weight = Null x_WeightPrice = Null x_VAT = Null x_Percentage = Null x_Actual_Cost = Null x_Retail_Price = Null x_Retail_Inc = Null x_Description = Null x_SpecialPrice = Null x_RedMessage = Null x_Image = Null x_CartPrefix = Null x_CartHyphen = Null x_CartCode1 = Null x_CartSuffix = Null x_Upsell1_Name = Null x_Upsell1_PartNo = Null x_Upsell2_Name = Null x_Upsell2_PartNo = Null x_Upsell3_Name = Null x_Upsell3_PartNo = Null x_Upsell_Prefix = Null x_Upsell_Suffix1 = Null %> <% Response.Buffer = True ' Load Key Parameters sKey = Request.querystring("key") If sKey = "" Or IsNull(sKey) Then sKey = Request.Form("key_d") End If arRecKey = Split(sKey&"", ",") ' Single delete record If sKey = "" Or IsNull(sKey) Then Response.Redirect "accessorieslist.asp" sDbWhere = sDbWhere & "[Part_No]='" & AdjustSql(Trim(sKey)) & "'" ' Get action sAction = Request.Form("a_delete") If sAction = "" Or IsNull(sAction) Then sAction = "I" ' Display with input box End If ' Open connection to the database Set conn = Server.CreateObject("ADODB.Connection") conn.Open xDb_Conn_Str Select Case sAction Case "I": ' Display If LoadRecordCount(sDbWhere) <= 0 Then conn.Close ' Close Connection Set conn = Nothing Response.Clear Response.Redirect "accessorieslist.asp" End If Case "D": ' Delete If DeleteData(sDbWhere) Then Session("ewmsg") = "Delete Successful For Key = " & sKey conn.Close ' Close Connection Set conn = Nothing Response.Clear Response.Redirect "accessorieslist.asp" End If End Select %>

Delete from TABLE: Accessories

Back to List

<% nRecCount = 0 For Each sRecKey In arRecKey sRecKey = Trim(sRecKey) nRecCount = nRecCount + 1 ' Set row color sItemRowClass = " bgcolor=""#FFFFFF""" ' Display alternate color for rows If nRecCount Mod 2 <> 0 Then sItemRowClass = " bgcolor=""#F5F5F5""" End If If LoadData(sRecKey) Then %> > <% End If Next %>
Part No Sale Special Category Product Name Image
<% Response.Write x_Part_No %> <% If x_Sale = True Then %> <% Else %> <% End If %> <% If x_Special = True Then %> <% Else %> <% End If %> <% Response.Write x_Category %> <% Response.Write x_Product_Name %> <% Response.Write x_Image %>

<% conn.Close ' Close Connection Set conn = Nothing %> <% '------------------------------------------------------------------------------- ' Function LoadData ' - Load Data based on Key Value sKey ' - Variables setup: field variables Function LoadData(sKey) Dim sKeyWrk, sSql, rs, sWhere, sGroupBy, sHaving, sOrderBy sKeyWrk = "'" & AdjustSql(sKey) & "'" sSql = "SELECT * FROM [accessories]" sSql = sSql & " WHERE [Part_No] = " & sKeyWrk sGroupBy = "" sHaving = "" sOrderBy = "" If sGroupBy <> "" Then sSql = sSql & " GROUP BY " & sGroupBy End If If sHaving <> "" Then sSql = sSql & " HAVING " & sHaving End If If sOrderBy <> "" Then sSql = sSql & " ORDER BY " & sOrderBy End If Set rs = Server.CreateObject("ADODB.Recordset") rs.Open sSql, conn If rs.Eof Then LoadData = False Else LoadData = True rs.MoveFirst ' Get the field contents x_Part_No = rs("Part_No") x_Sale = rs("Sale") x_Special = rs("Special") x_Category = rs("Category") x_Product_Name = rs("Product Name") x_Preferred_Supplier = rs("Preferred Supplier") x_Image_Prefix = rs("Image_Prefix") x_ImageSuffix = rs("ImageSuffix") x_Weight = rs("Weight") x_WeightPrice = rs("WeightPrice") x_VAT = rs("VAT") x_Percentage = rs("Percentage") x_Retail_Price = rs("Retail Price") x_Retail_Inc = rs("Retail Inc") x_Description = rs("Description") x_SpecialPrice = rs("SpecialPrice") x_RedMessage = rs("RedMessage") x_Image = rs("Image") x_CartPrefix = rs("CartPrefix") x_CartHyphen = rs("CartHyphen") x_CartCode1 = rs("CartCode1") x_CartSuffix = rs("CartSuffix") x_Upsell1_Name = rs("Upsell1_Name") x_Upsell1_PartNo = rs("Upsell1_PartNo") x_Upsell2_Name = rs("Upsell2_Name") x_Upsell2_PartNo = rs("Upsell2_PartNo") x_Upsell3_Name = rs("Upsell3_Name") x_Upsell3_PartNo = rs("Upsell3_PartNo") x_Upsell_Prefix = rs("Upsell_Prefix") x_Upsell_Suffix1 = rs("Upsell_Suffix1") End If rs.Close Set rs = Nothing End Function %> <% '------------------------------------------------------------------------------- ' Function LoadRecordCount ' - Load Record Count based on input sql criteria sqlKey Function LoadRecordCount(sqlKey) Dim sSql, rs, sWhere, sGroupBy, sHaving, sOrderBy sSql = "SELECT * FROM [accessories]" sSql = sSql & " WHERE " & sqlKey sGroupBy = "" sHaving = "" sOrderBy = "" If sGroupBy <> "" Then sSql = sSql & " GROUP BY " & sGroupBy End If If sHaving <> "" Then sSql = sSql & " HAVING " & sHaving End If If sOrderBy <> "" Then sSql = sSql & " ORDER BY " & sOrderBy End If Set rs = Server.CreateObject("ADODB.Recordset") rs.CursorLocation = 3 rs.Open sSql, conn, 1, 2 LoadRecordCount = rs.RecordCount rs.Close Set rs = Nothing End Function %> <% '------------------------------------------------------------------------------- ' Function DeleteData ' - Delete Records based on input sql criteria sqlKey Function DeleteData(sqlKey) Dim sSql, rs, sWhere, sGroupBy, sHaving, sOrderBy sSql = "SELECT * FROM [accessories]" sSql = sSql & " WHERE " & sqlKey sGroupBy = "" sHaving = "" sOrderBy = "" If sGroupBy <> "" Then sSql = sSql & " GROUP BY " & sGroupBy End If If sHaving <> "" Then sSql = sSql & " HAVING " & sHaving End If If sOrderBy <> "" Then sSql = sSql & " ORDER BY " & sOrderBy End If Set rs = Server.CreateObject("ADODB.Recordset") rs.CursorLocation = 3 rs.Open sSql, conn, 1, 2 Do While Not rs.Eof rs.Delete rs.MoveNext Loop rs.Close Set rs = Nothing DeleteData = True End Function %>