void ShowButton_Click(object sender, EventArgs e, string showId) { Program app = Program.GetInstance(); ShowService showService = app.GetService <ShowService>("shows"); ReservationCreate reservationScreen = app.GetScreen <ReservationCreate>("reservationCreate"); // Get show and redirect to screen List <Show> shows = showService.GetShowsByMovie(movie); List <Show> list = shows.Where(i => i.startTime > DateTime.Now).OrderBy(i => i.startTime).ToList(); Show show = list[int.Parse(showId)]; reservationScreen.SetShow(show); app.ShowScreen(reservationScreen); }
public override void OnShow() { Program app = Program.GetInstance(); ChairService chairService = app.GetService <ChairService>("chairs"); RoomService roomService = app.GetService <RoomService>("rooms"); MovieService movieservice = app.GetService <MovieService>("movies"); ShowService showService = app.GetService <ShowService>("shows"); base.OnShow(); title.Text = movie.name; descriptionInput.Text = movie.description; durationLabel.Text = "Speeltijd " + movie.duration + " Minuten"; genreLabel.Text = "Genre " + movie.genre; imagePreview.Image = movie.GetImage(); // Clear grid container.Controls.Clear(); container.RowStyles.Clear(); container.ColumnStyles.Clear(); // Prepare list int rowCount = 15; int columnCount = 5; container.ColumnCount = columnCount; container.RowCount = rowCount; for (int i = 0; i < columnCount; i++) { container.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 100 / columnCount)); } for (int i = 0; i < rowCount; i++) { container.RowStyles.Add(new RowStyle(SizeType.Percent, 100 / rowCount)); } // Build list List <Show> shows = showService.GetShowsByMovie(movie); List <Show> list = shows.Where(i => i.startTime > DateTime.Now).OrderBy(i => i.startTime).Take(rowCount * columnCount).ToList(); int rowIndex = 0; int columnIndex = 0; foreach (Show show in list) { Button button = new Button(); button.Text = show.startTime.ToString(Program.DATETIME_FORMAT); button.Name = "" + show.id; button.BackColor = Color.FromArgb(193, 193, 193); button.Dock = DockStyle.Fill; button.Click += (sender, e) => { ShowButton_Click(sender, e, show.id); }; container.Controls.Add(button, rowIndex, columnIndex); columnIndex += 1; if (columnIndex >= columnCount) { columnIndex = 0; rowIndex += 1; } } }
public override void OnShow() { base.OnShow(); Program app = Program.GetInstance(); ChairService chairService = app.GetService <ChairService>("chairs"); RoomService roomService = app.GetService <RoomService>("rooms"); MovieService movieservice = app.GetService <MovieService>("movies"); ShowService showService = app.GetService <ShowService>("shows"); title.Text = movie.name; descriptionInput.Text = movie.description; durationLabel.Text = "Speeltijd =" + movie.duration + " Minuten"; genreLabel.Text = "Genre = " + movie.genre; imagePreview.Image = movie.GetImage(); // Clear grid container.Controls.Clear(); container.RowStyles.Clear(); container.ColumnStyles.Clear(); // Print shows List <Show> shows = showService.GetShowsByMovie(movie); List <Show> list = shows.Where(i => i.startTime > DateTime.Now).OrderBy(i => i.startTime).ToList(); int maximum = list.Count; int rowCount = 15; int columnCount = 5; int showIndex = 0; container.ColumnCount = columnCount; container.RowCount = rowCount; for (int i = 0; i < columnCount; i++) { container.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 100 / columnCount)); } for (int i = 0; i < rowCount; i++) { container.RowStyles.Add(new RowStyle(SizeType.Percent, 100 / rowCount)); } for (int i = 0; i < rowCount && showIndex < list.Count; i++) { for (int j = 0; j < columnCount && showIndex < list.Count; j++) { Button button = new Button(); Show show = list[showIndex]; button.Text = show.startTime.ToString(Program.DATETIME_FORMAT); button.Name = "" + showIndex; button.Dock = DockStyle.Fill; button.Click += (sender, e) => { ShowButton_Click(sender, e, button.Name); }; container.Controls.Add(button, j, i); showIndex += 1; } } }