protected bool isValidMemberNum(string memNum, int nOption) { bool isValidMemNum = false; int nRunDBLookup = 0; if (memNum.Length != 11) { isValidMemNum = false; } else { /* * nOption is to define whether Medicare, Medicaid, Regular, or no preference * 0 = No Preference * 1 = Medicare */ if (nOption == 1) { if (memNum.Contains('A') || memNum.Contains('B') || memNum.Contains('C') || memNum.Contains('D')) { nRunDBLookup = 1; } } else if (nOption == 0) { nRunDBLookup = 1; } if (nRunDBLookup == 1) { try { string strSql = "SELECT * FROM AmisysUser WHERE MemberNo = '" + memNum + "'"; SqlConnection sqlConn = new SqlConnection(); sqlConn.ConnectionString = connString; sqlConn.Open(); SqlCommand sqlCommand = new SqlCommand(); sqlCommand.Connection = sqlConn; sqlCommand.CommandText = strSql; using (SqlDataReader dr = sqlCommand.ExecuteReader()) { if (dr.HasRows) { isValidMemNum = true; } else { isValidMemNum = false; } } } catch (Exception isvaliderror) { Response.Write("ISVALID Error"); } } } return isValidMemNum; }
Last Updated on October 26, 2015