<%@ CodePage = 65001 LCID = 1040 %> <% 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 %> <% If Session("lapinsitter_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) = "cerco" Then sTmp1 = sTmp Exit For End If Next ewCurLvl = Session("lapinsitter_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 ewAllowadd) <> ewAllowadd Then Response.Redirect "cercolist.asp" If Session("lapinsitter_status_UserID") = "" And Session("lapinsitter_status_UserID") <> -1 Then Response.Redirect "login.asp" End If %> <% ' Initialize common variables x_id = Null: ox_id = Null x_nome = Null: ox_nome = Null x_provincia = Null: ox_provincia = Null x_nome_niglio = Null: ox_nome_niglio = Null x_periodo = Null: ox_periodo = Null x_contatto = Null: ox_contatto = Null x_note = Null: ox_note = Null x_userid = Null: ox_userid = Null %> <% Response.Buffer = True ' Load key from QueryString bCopy = True x_id = Request.QueryString("id") If x_id = "" Or IsNull(x_id) 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_id = Request.Form("x_id") x_nome = Request.Form("x_nome") x_provincia = Request.Form("x_provincia") x_nome_niglio = Request.Form("x_nome_niglio") x_periodo = Request.Form("x_periodo") x_contatto = Request.Form("x_contatto") x_note = Request.Form("x_note") x_userid = Request.Form("x_userid") 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") = "Nessun Record trovato" conn.Close ' Close Connection Set conn = Nothing Response.Clear Response.Redirect "cercolist.asp" End If Case "A": ' Add If AddData() Then ' Add New Record Session("ewmsg") = "Nuovo record aggiunto" conn.Close ' Close Connection Set conn = Nothing Response.Clear Response.Redirect "cercolist.asp" Else End If End Select %>

Aggiungi a CERCO LAPINSITTER

Torna alla lista

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

<%= Session("ewmsg") %>

<% Session("ewmsg") = "" ' Clear message End If %>
il tuo nome ">
localita' o zona ">
nome del tuo coniglio ">
periodo lapinsitter
come contattarti
note (esigenze, richieste specifiche, requisiti, altro)

<% 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 [cerco]" sWhere = "" sGroupBy = "" sHaving = "" sOrderBy = "" If sWhere <> "" Then sWhere = sWhere & " AND " sWhere = sWhere & "([id] = " & AdjustSql(x_id) & ")" sSql = sSql & " WHERE " & sWhere If Session("lapinsitter_status_UserID") <> -1 And Session("lapinsitter_status_UserID") <> "" Then ' Non system admin sSql = sSql & " AND ([userid] = " & Session("lapinsitter_status_UserID") & ")" End If 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_nome = rs("nome") x_provincia = rs("provincia") x_nome_niglio = rs("nome_niglio") x_periodo = rs("periodo") x_contatto = rs("contatto") x_note = rs("note") x_userid = rs("userid") 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 [cerco]" sWhere = "" sGroupBy = "" sHaving = "" sOrderBy = "" ' Check for duplicate key bCheckKey = True sWhereChk = sWhere If x_id = "" Or IsNull(x_id) Then bCheckKey = False Else If sWhereChk <> "" Then sWhereChk = sWhereChk & " AND " sWhereChk = sWhereChk & "([id] = " & AdjustSql(x_id) & ")" End If If bCheckKey Then sSqlChk = sSql & " WHERE " & sWhereChk Set rsChk = conn.Execute(sSqlChk) If Not rsChk.Eof Then Session("ewmsg") = "Chiave Primaria Duplicata --" 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 nome sTmp = Trim(x_nome) If Trim(sTmp) = "" Then sTmp = Null rs("nome") = sTmp ' Field provincia sTmp = Trim(x_provincia) If Trim(sTmp) = "" Then sTmp = Null rs("provincia") = sTmp ' Field nome_niglio sTmp = Trim(x_nome_niglio) If Trim(sTmp) = "" Then sTmp = Null rs("nome_niglio") = sTmp ' Field periodo sTmp = Trim(x_periodo) If Trim(sTmp) = "" Then sTmp = Null rs("periodo") = sTmp ' Field contatto sTmp = Trim(x_contatto) If Trim(sTmp) = "" Then sTmp = Null rs("contatto") = sTmp ' Field note sTmp = Trim(x_note) If Trim(sTmp) = "" Then sTmp = Null rs("note") = sTmp If Session("lapinsitter_status_UserID") <> -1 And Session("lapinsitter_status_UserID") <> "" Then ' Non system admin rs("userid") = Session("lapinsitter_status_UserID") End If rs.Update rs.Close Set rs = Nothing AddData = True End Function %>