<% 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) = "Users" 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 "Userslist.asp" End If %> <% ' Initialize common variables x_ID = Null x_Username = Null x_password = Null x_First_Name = Null x_Last_Name = Null x_AccesssLevel = Null x_Create_Date = 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 "Userslist.asp" sDbWhere = sDbWhere & "[ID]=" & 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 "Userslist.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 "Userslist.asp" End If End Select %>

Delete from TABLE: Users

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 %>
ID Username password First Name Last Name Accesss Level Create Date
<% Response.Write x_ID %> <% Response.Write x_Username %> <% Response.Write x_password %> <% Response.Write x_First_Name %> <% Response.Write x_Last_Name %> <% If (ewCurSec And ewAllowAdmin) = ewAllowAdmin Then ' System admin %> <% Select Case x_AccesssLevel Case "-1" sTmp = "Administrator" Case "0" sTmp = "Anonymous" Case "1" sTmp = "default_user" Case Else sTmp = Null End Select ox_AccesssLevel = x_AccesssLevel ' Backup Original Value x_AccesssLevel = sTmp %> <% Response.Write x_AccesssLevel %> <% x_AccesssLevel = ox_AccesssLevel ' Restore Original Value %> <% Else %> ******** <% End If %> <% Response.Write x_Create_Date %>

<% 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 [Users]" sSql = sSql & " WHERE [ID] = " & 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_ID = rs("ID") x_Username = rs("Username") x_password = rs("password") x_First_Name = rs("First_Name") x_Last_Name = rs("Last_Name") x_AccesssLevel = rs("AccesssLevel") x_Create_Date = rs("Create_Date") 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 [Users]" 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 [Users]" 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 %>