private void Insert_Communications() { lblGlobal_Insert_Communications.ForeColor = System.Drawing.Color.ForestGreen; StringBuilder sb = new StringBuilder(); try { using (WACDataClassesDataContext wac = new WACDataClassesDataContext()) { string sAreaCode = null; if (!string.IsNullOrEmpty(tbCommunications_AreaCode.Text)) { sAreaCode = WACGlobal_Methods.Format_Global_PhoneNumber_StripToNumbers(tbCommunications_AreaCode.Text, WACGlobal_Methods.Enum_Number_Type.AREACODE); } else { sb.Append("Area Code is required. "); } if (string.IsNullOrEmpty(sAreaCode)) { sb.Append("Area Code not in correct format. "); } string sPhoneNumber = null; if (!string.IsNullOrEmpty(tbCommunications_PhoneNumber.Text)) { sPhoneNumber = WACGlobal_Methods.Format_Global_PhoneNumber_StripToNumbers(tbCommunications_PhoneNumber.Text, WACGlobal_Methods.Enum_Number_Type.PHONENUMBER); } else { sb.Append("Phone Number is required. "); } if (string.IsNullOrEmpty(sPhoneNumber)) { sb.Append("Phone Number not in correct format. "); } if (string.IsNullOrEmpty(sb.ToString())) { int?i = null; int iCode = wac.communication_add(sAreaCode, sPhoneNumber, Session["userName"].ToString(), ref i); if (iCode == 0) { tbCommunications_AreaCode.Text = ""; tbCommunications_PhoneNumber.Text = ""; lblGlobal_Insert_Communications.Text = "Successfully added Communication: " + WACGlobal_Methods.Format_Global_PhoneNumberSeparateAreaCode(sAreaCode, sPhoneNumber); } else { WACAlert.Show("Error Inserting Communication: ", iCode); } } else { WACAlert.Show(sb.ToString(), 0); } } } catch (Exception ex) { lblGlobal_Insert_Communications.ForeColor = System.Drawing.Color.Red; lblGlobal_Insert_Communications.Text = "Error Inserting Communication: " + ex.Message; } }