private void butDelete_Click(object sender, EventArgs e) { if (IsNew) { DialogResult = DialogResult.Cancel; //delete takes place in FormClosing } else { AutomationConditions.DeleteByAutomationNum(AutoCur.AutomationNum); Automations.Delete(AutoCur); DialogResult = DialogResult.OK; } }
private void FormAutomationEdit_FormClosing(object sender, FormClosingEventArgs e) { if (DialogResult == DialogResult.OK) { return; } //this happens if cancel or if user deletes a new automation if (IsNew) { AutomationConditions.DeleteByAutomationNum(AutoCur.AutomationNum); Automations.Delete(AutoCur); } }
private void butDelete_Click(object sender, EventArgs e) { //if(IsNew){ // // return; //} AutomationConditions.DeleteByAutomationNum(AutoCur.AutomationNum); Automations.Delete(AutoCur); if (IsNew) { DialogResult = DialogResult.Cancel; } else { DialogResult = DialogResult.OK; } }