private void btnAddNewScreening_Click(object sender, RoutedEventArgs e) { DateTime?date = this.txtNewDate.SelectedDate; int? hour = this.txtNewHour.Value; int? minute = this.txtNewMinute.Value; if (date == null) { MessageBox.Show("You must choose date!", "Error", MessageBoxButton.OK, MessageBoxImage.Error); return; } if (hour == null) { MessageBox.Show("You must choose hour!", "Error", MessageBoxButton.OK, MessageBoxImage.Error); return; } else if (hour < 0 || 23 < hour) { MessageBox.Show("Hour must be between 0 and 23!", "Error", MessageBoxButton.OK, MessageBoxImage.Error); return; } if (minute == null) { MessageBox.Show("You must choose minute!", "Error", MessageBoxButton.OK, MessageBoxImage.Error); return; } else if (minute < 0 || 59 < minute) { MessageBox.Show("Minute must be between 0 and 59!", "Error", MessageBoxButton.OK, MessageBoxImage.Error); return; } DateTime finalDateTime = date.Value.AddHours((double)hour); finalDateTime = finalDateTime.AddMinutes((double)minute); float price = 0; if (!float.TryParse(this.txtNewPrice.Text, out price)) { MessageBox.Show("Price must be a number!", "Error", MessageBoxButton.OK, MessageBoxImage.Error); return; } Schedule schedule = new Schedule(finalDateTime, price, int.Parse(this.txtId.Text)); if (AdminQuery.AddScreening(schedule)) { MessageBox.Show("You successfully added new screening to the movie.", "Information", MessageBoxButton.OK, MessageBoxImage.Information); this.schedulePanel.Children.Clear(); this.ClearInsertScheduleContainer(); this.insertScheduleContainer.Visibility = Visibility.Hidden; this.btnBookPlace_Click(sender, e); } }