private void termin_SelectionChanged(object sender, SelectionChangedEventArgs e) { DataTable queryResult = new DataTable(); Manage.dbConTab("SELECT DISTINCT s.CZAS_ROZPOCZECIA " + "FROM WSI_CINEMA_SEANS s " + "JOIN WSI_CINEMA_REPERTUAR r ON(s.ID_REPERTUAR = r.ID_REPERTUAR) " + "WHERE s.ID_FILM = " + idFilm + " AND DATE_FORMAT(r.TERMIN,'%d.%m.%y') = " + "'" + termin.SelectedValue + "'").Fill(queryResult); czas.ItemsSource = queryResult.DefaultView; czas.DisplayMemberPath = queryResult.Columns[0].ToString(); czas.SelectedValuePath = queryResult.Columns[0].ToString(); reservedSeats.Clear(); resNow.Visibility = Visibility.Hidden; if (queryResult.Rows.Count == 1) { czas.SelectedIndex = 0; } }
public Reservation(string idUser, string idFilm) { InitializeComponent(); this.idUser = idUser; this.idFilm = idFilm; reservedSeats.Columns.Add("id", typeof(int)); DataTable queryResult = new DataTable(); Manage.dbConTab("SELECT DISTINCT DATE_FORMAT(r.TERMIN,'%d.%m.%y') " + "FROM WSI_CINEMA_SEANS s " + "JOIN WSI_CINEMA_REPERTUAR r ON(s.ID_REPERTUAR = r.ID_REPERTUAR) " + "WHERE s.ID_FILM = " + idFilm).Fill(queryResult); termin.ItemsSource = queryResult.DefaultView; termin.DisplayMemberPath = queryResult.Columns[0].ToString(); termin.SelectedValuePath = queryResult.Columns[0].ToString(); if (queryResult.Rows.Count == 1) { termin.SelectedIndex = 0; } }
private void drawHudIcons(WrapPanel panel, Action <object, RoutedEventArgs> action, string aButtCon, string query) { DataTable queryResult = new DataTable(); Manage.dbConTab(query).Fill(queryResult); panel.Children.Clear(); if (queryResult.Rows.Count == 0) { Label notFound = new Label(); notFound.Content = "Brak elementow do wyswietlenia"; notFound.FontSize = 32; panel.Children.Add(notFound); } else { drawIconsThread(panel, action, aButtCon, queryResult, 0, 4); drawIconsThread(panel, action, aButtCon, queryResult, 1, 4); drawIconsThread(panel, action, aButtCon, queryResult, 2, 4); drawIconsThread(panel, action, aButtCon, queryResult, 3, 4); } }
private void sala_SelectionChanged(object sender, SelectionChangedEventArgs e) { seatScheme.Children.Clear(); reservedSeats.Clear(); resNow.Visibility = Visibility.Hidden; if (sala.SelectedIndex != -1) { DataTable freeSeats = new DataTable(); DataTable takenSeats = new DataTable(); Manage.dbConTab( "SELECT ID_SIEDZENIE, NR_SIEDZENIE " + "FROM WSI_CINEMA_SIEDZENIE " + "WHERE NR_SALA = " + sala.SelectedValue + " " + "AND ID_SIEDZENIE NOT IN(" + "SELECT rez.ID_SIEDZENIE " + "FROM WSI_CINEMA_REZERWACJA rez " + "JOIN WSI_CINEMA_SEANS se ON(rez.ID_SEANS = se.ID_SEANS) " + "JOIN WSI_CINEMA_REPERTUAR rep ON(se.ID_REPERTUAR = rep.ID_REPERTUAR) " + "JOIN WSI_CINEMA_SIEDZENIE si ON(si.ID_SIEDZENIE = rez.ID_SIEDZENIE) " + "WHERE se.ID_FILM = " + idFilm + " AND DATE_FORMAT(rep.TERMIN,'%d.%m.%y') = '" + termin.SelectedValue + "' AND se.CZAS_ROZPOCZECIA = '" + czas.SelectedValue + "' AND rep.NR_SALA = " + sala.SelectedValue + ")" ).Fill(freeSeats); Manage.dbConTab("SELECT rez.ID_SIEDZENIE, si.NR_SIEDZENIE " + "FROM WSI_CINEMA_REZERWACJA rez " + "JOIN WSI_CINEMA_SEANS se ON(rez.ID_SEANS = se.ID_SEANS) " + "JOIN WSI_CINEMA_REPERTUAR rep ON(se.ID_REPERTUAR = rep.ID_REPERTUAR) " + "JOIN WSI_CINEMA_SIEDZENIE si ON(si.ID_SIEDZENIE = rez.ID_SIEDZENIE) " + "WHERE se.ID_FILM = " + idFilm + " AND DATE_FORMAT(rep.TERMIN,'%d.%m.%y') = '" + termin.SelectedValue + "' AND se.CZAS_ROZPOCZECIA = '" + czas.SelectedValue + "' AND rep.NR_SALA = " + sala.SelectedValue).Fill(takenSeats); int freeCreated = 0; int takenCreated = 0; WrapPanel line = null; const int LINE_LENGTH = 10; while (freeCreated < freeSeats.Rows.Count && takenCreated < takenSeats.Rows.Count) { if ((freeCreated + takenCreated) % LINE_LENGTH == 0) { seatScheme.Children.Add(line = new WrapPanel()); line.HorizontalAlignment = HorizontalAlignment.Center; } int FREE_SEATS_ID = Convert.ToInt32(freeSeats.Rows[freeCreated][1]); int TAKEN_SEATS_ID = Convert.ToInt32(takenSeats.Rows[takenCreated][1]); if (FREE_SEATS_ID < TAKEN_SEATS_ID) { int id = Convert.ToInt32(freeSeats.Rows[freeCreated][0]); int seatNumber = Convert.ToInt32(freeSeats.Rows[freeCreated][1]); line.Children.Add(new freeSeat(id, seatNumber, addReserv)); freeCreated++; } else { line.Children.Add(new takenSeat()); takenCreated++; } } while (freeCreated != freeSeats.Rows.Count) { if ((freeCreated + takenCreated) % LINE_LENGTH == 0) { seatScheme.Children.Add(line = new WrapPanel()); line.HorizontalAlignment = HorizontalAlignment.Center; } line.Children.Add(new freeSeat(Convert.ToInt32(freeSeats.Rows[freeCreated][0]), Convert.ToInt32(freeSeats.Rows[freeCreated++][1]), addReserv)); } while (takenCreated != takenSeats.Rows.Count) { if ((freeCreated + takenCreated) % LINE_LENGTH == 0) { seatScheme.Children.Add(line = new WrapPanel()); line.HorizontalAlignment = HorizontalAlignment.Center; } line.Children.Add(new takenSeat()); takenCreated++; } } }