private void ComboDocNo_TextChanged(object sender, EventArgs e) { FormatBtnUpdate(); FormatBtnDelete(); // Loading data into the form: try { using (DBAuditDataContext dc = new DBAuditDataContext()) { if (ComboDocNo.Text != "") { string StrDocNo = null; DateTime?VarDatePay = null; int? IntLocationID = null; int? IntEmployeeID = null; string StrLocation = null; string StrEmployee = null; string StrPerson = null; decimal? decimalAmount = null; string StrDesc = null; string StrNotes = null; var c = dc.ProSelectCure(ComboDocNo.Text, ref StrDocNo, ref IntEmployeeID, ref IntLocationID, ref StrPerson, ref decimalAmount, ref VarDatePay, ref StrDesc, ref StrNotes); TxtDocNo.Text = StrDocNo; if (VarDatePay != null) { DatePayDate.Value = VarDatePay.Value; } var d = dc.ProGetLocationByID(IntLocationID, ref StrLocation); ComboLocation.Text = StrLocation; var x = dc.ProGetEmployeeByID(IntEmployeeID, ref StrEmployee); ComboName.Text = StrEmployee; TxtPerson.Text = StrPerson; TxtAmount.Text = decimalAmount.ToString(); TxtDesc.Text = StrDesc; TxtNotes.Text = StrNotes; } else { TxtDocNo.Text = ""; TxtPerson.Text = ""; ComboLocation.Text = ""; TxtAmount.Text = ""; TxtDesc.Text = ""; TxtNotes.Text = ""; } } } catch (NullReferenceException) { BtnDelete.Enabled = false; } catch (InvalidOperationException) { BtnDelete.Enabled = false; } catch (Exception EX) { MessageBox.Show(EX.Message); } }