コード例 #1
0
    // This method will allow us to display a record based on the patient's ward
    public Int32 PatientsInDataGridViewByWard(Int32 WardNoFilter)
    {
        //create an instance of the class clsPatientCollection
        clsPatientCollection MyPatients = new clsPatientCollection();

        //apply the method FindPatientByName to find the patients in the database
        MyPatients.FindPatientByWard(WardNoFilter);

        // apply the data table method to the gridview now and don't forget it is not a method as such it is a property
        PatientDataGridView.DataSource = MyPatients.Patients_DataTable;

        //Now Bind the data to the gridview
        PatientDataGridView.DataBind();

        // Make the the Gridview visible now
        PatientDataGridView.Visible = true;

        // variable to store the count of records in the object MyPatients
        Int32 recordCount = MyPatients.Count;

        // see the number of records found
        lblPatientMessage.Text = " There are " + recordCount + " Patient(s) found and they are sorted alphabetically by their Last Name.";

        //return the count of the records
        return(recordCount);
    }
コード例 #2
0
    // Method to filter all patients in the listbox based by their WardNo
    // given the WardNo is 0 , 1, 2.... as we will be using a ddlSelectedIndex value to identify the WardNo
    public Int32 ViewAllPatientsByWard(Int32 wardNoFilter)
    {
        //Declare the variables that will be visible in the list
        Int32    patientID;
        string   gender;
        string   firstName;
        string   lastName;
        DateTime dateOfBirth;
        DateTime dateAdmitted;
        DateTime dateDischarged;

        //The foreign keys in the tblPatient are WardNo and TreatmentId ..
        //Int32  WardNo;
        //Int32 TreatmentID;


        //create an instance of the class clsPatientCollection
        clsPatientCollection MyPatients = new clsPatientCollection();

        // apply the filter by the wardNo
        MyPatients.FindPatientByWard(wardNoFilter);

        // variable to store the count of records in the object MyPatients
        Int32 recordCount = MyPatients.Count;

        // variable to store the index for the loop
        Int32 index = 0;

        // clear any data off the list first
        lstPatients.Items.Clear();

        // loop while there are still some records to process
        while (index < recordCount)
        {
            patientID      = MyPatients.PatientList[index].PatientID;      // get the primary key of the patient
            gender         = MyPatients.PatientList[index].Gender;         //get the patient's gender
            firstName      = MyPatients.PatientList[index].FirstName;      //get the patient's firstname
            lastName       = MyPatients.PatientList[index].LastName;       //get the patient's LastName
            dateOfBirth    = MyPatients.PatientList[index].DateOfBirth;
            dateAdmitted   = MyPatients.PatientList[index].DateAdmitted;   // get the date admmited
            dateDischarged = MyPatients.PatientList[index].DateDischarged; // get the date discharged

            // create a new entry for the listbox in the UI
            ListItem newEntry = new ListItem(gender + "  " +
                                             firstName + "  " +
                                             lastName + "  " +
                                             dateOfBirth.ToString("dd/MM/yyyy") + " " +
                                             dateAdmitted + "  " +
                                             dateDischarged + "  ", patientID.ToString());

            // add the patients data collected from newEntry to the list
            lstPatients.Items.Add(newEntry);

            // move the index to the next record for the loop to continue
            index++;
        }

        // Tell the user how many records were found
        lblPatientMessage.Text = "There are  " + recordCount + " Patient(s) found and they are sorted alphabetically by their Last Name.";

        // return the count of the records found
        return(recordCount);
    }