Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7050111
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T03:06:13+00:00 2026-05-28T03:06:13+00:00

Am building windows form application for a Hospital using VS2010 ON ACCESS 2010. I

  • 0

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T03:06:14+00:00Added an answer on May 28, 2026 at 3:06 am
    public enum Gender
    {
        Male = 1,
        Female = 2
    }
    
    class PatientNumberGenerator
    {
        private static Random _random = new Random();
    
        public string GetCurrentDate()
        {
            return DateTime.Today.ToShortDateString();
        }
    
        public int RadomNum()
        {
            return _random.Next(0, 1000);
        }
    
        public string GeneratePatientNumber(Gender gender)
        {
            return GetCurrentDate() + "-" + (int)gender + "-" + RadomNum();
        }
    }
    

    You would call it with

    var generator = new PatientNumberGenerator();
    string patientNumber = generator.GeneratePatientNumber(Gender.Female);
    

    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 _random one single time.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm building a windows application that search items from sharepoint document libraries, using the
I am building a Windows form application using .NET 3.5. I would like to
I'm building an application that is targeting Windows, Mac and Linux soon. I was
I 'am building a small windows form application. I have a View - a
I am building a small windows form application in C#. Within the form code
I'm globalizing a Windows form application. Is there a way to access common text
See Title. .NET 2010 Express, building a C# Windows Form. Trying to enable Debug-and-edit,
I am building a windows forms application for a school that has a very
I'm building a web application that will automatically complete user forms online for many
I'm building a Windows Forms form in C# with various elements in a panel

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.