Example #1
0
 //When a user clicks a selection from the dropdown box all the values of the selected patient will
 //populate the fields.
 private void Dropdown_1_SelectionChangeCommitted(object sender, EventArgs e)
 {
     Patient_Database.PatientSelectedConsultation1(Dropdown_1, Input_1, Input_2, Input_3,
                                                   Input_4, Input_5);
     Consultation_Database.PopulateConsultationDataGridView(Dropdown_1, Existing_Consultations); //Poplulates existing consultations if any
     Dropdown_2.Enabled = true;                                                                  //Allows user to choose time period
     if (Dropdown_2.SelectedIndex != -1)
     {
         Add_Consultation.Enabled = true;
     }
 }
Example #2
0
        //Deletes selected consultation
        private void Delete_Click(object sender, EventArgs e)
        {
            bool deleteSuccessful = Consultation_Database.DeleteConsultation(Dropdown_1, Existing_Consultations); //Deletes Consultation

            //If user chooses to cancel delete or there is no consultations to delete it stops the method
            if (deleteSuccessful == false)
            {
                return;
            }
            Consultation_Database.PopulateConsultationDataGridView(Dropdown_1, Existing_Consultations); //Refreshes existing consultations
        }
        //DDL for Consultation
        //    "CREATE TABLE [CONSULTATION]" +
        //    "(CONS_ID_Number TEXT NOT NULL PRIMARY KEY UNIQUE," +
        //    "PAT_ID_Number INT NOT NULL," +
        //    "CONS_Consultant TEXT NOT NULL," +
        //    "CONS_Time_Period TEXT NOT NULL," +
        //    "CONS_Date DATE NOT NULL," +
        //    "CONS_Health_Rating TEXT," +
        //    "CONS_Smoking_Status TEXT," +
        //    "CONS_Alcohol_Days NUMERIC," +
        //    "CONS_Alcohol_Drinks NUMERIC," +
        //    "CONS_Height NUMERIC," +
        //    "CONS_Weight NUMERIC," +
        //    "CONS_BMI NUMERIC," +
        //    "CONS_Waist NUMERIC," +
        //    "CONS_SBP NUMERIC," +
        //    "CONS_DBP NUMERIC," +
        //    "CONS_Body_Fat_Percentage NUMERIC," +
        //    "CONS_LBM NUMERIC," +
        //    "CONS_Visceral_Fat_Rating NUMERIC," +
        //    "CONS_CHO_TC NUMERIC," +
        //    "CONS_CHO_LDL NUMERIC," +
        //    "CONS_CHO_HDL NUMERIC," +
        //    "CONS_CHO_TG NUMERIC," +
        //    "CONS_Fasting_Glucose NUMERIC," +
        //    "CONS_HbA1c NUMERIC," +
        //    "CONS_Resistance INTEGER," +
        //    "CONS_Cardio INTEGER," +
        //    "CONS_Brisk_Walk INTEGER," +
        //    "CONS_Light_Activity INTEGER," +
        //    "CONS_Fruit_Serves NUMERIC," +
        //    "CONS_Fruit_Greater_2_Serves NUMERIC," +
        //    "CONS_Vegetable_Serves NUMERIC," +
        //    "CONS_Vegetable_Greater_5_Serves NUMERIC," +
        //    "CONS_Commercial_Meals INTEGER," +
        //    "CONS_Sweets INTEGER," +
        //    "CONS_Soft_Drinks INTEGER," +
        //    "CONS_Skip_Main_Meals INTEGER," +
        //    "CONS_Keep_Track_Of_Food INTEGER," +
        //    "CONS_Limit_Portions INTEGER," +
        //    "CONS_Eat_When_Upset INTEGER," +
        //    "CONS_Eat_In_Front_Of_TV INTEGER," +
        //    "CONS_Choose_Healthier_Foods INTEGER," +
        //    "CONS_Notes TEXT);";


        //********************Class Constructor********************

        public Add_Edit_Consultation_2()
        {
            InitializeComponent();
            Global.testConnection(this);                   //Tests database connection
            Date_1.Value   = DateTime.Now;                 //Sets Date to today
            UserLabel.Text = "Current User: "******" " + Global.userLastName;     //Sets user label

            //Shows existing consultations in the DGV
            Consultation_Database.PopulateConsultationDataGridView(Exisiting_Consultations);
            FillPatientDetails();                           //Sets pre fill details
        }
        //********************Database Event Methods********************

        //Saves changes to new patient or existing patient
        private void Save_Click(object sender, EventArgs e)
        {
            //All input boxes are read only when they can't be saved.
            //This will stop users from clicking save when not in edit mode
            if (Input_3.ReadOnly == true)
            {
                MessageBox.Show("Please click 'Edit Current' button to save changes", "Error",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            //Consultant must be chosen
            if (Dropdown_2.SelectedIndex == -1)
            {
                MessageBox.Show("Please choose a consultant", "Error",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            //Testing if only numbers were input
            if (TestNumbers() == false)
            {
                MessageBox.Show("All fields need to be numbers except for:\nHeath Rating,\nSmoking Status and\nNotes", "Error",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            //Saves Consultation to Database
            bool saveSuccessful = Consultation_Database.SaveConsultation(Input_1, Input_2, Input_3, Input_4, Input_5, Input_6, Input_7,
                                                                         Input_8, Input_9, Input_10, Input_11, Input_12, Input_13, Input_14, Input_15, Input_16,
                                                                         Input_17, Input_18, Input_19, Input_20, Input_21, Input_22, Input_23, Input_24, Input_25,
                                                                         Input_26, Input_27, Input_28, Input_29, Input_30, Input_31, Input_32, Input_33, Input_34,
                                                                         Input_35, Input_36, Input_37, Input_38, Date_1, Dropdown_1, Dropdown_2);

            //Triggered if user is promted that a record exists with the same time period and the user clicks cancel
            if (saveSuccessful == false)
            {
                return;
            }

            //Once consultation is saved the DGV is updated
            Consultation_Database.PopulateConsultationDataGridView(Exisiting_Consultations);

            AddOrEditFields(false);                 //Changes all fields to read only
            Edit_Consultation.Visible = true;       //Allows user to make edits if necessary
        }