private void SaveButton_Click(object sender, EventArgs e) { if (string.IsNullOrWhiteSpace(nameTextBox.Text)) { MessageBox.Show("Must enter a name"); return; } if (issueData == null) { issueData = Database.NewItem <IssueData>(nameTextBox.Text, descriptionTextBox.Text); } issueData.Name = nameTextBox.Text; issueData.Description = descriptionTextBox.Text; issueData.DateAssigned = dateAssignedPicker.Value; issueData.DateRaised = dateRaisedPicker.Value; issueData.ActualCompletionDate = actualCompletitonDatePicker.Value; issueData.ExpectedCompletionDate = expectedCompletionDatePicker.Value; issueData.LastUpdateDate = DateTime.Now; issueData.Status = statusComboBox.Text; issueData.StatusDescription = statusDescriptionTextBox.Text; issueData.Priority = priorityComboBox.Text; issueData.Severity = severityComboBox.Text; issueData.ActionItems.Clear(); foreach (string ai in currentActionItemsListBox.Items) { issueData.AddActionItem(ai); } issueData.Decisions.Clear(); foreach (string ai in currentDecisionsListBox.Items) { issueData.AddDecision(ai); } Database.Save(); this.Close(); }
public NewIssue(IssueData issueData) { this.issueData = issueData; InitializeComponent(); this.AddSaveHandler(saveButton); this.AddCloseHandler(cancelButton); lastUpdatePicker.Value = DateTime.Now; if (issueData == null) { dateRaisedPicker.Value = DateTime.Now; } else { this.Text = "Update Issue"; idTextBox.Text = issueData.Id.ToString(); nameTextBox.Text = issueData.Name; priorityComboBox.Text = issueData.Priority; severityComboBox.Text = issueData.Severity; statusComboBox.Text = issueData.Status; statusDescriptionTextBox.Text = issueData.StatusDescription; descriptionTextBox.Text = issueData.Description; foreach (var res in issueData.ActionItems) { var item = Database.Instance.ActionItems.Where(x => x.Id == res).FirstOrDefault(); if (item != null) { currentActionItemsListBox.Items.Add(item.Name); } } foreach (var res in issueData.Decisions) { var item = Database.Instance.Decisions.Where(x => x.Id == res).FirstOrDefault(); if (item != null) { currentDecisionsListBox.Items.Add(item.Name); } } expectedCompletionDatePicker.Value = issueData.ExpectedCompletionDate; dateRaisedPicker.Value = issueData.DateRaised; dateAssignedPicker.Value = issueData.DateAssigned; actualCompletitonDatePicker.Value = issueData.ActualCompletionDate; lastUpdatePicker.Value = issueData.LastUpdateDate; } actionItemsListBox.Items.Clear(); foreach (string res in Database.Instance.ActionItems.Select(x => x.Name)) { actionItemsListBox.Items.Add(res); } decisionsListBox.Items.Clear(); foreach (string res in Database.Instance.Decisions.Select(x => x.Name)) { decisionsListBox.Items.Add(res); } }