private void OpenSignupSheet(string filePath) { try { // Create the object and add to panel. DisplaySignupSheet display = new DisplaySignupSheet(this, filePath); AddDisplayToPanel(this.displayRegion.Panel1, display); // Write hint on the status bar. this.applicationStatus.Text = "Right click on the list to close it."; this.serverToolStripMenuItem.Enabled = true; } catch { // Not loaded. this.serverToolStripMenuItem.Enabled = false; // Only file problem can cause issue here, so all the exceptions are catched here. this.applicationStatus.Text = "Failed to open the file."; MessageBox.Show("There are unsupported strings in the file.", "Failed to open.", MessageBoxButtons.OK, MessageBoxIcon.Stop); } }
private void newSignupSheet_Click(object sender, EventArgs e) { DialogResult status; string filePath = ChooseFolder(); if(filePath.Length == 0) { return; } using(SignupSheetDetail details = new SignupSheetDetail()) { status = details.ShowDialog(); if(status == DialogResult.OK) { bool showNewSignupSheet = true; if(!IsUserListLoaded()) { status = MessageBox.Show("Please load a user list to continue.", "No user list loaded.", MessageBoxButtons.OKCancel, MessageBoxIcon.Question); if(status == DialogResult.OK) { this.openUserList.PerformClick(); } else { showNewSignupSheet = false; } } // Force save the user list. DisplayUserList userList = this.displayRegion.Panel2.Controls["display"] as DisplayUserList; userList.ForceSave(); if(showNewSignupSheet) { // Create a dummy signup sheet object. SignupSheet newSheet = new SignupSheet(); newSheet.SessionName = details.SessionName; newSheet.StartTime = details.StartTime; newSheet.EndTime = details.EndTime; // Import the users from the user list. BindingList<Entry> templateEntries = new BindingList<Entry>(); foreach(UserInfo user in userList.GetUsers()) { Entry newEntry = new Entry(); newEntry.Name = user.FirstName + ' ' + user.LastName; newEntry.Signed = false; templateEntries.Add(newEntry); } newSheet.Entries = templateEntries; // Create the object and add to panel. DisplaySignupSheet display = new DisplaySignupSheet(this, filePath, newSheet); AddDisplayToPanel(this.displayRegion.Panel1, display); // Write hint on the status bar. this.applicationStatus.Text = "Right click on the list to close it."; this.serverToolStripMenuItem.Enabled = true; } else { this.applicationStatus.Text = "Abort create new signup sheet."; this.applicationStatus.ForeColor = Color.Red; } } else { this.applicationStatus.Text = "Abort creation."; } } }