Example #1
0
        private void btn_load_Click(object sender, EventArgs e)
        {
            file.Filter = "CSV|*.csv";
            List <Patient> patients = new List <Patient>();

            if (file.ShowDialog() == DialogResult.OK)
            {
                textBoxLoad1.Text = file.FileName;
                string path = file.FileName;
                textBoxLoad2.Text = file.SafeFileName;
                MessageBox.Show("Data loaded succesfully.");
                controller.loadGrid(path);
                patients = controller.patient();
                Console.WriteLine(patients.Count);
                gridPatiens.loadGrid(patients);
                filterOptions.cb_filterSetVisible(true);
                enableButtons(true);
                gridPatiens.enableExport();
            }
        }
        private void btn_add_Click(object sender, EventArgs e)
        {
            try
            {
                int age           = int.Parse(txt_age.Text);
                int sex           = cb_sex.SelectedIndex;
                int typePain      = cb_painType.SelectedIndex;
                int bloodPressure = int.Parse(txt_bloodPressure.Text);
                int cholesterol   = int.Parse(txt_colesterol.Text);
                int bloodSugar    = cb_bloodSugar.SelectedIndex;
                int electro       = cb_electroResults.SelectedIndex;
                int heartRate     = int.Parse(txt_maxHeart.Text);
                int angina        = cb_angina.SelectedIndex;

                if (age < 18 || age >= 130 || bloodPressure <= 30 || bloodPressure >= 260 || cholesterol <= 30 || cholesterol >= 700 || heartRate <= 60 || heartRate >= 280 ||
                    sex == -1 || typePain == -1 || bloodSugar == -1 || electro == -1 || angina == -1)
                {
                    throw new FormatException();
                }

                DialogResult result = MessageBox.Show("ARE YOU SURE YOU WANT TO ADD THAT PATIENT?", "Confirm add patient", MessageBoxButtons.YesNo);
                if (result == System.Windows.Forms.DialogResult.Yes)
                {
                    controller.add(age, sex, typePain, bloodPressure, cholesterol, bloodSugar, angina, electro, heartRate);
                    List <Patient> patients = controller.patient();
                    grid.loadGrid(patients);
                    clear();
                    grid.enableExport();
                    btnopt.enableButtons(true);
                    ft.cb_filterSetVisible(true);
                    this.Close();
                }
            }
            catch (NullReferenceException)
            {
                MessageBox.Show("Some values are Empty", " Values Empty", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            catch (FormatException)
            {
                MessageBox.Show("Some values are not valid", "Invalid Values", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }