private void butOK_Click(object sender, EventArgs e) { Icd9Cur.ICD9Code = textCode.Text; Icd9Cur.Description = textDescription.Text; if (IsNew) //Used the "+Add" button to open this form. { if (ICD9s.CodeExists(Icd9Cur.ICD9Code)) //Must enter a unique code. { MsgBox.Show(this, "You must choose a unique code."); return; } ICD9s.Insert(Icd9Cur); } else { ICD9s.Update(Icd9Cur); } DialogResult = DialogResult.OK; }