private void SaveButton_Click(object sender, EventArgs e) { if (string.IsNullOrWhiteSpace(nameTextBox.Text)) { MessageBox.Show("Must enter a name"); return; } if (itemData == null) { itemData = Database.NewItem <ActionItemData>(nameTextBox.Text, descriptionTextBox.Text); } itemData.Name = nameTextBox.Text; itemData.Description = descriptionTextBox.Text; itemData.SetResource(selectedResource); itemData.ExpectedCompletionDate = expectedCompletion.Value; itemData.Status = statusComboBox.Text; itemData.StatusDescription = statusDescriptionTextBox.Text; Database.Save(); this.Close(); }
public AddActionItem(ActionItemData itemData) { InitializeComponent(); this.AddSaveHandler(saveButton); this.AddCloseHandler(cancelButton); if (itemData != null) { this.Text = "Update Action Item"; this.itemData = itemData; idTextBox.Text = itemData.Id.ToString(); nameTextBox.Text = itemData.Name; descriptionTextBox.Text = itemData.Description; selectedResource = Database.Instance.Resources.Where(x => x.Id == itemData.Resource).FirstOrDefault(); if (selectedResource != null) { CurrentResourceLabel.Text = selectedResource.Name; } if (!statusComboBox.Items.Contains(itemData.Status)) { statusComboBox.Items.Add(itemData.Status); } statusComboBox.SelectedItem = itemData.Status; expectedCompletion.Value = itemData.ExpectedCompletionDate; statusDescriptionTextBox.Text = itemData.StatusDescription; } else { statusComboBox.SelectedIndex = 0; } idTextBox.ReadOnly = true; idTextBox.Enabled = false; availableResourcesListBox.Items.Clear(); foreach (string res in Database.Instance.Resources.Select(x => x.Name)) { availableResourcesListBox.Items.Add(res); } }