示例#1
0
        void CategoryButtonClick(object sender, EventArgs e)
        {
            flPanelProd.Controls.Clear();

            Button btn = (Button)sender;

            int CategoryID = Convert.ToInt32(btn.Tag);

            ProduitDAO bd = new ProduitDAO();

            AllProduit = bd.FindToCat(CategoryID);



            foreach (Produit Product in AllProduit)
            {
                Button ProductButton = new Button();
                ProductButton.Text      = Product.Nom;
                ProductButton.Size      = new System.Drawing.Size(90, 90);
                ProductButton.ForeColor = Color.White;
                ProductButton.Cursor    = Cursors.Hand;
                ProductButton.Font      = new System.Drawing.Font(ProductButton.Font.Name, 10, FontStyle.Bold);

                MemoryStream ms = new MemoryStream(Product.Img);
                ProductButton.Image = Image.FromStream(ms);
                ProductButton.Image = new Bitmap(ProductButton.Image, ProductButton.Size);

                ProductButton.Tag = Product.Id;

                flPanelProd.Controls.Add(ProductButton);

                ProductButton.Click += ProductButton_Click;
                //ProductButton.MouseClick += ProductButton_MouseClick;
            }
        }
示例#2
0
        private void cbxCat_SelectedIndexChanged(object sender, EventArgs e)
        {
            dataGridView1.Rows.Clear();
            ProduitDAO pd = new ProduitDAO();

            produits = pd.FindAll();

            if (cbxCat.SelectedIndex == 0)
            {
                foreach (Produit ProductDetail in produits)
                {
                    dataGridView1.Rows.Add(ProductDetail.Id, ProductDetail.Nom, ProductDetail.Prix, ProductDetail.IdCat, ProductDetail.Description, ProductDetail.Img);
                }
            }
            else if (cbxCat.SelectedIndex > 0)
            {
                string       CategoryName = cbxCat.SelectedItem.ToString();
                CategorieDAO c            = new CategorieDAO();
                int          id           = c.ReturnCategorieID(CategoryName);
                ProduitDAO   pdao         = new ProduitDAO();
                produits = pdao.FindToCat(id);

                // int CategoryID = _DataAccess.ReturnCategoryID(CategoryName);

                foreach (Produit ProductDetail in produits)
                {
                    dataGridView1.Rows.Add(ProductDetail.Id, ProductDetail.Nom, ProductDetail.Prix, ProductDetail.IdCat, ProductDetail.Description, ProductDetail.Img);
                }
            }
        }