Exemplo n.º 1
0
 private void btn_new_Click(object sender, EventArgs e)
 {
     grid_data.DataSource    = controller.patient();//llamar metodo
     cb_choose.Visible       = false;
     txt_to.Visible          = false;
     tb_higger.Visible       = false;
     tb_lower.Visible        = false;
     tb_cadena.Visible       = false;
     cb_filter.Visible       = false;
     btn_search.Visible      = false;
     cb_filter.SelectedIndex = 0;
     cb_choose.Items.Clear();
     cb_choose.SelectedItem = "";
 }
Exemplo n.º 2
0
        private void tableLayoutPanel1_Paint(object sender, PaintEventArgs e)
        {
            string selected = cb_filter.SelectedItem.ToString();

            string[]       valuesC = controller.valuesC();
            string[]       valuesN = controller.valuesN();
            string[]       valuesB = controller.valuesB();
            List <Patient> patients;

            try
            {
                if (valuesC.Contains(selected))
                {
                    int id = int.Parse(tb_cadena.Text);
                    patients = controller.search(id);
                }
                else if (valuesN.Contains(selected))
                {
                    int lower  = Math.Abs(int.Parse(tb_lower.Text));
                    int higger = Math.Abs(int.Parse(tb_higger.Text));
                    if (higger < lower)
                    {
                        int aux = lower;
                        lower  = higger;
                        higger = aux;
                    }
                    tb_lower.Text  = lower.ToString();
                    tb_higger.Text = higger.ToString();

                    patients = controller.search(selected, lower, higger);
                }
                else if (valuesB.Contains(selected))
                {
                    int value = int.Parse(cb_choose.SelectedItem.ToString());
                    patients = controller.search(selected, value);
                }
                else
                {
                    patients = controller.patient();
                }
                gridPatients.loadGrid(patients);
            }
            catch (FormatException t)
            {
                Console.WriteLine(t.Message);
            }
        }
Exemplo n.º 3
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);
            }
        }