Example #1
0
        private void btnaddProd_Click(object sender, EventArgs e)
        {
            prodacc = int.Parse(dgvItemMenu.CurrentRow.Cells[0].Value.ToString());
            ItemAccDAO iadao   = new ItemAccDAO();
            ItemAcc    itemacc = new ItemAcc()
            {
                ProductId = prodacc,
                AccountId = idacc,
                Qnt       = 1
            };

            iadao.Add(itemacc);

            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";
        }
Example #2
0
 public void Remove(ItemAcc itemacc)
 {
     context.ItemAccs.Remove(itemacc);
     context.SaveChanges();
 }
Example #3
0
 public void Add(ItemAcc itemacc)
 {
     context.ItemAccs.Add(itemacc);
     context.SaveChanges();
 }