<% Dim CalendarHeader, CalendarRows Dim Style_ClickForEdit, Style_HowToEdit, Style_HowToEditTop Dim Style_AddDate, Style_EditDate Dim nMonth, nMonthStr, MonthArray, bLoggedIn bLoggedIn = IsLoggedIn() If bLoggedIn Then Style_ClickForEdit = " style=""display:none""" Style_HowToEdit = " style=""display:block""" Style_HowToEditTop = " style=""display:block""" Else Style_ClickForEdit = " style=""display:block""" Style_HowToEdit = " style=""display:none""" End If Style_AddDate = " style=""display:block""" Style_EditDate = " style=""display:none""" Select Case Request.Form("action") Case "Add" AddTourDate Case "Edit" If Request.Form("Go") Then EditTourDate Else SelectTourDate Style_AddDate = " style=""display:none""" Style_EditDate = " style=""display:block""" Style_HowToEditTop = " style=""display:none""" End If Case "Delete" DeleteTourDate End Select CalendarHeader = GetTableHeader() CalendarRows = GetTourRowsHTML() MonthArray = Array("January", "February", "March", "April", "May", "June", "July", "August", _ "September", "October", "November", "December") nMonth = Month(Now) Mod 12 ' 0 based nMonthStr = MonthArray(nMonth) nMonth = nMonth + 1 ' --------------------------------------------- Check Login Status --------------------------------------------- Function IsLoggedIn ' makes logging in unnecessary IsLoggedIn = True '''''''''''''''''''''''''''''''''''''''''' ' If Session("UserName") = "demo" Then ' IsLoggedIn = True ' Else ' IsLoggedIn = False ' End If '''''''''''''''''''''''''''''''''''''''''' End Function ' ------------------------------- Insert a new tour date into the calendar ------------------------------------- Function GetStartTime GetStartTime = Request.Form("StartHour") & ":" & Request.Form("StartMin") & " " & Request.Form("AMPM") End Function Sub AddTourDate Dim dbConn, strSQL, lngRecs ''' On Error Resume Next Set dbConn = GetConnection() ShowADOErrors dbConn strSQL = "INSERT INTO Tour VALUES (" strSQL = strSQL & "'" & Session.SessionID & "'," strSQL = strSQL & "'" & SQLEncode(Request.Form("MonthField")) & "'," strSQL = strSQL & "'" & SQLEncode(Request.Form("DayField")) & "'," strSQL = strSQL & "'" & SQLEncode(GetStartTime()) & "'," strSQL = strSQL & "'" & SQLEncode(Request.Form("Venue")) & "'," strSQL = strSQL & "'" & SQLEncode(Request.Form("StreetAddress")) & "'," strSQL = strSQL & "'" & SQLEncode(Request.Form("City")) & "'," strSQL = strSQL & "'" & SQLEncode(Request.Form("State")) & "'," strSQL = strSQL & "'" & SQLEncode(Request.Form("VenueLink")) & "')" dbConn.Execute strSQL, lngRecs, adCmdText + adExecuteNoRecords ShowADOErrors dbConn dbConn.Close Set dbConn = Nothing End Sub ' ------------------------------------ Get the info for a tour date in the database ----------------------------------- Sub SelectTourDate Dim strSQL, rs, field Dim tempArray1, tempArray2 strSQL = "SELECT * From Tour WHERE BandId = '" & Request.Form("BandId") & "' AND " & _ "MonthField= " & Request.Form("MonthField") & " AND " & _ "DayField = " & Request.Form("DayField") & " AND " & _ "StartTime = CDate('" & Request.Form("StartTime") & "')" ' Query the database Set dbConn = GetConnection() ShowADOErrors dbConn Set rs = dbConn.Execute(strSQL) ShowADOErrors dbConn ' Save the row in the session variable If Not rs.EOF Then For Each field In rs.Fields Session("fld_" & field.Name) = field.Value If field.Name = "StartTime" Then tempArray1 = Split(field.Value, " ") Session("fld_AMPM") = tempArray1(1) tempArray2 = Split(tempArray1(0), ":") Session("fld_StartHour") = tempArray2(0) Session("fld_StartMin") = tempArray2(1) End If Next End If Set rs = Nothing dbConn.Close Set dbConn = Nothing End Sub ' ------------------------------------ Edit a tour date in the database ----------------------------------- Sub EditTourDate Dim strSQL, field, strTime strSQL = "UPDATE Tour SET " strSQL = strSQL & "MonthField='" & SQLEncode(Request.Form("MonthField")) & "', " strSQL = strSQL & "DayField='" & SQLEncode(Request.Form("DayField")) & "', " strSQL = strSQL & "StartTime='" & SQLEncode(GetStartTime()) & "', " strSQL = strSQL & "Venue='" & SQLEncode(Request.Form("Venue")) & "', " strSQL = strSQL & "StreetAddress='" & SQLEncode(Request.Form("StreetAddress")) & "', " strSQL = strSQL & "City='" & SQLEncode(Request.Form("City")) & "', " strSQL = strSQL & "State='" & SQLEncode(Request.Form("State")) & "', " strSQL = strSQL & "VenueLink='" & SQLEncode(Request.Form("VenueLink")) & "'" strSQL = strSQL & " WHERE BandId='" & Request.Form("old_BandId") & "' AND " & _ "MonthField = " & Request.Form("old_MonthField") & " AND " & _ "DayField = " & Request.Form("old_DayField") & " AND " & _ "StartTime = CDate('" & Request.Form("old_StartTime") & "')" ' Query the database Set dbConn = GetConnection() ShowADOErrors dbConn dbConn.Execute(strSQL) ShowADOErrors dbConn dbConn.Close Set dbConn = Nothing End Sub ' ----------------------------------------- Delete a tour date from the database --------------------------------- Sub DeleteTourDate Dim strSQL strSQL = "DELETE From Tour WHERE BandId = '" & Request.Form("BandId") & "' AND " & _ "MonthField= " & Request.Form("MonthField") & " AND " & _ "DayField = " & Request.Form("DayField") & " AND " & _ "StartTime = CDate('" & Request.Form("StartTime") & "')" ' Send the delete query to the database Set dbConn = GetConnection() ShowADOErrors dbConn Set rs = dbConn.Execute(strSQL) ShowADOErrors dbConn dbConn.Close Set dbConn = Nothing End Sub ' ------------------------------------------------ Lookup state name --------------------------------------------- Function LookupState(code) Select Case code Case "AL" LookupState = "Alabama" Case "AK" LookupState = "Alaska" Case "AZ" LookupState = "Arizona" Case "AR" LookupState = "Arkansas" Case "CA" LookupState = "California" Case "CO" LookupState = "Colorado" Case "CT" LookupState = "Connecticut" Case "DE" LookupState = "Delaware" Case "DC" LookupState = "District of Columbia" Case "FL" LookupState = "Florida" Case "GA" LookupState = "Georgia" Case "GU" LookupState = "Guam" Case "HI" LookupState = "Hawaii" Case "ID" LookupState = "Idaho" Case "IL" LookupState = "Illinois" Case "IN" LookupState = "Indiana" Case "IA" LookupState = "Iowa" Case "KS" LookupState = "Kansas" Case "KY" LookupState = "Kentucky" Case "LA" LookupState = "Louisiana" Case "ME" LookupState = "Maine" Case "MD" LookupState = "Maryland" Case "MA" LookupState = "Massachusetts" Case "MI" LookupState = "Michigan" Case "MN" LookupState = "Minnesota" Case "MS" LookupState = "Mississippi" Case "MO" LookupState = "Missouri" Case "MT" LookupState = "Montana" Case "NE" LookupState = "Nebraska" Case "NV" LookupState = "Nevada" Case "NH" LookupState = "New Hampshire" Case "NJ" LookupState = "New Jersey" Case "NM" LookupState = "New Mexico" Case "NY" LookupState = "New York" Case "NC" LookupState = "North Carolina" Case "ND" LookupState = "North Dakota" Case "OH" LookupState = "Ohio" Case "OK" LookupState = "Oklahoma" Case "OR" LookupState = "Oregon" Case "PA" LookupState = "Pennsylvania" Case "RI" LookupState = "Rhode Island" Case "SC" LookupState = "South Carolina" Case "SD" LookupState = "South Dakota" Case "TN" LookupState = "Tennessee" Case "TX" LookupState = "Texas" Case "UT" LookupState = "Utah" Case "VT" LookupState = "Vermont" Case "VA" LookupState = "Virginia" Case "WA" LookupState = "Washington" Case "WV" LookupState = "West Virginia" Case "WI" LookupState = "Wisconsin" Case "WY" LookupState = "Wyoming" Case Else LookupState = "" End Select End Function ' --------------------------------------------- HTML table header rows ------------------------------------------- Function GetTableHeader GetTableHeader = "" & _ "" & _ "" & _ "
Date
" & _ "" & _ "" & _ "
Venue
" & _ "" & _ "" & _ "
" & _ "

