private void DeleteSelectedEquipment() { _context = new WmsEntities(); var eq = _context.Equipments.FirstOrDefault(e => e.EquipmentId == _equipment.EquipmentId); _context.DeleteObject(eq); _context.SaveChanges(); RefreshEquipmentList(); }
private void BtnDelete_Click(object sender, EventArgs ev) { DialogResult result = ViewHelper.ShowConfirmDialog("Are you sure you want to delete this equipment."); if (result == DialogResult.Yes) { _context = new WmsEntities(); var eq = _context.Equipments.FirstOrDefault(e => e.EquipmentId == _selectEquipment.EquipmentId); _context.DeleteObject(eq); _context.SaveChanges(); RefreshList(); } }
public void DeleteObject() { _context = new WmsEntities(); var eq = _context.Equipments.FirstOrDefault(e => e.EquipmentId == _equipment.EquipmentId); _context.DeleteObject(eq); _context.SaveChanges(); Close(); if (ContractDetailView != null) { ContractDetailView.RefreshEquipmentList(); } }
private void DeleteContract() { try { _context = new WmsEntities(); var d = _context.Contracts.First(ct => ct.ContractId == this._contract.ContractId); _context.DeleteObject(d); _context.SaveChanges(); RefreshList(); } catch (Exception) { throw; } }
public void DeleteObject() { try { _context = new WmsEntities(); var d = _context.Invoices.First(ct => ct.Id == _invoice.Id); _context.DeleteObject(d); _context.SaveChanges(); RefreshList(); } catch (Exception) { throw; } }
public void DeleteObject() { if (_invoice != null) { InvoicebindingSource.EndEdit(); _invoice = (Invoice)InvoicebindingSource.DataSource; try { foreach (var p in _invoice.MiscellaneousItem.ToList()) { if (p.MisPartId == 0) { _invoice.MiscellaneousItem.Remove(p); } else { _context.MiscellaneousItems.DeleteObject(p); } } foreach (var pr in _invoice.PaymentRecord.ToList()) { if (pr.PaymentId == 0) { _invoice.PaymentRecord.Remove(pr); } else { _context.PaymentRecords.DeleteObject(pr); } } _context.DeleteObject(_invoice); _context.SaveChanges(); Close(); } catch (Exception e) { ViewHelper.ShowDeleteError(); ErrorLogger.LogError(this, e); } } }