I've got a test going on right now and will last 30 more minutes.
Edit: Forgot to add that I'm using Microsoft Visual Studio 2010 (C#) - Sorry, my bad!
Also for the whole requirements: "User enters patient id and name then clicks the "Add Patient" button. The application saves the patient id and the name in two seperate arrays
and at the same time adds the id to the combo box. Once the patient record is added, the application should update the number of patients label to reflect the number of patients already in the system.
The application should not allow the user to add duplicate patients with the same ID. An appropriate message should be shown if the user tries to do that. Patient ID and name text boxes cannot be empty."
Bold: Things I haven't done. If you could help, that would be great!
I have to add the array below named: arrayID to the combobox
Requirements: "For the user to search for a patient, he has to select the patient from the combo box, and click the "Search" button. The application displays the details of the patient if found. If the user clicks "Search" without selecting a patient ID, an appropriate message should be displayed. If there are no patients, message should be displayed in Listbox."
Inputs are:
P01 for first ID and Sam for first name.
P02 for second ID and Jack for second name.
So on...
Search works with selecting the ID and getting the name.
Any help at all would be appreciated.
Thanks in advance.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57
|
const int MAX_VALUE = 5;
string[] arrayID = new string[MAX_VALUE];
string[] arrayName = new string[MAX_VALUE];
int count = 0;
public Form1()
{
InitializeComponent();
}
private void btnAddPatient_Click(object sender, EventArgs e)
{
if (count == MAX_VALUE)
{
MessageBox.Show("Error! No more space available.", "Alert");
return;
}
if (tbID.Text == "" || tbName.Text == "")
{
MessageBox.Show("Field(s) required!");
return;
}
string userID = tbID.Text;
string userName = tbName.Text;
arrayID[count] = userID;
arrayName[count] = userName;
count++;
tbID.Text = "";
tbName.Text = "";
tbNumOfPatients.Text = Convert.ToString(count);
}
private void btnShowPatients_Click(object sender, EventArgs e)
{
lbShowPatients.Items.Clear();
if (count == 0)
{
lbShowPatients.Items.Add("No details to show!");
return;
}
lbShowPatients.Items.Add("ID Name");
lbShowPatients.Items.Add("-- ----");
for (int i = 0; i < count; i++)
{
lbShowPatients.Items.Add(arrayID[i] + " " + arrayName[i]);
}
|