%@LANGUAGE="VBSCRIPT"%> <% IF Len(Session("password")) < 1 THEN Response.Redirect("pword.asp") END IF %> <% ConnectionString = "DSN=morris;UID=morris;PWD=pickering516" ' *** Prepare to Insert Record: Set form vars If (lcase(Request("MM_mode")) = "" And CStr(Request("Event_ID")) = "") Then Event_ID = "(new event #)" Event_Title = "" Start_Date = Now() End_Date = Now() Event_Details = "" Event_URL = "" Event_Contact = "" MM_NextMode = "insert" strModeTitle = "Insert New Event" end if ' *** Prepare to Update Record: Set form vars If (lcase(Request("MM_mode")) = "" And CStr(Request("Event_ID")) <> "") Then set rsEvent = Server.CreateObject("ADODB.Recordset") rsEvent.ActiveConnection = ConnectionString rsEvent.Source = "SELECT Event_Title, Start_Date, End_Date, Event_URL, Event_Contact, Event_ID, Event_Details FROM tEvents WHERE Event_ID = " & CStr(Request("Event_ID")) & " " rsEvent.CursorType = 0 rsEvent.CursorLocation = 2 rsEvent.LockType = 3 rsEvent.Open rsEvent_numRows = 0 Event_Title = rsEvent.Fields.Item("Event_Title").Value Start_Date = rsEvent.Fields.Item("Start_Date").Value End_Date = rsEvent.Fields.Item("End_Date").Value Event_URL = rsEvent.Fields.Item("Event_URL").Value Event_Contact = rsEvent.Fields.Item("Event_Contact").Value Event_ID = rsEvent.Fields.Item("Event_ID").Value Event_Details = rsEvent.Fields.Item("Event_Details").Value MM_NextMode = "update" strModeTitle = "Update Event" end if ' *** Prepare Delete Record: prepare form for confirmation if (CStr(Request("MM_Mode")) = "delete" And CStr(Request("Event_ID")) <> "") Then set rsEvent = Server.CreateObject("ADODB.Recordset") rsEvent.ActiveConnection = ConnectionString rsEvent.Source = "SELECT Event_Title, Start_Date, End_Date, Event_URL, Event_Contact, Event_ID, Event_Details FROM tEvents WHERE Event_ID = " & CStr(Request("Event_ID")) & " " rsEvent.CursorType = 0 rsEvent.CursorLocation = 2 rsEvent.LockType = 3 rsEvent.Open rsEvent_numRows = 0 Event_Title = rsEvent.Fields.Item("Event_Title").Value Start_Date = rsEvent.Fields.Item("Start_Date").Value End_Date = rsEvent.Fields.Item("End_Date").Value Event_URL = rsEvent.Fields.Item("Event_URL").Value Event_Contact = rsEvent.Fields.Item("Event_Contact").Value Event_ID = rsEvent.Fields.Item("Event_ID").Value Event_Details = rsEvent.Fields.Item("Event_Details").Value MM_NextMode = "deleteconfirm" strModeTitle = "Confirm Deletion of Event" end if ' *** Prepare to Duplicate a Record: prepare form for editing but set NextMode to Insert if (CStr(Request("MM_Mode")) = "dup" And CStr(Request("Event_ID")) <> "") Then set rsEvent = Server.CreateObject("ADODB.Recordset") rsEvent.ActiveConnection = ConnectionString rsEvent.Source = "SELECT Event_Title, Start_Date, End_Date, Event_URL, Event_Contact, Event_ID, Event_Details FROM tEvents WHERE Event_ID = " & CStr(Request("Event_ID")) & " " rsEvent.CursorType = 0 rsEvent.CursorLocation = 2 rsEvent.LockType = 3 rsEvent.Open rsEvent_numRows = 0 Event_Title = rsEvent.Fields.Item("Event_Title").Value Start_Date = rsEvent.Fields.Item("Start_Date").Value End_Date = rsEvent.Fields.Item("End_Date").Value Event_URL = rsEvent.Fields.Item("Event_URL").Value Event_Contact = rsEvent.Fields.Item("Event_Contact").Value Event_ID = rsEvent.Fields.Item("Event_ID").Value Event_Details = rsEvent.Fields.Item("Event_Details").Value MM_NextMode = "insert" strModeTitle = "Duplicate this Event" end if ' *** Insert Record: construct a sql insert statement and execute it If (lcase(Request.Form("MM_mode")) = "insert") Then MM_tableName = "tEvents" MM_fields = "textTitle,Event_Title,',none,'',textStartDate,Start_Date,',none,NULL,textEndDate,End_Date,',none,NULL,textDetails,Event_Details,',none,'',textURL,Event_URL,',none,'',textContact,Event_Contact,',none,''" MM_redirectPage = "calendaradmin.asp" ' create the insert sql statement MM_tableValues = "" MM_dbValues = "" MM_fieldsArray = Split(MM_fields, ",") For i = LBound(MM_fieldsArray) To UBound(MM_fieldsArray) Step 5 FormVal = CStr(Request.Form(MM_fieldsArray(i))) Delim = MM_fieldsArray(i+2) If (Delim = "none") Then Delim = "" AltVal = MM_fieldsArray(i+3) If (AltVal = "none") Then AltVal = "" EmptyVal = MM_fieldsArray(i+4) If (EmptyVal = "none") Then EmptyVal = "" If (FormVal = "") Then FormVal = EmptyVal Else If (AltVal <> "") Then FormVal = AltVal ElseIf (Delim = "'") Then ' escape quotes FormVal = "'" & Replace(FormVal,"'","''") & "'" Else FormVal = Delim + FormVal + Delim End If End If If (i <> LBound(MM_fieldsArray)) Then MM_tableValues = MM_tableValues & "," MM_dbValues = MM_dbValues & "," End if MM_tableValues = MM_tableValues & MM_fieldsArray(i+1) MM_dbValues = MM_dbValues & FormVal Next MM_insertStr = "insert into " & MM_tableName & " (" & MM_tableValues & ") values (" & MM_dbValues & ")" ' finish the sql and execute it Set MM_insertCmd = Server.CreateObject("ADODB.Command") MM_insertCmd.ActiveConnection = ConnectionString MM_insertCmd.CommandText = MM_insertStr MM_insertCmd.Execute ' redirect with URL parameters If (MM_redirectPage = "") Then MM_redirectPage = CStr(Request("URL")) End If If (InStr(1, MM_redirectPage, "?", vbTextCompare) = 0 And (Request.QueryString <> "")) Then MM_redirectPage = MM_redirectPage & "?" & Request.QueryString End If Call Response.Redirect(MM_redirectPage) End If %><% Dim Event_Title,Start_Date,End_Date,Event_Details,Event_URL,Event_Contact,Event_ID ' *** Update Record: construct a sql update statement and execute it If (lcase(Request.Form("MM_mode")) = "update" And CStr(Request("MM_recordId")) <> "") Then MM_tableName = "tEvents" MM_tableCol = "Event_ID" MM_recordId = "" + Request.Form("MM_recordId") + "" MM_fields = "textTitle,Event_Title,',none,'',textStartDate,Start_Date,',none,NULL,textEndDate,End_Date,',none,NULL,textDetails,Event_Details,',none,'',textURL,Event_URL,',none,'',textContact,Event_Contact,',none,''" MM_redirectPage = "calendaradmin.asp" ' create the sql update statement MM_updateStr = "update " & MM_tableName & " set " MM_fieldsArray = Split(MM_fields, ",") For i = LBound(MM_fieldsArray) To UBound(MM_fieldsArray) Step 5 FormVal = CStr(Request.Form(MM_fieldsArray(i))) Delim = MM_fieldsArray(i+2) If (Delim = "none") Then Delim = "" AltVal = MM_fieldsArray(i+3) If (AltVal = "none") Then AltVal = "" EmptyVal = MM_fieldsArray(i+4) If (EmptyVal = "none") Then EmptyVal = "" If (FormVal = "") Then FormVal = EmptyVal Else If (AltVal <> "") Then FormVal = AltVal ElseIf (Delim = "'") Then ' escape quotes FormVal = "'" & Replace(FormVal,"'","''") & "'" Else FormVal = Delim + FormVal + Delim End If End If If (i <> LBound(MM_fieldsArray)) Then MM_updateStr = MM_updateStr & "," End If MM_updateStr = MM_updateStr & MM_fieldsArray(i+1) & " = " & FormVal Next MM_updateStr = MM_updateStr & " where " & MM_tableCol & " = " & MM_recordId ' finish the sql and execute it Set MM_updateCmd = Server.CreateObject("ADODB.Command") MM_updateCmd.ActiveConnection = ConnectionString MM_updateCmd.CommandText = MM_updateStr MM_updateCmd.Execute ' redirect with URL parameters If (MM_redirectPage = "") Then MM_redirectPage = CStr(Request("URL")) End If If (InStr(1, MM_redirectPage, "?", vbTextCompare) = 0 And Request.QueryString <> "") Then MM_redirectPage = MM_redirectPage & "?" & Request.QueryString End If Call Response.Redirect(MM_redirectPage) End If %> <% ' *** Delete Record: construct a sql delete statement and execute it if (CStr(Request.Form("MM_Mode")) = "deleteconfirm" And CStr(Request("MM_recordId")) <> "") Then MM_tableName = "tEvents" MM_tableCol = "Event_ID" MM_recordId = "" + Request.Form("MM_recordId") + "" MM_redirectPage = "calendaradmin.asp" ' create the delete sql statement MM_deleteStr = "delete from " & MM_tableName & " where " & MM_tableCol & " = " & MM_recordId ' finish the sql and execute it Set MM_deleteCmd = Server.CreateObject("ADODB.Command") MM_deleteCmd.ActiveConnection = ConnectionString MM_deleteCmd.CommandText = MM_deleteStr MM_deleteCmd.Execute ' redirect with URL parameters If (MM_redirectPage = "") Then MM_redirectPage = CStr(Request("URL")) End If If (InStr(1, MM_redirectPage, "?", vbTextCompare) = 0 And Request.QueryString <> "") Then MM_redirectPage = MM_redirectPage & "?" & Request.QueryString End If Call Response.Redirect(MM_redirectPage) End If %>
| Calendar Detail | |
| Return to Calendar
Menu |