S
SafwanGR
Guest
this is the full code
namespace POS
{
public partial class frmpos : Form
{
CoffeeShopDatabaseEntities1 csde = new CoffeeShopDatabaseEntities1();
BindingList<TblProduct> products = new BindingList<TblProduct>();
public frmpos()
{
InitializeComponent();
dgvProductsChosen.DataSource = products;
CreateTabbedPanel();
AddProductsToTabbedPanel();
}
private void AddProductsToTabbedPanel()
{
int i = 1;
tabControl1.SizeMode = TabSizeMode.Fixed;
tabControl1.ItemSize = new Size(100, 75);
foreach (TabPage tp in tabControl1.TabPages)
{
ObjectQuery<TblProduct> filteredProduct = new ObjectQuery<TblProduct>("SELECT VALUE P FROM TblProducts AS P Where P.ProductType = " + i.ToString(),csde);
FlowLayoutPanel flp = new FlowLayoutPanel();
flp.Dock = DockStyle.Fill;
foreach (TblProduct tprod in filteredProduct)
{
Button b = new Button();
b.Size = new Size(90, 90);
b.Text = tprod.Description;
b.Tag = tprod;
b.Click += new EventHandler(UpdateProductDataGridView);
flp.Controls.Add(b);
}
tp.Controls.Add(flp);
i++;
}
}
private void CreateTabbedPanel()
{
foreach (TblProductType pt in csde.TblProductTypes)
{
tabControl1.TabPages.Add(pt.ProductType.ToString(), pt.Description);
}
}
void UpdateProductDataGridView(object sender, EventArgs e)
{
Button b = (Button)sender;
TblProduct p = (TblProduct)b.Tag;
products.Add(p);
}
}
}
This is windows Forms application and I have datagridview on it, in this datagridview I need to group all Same Items together and count it.
My datagridview now looks like as this photo;

Continue reading...
namespace POS
{
public partial class frmpos : Form
{
CoffeeShopDatabaseEntities1 csde = new CoffeeShopDatabaseEntities1();
BindingList<TblProduct> products = new BindingList<TblProduct>();
public frmpos()
{
InitializeComponent();
dgvProductsChosen.DataSource = products;
CreateTabbedPanel();
AddProductsToTabbedPanel();
}
private void AddProductsToTabbedPanel()
{
int i = 1;
tabControl1.SizeMode = TabSizeMode.Fixed;
tabControl1.ItemSize = new Size(100, 75);
foreach (TabPage tp in tabControl1.TabPages)
{
ObjectQuery<TblProduct> filteredProduct = new ObjectQuery<TblProduct>("SELECT VALUE P FROM TblProducts AS P Where P.ProductType = " + i.ToString(),csde);
FlowLayoutPanel flp = new FlowLayoutPanel();
flp.Dock = DockStyle.Fill;
foreach (TblProduct tprod in filteredProduct)
{
Button b = new Button();
b.Size = new Size(90, 90);
b.Text = tprod.Description;
b.Tag = tprod;
b.Click += new EventHandler(UpdateProductDataGridView);
flp.Controls.Add(b);
}
tp.Controls.Add(flp);
i++;
}
}
private void CreateTabbedPanel()
{
foreach (TblProductType pt in csde.TblProductTypes)
{
tabControl1.TabPages.Add(pt.ProductType.ToString(), pt.Description);
}
}
void UpdateProductDataGridView(object sender, EventArgs e)
{
Button b = (Button)sender;
TblProduct p = (TblProduct)b.Tag;
products.Add(p);
}
}
}
This is windows Forms application and I have datagridview on it, in this datagridview I need to group all Same Items together and count it.
My datagridview now looks like as this photo;

Continue reading...