<%@ LCID = 5129 %> <% 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 %> <% ' Initialize common variables x_csn = Null x_type = Null x_status = Null x_issue = Null x_card_size = Null x_expiry_date = Null x_issued_date = Null x_issued_at = Null x_issuer = Null x_reissued = Null x_hot = Null x_id = 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_csn = Request.Form("x_csn") x_type = Request.Form("x_type") x_status = Request.Form("x_status") x_issue = Request.Form("x_issue") x_card_size = Request.Form("x_card_size") x_expiry_date = Request.Form("x_expiry_date") x_issued_date = Request.Form("x_issued_date") x_issued_at = Request.Form("x_issued_at") x_issuer = Request.Form("x_issuer") x_reissued = Request.Form("x_reissued") x_hot = Request.Form("x_hot") x_id = Request.Form("x_id") End If If sKey = "" Or IsNull(sKey) Then Response.Redirect "card_datalist.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 "card_datalist.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 "card_datalist.asp" End If End Select %>

Edit TABLE: card data

Back to List

csn ">
type ">
status ">
issue ">
card size ">
expiry date
issued date
issued at ">
issuer ">
reissued checked<% End If %> value="Yes"> <%= "Yes" %> checked<% End If %> value="No"> <%= "No" %>
hot checked<% End If %> value="Yes"> <%= "Yes" %> checked<% End If %> value="No"> <%= "No" %>
id ">

<% 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 [card_data]" sSql = sSql & " WHERE [csn] = " & 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_csn = rs("csn") x_type = rs("type") x_status = rs("status") x_issue = rs("issue") x_card_size = rs("card_size") x_expiry_date = rs("expiry_date") x_issued_date = rs("issued_date") x_issued_at = rs("issued_at") x_issuer = rs("issuer") x_reissued = rs("reissued") x_hot = rs("hot") x_id = rs("id") 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 = "'" & sKey & "'" sSql = "SELECT * FROM [card_data]" sSql = sSql & " WHERE [csn] = " & 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 csn sTmp = Trim(x_csn) If Trim(sTmp) = "" Then sTmp = Null rs("csn") = sTmp ' Field type sTmp = x_type If Not IsNumeric(sTmp) Then sTmp = Null Else sTmp = CLng(sTmp) End If rs("type") = sTmp ' Field status sTmp = Trim(x_status) If Trim(sTmp) = "" Then sTmp = Null rs("status") = sTmp ' Field issue sTmp = x_issue If Not IsNumeric(sTmp) Then sTmp = Null Else sTmp = CLng(sTmp) End If rs("issue") = sTmp ' Field card_size sTmp = Trim(x_card_size) If Trim(sTmp) = "" Then sTmp = Null rs("card_size") = sTmp ' Field expiry_date sTmp = EW_UnFormatDateTime(x_expiry_date,7) If IsDate(sTmp) Then rs("expiry_date") = CDate(sTmp) Else rs("expiry_date") = Null End If ' Field issued_date sTmp = EW_UnFormatDateTime(x_issued_date,7) If IsDate(sTmp) Then rs("issued_date") = CDate(sTmp) Else rs("issued_date") = Null End If ' Field issued_at sTmp = Trim(x_issued_at) If Trim(sTmp) = "" Then sTmp = Null rs("issued_at") = sTmp ' Field issuer sTmp = Trim(x_issuer) If Trim(sTmp) = "" Then sTmp = Null rs("issuer") = sTmp ' Field reissued sTmp = x_reissued If sTmp = "Yes" Then rs("reissued") = True Else rs("reissued") = False End If ' Field hot sTmp = x_hot If sTmp = "Yes" Then rs("hot") = True Else rs("hot") = False End If ' Field id sTmp = x_id If Not IsNumeric(sTmp) Then sTmp = Null Else sTmp = CLng(sTmp) End If rs("id") = sTmp rs.Update EditData = True ' Update Successful End If rs.Close Set rs = Nothing End Function %>