C # Summary Project "Cinema Ticketing System" compilation summary Three

Source: Internet
Author: User

Yesterday summarizes the dynamic drawing controls, ticket type switching, and the presentation of the data in the form. Today continue to summarize, you like to do it, let others say go, province of their own left what regret regret, oh yes, come on!

Today, we summarize the most important parts of the project-ticketing, change of seat color status and display of the status of the seats.

Analysis:

1. The Seat Status (label implementation) is updated after the selected time, the red is sold, and the unsold display is yellow.

2. The sold tip has been sold and no action has been taken, and the unsold inquiry is purchased.

3. According to the selection of the general, gift, or student tickets to create a different ticket object

If you choose a gift ticket, you will need to check if the presenter fills

If you select a student ticket you need to check whether the discount is selected

4. Get the seat number of the selected seat, call the Createticket () method of the tool class to create a ticket of the selected type, and the regular ticket to create it directly using the ticket class

5. The user chooses to change the color of the seat set to red after the purchase, re-use the calculation method of the Ticket class; Add the tickets sold to the Soldtickets collection in the Cinema class; update the seat color status, on the code

1 Try2             {3                 //gets the seat number of the currently clicked seat label (Text property)4                 stringSeatnum =((Label) sender). Text.tostring ();5                 //Giver's name6                 stringCustomerName = This. txtGiver.Text.ToString ();7                 //Discount8                 intDiscount =0;9                 //type of ticketTen                 stringType =""; One                 //If the student ticket is selected A                 if( This. rdostuticket.checked) -                 { -Type ="Studentticket"; the                     if( This. Cbodiscount.text = =NULL) -                     { -MessageBox.Show ("Please enter the number of discount! ","Tips"); -                         return; +                     } -                     Else +                     { ADiscount =int. Parse ( This. Cbodiscount.text); at                     } -                 } -                 //If the gift ticket is selected -                 Else if( This. rdogiveticket.checked) -                 { -                     if(string. IsNullOrEmpty ( This. Txtgiver.text)) in                     { -MessageBox.Show ("Please enter the name of the person who gave the ticket! ","Tips"); to                         return; +                     } -Type ="Freeticket"; the                 } *                 //Create a ticket static method using tool class $Ticket Newticket =Ticketutil.createticket (Cinema. Schedule.items[key], cinema. Seats[seatnum], discount, customerName, type);Panax Notoginseng                 //if the color of the current seat is yellow-pending sale -                 if(Cinema. Seats[seatnum]. Color = =Color.yellow) the                 { +                     //Ask ADialogResult result = MessageBox.Show ("do you want to buy? ","Tips", Messageboxbuttons.yesno); the                     if(Result = =Dialogresult.yes) +                     { -                         //Recalculate Fares $ Newticket.calcprice (); $                         //Add a ticket to the collection of tickets already sold - Cinema. Soldtickets.add (newticket); -                         //Update seat color status the updateseat (); -Lblpreferentialprice.text =newTicket.Price.ToString ();Wuyi newticket.print (); the                         //Change the color state of the seat set -Cinema. Seats[seatnum]. Color =color.red; Wu                     } -                 } About                 //if it's a ticket already sold, $                 Else -                 { -                     //Show current Ticketing information -                     foreach(Ticket ticket0inchCinema. Soldtickets) A                     { +                         //The seat number of the sold ticket collection is equal to the current click Seat number and the selected time equals the time of the sold ticket and the movie name in the plan for the sale of the ticket equals the parent node of the TreeView's selected time. the                         if(Ticket0. Seat.seatnum = = Seatnum && ticket0. Scheduitem.time = = TreeView1.SelectedNode.Text && ticket0. ScheduItem.Movie.MovieName = =treeView1.SelectedNode.Parent.Text) -                         { $ ticket0. Show (); the                         } the                     } the                 } the  -             } in             Catch(Exception ex) the             { theMessageBox.Show ("Please select the session first! "+Ex. Message); About}
Lblseat_click

Here's a way to call the seat color update updateseat (), initialize the color of the seats collection and labels collection first, that is, reset the color to yellow, and then set the color of the sold seats to red based on the information sold

1 //Resets the color of the Labels collection label2             foreach(stringLkeyinchlabels. Keys)3             {4Labels[lkey]. BackColor =Color.yellow;5             }6             //Reset seat Set color7             foreach(stringKeyinchCinema. Seats.keys)8             {9Cinema. Seats[key]. Color =Color.yellow;Ten             } One             //traverse the collection of sold tickets A             foreach(Ticket TicketinchCinema. Soldtickets) -             { -                 //if the matches are the same, and the movie names match the                 if(Ticket. Scheduitem.time = = This. TreeView1.SelectedNode.Text && Ticket. ScheduItem.Movie.MovieName = = This. Lblname.text) -                 { -                     //Change color again -Labels[ticket. Seat.seatnum]. BackColor =color.red; +Cinema. Seats[ticket. Seat.seatnum]. Color =color.red; -                 } +}
updateseat ()

This makes it possible to change the color status of the seat after the purchase of the ticket.

The tickets that have been sold in each field are then refreshed according to the time (session) node of the selected TreeView.

This is the second treeview1_afterselect of the previous event, call our Updateseat method, so that each selected session will be updated once the seat sale.

It's here today, tomorrow. The local save of sales information, and the last saved sales information is loaded each time it is opened, and the whole project is summarized.

"Cai Yuan Zi from Le Zhi: Www.cnblogs.com/AIThink, the code word is not easy, reproduced please indicate the source." 】

C # Summary Project "Cinema Ticketing System" compilation summary Three

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.