Esempio n. 1
0
 public DayForm(User user, HealthCard hc)
 {
     this.user = user;
     this.hc   = hc;
     CreateDay();
     list = createDaysList();
     InitializeComponent();
     labelDate.Text = DateTime.Now.Date.ToString();
 }
Esempio n. 2
0
        private double LevelOfActiveness(HealthCard hc)
        {
            double PAL = 0.0;

            switch (hc.ActLevel)
            {
            case "Sedentary: little or no exercise":
            {
                PAL = 1.2;
                break;
            }

            case "Light: exercise 1-3 times a week":
            {
                PAL = 1.3;
                break;
            }

            case "Moderate: exercise 4-5 times a week":
            {
                PAL = 1.4;
                break;
            }

            case "Active: daily exercise or intense exercise 3-4 times a week":
            {
                PAL = 1.5;
                break;
            }

            case "Very active: intense exercise 6-7 times a week":
            {
                PAL = 1.6;
                break;
            }

            case "Extra active: very intense exercise daily or physical job":
            {
                PAL = 1.7;
                break;
            }

            default:
            {
                PAL = 1.2;
                break;
            }
            }
            return(PAL);
        }
Esempio n. 3
0
 public BMI(HealthCard hc, User user)
 {
     InitializeComponent();
     this.user = user;
     if (hc.Height == 0 || hc.Weight == 0.0)
     {
         labelCustomBMI.Text = "";
         trackBar.Value      = 14;
     }
     else
     {
         double bmi1 = countBMI(hc.Height, hc.Weight);
         labelCustomBMI.Text = bmi1.ToString();
         trackBar.Value      = Convert.ToInt32(bmi1);
         colorResult(bmi1);
     }
 }
Esempio n. 4
0
        private void createHealthCard(HealthCard hc, DB db)
        {
            MySqlCommand com = new MySqlCommand("select `id` from `health_card` where id_person=@id", db.getConnection());

            com.Parameters.Add("@id", MySqlDbType.Int32).Value = user.Id;
            MySqlDataReader reader = com.ExecuteReader();

            while (reader.Read())
            {
                hc.Id = reader.GetInt32("id");
            }
            hc.BirthDate = datePick.Value;
            hc.Height    = int.Parse(fieldHeight.Text);
            hc.Weight    = double.Parse(fieldWeight.Text);
            hc.ActLevel  = comboBoxActLevel.SelectedItem.ToString();
            hc.IdPerson  = user.Id;
        }
Esempio n. 5
0
        private void updateHistory(HealthCard hc)
        {
            DB           db  = new DB();
            MySqlCommand com = new MySqlCommand("SELECT `id` FROM `updates_history` WHERE " +
                                                "`id_hc` = @uID_hc AND `update_date` = @uD", db.getConnection());

            com.Parameters.Add("@uID_hc", MySqlDbType.Int32).Value = hc.Id;
            com.Parameters.Add("@uD", MySqlDbType.DateTime).Value  = DateTime.Now.Date;
            db.openConnection();
            MySqlDataReader reader = com.ExecuteReader();

            if (reader.HasRows) // jesli istnieje juz aktualizacja tego dnia
            {
                int id = 0;
                while (reader.Read())
                {
                    id = reader.GetInt32("id");
                }

                db.closeConnection();
                MySqlCommand comUpdate = new MySqlCommand("UPDATE  updates_history" +
                                                          "  SET  weight = @uW, activ_level = @uAL WHERE id = @uID", db.getConnection());
                comUpdate.Parameters.Add("@uW", MySqlDbType.Double).Value   = hc.Weight;
                comUpdate.Parameters.Add("@uAL", MySqlDbType.VarChar).Value = hc.ActLevel;
                comUpdate.Parameters.Add("@uID", MySqlDbType.Int32).Value   = id;
                db.openConnection();
                comUpdate.ExecuteNonQuery();
                db.closeConnection();
            }
            else // nie ma aktualizacji w ten dzien w bazie danych
            {
                db.closeConnection();
                MySqlCommand comUpdate = new MySqlCommand("INSERT INTO `updates_history`" +
                                                          " (`update_date`, `weight`, `activ_level`, `id_hc`)" +
                                                          " VALUES (@uDate, @uW, @uAL, @uID)", db.getConnection());

                comUpdate.Parameters.Add("@uDate", MySqlDbType.DateTime).Value = DateTime.Now.Date;
                comUpdate.Parameters.Add("@uW", MySqlDbType.Double).Value      = hc.Weight;
                comUpdate.Parameters.Add("@uAL", MySqlDbType.VarChar).Value    = hc.ActLevel;
                comUpdate.Parameters.Add("@uID", MySqlDbType.Int32).Value      = hc.Id;
                db.openConnection();
                comUpdate.ExecuteNonQuery();
                db.closeConnection();
            }
        }