public Theater1(Show show, Customer customer, int theater) { InitializeComponent(); switch (THEATER) { case 1: listShows = Theater1.ReadXML <Show>(tab1path); break; //get shows information case 2: listShows = Theater1.ReadXML <Show>(tab2path); break; //get shows information case 3: listShows = Theater1.ReadXML <Show>(tab3path); break; //get shows informationbreak; } int inde = 0; for (int i = 0; i < listShows.Count; i++) { if (listShows.ElementAt(i).Name == show.Name) { inde = i; i = listShows.Count; } } //gets index //all global vars for a particular customer INDEX = inde; //passing the index of the show in the list of showws CUSTOMER = customer; //passing who the customer is SHOW = show; //passing show selected info THEATER = theater; }
private void Theater1_Load(object sender, EventArgs e) { AlreadyReservedShow = false; CreateButtons(); switch (THEATER) { case 1: listShows = Theater1.ReadXML <Show>(tab1path); break; //get shows information case 2: listShows = Theater1.ReadXML <Show>(tab2path); break; //get shows information case 3: listShows = Theater1.ReadXML <Show>(tab3path); break; //get shows informationbreak; } foreach (Button a in buttonArray) //for the whole theater seats { foreach (Viewer b in listShows.ElementAt(INDEX).viewers) //check everyone in the show, all the viewers { foreach (string c in b.Seating) //if their seats { if (a.Text == c) //match up with the button { a.BackColor = Color.Red; //then turn it red indicate taken a.Enabled = false; //disable reserved seats if ((b.Firstname == CUSTOMER.Firstname) && (b.Lastname == CUSTOMER.Lastname)) //checks to see if the vewer matches with the customer { AlreadyReservedShow = true; } // bool indicating person already in show } } } } }
private void button5_Click(object sender, EventArgs e) { switch (TicketsTab.SelectedTab.Name) { case "Tab2": sched = EmployeeSellTickets.ReadXML <Show>(tab2path); if (schedLB2.SelectedItem != null) { Show selectedshow = (Show)schedLB2.SelectedItem; Theater1 theater1 = new Theater1(selectedshow, CUSTOMER, 2); theater1.ShowDialog(); } else { MessageBox.Show("Select a show please"); } break; case "Tab3": sched = EmployeeSellTickets.ReadXML <Show>(tab3path); if (schedLB3.SelectedItem != null) { Show selectedshow = (Show)schedLB3.SelectedItem; Theater1 theater1 = new Theater1(selectedshow, CUSTOMER, 3); theater1.ShowDialog(); } else { MessageBox.Show("Select a show please"); } break; default: sched = EmployeeSellTickets.ReadXML <Show>(tab1path); if (schedLB.SelectedItem != null) { Show selectedshow = (Show)schedLB.SelectedItem; Theater1 theater1 = new Theater1(selectedshow, CUSTOMER, 1); theater1.ShowDialog(); } else { MessageBox.Show("Select a show please"); } break; } }
private void button2_Click(object sender, EventArgs e) { bool AtLeast1Picked = false; //List<Customer> custXML = Theater1.ReadXML<Customer>("..\\..\\Customer.xml"); //get all the customers info if (!(AlreadyReservedShow)) { //if he isn't in the list of viewers add them Viewer currentcustomer = new Viewer(CUSTOMER.Firstname, CUSTOMER.Lastname, CUSTOMER.Seats); listShows.ElementAt(INDEX).viewers.Add(currentcustomer);//access current show in list of shows and adding customer to that show } else { Viewer oldcust = new Viewer(); foreach (Viewer t in listShows.ElementAt(INDEX).viewers) { if ((t.Firstname == CUSTOMER.Firstname) && (t.Lastname == CUSTOMER.Lastname)) { oldcust = t; } } listShows.ElementAt(INDEX).viewers.Remove(oldcust); listShows.ElementAt(INDEX).viewers.Add(oldcust); //to put them at the end } foreach (Button p in buttonArray) { if (p.BackColor == Color.Yellow) { //add the yellow seats selected to persons listing int count = listShows.ElementAt(INDEX).viewers.Count; listShows.ElementAt(INDEX).viewers.ElementAt(count - 1).Seating.Add(p.Text); //add to the viewers seating list AtLeast1Picked = true; //make it true indicate person picked at least one } } if (AtLeast1Picked) { foreach (Button reserve in buttonArray) { if (reserve.BackColor == Color.Yellow) { reserve.BackColor = Color.Red; reserve.Enabled = false; } } /*Customer cust = new Customer(); * * foreach (Customer a in custXML) * { * if (a.Firstname == CUSTOMER.Firstname) * { * cust = a; * } * } * custXML.Remove(cust); * custXML.Add(CUSTOMER); * Theater1.WriteXML<Customer>("..\\..\\Customer.xml", custXML);*/ switch (THEATER) { case 1: Theater1.WriteXML <Show>(tab1path, listShows); break; case 2: Theater1.WriteXML <Show>(tab2path, listShows); break; case 3: Theater1.WriteXML <Show>(tab3path, listShows); break; } AtLeast1Picked = false; MessageBox.Show("Seats successfully reserved."); } else { MessageBox.Show("Please select at least 1 seat."); } }