private void butRun_Click(object sender, EventArgs e) { if (textDateStart.errorProvider1.GetError(textDateStart) != "" || textDateEnd.errorProvider1.GetError(textDateEnd) != "" || textDateStart.Text == "" || textDateEnd.Text == "" ) { MsgBox.Show(this, "Please enter a valid date range."); return; } if (comboEncCodes.SelectedIndex == -1 && textEncCodeValue.Text == "") { MsgBox.Show(this, "Please select a code."); return; } string codeValue; if (comboEncCodes.SelectedIndex == -1) { codeValue = textEncCodeValue.Text; } else { codeValue = comboEncCodes.SelectedItem.ToString(); } long encInserted = Encounters.InsertEncsFromProcDates(PIn.Date(textDateStart.Text), PIn.Date(textDateEnd.Text), codeValue, EncCodeSystem); MessageBox.Show(Lan.g("FormEncounterTool", "Number of encounters inserted:") + " " + encInserted.ToString()); if (PrefC.GetString(PrefName.CQMDefaultEncounterCodeValue) == "none") { if (MsgBox.Show(this, MsgBoxButtons.YesNo, "Do you want to set this code as the default encounter code?")) { Prefs.UpdateString(PrefName.CQMDefaultEncounterCodeValue, codeValue); Prefs.UpdateString(PrefName.CQMDefaultEncounterCodeSystem, EncCodeSystem); } } DialogResult = DialogResult.OK; }