private void butOk_Click(object sender, EventArgs e) { //validation if (EduResourceCur.DiseaseDefNum == 0 && EduResourceCur.MedicationNum == 0 && EduResourceCur.SmokingSnoMed == "" && textLabResultsID.Text == "" && textLabTestName.Text == "" && textCompareValue.Text == "") { MessageBox.Show("Please Select a valid problem, medication, or lab result."); return; } if (EduResourceCur.DiseaseDefNum == 0 && EduResourceCur.MedicationNum == 0 && EduResourceCur.SmokingSnoMed == "") { if (textLabTestName.Text == "") { MessageBox.Show("Invalid test name for lab result."); return; } if (textCompareValue.Text.Length < 2) { MessageBox.Show("Compare value must be comparator followed by a number. eg. \">120\"."); return; } if (textCompareValue.Text[0] != '<' && textCompareValue.Text[0] != '>') { MessageBox.Show("Compare value must begin with either \"<\" or \">\"."); return; } try { int.Parse(textCompareValue.Text.Substring(1)); } catch { MessageBox.Show("Compare value is not a valid number."); return; } } if (textUrl.Text == "") { MessageBox.Show("Please input a valid recource URL."); return; } //done validating EduResourceCur.LabResultID = textLabResultsID.Text; EduResourceCur.LabResultName = textLabTestName.Text; EduResourceCur.LabResultCompare = textCompareValue.Text; EduResourceCur.ResourceUrl = textUrl.Text; if (IsNew) { EduResources.Insert(EduResourceCur); } else { EduResources.Update(EduResourceCur); } DialogResult = DialogResult.OK; }