Address

" & _ "
" & _ "" & _ "" & _ "
City, State
" & _ "" & _ "" & _ "
Time
" & _ "" If bLoggedIn Then GetTableHeader = GetTableHeader & "Action" End If GetTableHeader = GetTableHeader & "" & "" End Function ' ------------------------------------ Write the static row Edit/Delete buttons ----------------------------------- Sub WriteRowButtons If bLoggedIn Then Response.Write "" & _ "" & _ "" & _ "" End If End Sub ' ------------------------------- Query the db for the tour dates and display ------------------------------------- Function GetTourRowsHTML Dim dbConn, rs, HTML, fArray, field, cellContents Dim temp, pos, bLoggedIn, strJS1, strJS2 ''' On Error Resume Next fArray = Array("DayField", "Venue", "StreetAddress", "City", "StartTime") bLoggedIn = IsLoggedIn() Set dbConn = GetConnection() ShowADOErrors dbConn Set rs = dbConn.Execute("SELECT * FROM Tour WHERE BandId = '" & Session.SessionID & "' ORDER BY DayField, StartTime") ShowADOErrors dbConn If rs.EOF Then HTML = "Your tour calendar is empty. Please enter a tour date above." Else HTML = HTML & "
" HTML = HTML & "" HTML = HTML & "" HTML = HTML & "" HTML = HTML & "" HTML = HTML & "" While Not rs.EOF HTML = HTML & "" & vbCrLf HTML = HTML & "" For Each field In fArray Select Case field Case "City" cellContents = rs.Fields.Item("City").Value & ", " & rs.Fields.Item("State").Value Case "StartTime" temp = rs.Fields.Item(field).Value pos = InStrRev(temp, ":") cellContents = Mid(temp, 1, pos-1) & Mid(temp, pos+3) Case Else venueLink = rs.Fields.Item("VenueLink") If field = "Venue" And venueLink <> "" Then cellContents = "" & rs.Fields.Item(field).Value & "" Elseif field = "DayField" then cellContents = rs("MonthField") & "/" & rs("DayField") elseif Not field = "MonthField" And Not field = "DayField" then cellContents = rs.Fields.Item(field).Value End If End Select HTML = HTML & "" & cellContents & "" Next If bLoggedIn Then HTML = HTML & "" strJS1 = "submitForm2('" & rs.Fields.Item("BandId") & "','" & rs.Fields.Item("MonthField") & "','" &_ rs.Fields.Item("DayField") & "','" & rs.Fields.Item("StartTime") & "');" strJS2 = "checkDelete('" & rs.Fields.Item("BandId") & "','" & rs.Fields.Item("MonthField") & "','" &_ rs.Fields.Item("DayField") & "','" & rs.Fields.Item("StartTime") & "');" HTML = HTML & "" HTML = HTML & "" HTML = HTML & "" End If HTML = HTML & "" rs.MoveNext Wend HTML = HTML & " " & vbCrLf HTML = HTML & "
" End If dbConn.Close Set dbConn = Nothing GetTourRowsHTML = HTML End Function Function optionSelectStatus(optionValue, actualValue) If optionValue = actualValue Then optionSelectStatus = "selected" End Function %>
align="left"> align="left"> align="left"> <% Response.Write CalendarHeader Response.Write CalendarRows %> align="left"> align="left">

