Пример #1
0
        // Вивести ОВОЧІ
        public static List <Vegetable> getVegetables()
        {
            List <Vegetable> list = new List <Vegetable>();

            try
            {
                MySqlCommand    command = new MySqlCommand("CALL select_vegetables", connect);
                MySqlDataReader reader  = command.ExecuteReader();
                while (reader.Read())
                {
                    Vegetable x = new Vegetable(reader.GetInt32(0), reader.GetString(1),
                                                reader.GetFloat(2), reader.GetFloat(3),
                                                reader.GetInt32(4));
                    x.setStoreName(reader.GetString(5));
                    list.Add(x);
                }
                reader.Close();
            }
            catch (MySql.Data.MySqlClient.MySqlException ex)
            {
                MessageBox.Show(ex.Message);
            }
            return(list);
        }