<%@ LCID = 3081 %> <% Response.expires = 0 Response.expiresabsolute = Now() - 1 Response.addHeader "pragma", "no-cache" Response.addHeader "cache-control", "private" Response.addHeader "cache-control", "no-cache" Response.addHeader "cache-control", "no-store" 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_VENUE_CODE = Null: ox_VENUE_CODE = Null x_CREDITOR_CODE = Null: ox_CREDITOR_CODE = Null x_VENUE_NAME = Null: ox_VENUE_NAME = Null x_ADDRESS_1 = Null: ox_ADDRESS_1 = Null x_ADDRESS_2 = Null: ox_ADDRESS_2 = Null x_ADDRESS_3 = Null: ox_ADDRESS_3 = Null x_ADDRESS_4 = Null: ox_ADDRESS_4 = Null x_POST_CODE = Null: ox_POST_CODE = Null x_COUNTRY = Null: ox_COUNTRY = Null x_PHONE_NUMBER = Null: ox_PHONE_NUMBER = Null x_FAX_NUMBER = Null: ox_FAX_NUMBER = Null x_CONTACT_NAME = Null: ox_CONTACT_NAME = Null x_EMAIL_ADDRESS = Null: ox_EMAIL_ADDRESS = Null x_ROOM_NAME = Null: ox_ROOM_NAME = Null x_DFRECNUM = Null: ox_DFRECNUM = Null %> <% Response.Buffer = True ' Load key from QueryString bCopy = True x_VENUE_CODE = Request.QueryString("VENUE_CODE") If x_VENUE_CODE = "" Or IsNull(x_VENUE_CODE) Then bCopy = False End If ' Get action sAction = Request.Form("a_add") If (sAction = "" Or IsNull(sAction)) Then If bCopy Then sAction = "C" ' Copy record Else sAction = "I" ' Display blank record End If Else ' Get fields from form x_VENUE_CODE = Request.Form("x_VENUE_CODE") x_CREDITOR_CODE = Request.Form("x_CREDITOR_CODE") x_VENUE_NAME = Request.Form("x_VENUE_NAME") x_ADDRESS_1 = Request.Form("x_ADDRESS_1") x_ADDRESS_2 = Request.Form("x_ADDRESS_2") x_ADDRESS_3 = Request.Form("x_ADDRESS_3") x_ADDRESS_4 = Request.Form("x_ADDRESS_4") x_POST_CODE = Request.Form("x_POST_CODE") x_COUNTRY = Request.Form("x_COUNTRY") x_PHONE_NUMBER = Request.Form("x_PHONE_NUMBER") x_FAX_NUMBER = Request.Form("x_FAX_NUMBER") x_CONTACT_NAME = Request.Form("x_CONTACT_NAME") x_EMAIL_ADDRESS = Request.Form("x_EMAIL_ADDRESS") x_ROOM_NAME = Request.Form("x_ROOM_NAME") x_DFRECNUM = Request.Form("x_DFRECNUM") End If ' Open connection to the database Set conn = Server.CreateObject("ADODB.Connection") conn.Open xDb_Conn_Str Select Case sAction Case "C": ' Get a record to display If Not LoadData() Then ' Load Record based on key Session("ewmsg") = "No records found" conn.Close ' Close Connection Set conn = Nothing Response.Clear Response.Redirect "VENUESlist.asp" End If Case "A": ' Add If AddData() Then ' Add New Record Session("ewmsg") = "Add New Record Successful" conn.Close ' Close Connection Set conn = Nothing Response.Clear Response.Redirect "VENUESlist.asp" Else End If End Select %>

Add to TABLE: VENUES

Back to List

<% If Session("ewmsg") <> "" Then %>

<%= Session("ewmsg") %>

<% Session("ewmsg") = "" ' Clear message End If %>
VENUE CODE ">
CREDITOR CODE <% x_CREDITOR_CODEList = "" Response.Write x_CREDITOR_CODEList %>
VENUE NAME ">
ADDRESS 1 ">
ADDRESS 2 ">
ADDRESS 3 ">
ADDRESS 4 ">
POST CODE ">
COUNTRY ">
PHONE NUMBER ">
FAX NUMBER ">
CONTACT NAME ">
EMAIL ADDRESS ">
ROOM NAME ">

