Avatar billede tuppi Nybegynder
01. marts 2010 - 11:43 Der er 5 kommentarer og
1 løsning

kalender problemer.

Jeg har downloadet en asp kalender og redigeret lidt i den så den passer ind efter min behov. Har siddet de sidste mange dage og prøvet at finde frem til problemet. ( skal lige siges jeg er lidt af en newbie ).  Normalt spørger jeg ikke om hjælp da jeg gerne selv vil læse/prøve mig frem til løsningen. men nu er jeg efterhånden løbet godt træt i dette projekt.

Det er en event kalender, hvor man kan trykke på dato og oprette event. herefter er den dato så fremhævet. Oprindelig calender hedder calendar_V1.asp og er downloadet via

http://www.kamath.com

mit problem ligger i at de første 12 dage af hver måned åbner den forkerte event dag.

Den 3 feb bliver til 2 marts den 4 feb bliver til 2 april osv.

4 marts bliver til 3 april og 5 marts bliver til 3 maj.

script er her:

<%
    '------------------------------------------------------------
    ' This function finds the last date of the given month
    '------------------------------------------------------------
    Function GetLastDay(intMonthNum, intYearNum)
        Dim dNextStart
        If CInt(intMonthNum) = 12 Then
            dNextStart = CDate( "1/1/" & intYearNum)
        Else
            dNextStart = CDate(intMonthNum + 1 & "/1/" & intYearNum)
        End If
        GetLastDay = Day(dNextStart - 1)
    End Function
   
    '-------------------------------------------------------------------------
    ' This routine prints the individual table divisions for days of the month
    '-------------------------------------------------------------------------
    Sub Write_TD(sValue, sClass)
        Response.Write "        <TD ALIGN='RIGHT' WIDTH=20 HEIGHT=15 VALIGN='BOTTOM' CLASS='" & sClass & "'> " & sValue & "</TD>" & vbCrLf
    End Sub


    ' Constants for the days of the week
    Const cSUN = 1, cMON = 2, cTUE = 3, cWED = 4, cTHU = 5, cFRI = 6, cSAT = 7
   
    ' Get the name of this file
    sScript = Request.ServerVariables("SCRIPT_NAME")
   
    ' Check for valid month input
    If IsEmpty(Request("MONTH")) OR NOT IsNumeric(Request("MONTH")) Then
      datToday = Date()
      intThisMonth = Month(datToday)
    ElseIf CInt(Request("MONTH")) < 1 OR CInt(Request("MONTH")) > 12 Then
      datToday = Date()
      intThisMonth = Month(datToday)
    Else
      intThisMonth = CInt(Request("MONTH"))
    End If
   
    ' Check for valid year input
    If IsEmpty(Request("YEAR")) OR NOT IsNumeric(Request("YEAR")) Then
      datToday = Date()
      intThisYear = Year(datToday)
    Else
      intThisYear = CInt(Request("YEAR"))
    End If

    strMonthName = MonthName(intThisMonth)
    datFirstDay = DateSerial(intThisYear, intThisMonth, 1)
    intFirstWeekDay = WeekDay(datFirstDay, vbSunday)
    intLastDay = GetLastDay(intThisMonth, intThisYear)
   
    ' Get the previous month and year
    intPrevMonth = intThisMonth - 1
    If intPrevMonth = 0 Then
        intPrevMonth = 12
        intPrevYear = intThisYear - 1
    Else
        intPrevYear = intThisYear   
    End If
   
    ' Get the next month and year
    intNextMonth = intThisMonth + 1
    If intNextMonth > 12 Then
        intNextMonth = 1
        intNextYear = intThisYear + 1
    Else
        intNextYear = intThisYear
    End If

    ' Get the last day of previous month. Using this, find the sunday of
    ' last week of last month
    LastMonthDate = GetLastDay(intLastMonth, intPrevYear) - intFirstWeekDay + 2
    NextMonthDate = 1

    ' Initialize the print day to 1 
    intPrintDay = 1

    ' Open a record set of schedules
    Set Rs = Server.CreateObject("ADODB.RecordSet")
   
    ' These dates are used in the SQL
    dFirstDay = intThisMonth & "/1/" & intThisYear
    dLastDay = intThisMonth & "/" & intLastDay & "/" & intThisYear

    sSQL =     "SELECT DISTINCT Start_Date, End_Date FROM tEvents WHERE " & _
                    "(Start_Date >=#" & dFirstDay & "# AND Start_Date <= #" & dLastDay & "#) " & _
                    "OR " & _
                    "(End_Date >=#" & dFirstDay & "# AND End_Date <= #" & dLastDay & "#) " & _
                    "OR " & _
                    "(Start_Date < #" & dFirstDay & "# AND End_Date > #" & dLastDay & "# )"  & _
                    "ORDER BY Start_Date"
    'Response.Write sSQL

    ' Open the RecordSet with a static cursor. This cursor provides bi-directional navigation
    Rs.Open sSQL, sDSN, adOpenStatic, adLockReadOnly, adCmdText
