private void B_UrunGetir(object sender, EventArgs e)
        {
            flowLayoutPanel2.Controls.Clear();
            List <ProductModel> products = HelperProduct.GetListByCategoryName((sender as Button).Text);
            int           urunsayi       = 0;
            List <string> temp3          = new List <string>();

            foreach (var item in products)
            {
                int stock = HelperStock.GetStockByProductID(item.productID);
                if (item.IsActive == true)
                {
                    if (item.discontinued == false)
                    {
                        if (item.stock > 0)
                        {
                            temp3.Add(item.productName);
                        }
                    }
                }
            }
            urunsayi = temp3.Count;
            for (int i = 0; i < urunsayi; i++)
            {
                urun             = new Button();
                urun.Size        = new Size(100, 50);
                urun.Text        = temp3[i];
                urun.BackColor   = Color.Cyan;
                urun.MouseEnter += Urun_Click;
                urun.MouseLeave += Urun_Click2;
                flowLayoutPanel2.Controls.Add(urun);
                urun.Click += Urun_SipariseEkle;
            }
        }
Exemplo n.º 2
0
        private void button1_Click(object sender, EventArgs e)
        {
            //Stok eklemek için ürün arama butonu
            dataGridView1.Rows.Clear();
            List <ProductModel> pm = new List <ProductModel>();

            if (comboBox1.SelectedIndex == 0)
            {
                pm = HelperProduct.GetListByProductname(textBox1.Text);
            }
            else if (comboBox1.SelectedIndex == 1)
            {
                pm = HelperProduct.GetListByCompanyName(textBox1.Text);
            }
            else if (comboBox1.SelectedIndex == 2)
            {
                pm = HelperProduct.GetListByCategoryName(textBox1.Text);
            }

            foreach (var item in pm)
            {
                if (item.IsActive == true)
                {
                    dataGridView1.Rows.Add(item.productID, item.productName, item.Supplier.companyName, item.category.categoryName, item.unitPrice, item.dateOfAdded, item.stringDiscounted);
                }
            }
            textBox1.Clear();
        }