private void btnOk_Click(object sender, RoutedEventArgs e) { string adjText = txtAdjustment.Text.Trim(); if (adjText.StartsWith("+")) { adjText = adjText.Substring(1); } int tempValue; if (!Int32.TryParse(adjText, out tempValue)) { MessageBox.Show("Please enter a number for the adjustment.", "Invalid adjustment", MessageBoxButton.OK, MessageBoxImage.Warning); txtAdjustment.Focus(); return; } if (String.IsNullOrWhiteSpace(txtNote.Text)) { MessageBox.Show("Please enter a note.", "Invalid note", MessageBoxButton.OK, MessageBoxImage.Warning); txtNote.Focus(); return; } adjustment = new BasicAdjustment(tempValue, txtNote.Text); DialogResult = true; Close(); }
private void btnDelete_Click(object sender, RoutedEventArgs e) { BasicAdjustment adjustment = (lvMain.SelectedItem as BasicAdjustment); if (adjustment == null) { return; } if (MessageBox.Show("Are you sure you want to delete this adjustment?", "Delete adjustment?", MessageBoxButton.YesNo, MessageBoxImage.Question, MessageBoxResult.No) == MessageBoxResult.Yes) { List.Remove(adjustment); } }
public AddBasicAdjustmentWindow(BasicAdjustment adjustment) { this.originalAdjustment = adjustment; InitializeComponent(); this.Title = (adjustment == null ? "Add Adjustment" : "Edit Adjustment"); if (adjustment != null) { txtAdjustment.Text = adjustment.Modifier.ToString(); txtNote.Text = adjustment.Note; } }
private void EditSelectedItem() { BasicAdjustment adjustment = (lvMain.SelectedItem as BasicAdjustment); if (adjustment == null) { return; } AddBasicAdjustmentWindow window = new AddBasicAdjustmentWindow(adjustment); if (window.ShowDialog(Application.Current.MainWindow)) { adjustment.Modifier = window.Adjustment.Modifier; adjustment.Note = window.Adjustment.Note; } }