Exemple #1
0
        public static CoffeeEntite GetCoffeeByType(string coffeeType)
        {
            CoffeeEntite retour = new CoffeeEntite();
            string       query  = string.Format("SELECT * FROM coffee WHERE type LIKE '{0}'", coffeeType);

            try
            {
                conn.Open();
                command.CommandText = query;
                SqlDataReader reader = command.ExecuteReader();

                while (reader.Read())
                {
                    int    id    = reader.GetInt32(0);
                    string name  = reader.GetString(1);
                    string type  = reader.GetString(2);
                    double price = reader.GetDouble(3);

                    retour.Id    = id;
                    retour.Name  = name;
                    retour.Type  = type;
                    retour.Price = price;

                    //CoffeeEntite coffee = new CoffeeEntite(id, name, type, price);
                    //list.Add(coffee);
                }
            }
            finally
            {
                conn.Close();
            }

            return(retour);
        }
Exemple #2
0
        protected void ButtonObtenir_Click(object sender, EventArgs e)
        {
            //CoffeeEntite cafegui = LC_ENTTR.ConnectionClass.GetCoffeeByType("classic");

            CoffeeEntite cafegui = new CoffeeEntite();

            cafegui.Type = "classic";

            CoffeeEntite        retour1 = null;
            List <CoffeeEntite> retour  = null;

            LC_CDA.CoffeeCDA pourAppel = new LC_CDA.CoffeeCDA();
            //retour1 = pourAppel.ObtenirInfoCoffee(cafegui);
            retour = pourAppel.RechercherTP(cafegui);

            LabelID.Text    = retour[0].Id.ToString();
            LabelName.Text  = retour[0].Name;
            LabelType.Text  = retour[0].Type;
            LabelPrice.Text = retour[0].Price.ToString();

            //LabelID.Text = retour1.Id.ToString();
            //LabelName.Text = retour1.Name;
            //LabelType.Text = retour1.Type;
            //LabelPrice.Text = retour1.Price.ToString();
        }