private void saveButton_Click(object sender, RoutedEventArgs e)
        {
            if (checkCanSave())
            {
                if (isEditMode) // in edit mode, replace existing details with modified.
                {
                    int idInt = 0;
                    int.TryParse(id, out idInt);
                    if (idInt != 0)
                    {
                        Performance p = thisTheatre.getPerformances().Find(x => x.getID() == idInt);

                        DateTime date = new dateConverter().stringToDate(dateBox.Text);
                        Screen   s    = p.getScreen();
                        s.setDressPrice(float.Parse(priceDress.Text));
                        s.setStallsPrice(float.Parse(priceStalls.Text));
                        s.setUpperPrice(float.Parse(priceUpper.Text));
                        Performance temp = new Performance(idInt, titleBox.Text, descriptionBox.Text, date, s);
                        thisTheatre.deletePerformanceEntry(id);
                        thisTheatre.getPerformances().Remove(p);
                        thisTheatre.addPerformance(temp);
                        MessageBox.Show("Updated Performance.");
                        this.Close();
                    }
                }
                else // not in edit mode, add new performance.
                {
                    string[]        dates    = dateBox.Text.Split(',').ToArray();
                    List <DateTime> dateList = new List <DateTime>();
                    for (int i = 0; i < dates.Length; ++i)
                    {
                        DateTime date = new dateConverter().stringToDate(dates[i]);
                        if (dateList.Contains(date))
                        {
                            break;
                        }
                        dateList.Add(date);
                        Performance newPerf = new Performance(titleBox.Text, descriptionBox.Text, date, float.Parse(priceUpper.Text), float.Parse(priceDress.Text), float.Parse(priceStalls.Text));
                        thisTheatre.addPerformance(newPerf);
                    }
                    MessageBox.Show("New performance/s added succesfully.");
                    this.Close();
                }
            }
            else
            {
                MessageBox.Show("Please ensure all details have been entered.");
            }
        }
Example #2
0
        public void TestAdd()
        {
            myTheatreTest = new Theatre();
            Performance temp = new Performance("Test", "TestDescription", "12/12/1212 21:00", 3.5f, 5.0f, 8.5f);

            myTheatreTest.addPerformance(temp);
            id = temp.getID();
            Assert.IsNotNull(myTheatreTest.getPerformances().Find(x => x.getID() == id));
        }
Example #3
0
        public void TestAddReservation()
        {
            Performance temp = new Performance("Test", "TestDescription", "12/12/1212 21:00", 3.5f, 5.0f, 8.5f);

            myTheatreTest.addPerformance(temp);
            List <Seat> seats = new List <Seat>()
            {
                new Seat('E', 4, seatType.dress, 5.0f),
                new Seat('C', 4, seatType.upper, 3.5f)
            };
            string perf = myTheatreTest.getPerformances()[0].getID() + "-" + myTheatreTest.getPerformances()[0].getTitle();

            myTheatreTest.getCustomers()[0].addReservation(perf, seats, true, DateTime.Now);
            Assert.IsTrue(myTheatreTest.getCustomers()[0].getReservations().Count > 0);
        }