private void RaceDetailsToolStripMenuItemClick(object sender, EventArgs e) { if ( !CheckHaveDb()) return; var raceDetailsDialog = new RaceDetailsDialog(appController.CurrentRace); if (raceDetailsDialog.ShowDialog() != DialogResult.OK) { // OK - user wants to quit return; } // Create race object var race = new Race { Name = raceDetailsDialog.RaceName, Description = raceDetailsDialog.RaceDescritpion, Distance = raceDetailsDialog.RaceDistance, Date = raceDetailsDialog.RaceDate }; appController.UpdateCurrentRace( race ); SetTitle(); }
private void NewToolStripMenuItemClick( object sender, EventArgs e ) { // If we have a DB open, check if we want it to be closed first. if (! CheckWhatToDoIfHaveDbOpen() ) return; // 1. Get race details from user var raceDetailsDialog = new RaceDetailsDialog() { Icon = Icon, }; if ( raceDetailsDialog.ShowDialog() != DialogResult.OK ) { // OK - user wants to quit return; } // Create race object var race = new Race { Name = raceDetailsDialog.RaceName, Description = raceDetailsDialog.RaceDescritpion, Distance = raceDetailsDialog.RaceDistance, Date = raceDetailsDialog.RaceDate }; // 2. Get a filename for data storage from user. This also checks to see if the // file can be overwritten if it exists. var saveFileDlg = new SaveFileDialog { RestoreDirectory = true, Filter = "database files (*.dbs)|*.dbs|All files (*.*)|*.*", FileName = race.Name + ".dbs", Title = "Database file for the race data..." }; if ( saveFileDlg.ShowDialog() != DialogResult.OK ) { // OK - user wants to quit return; } // This will close the current DB and create a new one. appController.CreateNewRace( race, saveFileDlg.FileName ); SetTitle(); }