Function to lock form entry

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Tawni
    New Member
    • Sep 2007
    • 5

    Function to lock form entry

    gameDatetime comes from database
    dateTimeNow of course is current time.

    Question:

    I want to be able to lock users from making changes, Friday to Sunday.

    see once it is locked then all users can see other users data, but no one can change anything, not even individuals who entered the data, this is useful for printing all users data which is what I am trying to accomplish.

    When it is not locked, then each user can only add/change their own data, this is perfect as well.

    '--------------------------------------------------------------------------
    ' Returns true if all games for the specified week are locked.
    '--------------------------------------------------------------------------
    function AllGamesLocked( week)

    dim dateTimeNow, rs, gameDatetime

    AllGamesLocked = false

    dateTimeNow = CurrentDateTime ()
    set rs = WeeklySchedule( week)
    do while not rs.EOF
    gameDatetime = CDate(rs.Fields ("Date").Val ue & " " & rs.Fields("Time ").Value)
    if Weekday(gameDat etime) = vbSunday and gameDatetime <= dateTimeNow then
    AllGamesLocked = true
    exit function
    end if
    rs.MoveNext
    loop

    end function

    '--------------------------------------------------------------------------
    ' Returns true if the game is locked, based on the specified start time.
    '--------------------------------------------------------------------------
    function GameLocked(game Datetime)

    GameLocked = false

    if gameDatetime < CurrentDateTime () then
    GameLocked = true
    end if

    end function
  • Tawni
    New Member
    • Sep 2007
    • 5

    #2
    Must Be a Simple Way to like add 2 or minus 2 from "gameDateti me"

    2 days before sunday is friday right?

    but then will it screw up monday night football games ?

    I should have mentioned this is for a football pool

    Comment

    • jhardman
      Recognized Expert Specialist
      • Jan 2007
      • 3405

      #3
      I might not understand, but this seems like a really simple problem, but I'm not sure I understand your question. What part is giving you trouble? If I was doing something like this, I would just hard-code the date requirement into the script:
      [code=asp]if weekDay(date()) >=6 OR weekDay(date()) = 1 then
      response.write "db is view-only until Monday"
      else
      'give form for updating
      end if [/code]Jared

      Comment

      • Tawni
        New Member
        • Sep 2007
        • 5

        #4
        Thanks for reply, I been searching site daily for replies or info to help.As well as try fix myself.

        here is what i did recently and still no work (compare to above post code)

        first off to explain better, this is a football pool.

        right now for each week of play, user log in and enter their picks.
        Each user cant see the other users picks when they go to the results page.
        they only see "xxxxx" or their own picks, but once the Games are locked, then they can go back to the results page and print it out. SO lets say for simple explanation there is only Sunday games this week. Users might pick their picks on say Wed, and cant see other users picks until the pool is locked ( a deadline for picks to be in, cant make changes when pool locked).

        I want to Lock the pool always on thur or say friday ( cause some weeks there is thur games) in which the current code will lock them out when game starts.

        way code is now it works perfect with one exception, it allows picks to be changed up until start of the games, this is for security reason so no one keeps browser open after game start to cheat. It locks users out when game starts.

        I want to keep that but add another lock where picks must be in no later then say friday.

        Compare to above I was trying to lock as a test tuesday.



        function AllGamesLocked( week)

        dim dateTimeNow, rs, gameDatetime

        AllGamesLocked = false

        dateTimeNow = CurrentDateTime ()
        set rs = WeeklySchedule( week)
        do while not rs.EOF
        gameDatetime = CDate(rs.Fields ("Date").Val ue & " " & rs.Fields("Time ").Value)
        if Weekday(gameDat etime) = vbSunday and gameDatetime <= dateTimeNow then
        AllGamesLocked = true
        exit function
        end if
        rs.MoveNext
        loop

        end function

        '--------------------------------------------------------------------------
        ' Returns true if the game is locked, based on the specified start time.
        '--------------------------------------------------------------------------
        function GameLocked(week day)

        GameLocked = false

        if weekday = vbTuesday then
        GameLocked = true
        end if

        end function

        Comment

        • Tawni
          New Member
          • Sep 2007
          • 5

          #5
          Originally posted by jhardman
          I might not understand, but this seems like a really simple problem, but I'm not sure I understand your question. What part is giving you trouble? If I was doing something like this, I would just hard-code the date requirement into the script:
          [code=asp]if weekDay(date()) >=6 OR weekDay(date()) = 1 then
          response.write "db is view-only until Monday"
          else
          'give form for updating
          end if [/code]Jared
          Jared thanks,

          I will try that, one question though, since I get currentdatetime from server, then using your code, user cant trick it by changing their pc clocks right ?

          if that is correct , I think I am more of a Noob then I thought at this, can't wait for my 6 books I ordered to arrive from amazon. That was such an easy fix, thanks a million. back to drawing board, I will post back let you know.

          Comment

          • jhardman
            Recognized Expert Specialist
            • Jan 2007
            • 3405

            #6
            Originally posted by Tawni
            Jared thanks,

            I will try that, one question though, since I get currentdatetime from server, then using your code, user cant trick it by changing their pc clocks right ?

            if that is correct , I think I am more of a Noob then I thought at this, can't wait for my 6 books I ordered to arrive from amazon. That was such an easy fix, thanks a million. back to drawing board, I will post back let you know.
            date() and now() functions returns the date from the server, not from the user, so that isn't a problem.

            My solution just kept the user from seeing the form if it was past the set date, but this could be tricked by users opening the page before the deadline, so you might need a more complicated solution. The same approach will work, but I'm not sure I've been all that helpful.

            Jared

            Comment

            Working...