<% conn.Close ' Close Connection Set conn = Nothing %> <% '------------------------------------------------------------------------------- ' Function LoadData ' - Load Data based on Key Value ' - Variables setup: field variables Function LoadData() Dim sSql, rs, sWhere, sGroupBy, sHaving, sOrderBy sSql = "SELECT * FROM [VENUES]" sWhere = "" sGroupBy = "" sHaving = "" sOrderBy = "" If sWhere <> "" Then sWhere = sWhere & " AND " sWhere = sWhere & "([VENUE_CODE] = '" & AdjustSql(x_VENUE_CODE) & "')" sSql = sSql & " WHERE " & sWhere 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_VENUE_CODE = rs("VENUE_CODE") x_CREDITOR_CODE = rs("CREDITOR_CODE") x_VENUE_NAME = rs("VENUE_NAME") x_ADDRESS_1 = rs("ADDRESS_1") x_ADDRESS_2 = rs("ADDRESS_2") x_ADDRESS_3 = rs("ADDRESS_3") x_ADDRESS_4 = rs("ADDRESS_4") x_POST_CODE = rs("POST_CODE") x_COUNTRY = rs("COUNTRY") x_PHONE_NUMBER = rs("PHONE_NUMBER") x_FAX_NUMBER = rs("FAX_NUMBER") x_CONTACT_NAME = rs("CONTACT_NAME") x_EMAIL_ADDRESS = rs("EMAIL_ADDRESS") x_ROOM_NAME = rs("ROOM_NAME") x_DFRECNUM = rs("DFRECNUM") End If rs.Close Set rs = Nothing End Function %> <% '------------------------------------------------------------------------------- ' Function AddData ' - Add Data ' - Variables used: field variables Function AddData() Dim sSql, rs, sWhere, sGroupBy, sHaving, sOrderBy Dim bCheckKey, sSqlChk, sWhereChk sSql = "SELECT * FROM [VENUES]" sWhere = "" sGroupBy = "" sHaving = "" sOrderBy = "" ' Check for duplicate key bCheckKey = True sWhereChk = sWhere If x_VENUE_CODE = "" Or IsNull(x_VENUE_CODE) Then bCheckKey = False Else If sWhereChk <> "" Then sWhereChk = sWhereChk & " AND " sWhereChk = sWhereChk & "([VENUE_CODE] = '" & AdjustSql(x_VENUE_CODE) & "')" End If If bCheckKey Then sSqlChk = sSql & " WHERE " & sWhereChk Set rsChk = conn.Execute(sSqlChk) If Not rsChk.Eof Then Session("ewmsg") = "Duplicate value for primary key" rsChk.Close Set rsChk = Nothing AddData = False Exit Function End If rsChk.Close Set rsChk = Nothing End If ' Add New Record If sWhere <> "" Then sWhere = sWhere & " AND " sWhere = sWhere & "(0 = 1)" sSql = sSql & " WHERE " & sWhere 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 rs.AddNew ' Field VENUE_CODE sTmp = Trim(x_VENUE_CODE) If Trim(sTmp) = "" Then sTmp = "" rs("VENUE_CODE") = sTmp ' Field CREDITOR_CODE sTmp = Trim(x_CREDITOR_CODE) If Trim(sTmp) = "" Then sTmp = "" rs("CREDITOR_CODE") = sTmp ' Field VENUE_NAME sTmp = Trim(x_VENUE_NAME) If Trim(sTmp) = "" Then sTmp = "" rs("VENUE_NAME") = sTmp ' Field ADDRESS_1 sTmp = Trim(x_ADDRESS_1) If Trim(sTmp) = "" Then sTmp = "" rs("ADDRESS_1") = sTmp ' Field ADDRESS_2 sTmp = Trim(x_ADDRESS_2) If Trim(sTmp) = "" Then sTmp = "" rs("ADDRESS_2") = sTmp ' Field ADDRESS_3 sTmp = Trim(x_ADDRESS_3) If Trim(sTmp) = "" Then sTmp = "" rs("ADDRESS_3") = sTmp ' Field ADDRESS_4 sTmp = Trim(x_ADDRESS_4) If Trim(sTmp) = "" Then sTmp = "" rs("ADDRESS_4") = sTmp ' Field POST_CODE sTmp = Trim(x_POST_CODE) If Trim(sTmp) = "" Then sTmp = "" rs("POST_CODE") = sTmp ' Field COUNTRY sTmp = Trim(x_COUNTRY) If Trim(sTmp) = "" Then sTmp = "" rs("COUNTRY") = sTmp ' Field PHONE_NUMBER sTmp = Trim(x_PHONE_NUMBER) If Trim(sTmp) = "" Then sTmp = "" rs("PHONE_NUMBER") = sTmp ' Field FAX_NUMBER sTmp = Trim(x_FAX_NUMBER) If Trim(sTmp) = "" Then sTmp = "" rs("FAX_NUMBER") = sTmp ' Field CONTACT_NAME sTmp = Trim(x_CONTACT_NAME) If Trim(sTmp) = "" Then sTmp = "" rs("CONTACT_NAME") = sTmp ' Field EMAIL_ADDRESS sTmp = Trim(x_EMAIL_ADDRESS) If Trim(sTmp) = "" Then sTmp = "" rs("EMAIL_ADDRESS") = sTmp ' Field ROOM_NAME sTmp = Trim(x_ROOM_NAME) If Trim(sTmp) = "" Then sTmp = "" rs("ROOM_NAME") = sTmp rs.Update rs.Close Set rs = Nothing AddData = True End Function %>