private void ListItem_Click(object sender, EventArgs e) { Program app = Program.GetInstance(); ShowService showService = app.GetService <ShowService>("shows"); // Get the clicked item ListViewItem item = container.SelectedItems[0]; if (item == null) { GuiHelper.ShowError("Geen item geselecteerd"); return; } // Find the show int id = (int)item.Tag; Show show = showService.GetShowById(id); if (show == null) { GuiHelper.ShowError("Kon geen voorstelling vinden voor dit item"); return; } // Redirect to screen ShowDetail showDetail = app.GetScreen <ShowDetail>("showDetail"); showDetail.SetShow(show); app.ShowScreen(showDetail); }
private void SaveButton_Click(object sender, System.EventArgs e) { Program app = Program.GetInstance(); ShowService showService = app.GetService <ShowService>("shows"); // Parse values Movie movie = (Movie)movieInput.SelectedItem; Room room = (Room)roomInput.SelectedItem; if (movie == null) { GuiHelper.ShowError("Je moet een film kiezen"); return; } if (room == null) { GuiHelper.ShowError("Je moet een zaal kiezen"); return; } // Create and save show Show show = new Show(movie.id, room.id, datetimeInput.Value); if (!showService.SaveShow(show)) { GuiHelper.ShowError(ValidationHelper.GetErrorList(show)); return; } // Redirect to screen ShowDetail showDetail = app.GetScreen <ShowDetail>("showDetail"); showDetail.SetShow(show); app.ShowScreen(showDetail); GuiHelper.ShowInfo("Voorstelling succesvol aangemaakt"); }