RSVP for events

Feb 22, 2007 at 10:33 AM
I just want to seperate this discussion out from the other one.

I have uploaded the database, Club.zip. If it still isn't working, I can zip up the whole thing and put it out on my website so you can get to it.
Feb 23, 2007 at 11:13 AM
Great job on RSVP mnebinger!
Feb 23, 2007 at 9:41 PM
Edited Feb 23, 2007 at 11:25 PM
Hi mnebinger,

I would like the code to stop when you go over the limit. So I attempted a minor change.
Not sure if its totally ok though.
A nice Msgbox as reminder would be great too, ;-D
Please feel free to ignore it if you dislike it.
Regards,
Lex


Private Sub AddAttendance()

'Get the current and maximum # of guests for an event
GetEventAttendance()

'Get the current # of guests this user has registered previously.
Dim oldNumGuests As Integer = GetUserAttendance()

Dim num As Integer
num = CInt(numofguests.Text)

Dim newCurrentAttendance As Integer = _currentAttendance + num - oldNumGuests

'Test to see if this will put us over the maximum # of guests for an event.
If newCurrentAttendance > _totalAttendance Then
errorMsg.Text = "Sorry, er kunnen nog maximaal " & _totalAttendance - _currentAttendance & " worden aangemeld."
numofguests.Text = oldNumGuests.ToString
errorMsg.Visible = True
ElseIf _totalAttendance = -1 Then '-1 means there isn't a maximum @ of guests set.
'Insert into the database
AddToAttendanceDatabase(num)
UpdateEventsGuests(newCurrentAttendance)
_currentAttendance = newCurrentAttendance
_NumGuests = num
Else
'Insert into the database
AddToAttendanceDatabase(num)
UpdateEventsGuests(newCurrentAttendance)
_currentAttendance = newCurrentAttendance
_NumGuests = num
End If

End Sub
Feb 24, 2007 at 2:41 AM
I don't know what your errorMsg.Text is saying.

Are you trying to say if _totalAttendance is set at 75, and _currentAttendance is 73, then errorMsg.Text says Sorry, but there is only room for 2 more people?

That would work. But one thing I forgot to do is at the end of the If, before the ElseIf, there needs to be a return statement, so that the last 2 lines are not executed. Or move those 2 lines to the end of the ElseIf and Else blocks. I see you got that in your code. I am going to make that change to my code.
Feb 24, 2007 at 2:55 AM
Okay, just fixed another bug with this. The test for -1 has to be first.

'First test to see if _totalAttendance is -1
If _totalAttendance = -1 Then
'Insert into the database
AddToAttendanceDatabase(num)
UpdateEventsGuests(newCurrentAttendance)
_currentAttendance = newCurrentAttendance
_NumGuests = num
'Test to see if this will put us over the maximum # of guests for an event.
ElseIf newCurrentAttendance > _totalAttendance Then
errorMsg.Text = "Sorry, adding " & numofguests.Text & " to the event would put it over the limit!"
errorMsg.Visible = True
Return
Else
'Insert into the database
AddToAttendanceDatabase(num)
UpdateEventsGuests(newCurrentAttendance)
_currentAttendance = newCurrentAttendance
_NumGuests = num
End If
Feb 24, 2007 at 2:55 AM
This discussion has been copied to Work Item 494. You may wish to continue further discussion there.