Am building windows form application for a Hospital using VS2010 ON ACCESS 2010.
I want to create method that will generate a Patient :
public string GetCurrentDate()
{
DateTime currentDate = new DateTime();
string todaydate = currentDate.ToShortDateString().ToString();
return todaydate;
}
public Int32 MalePatient()
{
return 1;
}
public Int32 FemalePatient()
{
return 2;
}
public Int32 RadomNum()
{
Random randomNumer = new Random();
Int32 number = randomNumer.Next(0, 1000);
return number;
}
public string GeneratePatientNumber();
{
patientNumber = Convert.ToString(GetCurrentDate())"+ "-" ????
}
Number in this format:
"Date of Enrollment" + "PatientGender" +"randomNumber"
Example of Male patientNumber of type string:2012-1-10
Example of Female patientNumber of type string:2012-2-8
Female=2
Male=1
But I have a problem with the GeneratePatientNumber method which is supposed to convert the other method to a string and concatenate them as in the two samples above.
You would call it with
Be careful with the Random class. Each time you create a new instance, it will generate a seed value from the current date and time. This determines the first random number that is generated. If you call your
RanomNum()very fast several times then it might generate the same random number, because the internal clock in your PC has a limited resolution. This is why I declared it as a static member. This will only create_randomone single time.