<% 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 ewAllowedit) <> ewAllowedit 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 sKey = Request.Querystring("key") If sKey = "" Or IsNull(sKey) Then sKey = Request.Form("key") ' Get action sAction = Request.Form("a_edit") If sAction = "" Or IsNull(sAction) Then sAction = "I" ' Display with input box Else ' Get fields from form x_ID = Request.Form("x_ID") x_Username = Request.Form("x_Username") x_password = Request.Form("x_password") x_First_Name = Request.Form("x_First_Name") x_Last_Name = Request.Form("x_Last_Name") x_AccesssLevel = Request.Form("x_AccesssLevel") x_Create_Date = Request.Form("x_Create_Date") End If If sKey = "" Or IsNull(sKey) Then Response.Redirect "Userslist.asp" ' Open connection to the database Set conn = Server.CreateObject("ADODB.Connection") conn.Open xDb_Conn_Str Select Case sAction Case "I": ' Get a record to display If Not LoadData(sKey) Then ' Load Record based on key Session("ewmsg") = "No Record Found for Key = " & sKey conn.Close ' Close Connection Set conn = Nothing Response.Clear Response.Redirect "Userslist.asp" End If Case "U": ' Update If EditData(sKey) Then ' Update Record based on key Session("ewmsg") = "Update Record Successful for Key = " & sKey conn.Close ' Close Connection Set conn = Nothing Response.Clear Response.Redirect "Userslist.asp" End If End Select %>

Edit TABLE: Users

Back to List

ID <% Response.Write x_ID %>
Username ">
password ">
First Name ">
Last Name ">
Accesss Level <% If (ewCurSec And ewAllowAdmin) = ewAllowAdmin Then ' System admin %> <% x_AccesssLevelList = "" Response.Write x_AccesssLevelList %> <% Else %> ******** <% End If %>
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 EditData ' - Edit Data based on Key Value sKey ' - Variables used: field variables Function EditData(sKey) Dim sKeyWrk, sSql, rs, sWhere, sGroupBy, sHaving, sOrderBy ' Open record 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.CursorLocation = 3 rs.Open sSql, conn, 1, 2 If rs.Eof Then EditData = False ' Update Failed Else ' Field ID ' Field Username sTmp = Trim(x_Username) If Trim(sTmp) = "" Then sTmp = Null rs("Username") = sTmp ' Field password sTmp = Trim(x_password) If Trim(sTmp) = "" Then sTmp = Null rs("password") = sTmp ' Field First_Name sTmp = Trim(x_First_Name) If Trim(sTmp) = "" Then sTmp = Null rs("First_Name") = sTmp ' Field Last_Name sTmp = Trim(x_Last_Name) If Trim(sTmp) = "" Then sTmp = Null rs("Last_Name") = sTmp ' Field AccesssLevel If (ewCurSec And ewAllowAdmin) = ewAllowAdmin Then ' System admin sTmp = x_AccesssLevel If Not IsNumeric(sTmp) Then sTmp = Null Else sTmp = CLng(sTmp) End If rs("AccesssLevel") = sTmp End If ' Field Create_Date sTmp = x_Create_Date If IsDate(sTmp) Then rs("Create_Date") = CDate(sTmp) Else rs("Create_Date") = Null End If rs.Update EditData = True ' Update Successful End If rs.Close Set rs = Nothing End Function %>