<% '************************************************************************************** '* Application: ActionCalendar '* Version: 1.3 '* Author: Andrew L. Warren '* Email: andy@warrenstudios.com '* Publish Date: 03/01/2001 '* Updated: 01/26/2002 '* Copyright: (c) 2001 - 2002 Warren Studios, ALW. All Rights Reserved '* '* Warranties and Terms of Use Agreement: '* No warranties, implied or otherwise, are made regarding the usage of ActionCalendar '* and it's associated code. The users assumes all risk and the Author of '* ActionCalendar is in no part liable for any incurred damages. Execution of this '* code in part or whole constitutes acceptance of the Terms and Agreement for use. '************************************************************************************** Dim strWeekDayOccurrence Dim strMonthOccurrence Dim strDayOccurrence Dim strYearOccurrence Dim strEndDate Dim strStartDate Dim strAction Dim strEventID Dim strEventOccur Dim strEventEndDate Dim strEventData Dim objRS_User Dim strVerify Dim objRS_verify Select Case GetRequest("event_occur") Case "0" 'Annual Event strWeekDayOccurrence = "0" strMonthOccurrence = Month(GetRequest("event_date")) strDayOccurrence = Day(GetRequest("event_date")) strYearOccurrence = "0" strEndDate = "Null" strStartDate = "#" & Date & "#" Case "1" 'Monthly Event strWeekDayOccurrence = "0" strMonthOccurrence = "0" strDayOccurrence = Day(GetRequest("event_date")) If GetRequest("event_run") = "1" Then strYearOccurrence = "0" strEndDate = "Null" strStartDate = "#" & Date & "#" Else strYearOccurrence = "0" strEndDate = "#" & GetRequest("event_end_date") & "#" strStartDate = "#" & GetRequest("event_date") & "#" End If Case "2" 'Weekday Event strWeekDayOccurrence = WeekDay(GetRequest("event_date")) strMonthOccurrence = "0" strDayOccurrence = "0" If GetRequest("event_run") = "1" Then strYearOccurrence = "0" strEndDate = "Null" strStartDate = "#" & Date & "#" Else strYearOccurrence = "0" strEndDate = "#" & GetRequest("event_end_date") & "#" strStartDate = "#" & GetRequest("event_date") & "#" End If Case Else 'One-Time Event strWeekDayOccurrence = "0" strMonthOccurrence = Month(GetRequest("event_date")) strDayOccurrence = Day(GetRequest("event_date")) strYearOccurrence = Year(GetRequest("event_date")) strEndDate = "Null" strStartDate = "#" & Date & "#" End Select '******** user checks ******** If Session("ActiveUser") = "" Or strVerify = "no" Then objCommand.CommandText = "select * from User_Tbl where " &_ "user_name = '" & GetRequest("user") & "' and user_password = '" & GetRequest("pass") & "'" Set objRS_verify = objCommand.Execute If objRS_verify.EOF <> True Then strVerify = "yes" Session("ActiveUser") = objRS_verify("user_id") Session("ActiveUserLevel") = objRS_verify("user_level") Else strVerify = "no" End If Set objRS_verify = Nothing End If '******** SQL statements for getting current users ******** If GetRequest("user_admin") = "edit" Then objCommand.CommandText = "select * from User_Tbl where user_level <> 900 order by user_name" Set objRS_User = objCommand.Execute If GetRequest("user_id") <> "" Then Dim objRS_User_Profile,strUserID,strUserName,strUserPass,strUserLevel objCommand.CommandText = "select * from User_Tbl where user_id = " & GetRequest("user_id") Set objRS_User_Profile = objCommand.Execute strUserID = objRS_User_Profile("user_id") strUserName = objRS_User_Profile("user_name") strUserPass = objRS_User_Profile("user_password") strUserLevel = objRS_User_Profile("user_level") Set objRS_User_Profile = Nothing End If End If '******** SQL statements for adding new user or updating current users ******** If GetRequest("user_admin") = "add" Then If GetRequest("user_id") = "" Then objCommand.CommandText = "insert into User_Tbl (" &_ "user_name," &_ "user_password," &_ "user_level) " &_ "values (" &_ "'" & GetRequest("user_name") & "'," &_ "'" & GetRequest("user_pass") & "'," &_ "'" & GetRequest("user_level") & "')" Else objCommand.CommandText = "update User_Tbl set " &_ "user_name = '" & GetRequest("user_name") & "'," &_ "user_password = '" & GetRequest("user_pass") & "'," &_ "user_level = '" & GetRequest("user_level") & "'" &_ " where user_id = " & GetRequest("user_id") End If objCommand.Execute HandleError() Response.Redirect strFileName & "?user_admin=edit&action=admin" End If '******** SQL statements for deleting current users ******** If GetRequest("user_admin") = "delete" Then objCommand.CommandText = "delete from User_Tbl where user_id = " & GetRequest("user_id") objCommand.Execute HandleError() Response.Redirect strFileName & "?user_admin=edit&action=admin" End If '******** SQL statements for adding a new event ******** If GetRequest("admin_action") = "add" Then objCommand.CommandText = "insert into Event_Tbl (" &_ "user_id," &_ "date_entered," &_ "date_updated," &_ "event_end_date," &_ "event_month," &_ "event_day," &_ "event_year," &_ "event_data," &_ "event_occur," &_ "event_weekday) " &_ "values (" &_ Session("ActiveUser") & "," &_ "#" & Date & "#," &_ strStartDate & "," &_ strEndDate & "," &_ strMonthOccurrence & "," &_ strDayOccurrence & "," &_ strYearOccurrence & "," &_ "'" & Replace(GetRequest("event_data"),"'","''") & "'," &_ GetRequest("event_occur") & "," &_ strWeekDayOccurrence &_ ")" objCommand.Execute Response.Redirect strFileName & "?action=admin&date=" & GetRequest("event_date") End If '******** SQL statements for updating a current event ******** If GetRequest("admin_action") = "update" Then objCommand.CommandText = "update Event_Tbl set " &_ "user_id = " & Session("ActiveUser") & "," &_ "date_updated = " & strStartDate & "," &_ "event_end_date = " & strEndDate & "," &_ "event_month = " & strMonthOccurrence & "," &_ "event_day = " & strDayOccurrence & "," &_ "event_year = " & strYearOccurrence & "," &_ "event_data = " & "'" & Replace(GetRequest("event_data"),"'","''") & "'," &_ "event_occur = " & GetRequest("event_occur") & "," &_ "event_weekday = " & strWeekDayOccurrence &_ " where event_id = " & GetRequest("event_id") objCommand.Execute Response.Redirect strFileName & "?action=admin&date=" & GetRequest("event_date") End If '******** SQL statements for deleting a current event ******** If GetRequest("admin_action") = "delete" Then objCommand.CommandText = "delete from Event_Tbl where event_id = " & GetRequest("event_id") objCommand.Execute Response.Redirect strFileName & "?action=admin&date=" & GetRequest("date") End If '************************************************************************************** '* Subroutine Name: GetEventData() * '* Input: None. * '* Output: Sets variables for user event input. * '* Sample Call: GetEventData() * '************************************************************************************** Sub GetEventData() If GetRequest("admin_action") = "edit" Then strAction = "update" strEventID = objRS_view("event_id") strEventOccur = objRS_view("event_occur") strEventEndDate = objRS_view("event_end_date") strEventData = objRS_view("event_data") Else strAction = "add" strEventID = GetRequest("event_id") strEventOccur = GetRequest("event_occur") strEventEndDate = DateAdd("yyyy",1,GetRequest("date")) strEventData = GetRequest("event_data") End If End Sub '************************************************************************************** '* Function Name: BuildUserList() * '* Input: None. * '* Output: HTML string with edit and delete features for current users. * '* Sample Call: string = BuildUserList() * '************************************************************************************** Function BuildUserList() Dim strUser Do While objRS_User.EOF <> True strUser = strUser & "" &_ UCase(objRS_User("user_name")) &_ "" &_ "" &_ " " &_ "" &_ "" & VbCrLf objRS_User.MoveNext Loop Set objRS_User = Nothing BuildUserList = strUser End Function '************************************************************************************** '* Function Name: BuildOccurenceDropDown() * '* Input: None. * '* Output: HTML string with dropdown list of event occurence options. * '* Sample Call: string = BuildOccurenceDropDown() * '************************************************************************************** Function BuildOccurenceDropDown() Dim strHTML strHTML = "" & VbCrLf BuildOccurenceDropDown = strHTML End Function '************************************************************************************** '* Function Name: BuildRadioOptions() * '* Input: None. * '* Output: HTML string with radio options for events. * '* Sample Call: string = BuildRadioOptions() * '************************************************************************************** Function BuildRadioOptions() Dim strHTML strHTML = "Yes" & VbCrLf &_ " "" Then strHTML = strHTML & " checked" End If If strEventOccur = "-1" Or strEventOccur = "0" Or strEventOccur = "" Then strHTML = strHTML & " disabled" End If strHTML = strHTML & ">No" & VbCrLf BuildRadioOptions = strHTML End Function '************************************************************************************** '* Function Name: BuildInput() * '* Input: Type of input box, size of box, name of box. * '* Output: HTML string of form input box. * '* Sample Call: string = BuildInput("text",10,"user") 'gets text input box * '* string = BuildInput("password",10,"pass") 'gets password input box * '************************************************************************************** Function BuildInput(strType,intSize,strName) Dim strHTML strHTML = "" & VbCrLf Case "event_end_date" strHTML = strHTML & " value=""" If IsNull(strEventEndDate) Then strHTML = strHTML & DateAdd("yyyy",1,GetRequest("date")) & """" Else strHTML = strHTML & strEventEndDate & """" End If If (strEventOccur = "-1" Or strEventOccur = "0" Or strEventOccur = "") Or IsNull(strEventEndDate) Then strHTML = strHTML & """ disabled" End If strHTML = strHTML & ">" & VbCrLf Case Else strHTML = strHTML & " value="""">" & VbCrLf End Select BuildInput = strHTML End Function '************************************************************************************** '* Function Name: HandleError() * '* Input: None. * '* Output: Variable with HTML string message. * '* Sample Call: HandleError() * '************************************************************************************** Function HandleError() If Err Then Session("SysMessage") = "There was an error processing your request.
Please try again." Else Session("SysMessage") = "Your update was successful." End If End Function %>