Skip to content
David Kittell
David Kittell

Application & System: Development / Integration / Orchestration

  • Services
    • Application Development
    • Online Application Integration
  • Code
  • Online Tools
  • Tech Support
David Kittell

Application & System: Development / Integration / Orchestration

isValidMemberNum

Posted on February 21, 2013October 26, 2015 By David Kittell
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;
	}
Originally Posted on February 21, 2013
Last Updated on October 26, 2015
All information on this site is shared with the intention to help. Before any source code or program is ran on a production (non-development) system it is suggested you test it and fully understand what it is doing not just what it appears it is doing. I accept no responsibility for any damage you may do with this code.

Related

Code CSharp

Post navigation

Previous post
Next post

Related Posts

PHP – File Download

Posted on March 16, 2016

When WGET isn’t available PHP comes to the rescue. In this example $path file name can be different than the $url file name or the same, if it is different it will be saved with the file name in $path set_time_limit(0); //Unlimited max execution time $path = ‘filetodownload.txt’; $url =…

Read More

HTML5 Geolocation

Posted on November 5, 2013October 26, 2015

[raw] Click the button to get your coordinates: Try It [/raw] <!DOCTYPE html> <html> <body> <p id="demo">Click the button to get your coordinates:</p> <button onclick="getLocation()">Try It</button> <script> var x=document.getElementById("demo"); function getLocation() { if (navigator.geolocation) { navigator.geolocation.getCurrentPosition(showPosition); } else{x.innerHTML="Geolocation is not supported by this browser.";} } function showPosition(position) { x.innerHTML="Latitude: "…

Read More

C# GetData DataSet Function

Posted on May 21, 2015October 26, 2015

Great for populating just about anything you can databind. using System.Configuration; using System.Data.SqlClient; using System.Data; private DataSet GetData(string query) { SqlCommand cmd = new SqlCommand(query); using (SqlConnection con = new SqlConnection(connString)) { using (SqlDataAdapter sda = new SqlDataAdapter()) { cmd.Connection = con; sda.SelectCommand = cmd; using (DataSet ds = new…

Read More

Code

Top Posts & Pages

  • PowerShell - Rename Pictures to Image Taken
  • Front Page
  • C# - Start/Stop/Restart Services
  • MacPorts / HomeBrew - Rip CD tracks from terminal
  • PowerShell - Show File Extensions

Recent Posts

  • Javascript – Digital Clock with Style
  • BASH – Web Ping Log
  • BASH – Picture / Video File Name Manipulation
  • Mac OSX Terminal – Create SSH Key
  • Bash – Rename Picture

Top Posts

  • PowerShell - Rename Pictures to Image Taken
  • C# - Start/Stop/Restart Services
  • MacPorts / HomeBrew - Rip CD tracks from terminal
  • PowerShell - Show File Extensions
  • SQLite - Auto-Increment / Auto Generate GUID
©2025 David Kittell | WordPress Theme by SuperbThemes