private void butOK_Click(object sender, EventArgs e) { if (textDate.errorProvider1.GetError(textDate) != "") { MessageBox.Show(this, "Please fix data entry errors first."); return; } int newerDays = PIn.Int(textDays.Text); if (newerDays > 3000) { MessageBox.Show(this, "Days must be less than 3000."); return; } _permCur.NewerDays = newerDays; _permCur.NewerDate = PIn.Date(textDate.Text); try{ if (_permCur.IsNew) { GroupPermissions.Insert(_permCur); } else { GroupPermissions.Update(_permCur); } } catch (Exception ex) { MessageBox.Show(ex.Message); return; } DialogResult = DialogResult.OK; }