private void butOK_Click(object sender, EventArgs e) { if (textDescription.Text.Trim() == "") { MsgBox.Show(this, "Description cannot be blank."); return; } if (textUnii.Text != "" && textMedication.Text != "") { MsgBox.Show(this, "Only one code is allowed per allergy def."); return; } string validChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; StringBuilder notAllowed = new StringBuilder(); for (int i = 0; i < textUnii.Text.Length; i++) { if (validChars.IndexOf(textUnii.Text[i]) == -1) //Not found. { notAllowed.Append(textUnii.Text[i]); } } if (notAllowed.ToString() != "") { MessageBox.Show(Lan.g(this, "UNII code has invalid characters: ") + notAllowed); return; } if (textUnii.Text != "" && textUnii.Text.Length != 10) { MsgBox.Show(this, "UNII code must be 10 characters in length."); return; } AllergyDefCur.Description = textDescription.Text; AllergyDefCur.IsHidden = checkHidden.Checked; AllergyDefCur.SnomedType = (SnomedAllergy)comboSnomedAllergyType.SelectedIndex; AllergyDefCur.UniiCode = textUnii.Text; //if(snomedAllergicTo!=null) { //TODO: Do UNII check once the table is added // AllergyDefCur.SnomedAllergyTo=snomedAllergicTo.SnomedCode; //} if (AllergyDefCur.IsNew) { AllergyDefs.Insert(AllergyDefCur); } else { AllergyDefs.Update(AllergyDefCur); } DialogResult = DialogResult.OK; }
private void butOK_Click(object sender, EventArgs e) { if (textDescription.Text.Trim() == "") { MsgBox.Show(this, "Description cannot be blank."); return; } AllergyDefCur.Description = textDescription.Text; AllergyDefCur.IsHidden = checkHidden.Checked; AllergyDefCur.Snomed = (SnomedAllergy)comboSnomedAllergyType.SelectedIndex; if (AllergyDefCur.IsNew) { AllergyDefs.Insert(AllergyDefCur); } else { AllergyDefs.Update(AllergyDefCur); } DialogResult = DialogResult.OK; }