private void Back_Click(object sender, EventArgs e) { snacks.Clear(); Reserveerscherm3Stoelen nextForm = new Reserveerscherm3Stoelen(); this.Hide(); nextForm.ShowDialog(); this.Close(); }
private void Next_Click(object sender, EventArgs e) { List <string> dataList = new List <string>(); try { dbc.cnn.Open(); string selectQuery = "SELECT * FROM mydb.movies WHERE name = (SELECT name FROM mydb.movies WHERE idmovies = " + Program._ReservationSession.CurrentReservation.MovieId + ")"; MySqlCommand command = new MySqlCommand(selectQuery, dbc.cnn); MySqlDataReader dataReader = command.ExecuteReader(); while (dataReader.Read()) { string pegi = dataReader.GetString("pegi"); dataList.Add(pegi); } dbc.cnn.Close(); } catch (Exception) { throw; } finally { dbc.cnn.Close(); } int takenseats = 0; try { dbc.cnn.Open(); string selectQuery = $"SELECT * FROM mydb.seat WHERE idseat IN (SELECT seats_idseats FROM mydb.cinemahall WHERE movie_time_idmovie_time = (SELECT idmovie_time FROM mydb.movie_time WHERE movie_idmovie = '{Program._ReservationSession.CurrentReservation.MovieId}' AND date = '{Program._ReservationSession.CurrentReservation.date}' AND time_idtime = (SELECT idtime FROM mydb.time WHERE time = '{Program._ReservationSession.CurrentReservation.time}')))"; MySqlCommand command = new MySqlCommand(selectQuery, dbc.cnn); MySqlDataReader dataReader = command.ExecuteReader(); while (dataReader.Read()) { string seat = dataReader.GetString("seat"); takenseats++; } } catch (Exception) { throw; } finally { dbc.cnn.Close(); } addTickets(); System.Text.RegularExpressions.Regex regularExpression = new System.Text.RegularExpressions.Regex(@"^[0-6]$"); if (NormalField.Text == "" && ChildField.Text == "" && BoomerField.Text == "") { MessageBox.Show("Vul uw aantal tickets in AUB."); NormalField.Text = "0"; ChildField.Text = "0"; BoomerField.Text = "0"; } else if (NormalField.Text == "" || ChildField.Text == "" || BoomerField.Text == "") { NormalField.Text = "0"; ChildField.Text = "0"; BoomerField.Text = "0"; } else if (!regularExpression.IsMatch(NormalField.Text) || !regularExpression.IsMatch(ChildField.Text) || !regularExpression.IsMatch(BoomerField.Text)) { MessageBox.Show("Kies tussen 1 en 6 tickets."); } else if ((Convert.ToInt32(NormalField.Text) + Convert.ToInt32(ChildField.Text) + Convert.ToInt32(BoomerField.Text)) > 6 || (Convert.ToInt32(NormalField.Text) + Convert.ToInt32(ChildField.Text) + Convert.ToInt32(BoomerField.Text)) < 1) { MessageBox.Show("Kies tussen 1 en 6 tickets."); } else if (ChildField.Text != "0" && Convert.ToInt32(dataList[0]) > 12) { MessageBox.Show("Deze film is niet geschikt voor kinderen."); } else if ((takenseats + Program._ReservationSession.CurrentReservation.TicketAmount) >= 50) { MessageBox.Show($"Er zijn geen genoeg plekken. Voor deze film zijn er nog {50 - takenseats} over."); } else { Reserveerscherm3Stoelen nextForm = new Reserveerscherm3Stoelen(); this.Hide(); nextForm.ShowDialog(); this.Close(); } }