private void btnFilter2_Click(object sender, EventArgs e) { amount = int.Parse(txtAmount.Text); ItemAccDAO iadao = new ItemAccDAO(); var items = iadao.SearchItemAcc(idacc, idprodia); items.Qnt = amount; iadao.Update(); idprodia = 0; txtAmount.Clear(); EntitiesContext context = new EntitiesContext(); var busca = from p in context.Products join ia in context.ItemAccs on p.Id equals ia.ProductId join a in context.Accounts on ia.AccountId equals a.Id join c in context.Clients on a.ClientId equals c.Id where ia.AccountId == idacc select new { productid = p.Id, productname = p.Name, qnt = ia.Qnt }; var source9 = new BindingSource(busca.ToList(), null); dgvAccount.DataSource = source9; dgvAccount.Columns[0].HeaderText = "Product ID"; dgvAccount.Columns[1].HeaderText = "Product Name"; dgvAccount.Columns[2].HeaderText = "Amount"; }
private void btnRemoveProd_Click(object sender, EventArgs e) { if (MetroMessageBox.Show(this, "Are you sure you want to delete this register?", "Delete", MessageBoxButtons.YesNo, MessageBoxIcon.Stop, MessageBoxDefaultButton.Button2) == DialogResult.Yes) { idprodia = int.Parse(dgvAccount.CurrentRow.Cells[0].Value.ToString()); ItemAccDAO iadao = new ItemAccDAO(); var items = iadao.SearchItemAcc(idacc, idprodia); iadao.Remove(items); EntitiesContext context = new EntitiesContext(); var busca = from p in context.Products join ia in context.ItemAccs on p.Id equals ia.ProductId join a in context.Accounts on ia.AccountId equals a.Id join c in context.Clients on a.ClientId equals c.Id where ia.AccountId == idacc select new { productid = p.Id, productname = p.Name, qnt = ia.Qnt }; var source9 = new BindingSource(busca.ToList(), null); dgvAccount.DataSource = source9; dgvAccount.Columns[0].HeaderText = "Product ID"; dgvAccount.Columns[1].HeaderText = "Product Name"; dgvAccount.Columns[2].HeaderText = "Amount"; } }