Exemple #1
0
        internal ChartValues <double> GetMassFromHistory(string id_user)
        {
            ChartValues <double> spam = new ChartValues <double>();

            using (SqlConnection sqlCon = new SqlConnection(StringConnection))
            {
                try
                {
                    sqlCon.Open();
                    SqlCommand command = new SqlCommand();
                    command.Connection  = sqlCon;
                    command.CommandText = @"Select Weight From History Where id_user = @id_user;";
                    command.Parameters.Add("@id_user", SqlDbType.Int);

                    command.Parameters["@id_user"].Value = id_user;
                    SqlDataReader info = command.ExecuteReader();
                    object        date = -1;
                    int           i    = 1;

                    while (info.Read())
                    {
                        date = info["Weight"];
                        if (i == 1)
                        {
                            spam.Add(Convert.ToDouble(date));
                            i++;
                        }
                        else if (spam.IndexOf(Convert.ToDouble(date)) == -1)
                        {
                            spam.Add(Convert.ToDouble(date));
                        }
                    }

                    return(spam);
                }
                catch (Exception e)
                {
                    return(spam);
                }
            }
        }