locked
Counter for maximum tickets RRS feed

  • Question

  • User2016675517 posted

    In a school project, we are making a website for a fictional concert/festival (using Visual Studio 2005, C#). On that site users can register and order tickets.

    We have access to an SQL-database, by the way, where we can create tables etc. 

    We want the maximum amount of tickets to be 10000 per day. The festival is supposed to last from friday to sunday.

    What would be the best way to do this programatically? The counter should maybe be in an own database table?

    Monday, February 4, 2008 5:51 PM

Answers

  • User1470508873 posted

    Also, if you don't want to use a database, just save a file with the current ticket number.  The first ticket number would be 1.txt in C:\Tickets folder, next time you look for a txt file in the folder.  If it exists read the name, and convert it to a number.  If it is less than your max, then rename it to the next number ( 2.txt ), and keep going till the max is set.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, February 4, 2008 6:26 PM

All replies

  • User-1725998994 posted

    i do not see any other option the to keep the data in the database ... e.g. if you choose to take a static value, it will be reseted every time you load the system.

    normally you would also use an increment counter in your database table. i believe you have a kind of basket table which helds a ref. to ticket table for each ticket you have sold. once this table reaches your requested amount you do not sell any additional ticket.

     

     

    Monday, February 4, 2008 6:22 PM
  • User1470508873 posted

    Create a table (Tbl_Tickets) which has a primary and identity key as an integer.  For example:

    ==================================== 

    Tbl_Tickets columns:

    TicketID, Created Date, Ticket Number

    ====================================

    When ever you insert a record, the ticket id will automatically get inserted, so first you would check what is the max ticketid, example:

    select max(ticketid) from Tbl_Tickets

    Then you just read the vaue, and if it is less than 10000, then you can insert a new record (or a ticket can be sold for the festival),

    Insert into Tbl_Tickets values ( 'Todays Date', 'Your Ticket Number')

    Hope this helps.

    Monday, February 4, 2008 6:23 PM
  • User1470508873 posted

    Also, if you don't want to use a database, just save a file with the current ticket number.  The first ticket number would be 1.txt in C:\Tickets folder, next time you look for a txt file in the folder.  If it exists read the name, and convert it to a number.  If it is less than your max, then rename it to the next number ( 2.txt ), and keep going till the max is set.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, February 4, 2008 6:26 PM
  • User2016675517 posted

    Thanks guys, I'll try some of the things you suggested.

    But I need to know how to use SQL/database stuff in C# (correct syntax). For instance, the counter value from a table, inside an if-statement in C# (Code behind the submit button).

    Maybe I should make a new thread about that in the Data Access forum?

    Wednesday, February 6, 2008 4:56 AM
  • User1470508873 posted

    Use the System.Data.Sql.SqlClient reference.   There you can use the SqlConnection to make connections, SqlDataAdapter, SqlDataReader to do queries. 

    Wednesday, February 6, 2008 10:32 PM