public void testGetAllShowings() { dataSet = ShowingsClass.getAllShowings(); string actualShowingDateRow0 = dataSet.Tables[0].Rows[0]["Date"].ToString(); double actualShowingUpperCirclePriceRow0 = double.Parse(dataSet.Tables[0].Rows[0]["UpperCirclePrice"].ToString()); double actualShowingDressCirclePriceRow0 = double.Parse(dataSet.Tables[0].Rows[0]["DressCirclePrice"].ToString()); double actualShowingStallPriceRow0 = double.Parse(dataSet.Tables[0].Rows[0]["StallsPrice"].ToString()); string actualShowingDateRow1 = dataSet.Tables[0].Rows[1]["Date"].ToString(); double actualShowingUpperCirclePriceRow1 = double.Parse(dataSet.Tables[0].Rows[1]["UpperCirclePrice"].ToString()); double actualShowingDressCirclePriceRow1 = double.Parse(dataSet.Tables[0].Rows[1]["DressCirclePrice"].ToString()); double actualShowingStallPriceRow1 = double.Parse(dataSet.Tables[0].Rows[1]["StallsPrice"].ToString()); string expectedShowingDateRow0 = "2017-06-24 17:00"; double expectedShowingUpperCirclePriceRow0 = 50; double expectedShowingDressCirclePriceRow0 = 25; double expectedShowingStallPriceRow0 = 12.5; string expectedShowingDateRow1 = "2017-06-22 12:00"; double expectedShowingUpperCirclePriceRow1 = 7; double expectedShowingDressCirclePriceRow1 = 2; double expectedShowingStallPriceRow1 = 1; Assert.AreEqual(expectedShowingDateRow0, actualShowingDateRow0); Assert.AreEqual(expectedShowingUpperCirclePriceRow0, actualShowingUpperCirclePriceRow0); Assert.AreEqual(expectedShowingDressCirclePriceRow0, actualShowingDressCirclePriceRow0); Assert.AreEqual(expectedShowingStallPriceRow0, actualShowingStallPriceRow0); Assert.AreEqual(expectedShowingDateRow1, actualShowingDateRow1); Assert.AreEqual(expectedShowingUpperCirclePriceRow1, actualShowingUpperCirclePriceRow1); Assert.AreEqual(expectedShowingDressCirclePriceRow1, actualShowingDressCirclePriceRow1); Assert.AreEqual(expectedShowingStallPriceRow1, actualShowingStallPriceRow1); }
private void Row_ComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e) { if (this.Rows_combo.Items.Count != 0) { this.Seat_combo.Items.Clear(); string sqlDateString = ShowingsClass.formatDateTimeToSqlLiteDateString((DateTime)SelectDate_Booking.SelectedDate); int showingId = ShowingsClass.getShowingIdByDate(sqlDateString); if (UpperCircle_radio.IsChecked == true) { dataSet = SeatsClass.getAllAvailableNumbersByAreaRowShowingId(showingId, "UpperCircle", this.Rows_combo.SelectedValue.ToString()); fillNumberDropDown(dataSet); } else if (DressCircle_radio.IsChecked == true) { dataSet = SeatsClass.getAllAvailableNumbersByAreaRowShowingId(showingId, "DressCircle", this.Rows_combo.SelectedValue.ToString()); fillNumberDropDown(dataSet); } else { dataSet = SeatsClass.getAllAvailableNumbersByAreaRowShowingId(showingId, "Stall", this.Rows_combo.SelectedValue.ToString()); fillNumberDropDown(dataSet); } } }
private void LoadNewsletters_button_Click(object sender, RoutedEventArgs e) { DataSet dataset = ShowingsClass.getAllShowingsPastCurrentDate(); foreach (DataRow row in dataset.Tables[0].Rows) { this.Newsletters_txt.Text = this.Newsletters_txt.Text + row["Name"].ToString() + " " + row["Date"].ToString() + "\n"; } }
private void Generate2_button_Click(object sender, RoutedEventArgs e) { DataSet dataSet = ShowingsClass.getAllShowingsPastCurrentDate(); this.Report_txt.ItemsSource = dataSet.Tables[0].DefaultView; this.Report_txt.Columns[0].Visibility = Visibility.Collapsed; this.Report_txt.Columns[1].Visibility = Visibility.Collapsed; this.Report_txt.Columns[6].Visibility = Visibility.Collapsed; }
private void EditShowing_button_Click(object sender, RoutedEventArgs e) { if (SelectDate_EditDelShow.SelectedDate == null) { MessageBox.Show("Please select a date for the required showing"); } else { int showingId = ShowingsClass.getShowingIdByDate(ShowingsClass.formatDateTimeToSqlLiteDateString((DateTime)SelectDate_EditDelShow.SelectedDate)); string startTime = this.TimeOfShowing_EditDeleteShowing_txt.Text; string timeToBeChecked = ValidationClass.TimeChecker(startTime); if (timeToBeChecked != null) { MessageBox.Show(timeToBeChecked); } else { double upperCirclePrice = double.Parse(this.UpperCircle_EditDelShow_txt.Text); string priceToBeChecked = UpperCircle_EditDelShow_txt.Text.ToString(); priceToBeChecked = ValidationClass.FloatChecker(priceToBeChecked); if (priceToBeChecked != null) { MessageBox.Show(priceToBeChecked); } else { double dressCirclePrice = double.Parse(this.DressCircle_EditDelShow_txt.Text); priceToBeChecked = DressCircle_EditDelShow_txt.Text.ToString(); priceToBeChecked = ValidationClass.FloatChecker(priceToBeChecked); if (priceToBeChecked != null) { MessageBox.Show(priceToBeChecked); } else { double stallPrice = double.Parse(this.Stalls_EditDelShow_txt.Text); priceToBeChecked = Stalls_EditDelShow_txt.Text.ToString(); priceToBeChecked = ValidationClass.FloatChecker(priceToBeChecked); if (priceToBeChecked != null) { MessageBox.Show(priceToBeChecked); } else { dataSet = ShowingsClass.getShowingByShowingId(showingId); string unedditedSqlDateTimeString = dataSet.Tables[0].Rows[0]["Date"].ToString(); string newDateTimeSqlString = ShowingsClass.replaceSqlDateTimeWithNewTime(unedditedSqlDateTimeString, startTime); ShowingsClass.editShowingDetails(showingId, newDateTimeSqlString, upperCirclePrice, dressCirclePrice, stallPrice); MessageBox.Show("Showing edited"); } } } } } }
public void testDeletePlay() { PlaysClass.deletePlay(2); dataSet = ShowingsClass.getShowingByShowingId(2); int actualPlayId = int.Parse(dataSet.Tables[0].Rows[0]["Play_Id"].ToString()); int expectedPlayId = 1; Assert.AreEqual(expectedPlayId, actualPlayId); }
//-----------------------------------Add Showing ---------------------------------// //--------------------------------Edit/Delete Showing-----------------------------// private void SelectDate_EditDelShow_SelectionDateChanged(object sender, RoutedEventArgs e) { if (SelectDate_EditDelShow.SelectedDate != null) { int showingId = ShowingsClass.getShowingIdByDate(ShowingsClass.formatDateTimeToSqlLiteDateString((DateTime)SelectDate_EditDelShow.SelectedDate)); dataSet = ShowingsClass.getShowingByShowingId(showingId); string dateTime = dataSet.Tables[0].Rows[0]["Date"].ToString(); this.TimeOfShowing_EditDeleteShowing_txt.Text = ShowingsClass.getTimeFromSqlDateSting(dateTime); this.UpperCircle_EditDelShow_txt.Text = dataSet.Tables[0].Rows[0]["UpperCirclePrice"].ToString(); this.DressCircle_EditDelShow_txt.Text = dataSet.Tables[0].Rows[0]["DressCirclePrice"].ToString(); this.Stalls_EditDelShow_txt.Text = dataSet.Tables[0].Rows[0]["StallsPrice"].ToString(); } }
private void Stalls_radio_Checked(object sender, RoutedEventArgs e) { if (ChoosePlay_combo.Items.Count == 0) { MessageBox.Show("Please search for a showing before selecting seats"); } else { this.Rows_combo.Items.Clear(); this.UpperCircle_radio.IsChecked = false; this.DressCircle_radio.IsChecked = false; string sqlDateString = ShowingsClass.formatDateTimeToSqlLiteDateString((DateTime)SelectDate_Booking.SelectedDate); int showingId = ShowingsClass.getShowingIdByDate(sqlDateString); dataSet = SeatsClass.getAllAvailableRowByAreaShowingId(showingId, "Stall"); int numberOfSeatsLeftForArea = SeatsClass.getNumOfSeatsLeftInAreaForShowing(showingId, "Stall"); this.SeatsRemaining_lbl.Content = "Seats remaining: " + numberOfSeatsLeftForArea; fillRowDropDown(dataSet); } }
public void testDeleteShowing() { dataSet = ShowingsClass.deleteShowing(2); string actualEmail = dataSet.Tables[0].Rows[0]["Email"].ToString(); string expectedEmail = "*****@*****.**"; dataSet = SeatsClass.getSeatDetails("Stall", "M", 5, 2); int actualRowCountSeats = dataSet.Tables[0].Rows.Count; int expectedRowCountSeats = 0; dataSet = BookingsClass.getBookingDetailsById(1); int actualRowCountBookings = dataSet.Tables[0].Rows.Count; int expectedRowCountBookings = 0; Assert.AreEqual(expectedRowCountSeats, actualRowCountSeats); Assert.AreEqual(expectedEmail, actualEmail); Assert.AreEqual(expectedRowCountBookings, actualRowCountBookings); }
public void testGetShowingsByPlay() { dataSet = ShowingsClass.getShowingForPlays(2); string actualShowingDate = dataSet.Tables[0].Rows[0]["Date"].ToString(); double actualShowingUpperCirclePrice = double.Parse(dataSet.Tables[0].Rows[0]["UpperCirclePrice"].ToString()); double actualShowingDressCirclePrice = double.Parse(dataSet.Tables[0].Rows[0]["DressCirclePrice"].ToString()); double actualShowingStallPrice = double.Parse(dataSet.Tables[0].Rows[0]["StallsPrice"].ToString()); string expectedShowingDate = "2017-06-22 12:00"; double expectedShowingUpperCirclePrice = 7; double expectedShowingDressCirclePrice = 2; double expectedShowingStallPrice = 1; Assert.AreEqual(expectedShowingDate, actualShowingDate); Assert.AreEqual(expectedShowingUpperCirclePrice, actualShowingUpperCirclePrice); Assert.AreEqual(expectedShowingDressCirclePrice, actualShowingDressCirclePrice); Assert.AreEqual(expectedShowingStallPrice, actualShowingStallPrice); }
public void testEditShowing() { ShowingsClass.editShowingDetails(2, "2017-06-22 12:00", 7, 2, 1); dataSet = ShowingsClass.getShowingByShowingId(2); string actualShowingDate = dataSet.Tables[0].Rows[0]["Date"].ToString(); double actualShowingUpperCirclePrice = double.Parse(dataSet.Tables[0].Rows[0]["UpperCirclePrice"].ToString()); double actualShowingDressCirclePrice = double.Parse(dataSet.Tables[0].Rows[0]["DressCirclePrice"].ToString()); double actualShowingStallPrice = double.Parse(dataSet.Tables[0].Rows[0]["StallsPrice"].ToString()); string expectedShowingDate = "2017-06-22 12:00"; double expectedShowingUpperCirclePrice = 7; double expectedShowingDressCirclePrice = 2; double expectedShowingStallPrice = 1; Assert.AreEqual(expectedShowingDate, actualShowingDate); Assert.AreEqual(expectedShowingUpperCirclePrice, actualShowingUpperCirclePrice); Assert.AreEqual(expectedShowingDressCirclePrice, actualShowingDressCirclePrice); Assert.AreEqual(expectedShowingStallPrice, actualShowingStallPrice); }
private void BookPlay_button_Click(object sender, RoutedEventArgs e) { if (ChoosePlay_combo.Items.Count == 0) { MessageBox.Show("Please select a showing and fill out all other fields before selecting 'Add to Basket"); } else { string sqlDateString = ShowingsClass.formatDateTimeToSqlLiteDateString((DateTime)SelectDate_Booking.SelectedDate); int showingId = ShowingsClass.getShowingIdByDate(sqlDateString); int customerId = int.Parse(this.Surname_Booking_Combo.SelectedValue.ToString()); List <SeatBookingClass> seatBookingList = new List <SeatBookingClass>(); foreach (DataRow row in seatBookingsDataset.Rows) { SeatBookingClass seatBookingObj = new SeatBookingClass(row["Section"].ToString(), row["Row"].ToString(), int.Parse(row["Number"].ToString()), showingId); seatBookingList.Add(seatBookingObj); } //int pCustomerId, string pDate, int pPaid, List<SeatBookingClass> SeatsToBookList BookingsClass.newBooking(customerId, ShowingsClass.formatDateTimeToSqlLiteDateString(DateTime.Now), 0, seatBookingList); MessageBox.Show("New booking added"); } }
private void DeleteShowing_button_Click(object sender, RoutedEventArgs e) { if (SelectDate_EditDelShow.SelectedDate == null) { MessageBox.Show("Please select a date for the required showing"); } else { MessageBoxResult messageBoxResult = MessageBox.Show("Are you sure?", "Delete Confirmation", MessageBoxButton.YesNo); if (messageBoxResult == MessageBoxResult.Yes) { ShowingsClass.deleteShowing(ShowingsClass.getShowingIdByDate(ShowingsClass.formatDateTimeToSqlLiteDateString((DateTime)SelectDate_EditDelShow.SelectedDate))); MessageBox.Show("Showing deleted"); this.Close(); BookingOfficerWindow newBookingOfficerWindow = new BookingOfficerWindow(); newBookingOfficerWindow.Show(); //fillDatePicker(this.SelectDate_EditDelShow); } else { MessageBox.Show("Delete cancelled"); } } }
private void CreateShowing_button_Click(object sender, RoutedEventArgs e) { if (Play_AddShowing_combo.Items.Count == 0) { MessageBox.Show("Please enter a play to search for"); } else { KeyValuePair <int, string> test = (KeyValuePair <int, string>) this.Play_AddShowing_combo.SelectedValue; int playId = int.Parse((test.Key).ToString()); dataSet = PlaysClass.getPlayDetailsById(playId); int playLength = int.Parse(dataSet.Tables[0].Rows[0]["Length"].ToString()); string startTime = StartTime_AddShowing_txt.Text; string timeToBeChecked = ValidationClass.TimeChecker(startTime); if (timeToBeChecked != null) { MessageBox.Show(timeToBeChecked); } else { //var startTimeCharArray = startTime.ToCharArray(); //string startHour = startTimeCharArray[0].ToString() + startTimeCharArray[1].ToString(); //string startMinutes = startTimeCharArray[3].ToString() + startTimeCharArray[4].ToString(); //DateTime startDateTime = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, // int.Parse(startHour), int.Parse(startMinutes), 0); //DateTime endDateTime = startDateTime.AddMinutes(playLength); //string endTime = endDateTime.Hour + ":" + endDateTime.Minute; DateTime?startDate = this.StartDate_AddShowing.SelectedDate; DateTime?endDate = this.EndDate_AddShowing.SelectedDate; if (startDate > endDate) { MessageBox.Show("Start date must be earlier than End date"); } else { string priceToBeChecked = UpperCircle_AddShowing_txt.Text.ToString(); priceToBeChecked = ValidationClass.FloatChecker(priceToBeChecked); if (priceToBeChecked != null) { MessageBox.Show(priceToBeChecked); } else { float upperCirclePrice = float.Parse(this.UpperCircle_AddShowing_txt.Text.ToString()); priceToBeChecked = DressCircle_AddShowing_txt.Text.ToString(); priceToBeChecked = ValidationClass.FloatChecker(priceToBeChecked); if (priceToBeChecked != null) { MessageBox.Show(priceToBeChecked); } else { float dressCirclePrice = float.Parse(this.DressCircle_AddShowing_txt.Text.ToString()); priceToBeChecked = Stalls_AddShowing_txt.Text.ToString(); priceToBeChecked = ValidationClass.FloatChecker(priceToBeChecked); if (priceToBeChecked != null) { MessageBox.Show(priceToBeChecked); } else { float stallPrice = float.Parse(this.Stalls_AddShowing_txt.Text.ToString()); if (this.StartDate_AddShowing.SelectedDate == null || this.EndDate_AddShowing.SelectedDate == null) { MessageBox.Show("please enter start and end date"); } else { bool sqlQuerryState = ShowingsClass.makeShowings((DateTime)startDate, (DateTime)endDate, startTime, playId, upperCirclePrice, dressCirclePrice, stallPrice); if (sqlQuerryState == true) { MessageBox.Show("Showing added"); fillDatePicker(this.SelectDate_EditDelShow); } else { MessageBox.Show("conclict with current showing"); } } } } } } } } }
private void UpgradeMember_button_Click(object sender, RoutedEventArgs e) { if (SurnameSearch_UpgradeMember_combo.Items.Count == 0) { MessageBox.Show("Please enter a customer name to search for"); } else { int chosenCustomerID = int.Parse(this.SurnameSearch_UpgradeMember_combo.SelectedValue.ToString()); dataSet = CustomerClass.getCustomerById(chosenCustomerID); CustomerClass.editCustomerDetails(chosenCustomerID, dataSet.Tables[0].Rows[0]["First_Name"].ToString(), dataSet.Tables[0].Rows[0]["Last_Name"].ToString(), dataSet.Tables[0].Rows[0]["Email"].ToString(), ShowingsClass.formatDateTimeToSqlLiteDateString(DateTime.Now.AddMonths(12))); MessageBox.Show("Customer changed to gold club member"); } }
//---------------------------------------------- Add Member Tab ------------------------------------------------------// private void CreateMember_button_Click(object sender, RoutedEventArgs e) { string mFirstName = Forename_AddMember_txt.Text.ToString(); if (mFirstName.Length == 0) { MessageBox.Show("Please enter a Forename"); } else { string stringToBeChecked = ValidationClass.HasNumbersInStringChecker(mFirstName); if (stringToBeChecked != null) { MessageBox.Show("Forename cannot contain numbers"); } else { string mLastName = Surname_AddMember_txt.Text.ToString(); if (mLastName.Length == 0) { MessageBox.Show("Please enter a Surname"); } else { stringToBeChecked = ValidationClass.HasNumbersInStringChecker(mLastName); if (stringToBeChecked != null) { MessageBox.Show("Surname cannot contain numbers"); } else { string mEmail = Email_AddMember_txt.Text.ToString(); if (mEmail.Length == 0) { MessageBox.Show("Please enter an Email"); } else { if (CustomerClass.checkIfEmailExits(mEmail) == true) { MessageBox.Show("This email already exists - Please enter another email"); } else { if (GoldMember_checkbox.IsChecked == true) { var currentTime = ShowingsClass.formatDateTimeToSqlLiteDateString(DateTime.Now.AddMonths(12)); string mMembershipExpiryDate = currentTime.ToString(); CustomerClass.newCustomer(mFirstName, mLastName, mEmail, mMembershipExpiryDate); MessageBox.Show("Customer added"); } else { CustomerClass.newCustomer(mFirstName, mLastName, mEmail, null); MessageBox.Show("Customer added"); } } } } } } } }
private void fillDatePicker(DatePicker pDatePicker, int pId) { pDatePicker.BlackoutDates.Clear(); pDatePicker.BlackoutDates.AddDatesInPast(); List <DateTime> dateList = new List <DateTime>(); DataSet dataSet = ShowingsClass.getShowingForPlays(pId); //DataSet dataSet = ShowingsClass.getAllShowings(); foreach (DataRow row in dataSet.Tables[0].Rows) { int tempShowingId = int.Parse(row["Showing_Id"].ToString()); DateTime showingDate = ShowingsClass.turnSqlLiteDateStringIntoDateTime(row["Date"].ToString()); if (showingDate >= DateTime.Now) { dateList.Add(showingDate); } } dateList.Sort(); //if (dateList.Count != 0) //{ // DateTime nextStartDate = DateTime.Now.AddDays(-1); // int count = 1; // foreach (DateTime showingDateFromList in dateList) // { // if (count < dateList.Count) // { // nextStartDate = showingDateFromList; // if (showingDateFromList.AddDays(1).Date == dateList[count].Date) // { // //next date in list is for next day so do nothing // } // else // { // pDatePicker.BlackoutDates.Add(new CalendarDateRange(nextStartDate.AddDays(1), dateList[count].AddDays(-1))); // } // count = count + 1; // } // } // pDatePicker.BlackoutDates.Add(new CalendarDateRange(dateList[count - 1].AddDays(1), nextStartDate.AddYears(500))); // pDatePicker.BlackoutDates.Add(new CalendarDateRange(DateTime.Now, dateList[0].AddDays(-1))); //} //else //{ // pDatePicker.BlackoutDates.Add(new CalendarDateRange(DateTime.Now, DateTime.Now.AddYears(500))); //} if (dateList.Count == 0) { pDatePicker.BlackoutDates.Add(new CalendarDateRange(DateTime.Now, DateTime.Now.AddYears(1))); } else { DateTime startDate = DateTime.Now; for (int i = 0; i < dateList.Count; i++) { if (startDate.Date != dateList[i].Date) { pDatePicker.BlackoutDates.Add(new CalendarDateRange(startDate, dateList[i].AddDays(-1))); } startDate = dateList[i].AddDays(1); } pDatePicker.BlackoutDates.Add(new CalendarDateRange(startDate, startDate.AddMonths(12))); } }
private void AddToBasket_button_Click(object sender, RoutedEventArgs e) { if (ChoosePlay_combo.Items.Count == 0) { MessageBox.Show("Please Choose a play"); } else { if (SelectDate_Booking.SelectedDate == null) { MessageBox.Show("Please enter a showing date"); } else { if (UpperCircle_radio.IsChecked == false && DressCircle_radio.IsChecked == false && Stalls_radio.IsChecked == false) { MessageBox.Show("Please check a seating area"); } else { if (Rows_combo.SelectedValue == null) { MessageBox.Show("Please select a seat row"); } else { if (Seat_combo.SelectedValue == null) { MessageBox.Show("Please select a seat number"); } else { string area; if (UpperCircle_radio.IsChecked == true) { area = "UpperCircle"; } else if (DressCircle_radio.IsChecked == true) { area = "DressCircle"; } else { area = "Stall"; } string sqlDateString = ShowingsClass.formatDateTimeToSqlLiteDateString((DateTime)SelectDate_Booking.SelectedDate); int showingId = ShowingsClass.getShowingIdByDate(sqlDateString); string row = this.Rows_combo.SelectedValue.ToString(); int num = int.Parse(this.Seat_combo.SelectedValue.ToString()); //DataRow rowCheck = seatBookingsDataset.NewRow(); //rowCheck["Section"] = area; //rowCheck["Row"] = row; //rowCheck["Number"] = num; bool cannAddToBasket = true; foreach (DataRow loopRow in seatBookingsDataset.Rows) { if (loopRow["Section"].ToString() == area && loopRow["Row"].ToString() == row && int.Parse(loopRow["Number"].ToString()) == num) { cannAddToBasket = false; } } if (cannAddToBasket == false) { MessageBox.Show("Seat already in basket"); } else { if (seatBookingsDataset.Rows.Count < 6) { seatBookingsDataset.Rows.Add(area, row, num); this.UpperCircle_radio.IsChecked = false; this.DressCircle_radio.IsChecked = false; this.Stalls_radio.IsChecked = false; this.Rows_combo.Items.Clear(); this.Seat_combo.Items.Clear(); } } //SeatBookingClass seatBookingObj = new SeatBookingClass(area, row, num, showingId); } } } } } }