Exemplo n.º 1
0
 public void DeleteRecord(Sale sale, Item item, SaleDetail saleDetail)
 {
     context.Sales.Detach(sale);
     context.SaleDetails.Detach(saleDetail);
     context.Sales.Attach(context.Sales.Single(c => c.SaleId == sale.SaleId));
     context.SaleDetails.Attach(context.SaleDetails.Single(sd => sd.SaleId == sale.SaleId && sd.ItemId == item.ItemId));
     context.SaleDetails.DeleteObject(saleDetail);
     context.SaveChanges();
 }
Exemplo n.º 2
0
 private void addToCart_Click(object sender, EventArgs e)
 {
     int itemId = (int)showItems.SelectedRows[0].Cells["ItemId"].Value;
     SaleDetail detail = new SaleDetail { SaleId = sale.SaleId, ItemId = itemId, Quantity = (int) quantityBox.Value };
     if (details.Exists(s => s.SaleId == detail.SaleId && s.ItemId == detail.ItemId))
     {
         details.Remove(details.Find(s => s.SaleId == detail.SaleId && s.ItemId == detail.ItemId));
     }
     details.Add(detail);
     refreshCartBinding();
 }
Exemplo n.º 3
0
 public void UpdateSale(Sale sale, Item item, SaleDetail detail)
 {
     Sale_Manager.UpdateRecord(sale, item, detail);
 }
Exemplo n.º 4
0
 public void DeleteDetailFromSale(Sale sale, Item item, SaleDetail detail)
 {
     sale.SaleTotal -= item.Cost * detail.Quantity;
     Sale_Manager.UpdateRecord(sale, item, detail); //Updates the total in the database
     Sale_Manager.DeleteRecord(sale, item, detail);
 }
Exemplo n.º 5
0
 public void UpdateRecord(SaleDetail record)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 6
0
 public void AddRecord(SaleDetail saleDetail)
 {
     TestContext context = new TestContext();
     context.SaleDetails.AddObject(saleDetail);
     context.SaveChanges();
 }
Exemplo n.º 7
0
 public void UpdateRecord(Sale sale, Item item, SaleDetail saleDetail)
 {
     context.Sales.Detach(sale);
     context.SaleDetails.Detach(saleDetail);
     if (sale.EntityState == System.Data.EntityState.Detached)
     {
         context.Sales.Attach(context.Sales.Single(c => c.SaleId == sale.SaleId));
     }
     if (saleDetail.EntityState == System.Data.EntityState.Detached)
     {
       context.SaleDetails.Attach(context.SaleDetails.Single(sd => sd.SaleId == sale.SaleId && sd.ItemId == item.ItemId));
     }
     context.Sales.ApplyCurrentValues(sale);
     context.SaleDetails.ApplyCurrentValues(saleDetail);
     context.SaveChanges();
 }