Add an Entry to Your Tour Calendar

Simply fill out the following form and click the Enter Tour Date button. Your on-line Tour Calendar will simply build itself!


Edit or Delete An Entry On Your Tour Calendar

When you view your Tour Calendar, you can select to change any row by clicking
on the appropriate button.

Simply click the Edit button to modify any of your Tour Calendar entries.
To remove an entry from your Tour Calendar, simply click the Delete button.


Edit an Entry on Your Tour Calendar

Simply modify any of the following fields, then click the Save Changes button. Your
online Tour Calendar will be updated to reflect your changes.

To cancel editing of this entry and resume entering tour dates, just press the
Cancel Editing button.
   
Month:  
Day:  
Starting Time:   " size=15> "> : ">
Venue:   ">
Street Address:   ">
City:   ">
State:  
Venue Link:   http://www. ">
<% If Request.Form("action") = "Edit" And Request.Form("Go") = "" Then Response.Write "" Response.Write "" Else Response.Write "" End If %>  
Your On-line Tour Calendar
The actual program will also allow you to choose your own colors.
 
 

 

Additional Features

Click here to try out the next level Tour Calendar demo, where you will be able to:

  • See the sign-in user ID and password security features.
  • Sample the Tour Calendar edit/delete capabilities.
Edit or Delete An Entry On Your Tour Calendar

Simply click the Edit button to modify any of your Tour Calendar entries.
To remove an entry from your Tour Calendar, simply click the Delete button.



<% Dim UserName UserName = Session("UserName") Session.Contents.RemoveAll Session("UserName") = UserName %>