%>

<html>
<head>
<meta HTTP-EQUIV="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Schedule for <% = strMonthName & " " & intThisYear %></title>
<style TYPE="text/css">
  TD.NON {font-family :Tahoma, Verdana, Arial; font-size :12px; color :#C0C0C0; font-weight :normal;}
  TD.TOP {font-family :Tahoma, Verdana, Arial; font-size :12px; color :#0000FF; font-weight :bold;}
  TD.Some {font-family :Tahoma, Verdana, Arial; font-size :12px; color :#000000; font-weight :normal;}

  A.NOEVENT:Link {font-family :Tahoma, Verdana, Arial; font-size :12px; color :#000000; font-weight :normal; text-decoration: none;}
  A.NOEVENT:Visited {font-family :Tahoma, Verdana, Arial; font-size :12px; color :#000000; font-weight :normal; text-decoration: none;}

  A.EVENT:Link {font-family :Tahoma, Verdana, Arial; font-size :12px; color :#000000; font-weight :bold; text-decoration: none;}
  A.EVENT:Visited {font-family :Tahoma, Verdana, Arial; font-size :12px; color :#000000; font-weight :bold; text-decoration: none;}

  A.NORMAL:Link {font-family :Verdana, Arial; font-size :12px; color :#0000FF; font-weight :normal; text-decoration: none;}
  A.NORMAL:Visited {font-family :Verdana, Arial; font-size :12px; color :#0000FF; font-weight :normal; text-decoration: none;}
</style>
</head>
<body TEXT="#000000" LEFTMARGIN="3" LINK="#000000" VLINK="#000000">
<br>

<table ALIGN="CENTER" BORDER="1" CELLSPACING="0" CELLPADDING="2" BGCOLOR="White" BORDERCOLOR="Gray">
<tr><td>
    <table WIDTH="140" BORDER="0" CELLPADDING="1" CELLSPACING="0" BGCOLOR="#FFFFFF">
        <tr HEIGHT="18" BGCOLOR="Silver">
            <td WIDTH="20" HEIGHT="18" ALIGN="LEFT" VALIGN="MIDDLE"><a HREF="<% =sScript%>?month=<% =IntPrevMonth %>&year=<% =IntPrevYear %>"><img SRC="images/prev.gif" WIDTH="10" HEIGHT="18" BORDER="0" ALT="Previous Month"></a></td>
            <td WIDTH="120" COLSPAN="5" ALIGN="CENTER" VALIGN="MIDDLE" CLASS="SOME"><% = strMonthName & " " & intThisYear %></td>
            <td WIDTH="20" HEIGHT="18" ALIGN="RIGHT" VALIGN="MIDDLE"><a HREF="<% =sScript %>?month=<% =IntNextMonth %>&year=<% =IntNextYear %>"><img SRC="images/next.gif" WIDTH="10" HEIGHT="18" BORDER="0" ALT="Next Month"></a></td>
        </tr>
      <tr>
            <td ALIGN="RIGHT" CLASS="SOME" WIDTH="20" HEIGHT="15" VALIGN="BOTTOM">S</td>
            <td ALIGN="RIGHT" CLASS="SOME" WIDTH="20" HEIGHT="15" VALIGN="BOTTOM">M</td>
            <td ALIGN="RIGHT" CLASS="SOME" WIDTH="20" HEIGHT="15" VALIGN="BOTTOM">T</td>
            <td ALIGN="RIGHT" CLASS="SOME" WIDTH="20" HEIGHT="15" VALIGN="BOTTOM">W</td>
            <td ALIGN="RIGHT" CLASS="SOME" WIDTH="20" HEIGHT="15" VALIGN="BOTTOM">T</td>
            <td ALIGN="RIGHT" CLASS="SOME" WIDTH="20" HEIGHT="15" VALIGN="BOTTOM">F</td>
            <td ALIGN="RIGHT" CLASS="SOME" WIDTH="20" HEIGHT="15" VALIGN="BOTTOM">S</td>
      </tr>
      <tr><td HEIGHT="1" ALIGN="MIDDLE" COLSPAN="7"><img SRC="images/line.gif" HEIGHT="1" WIDTH="140" BORDER="0"></td></tr>
      <%
            ' Initialize the end of rows flag to false
            EndRows = False
            Response.Write vbCrLf
           
            ' Loop until all the rows are exhausted
            Do While EndRows = False
                ' Start a table row
                Response.Write "    <TR>" & vbCrLf
                ' This is the loop for the days in the week
                For intLoopDay = cSUN To cSAT
                    ' If the first day is not sunday then print the last days of previous month in grayed font
                    If intFirstWeekDay > cSUN Then
                        Write_TD LastMonthDate, "NON"
                        LastMonthDate = LastMonthDate + 1
                        intFirstWeekDay = intFirstWeekDay - 1
                    ' The month starts on a sunday   
                    Else
                        ' If the dates for the month are exhausted, start printing next month's dates
                        ' in grayed font
                        If intPrintDay > intLastDay Then
                            Write_TD NextMonthDate, "NON"
                            NextMonthDate = NextMonthDate + 1
                            EndRows = True
                        Else
                            ' If last day of the month, flag the end of the row
                            If intPrintDay = intLastDay Then
                                EndRows = True
                            End If
                           
                            dToday = CDate(intThisMonth & "/" & intPrintDay & "/" & intThisYear) 
                            If NOT Rs.EOF Then
                                ' Set events flag to false. This means the day has no event in it
                                bEvents = False
                              Do While NOT Rs.EOF AND bEvents = False
                                    ' If the date falls within the range of dates in the recordset, then
                                    ' the day has an event. Make the events flag True
                                If dToday >= Rs("Start_Date") AND dToday <= Rs("End_Date") Then
                                        ' Print the date in a highlighted font
                                  Write_TD "<A HREF=events.asp?date="& Server.URLEncode(dToday) & " CLASS='EVENT' TARGET='buttonframe'> " & intPrintDay & "</A>", "HL"
                                        bEvents = True
                                    ' If the Start date is greater than the date itself, there is no point
                                    ' checking other records. Exit the loop   
                                ElseIf dToday < Rs("Start_Date") Then
                                        Exit Do
                                    ' Move to the next record
                                    Else   
                                    Rs.MoveNext
                                    End If
                              Loop
                                ' Checks for that day
                                Rs.MoveFirst
                            End If
                           
                            ' If the event flag is not raise for that day, print it in a plain font
                            If bEvents = False Then
                                Write_TD "<A HREF=events.asp?date="& Server.URLEncode(dToday) & " CLASS='NOEVENT' TARGET='buttonframe'> " & intPrintDay & "</A>", "SOME"
                            End If
                        End If
                       
                        ' Increment the date. Done once in the loop.
                        intPrintDay = intPrintDay + 1
                    End If
               
                ' Move to the next day in the week
                Next
                Response.Write "    </TR>" & vbCrLf
               
            Loop
            Rs.Close
            Set Rs = Nothing
        %>
    </table>
    </td></tr>
</table>


<p align="center"><P>
<FONT FACE="Verdana, Arial" SIZE=2>
<FORM ACTION="<% =sScript%>" METHOD=GET>
<p align="center">
<SELECT NAME=MONTH>
<OPTION VALUE=1>Jan
<OPTION VALUE=2 SELECTED>Feb
<OPTION VALUE=3>Mar
<OPTION VALUE=4>Apr
<OPTION VALUE=5>May
<OPTION VALUE=6>Jun
<OPTION VALUE=7>Jul
<OPTION VALUE=8>Aug
<OPTION VALUE=9>Sep
<OPTION VALUE=10>Oct
<OPTION VALUE=11>Nov
<OPTION VALUE=12>Dec
</SELECT>
<SELECT NAME=YEAR>
<OPTION VALUE=2010 SELECTED>2010
<OPTION VALUE=2011>2011
<OPTION VALUE=2012>2012
<OPTION VALUE=2013>2013
<OPTION VALUE=2014>2014
</SELECT></p>
<p align="center"><P align="center"><INPUT TYPE="Image" NAME="" SRC="images/go.gif" BORDER="0" WIDTH="35" HEIGHT="20"></P></p>
</body>
</html>
Avatar billede frozenink Nybegynder
01. marts 2010 - 12:45 #1
Har du denne i toppen af din ASP side ?
<%
Session.LCID = 1030
%>

Og derefter en del læsning
Du skal sikre dig at din udbyder / webhotel understøtter landekoden, prøv F.eks. at læse her -
http://www.eksperten.dk/spm/622115

Dernæst er der mere læsning på dette link -
http://www.eksperten.dk/search?category=3&q=lcid

Søg på "lcid"
Avatar billede tuppi Nybegynder
01. marts 2010 - 13:05 #2
Den ligger på min egen server. Og den skriver allerede dansk tidsformat dd-mm-yyyy.

Og skal lige siges at alle dage efter d. 12 i hver måned virker fint nok.

Har prøvet at ændre session.LCID men så virker det slet ikke
Avatar billede frozenink Nybegynder
01. marts 2010 - 13:27 #3
Du skriver :
"Den 3 feb bliver til 2 marts den 4 feb bliver til 2 april osv."
samt
"4 marts bliver til 3 april og 5 marts bliver til 3 maj."

For mig at se er der byttet omkring som ved engelsk/dansk tidsformat.

Men prøv at læse en tidligere løsning omkring samme problem
http://www.eksperten.dk/spm/873567
Avatar billede tuppi Nybegynder
01. marts 2010 - 15:37 #4
kan godt se det er et tidsformat problem. kan bare ikke finde frem til hvor det er det går galt henne. det link ligner meget mit problem.

Hvis jeg ligger LCID = 1030 in så virker den måned siden starter på også men skifter jeg måned så viser den kun noge få dage. Som ved linket er det også her en evenvt.asp side der loader

script:

<!--#include file="adovbs.inc"-->
<!--#include file="dsn.asp"-->


<%
    If IsEmpty(Request.QueryString("Date")) OR NOT IsDate(Request.QueryString("Date")) Then
        dDate = Date
    Else
        dDate = CDate(Request.QueryString("Date"))
    End If
%>   
<HTML>
<HEAD>
<TITLE>Events for <%= FormatDateTime(dDate, 1) %></TITLE>
</HEAD>


<%
  ' Open a record set of schedules
    Response.Write "<FONT COLOR='Gray' FACE='Tahoma, Verdana' SIZE=2>" & FormatDateTime(dDate, 1) & "</FONT><BR><BR>" & vbCrLf
  Set Rs = Server.CreateObject("ADODB.RecordSet")
    sSQL =     "SELECT * FROM tEvents " & _
                    "WHERE Start_Date <= #" & dDate & "# AND End_Date >= #" & dDate & "# ORDER BY Event_ID "

  Rs.Open sSQL, sDSN, adOpenStatic, adLockReadOnly, adCmdText
    If NOT Rs.EOF Then
        arrColor =Array("#000000", "#CC9966", "#336600", "#003366", "#FFCC66", "#0000FF", "#FF0000")
        iIndex = 0
       
        Do While NOT Rs.EOF
            ' Create the outer table
            Response.Write "<TABLE WIDTH='400' BORDER='0' CELLSPACING='0' CELLPADDING='1' BGCOLOR='" & arrColor(iIndex) & "'><TR><TD>" & vbCrLf
            ' Create the inner table
            Response.Write "<TABLE WIDTH='100%' CELLSPACING=0 BORDER=0 CELLPADDING=2 BGCOLOR='White'>" & vbCrLf
            Response.Write "<TR BGCOLOR='" & arrColor(iIndex) & "'><TD HEIGHT=20 WIDTH=220 VALIGN='top'><B><FONT FACE='Verdana, Tahoma' SIZE='1' COLOR='White'>" & vbCrLf
            Response.Write Trim(Rs("Event_Title")) & VbCrLf
            Response.Write "</FONT></B>&nbsp;</TD>" & vbCrLf
           
            Response.Write "</TR>" & vbCrLf
           
            Response.Write "<TR><TD VALIGN='top' COLSPAN='3'>" & vbCrLf
           
            ' If the event lasts more than one day, indidate the start and end dates
            If Rs("Start_Date") <> Rs("End_Date") Then
                Response.Write "<FONT FACE='Verdana, Arial' SIZE=1 COLOR='Gray'>Starts: " & Rs("Start_Date") & vbCrLf
                Response.Write "<BR>Ends: " & Rs("End_Date") & vbCrLf
                Response.Write "</FONT><P>"
            End If
           
            ' Print the event details
            Response.Write "<FONT FACE='Verdana, Tahoma' SIZE='1' COLOR='Black'>" & vbCrLf
            Response.Write Replace(Rs("Event_Details") & " ", vbCrLf, "<BR>") & vbCrLf
            Response.Write "</FONT></TD></TR>" & vbCrLf
            Response.Write "</TABLE></TD></TR></TABLE>" & vbCrLf
           
            Response.Write "<BR>" & vbCrLf
            Rs.MoveNext
            iIndex = iIndex + 1
            If iIndex = 3 Then
                iIndex = 0
            End If
        Loop
    End If   
%>

   



<!-- #include file="menu.inc" -->
</BODY>
</HTML>

Men vil lige læse/prøve lidt videre ud fra den problemstilling han havde. Men input tages rigtig godt imod.
Avatar billede tuppi Nybegynder
01. marts 2010 - 16:12 #5
Så er

                            dToday = CDate(intThisMonth & "/" & intPrintDay & "/" & intThisYear)

byttet ud med                             dToday = CDate(intPrintDay & "/" & intThisMonth & "/" & intThisYear) det hjalp på det. så skal det bare skydes rigtigt ind i databasen så den rigtige dag bliver  higlightet.

det gøres med dette script :

<% Option Explicit %>
<!--#include virtual="/_private/logon.vbs"-->
<!-- #include file = "dsn.asp" -->
<!-- #include file = "adovbs.inc" -->

<%
    Dim sStart_Date, sEnd_Date, sEvent_Title, sEvent_Details
    Dim imgStart_Date, imgEnd_Date, imgEvent_Title, imgEvent_Details
    Dim sMode, bError, sScriptPath
   
    ' Get the name of the file
    sScriptPath = Request.ServerVariables("SCRIPT_NAME")
   
    ' Determine if the action required is an add or an edit. If it is an edit,
    ' retrieve the record and present it to the user. If not, present a
    ' blank form
    If IsEmpty(Request.Form("EVENT")) Then
        If NOT IsEmpty(Request.QueryString("Event_ID")) Then
            sMode = "EDIT"
            Get_Event(Request.QueryString("Event_ID"))
        Else
            sMode = "ADD"   
        End If   
       
        Show_Form()
    Else
        Update_Event(Request.Form("EVENT"))
    End If       
%>
<%
' This routine retrieves the event by the Event_ID. If the event is not found,
' set the mode to an "ADD".
Sub Get_Event(lEvent_ID)
    Dim sSQL, Rs
  ' Create a recordset and open the given event. If the Record is not found
    ' set the mode to ADD
  sSQL = "SELECT * FROM tEvents WHERE Event_ID=" & lEvent_ID
  Set Rs = Server.CreateObject("ADODB.RecordSet")
  Rs.MaxRecords = 1
  Rs.Open sSQL, sDSN, adOpenStatic, adLockReadOnly, adCmdText
   
    If Not Rs.EOF Then
        sStart_Date = Rs("Start_Date")
        sEnd_Date = Rs("End_Date")
        sEvent_Title = Rs("Event_Title")
        sEvent_Details = Rs("Event_Details")
    Else
        sMode = "ADD"
    End If
End Sub   
%>   

<%
' This routines presents the form to the user. Depending on the mode, the
' form fields are filled with data or blank.
Sub Show_Form()
    Dim sButtonMsg, sTitle
  If sMode = "ADD" Then
        sButtonMsg = "Tilføj"
    Else
        sButtonMsg = "Prøv igen"
    End If
   
    ' Set the title of the page depending on if an error occurred during
    ' form submission or not
    If bError = True Then
        sTitle = "Der er fejl i indtastning"
    Else
        sTitle = "Tilføj Event"
    End If       
%>
<HTML>
<HEAD>
  <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
    <p><% =sTitle %></p>
   
</HEAD>
<BODY BGCOLOR=FFFFFF onLoad="document.eventfrm.START_DATE.focus()">
<P ALIGN=LEFT></P>

<FORM NAME="eventfrm" ACTION="<% =sScriptPath %>" METHOD=POST>

<TABLE CELLSPACING=5 CELLPADDING=3 BORDER=0 WIDTH=95%>

<TR>
<TD VALIGN=TOP ALIGN=LEFT WIDTH=30%><FONT FACE=Verdana SIZE=2><B>Start Date</B>
<BR><FONT SIZE=1 COLOR='RED'><I>Skal skrives</I></FONT></FONT></TD>
<TD VALIGN=TOP ALIGN=LEFT WIDTH=70%><FONT FACE=Verdana SIZE=2><INPUT TYPE=TEXT SIZE=12 MAXLENGTH=12 NAME="START_DATE" VALUE="<% =Server.HTMLEncode(sStart_Date) %>"></FONT><% =imgStart_Date %><font size="2">DD-MM-ÅÅÅÅ</font></TD>
</TR>

<TR>
<TD VALIGN=TOP ALIGN=LEFT WIDTH=30%><FONT FACE=Verdana SIZE=2><B>End Date</B>
<BR></FONT><i><font face="Verdana" size="1" color="#FF0000">Valgfri</font></i></TD>
<TD VALIGN=TOP ALIGN=LEFT WIDTH=70%><FONT FACE=Verdana SIZE=2><INPUT TYPE=TEXT SIZE=12 MAXLENGTH=12 NAME="END_DATE" VALUE="<% =Server.HTMLEncode(sEnd_Date) %>"></FONT><% =imgEnd_Date %><font size="2">DD-MM-ÅÅÅÅ</font></TD>
</TR>

<TR>
<TD VALIGN=TOP ALIGN=LEFT><FONT FACE=Verdana SIZE=2><B>Event Title</B>
<BR></FONT><i><font face="Verdana" size="1" color="#FF0000">Skal skrives</font></i></TD>
<TD VALIGN=TOP ALIGN=LEFT><FONT FACE=Verdana SIZE=2><INPUT TYPE=TEXT SIZE=30 MAXLENGTH=100 NAME="EVENT_TITLE" VALUE="<% =Server.HTMLEncode(sEvent_Title) %>"><% =imgEvent_Title %></FONT></TD>
</TR>

<TR>
<TD VALIGN=TOP ALIGN=LEFT><b><font face="Verdana" size="2">Detajler</font></b><FONT FACE=Verdana SIZE=2>
<BR></FONT><i><FONT FACE=Verdana SIZE=1 color="#FF0000">
Skal skrives</FONT></i></TD>
<TD VALIGN=TOP ALIGN=LEFT><FONT FACE=Verdana SIZE=2><TEXTAREA COLS=30 ROWS=5 NAME="EVENT_DETAILS" WRAP=PHYSICAL><% =Server.HTMLEncode(sEvent_Details) %></TEXTAREA></FONT><% =imgEvent_Details %></TD>
</TR>

</TABLE>
<INPUT TYPE=HIDDEN NAME=EVENT VALUE=<% =sMode %>>
<INPUT TYPE=HIDDEN NAME=EVENT_ID VALUE=<% =Request.QueryString("EVENT_ID") %>>
<FONT FACE="Verdana" SIZE="2"><INPUT TYPE=SUBMIT VALUE="<% =sButtonMsg %>"></FONT>

</FORM>
</BODY>
</HTML>
<% End Sub %>

<%
Sub Update_Event(sUpdateMode)
    Dim sErrImage, Rs, sSQL, sTitle
    bError = False
  sErrImage = "<IMG SRC='images/error.gif' BORDER=0 HEIGHT=15 WIDTH=50>"
   
    ' Get the form data into variables
    sStart_Date = Request.Form("START_DATE")
    sEnd_Date = Request.Form("END_DATE")
    sEvent_Title = Request.Form("EVENT_TITLE")
    sEvent_Details = Request.Form("EVENT_DETAILS")
   
    ' The error checking routines start here. If any of the fields fails
    ' error check, the bError flag is raised, and the corresponding image
    ' string is set to the image source
   
    ' Check to see if Start date is a valid date
    If NOT IsDate(sStart_Date) Then
        bError = True
        imgStart_Date = sErrImage
    End If
   
    ' Check if the End date is a valid date provided it is not empty
    If Trim(sEnd_Date) <> "" AND NOT IsDate(sEnd_Date) Then
        bError = True
        imgEnd_Date = sErrImage
    End If
   
    ' Check if the event title field is blank
    If Trim(sEvent_Title) = "" Then
        bError = True
        imgEvent_Title = sErrImage
    End If
   
    ' Check if the event details field is blank
    If Trim(sEvent_Details) = "" Then
        bError = True
        imgEvent_Details = sErrImage
    End If
   
    ' Check if the start date and end date correspond to a valid range
    ' so that Start date is always prior to the end date
    If IsDate(sStart_Date) AND IsDate(sEnd_Date) Then
        If CDate(sStart_Date) > CDate(sEnd_Date) Then
            bError = True
            imgStart_Date = sErrImage
            imgEnd_Date = sErrImage
        End If
    End If

    If bError = False Then
      ' Create a recordset
      Set Rs = Server.CreateObject("ADODB.RecordSet")
       
        ' Depending on the Mode, open the Recordset in eith Add or Edit mode
        If sUpdateMode = "EDIT" Then
          sSQL = "SELECT * FROM tEvents WHERE Event_ID=" & Request.Form("Event_ID")
          Rs.Open sSQL, sDSN, adOpenKeySet, adLockPessimistic, adCmdText
        Else
          Rs.Open "tEvents", sDSN, adOpenKeySet, adLockPessimistic, adCmdTable
          Rs.AddNew
          Rs("Date_Added") = Now()
        End If
       
        ' Populate the RecordSet fields
    Rs("Start_Date") = CDate(Request.Form("START_DATE"))
       
        ' If the end date is blank, it equals start date
        If Trim(sEnd_Date) <> "" Then
        Rs("End_Date") = CDate(Request.Form("END_DATE"))
        Else
        Rs("End_Date") = CDate(Request.Form("START_DATE"))
        End If   
       
        Rs("Event_Title") = Request.Form("EVENT_TITLE")
        Rs("Event_Details") = Request.Form("EVENT_Details")
      Rs.Update
       
      Rs.Close
      Set Rs = Nothing
       
        If sUpdateMode = "ADD" Then
            sTitle = "Event tilføjet"
        Else
            sTitle = "Event updateret"

        End If
%>
<HTML>
<HEAD>
  <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
  <META NAME="Author" CONTENT="Manohar Kamath">
  <TITLE><% =sTitle %></TITLE>
</HEAD>
<BODY BGCOLOR=FFFFFF>
<H3><FONT FACE="Verdana"><% =sTitle %></FONT></H3>
<FONT SIZE=2 FACE="Verdana">

<P>
Af hjertet tak så hjælper det os alle lidt med at huske :-)
</P>
</FONT>

<!-- #include file="menu.inc" -->

</BODY>
</HTML>

<%       
    Else
        Show_Form()
    End If   
End Sub   
%>

Nu er der nok nogen der vil se at der er en masse ting omkring edit. men den funktion har jeg valgt at pille ud. men har ikke fået ryddet helt op i code endnu.
Avatar billede tuppi Nybegynder
16. juni 2010 - 13:54 #6
virker
Avatar billede Ny bruger Nybegynder

Din løsning...

Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.

Loading billede Opret Preview
Kategori
Kurser inden for grundlæggende programmering

Log ind eller opret profil

Hov!

For at kunne deltage på Computerworld Eksperten skal du være logget ind.

Det er heldigvis nemt at oprette en bruger: Det tager to minutter og du kan vælge at bruge enten e-mail, Facebook eller Google som login.

Du kan også logge ind via nedenstående tjenester