/// <summary> /// Handles when the text within the textbox changes. /// </summary> /// <param name="sender">The invoker of the event.</param> /// <param name="e">The event arguments.</param> private void RemoveButton_Clicked(object sender, EventArgs e) { string textToValidate = null; bool before = false, after = false, both = false; bool toReturn = false; switch (selectedOption) { case SelectedOption.Before: textToValidate = allBeforeTextBox.Text; before = true; break; case SelectedOption.After: textToValidate = allAfterTextBox.Text; after = true; break; case SelectedOption.Between: textToValidate = allBeforeTextBox.Text; textToValidate += "," + allAfterTextBox.Text; both = true; break; } if (validateText(textToValidate)) { DialogResult result = MessageBox.Show("Are you sure?", "Confirm Deletion", MessageBoxButtons.YesNo); if (result == DialogResult.Yes) { if (before) { DateTime dt = DateTime.Parse(textToValidate); if (dt != null) { toReturn = stageData.DeleteAllValuesBefore(dt); } } else if (after) { DateTime dt = DateTime.Parse(textToValidate); if (dt != null) { toReturn = stageData.DeleteAllValuesAfter(dt); } } else if (both) { DateTime f = DateTime.Parse(allBeforeTextBox.Text); DateTime s = DateTime.Parse(allAfterTextBox.Text); toReturn = stageData.DeleteAllValuesBetween(f, s); } } } if (toReturn) { DialogResult result = MessageBox.Show("Deletion Success!"); if (result == DialogResult.OK) { DataChanged(this, EventArgs.Empty); } } }