private void DeletePlay_button_Click(object sender, RoutedEventArgs e) { if (Play_EditDelPlay_combo.Items.Count == 0) { MessageBox.Show("Please enter a Play to search for"); } else { KeyValuePair <int, string> test = (KeyValuePair <int, string>) this.Play_EditDelPlay_combo.SelectedValue; int playId = int.Parse((test.Key).ToString()); MessageBoxResult messageBoxResult = MessageBox.Show("Are you sure?", "Delete Confirmation", MessageBoxButton.YesNo); if (messageBoxResult == MessageBoxResult.Yes) { PlaysClass.deletePlay(playId); this.Length_EditDelPlay_txt.Text = ""; this.Play_EditDelPlay_combo.Items.Clear(); this.PlayName_EditDelPlay_txt.Text = ""; MessageBox.Show("Play deleted"); } else { MessageBox.Show("Delete cancelled"); } } }
//-------------------------------------Add Play-----------------------------------// //--------------------------------Edit/Delete Play--------------------------------// private void PlaySearch_EditDelPlay_button_Click(object sender, RoutedEventArgs e) { this.Play_EditDelPlay_combo.Items.Clear(); string playNameSearchBy = this.PlayName_EditDelPlay_txt.Text; if (playNameSearchBy.Length == 0) { MessageBox.Show("Please eter a play to search for"); } else { dataSet = PlaysClass.getPlayDetailsByName(playNameSearchBy); if (dataSet.Tables[0].Rows.Count == 0) { MessageBox.Show("Play not found - Try entering another play or check spelling"); } else { this.Play_EditDelPlay_combo.SelectedValue = "Key"; this.Play_EditDelPlay_combo.DisplayMemberPath = "Value"; foreach (DataRow row in dataSet.Tables[0].Rows) { this.Play_EditDelPlay_combo.Items.Add(new KeyValuePair <int, string>(int.Parse(row["Play_Id"].ToString()), row["Name"].ToString())); } } } }
//-----------------------------------Add Showing ---------------------------------// private void AddShowingTabSearchPlay(object sender, RoutedEventArgs e) { this.Play_AddShowing_combo.Items.Clear(); if (Play_Name_AddShowing_txt.Text.ToString() == "") { MessageBox.Show("Please enter the name of the play to search for"); } else { dataSet = PlaysClass.getPlayDetailsByName(this.Play_Name_AddShowing_txt.Text.ToString()); if (dataSet.Tables[0].Rows.Count == 0) { MessageBox.Show("Play not found - Try entering another play or check spelling"); } else { this.Play_AddShowing_combo.SelectedValue = "Key"; this.Play_AddShowing_combo.DisplayMemberPath = "Value"; foreach (DataRow row in dataSet.Tables[0].Rows) { this.Play_AddShowing_combo.Items.Add(new KeyValuePair <int, string>(int.Parse(row["Play_Id"].ToString()), row["Name"].ToString())); } } } }
//--------------------------------Edit/Delete Showing-----------------------------// //-------------------------------------Add Play-----------------------------------// private void CreatePlay_AddPlay_button_Click(object sender, RoutedEventArgs e) { string playName = this.PlayName_AddPlay_txt.Text; if (playName.Length == 0) { MessageBox.Show("Please enter a Play name"); } else { if (PlaysClass.checkPlayExists(playName) == true) { MessageBox.Show("This Play already exists"); } else { string playLengthToBeChecked = Length_AddPlay_txt.Text.ToString(); if (playLengthToBeChecked.Length == 0) { MessageBox.Show("Please enter a {Play length"); } else { playLengthToBeChecked = ValidationClass.IntChecker(playLengthToBeChecked); if (playLengthToBeChecked != null) { MessageBox.Show(playLengthToBeChecked); } else { try { int playLengthToBeCheckedInt = int.Parse(Length_AddPlay_txt.Text.ToString()); if (playLengthToBeCheckedInt > 400) { MessageBox.Show("Play length too high - max length 400 minutes"); } else { int playLength = int.Parse(this.Length_AddPlay_txt.Text.ToString()); PlaysClass.addPlay(playName, playLength); this.PlayName_AddPlay_txt.Text = ""; this.Length_AddPlay_txt.Text = ""; MessageBox.Show("Play added"); } } catch (Exception) { MessageBox.Show("Play length too high - max length 400 minutes"); } } } } } }
//---------------------------------------------- Booking Tab ------------------------------------------------------// public void Choose_Play_Combo_Click(object sender, EventArgs e) //Populates combo box with Play data when clicked { this.ChoosePlay_combo.Items.Clear(); dataSet = PlaysClass.getAllPlays(); this.ChoosePlay_combo.SelectedValuePath = "Key"; this.ChoosePlay_combo.DisplayMemberPath = "Value"; foreach (DataRow row in dataSet.Tables[0].Rows) { this.ChoosePlay_combo.Items.Add(new KeyValuePair <int, string>(int.Parse(row["Play_Id"].ToString()), row["Name"].ToString())); } }
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); }
private void Play_EditDelPlay_combo_SelectionChanged(object sender, SelectionChangedEventArgs e) { if (this.Play_EditDelPlay_combo.SelectedItem != null) { KeyValuePair <int, string> test = (KeyValuePair <int, string>) this.Play_EditDelPlay_combo.SelectedValue; int playId = int.Parse((test.Key).ToString()); dataSet = PlaysClass.getPlayDetailsById(playId); this.Length_EditDelPlay_txt.Text = dataSet.Tables[0].Rows[0]["Length"].ToString(); } }
public void testGetPlayById() { dataSet = PlaysClass.getPlayDetailsById(2); string actualPlayName = dataSet.Tables[0].Rows[0]["Name"].ToString(); int actualPlaylength = int.Parse(dataSet.Tables[0].Rows[0]["Length"].ToString()); string expectedPlayName = "Play1Edited"; int expectedPlayLength = 91; Assert.AreEqual(expectedPlayName, actualPlayName); Assert.AreEqual(expectedPlayLength, actualPlaylength); }
private void EditPlay_button_Click(object sender, RoutedEventArgs e) { if (Play_EditDelPlay_combo.Items.Count == 0) { MessageBox.Show("Please enter a Play to search for"); } else { KeyValuePair <int, string> test = (KeyValuePair <int, string>) this.Play_EditDelPlay_combo.SelectedValue; int playId = int.Parse((test.Key).ToString()); string playLengthToBeChecked = this.Length_EditDelPlay_txt.Text.ToString(); if (playLengthToBeChecked.Length == 0) { MessageBox.Show("Please enter a play length"); } else { playLengthToBeChecked = ValidationClass.IntChecker(playLengthToBeChecked); if (playLengthToBeChecked != null) { MessageBox.Show(playLengthToBeChecked); } else { try { int playLengthToBeCheckedInt = int.Parse(Length_EditDelPlay_txt.Text.ToString()); if (playLengthToBeCheckedInt > 400) { MessageBox.Show("Play length too high - max length 400 minutes"); } else { int newPlayLength = int.Parse(this.Length_EditDelPlay_txt.Text); PlaysClass.editPlay(playId, this.PlayName_EditDelPlay_txt.Text, newPlayLength); this.Length_EditDelPlay_txt.Text = ""; this.Play_EditDelPlay_combo.Items.Clear(); this.PlayName_EditDelPlay_txt.Text = ""; MessageBox.Show("Play edited"); } } catch (Exception) { MessageBox.Show("Play length too high - max legth 400 minutes"); } } } } }
public void testAddPlay() { SqlClassBase.setUpDbForTesting(); PlaysClass.addPlay("Play1", 90); dataSet = PlaysClass.getPlayDetailsByName("Play1"); string actualPlayName = dataSet.Tables[0].Rows[0]["Name"].ToString(); int actualPlaylength = int.Parse(dataSet.Tables[0].Rows[0]["Length"].ToString()); string expectedPlayName = "Play1"; int expectedPlayLength = 90; Assert.AreEqual(expectedPlayName, actualPlayName); Assert.AreEqual(expectedPlayLength, actualPlaylength); }
public void testGetAllPlays() { dataSet = PlaysClass.getAllPlays(); string actualPlayNameRow0 = dataSet.Tables[0].Rows[0]["Name"].ToString(); int actualPlaylengthRow0 = int.Parse(dataSet.Tables[0].Rows[0]["Length"].ToString()); string actualPlayNameRow1 = dataSet.Tables[0].Rows[1]["Name"].ToString(); int actualPlaylengthRow1 = int.Parse(dataSet.Tables[0].Rows[1]["Length"].ToString()); string expectedPlayNameRow0 = "DeletedPlay"; int expectedPlayLengthRow0 = 0; string expectedPlayNameRow1 = "Play1Edited"; int expectedPlayLengthRow1 = 91; Assert.AreEqual(expectedPlayNameRow0, actualPlayNameRow0); Assert.AreEqual(expectedPlayLengthRow0, actualPlaylengthRow0); Assert.AreEqual(expectedPlayNameRow1, actualPlayNameRow1); Assert.AreEqual(expectedPlayLengthRow1, actualPlaylengthRow1); }
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"); } } } } } } } } }