public void DeleteObject() { if (_custodian != null) { custodiandetailbindingSource.EndEdit(); _custodian = (Custodian)custodiandetailbindingSource.DataSource; try { foreach (var p in _custodian.CustodianAsset.ToList()) { if (p.RecordId == 0) { _custodian.CustodianAsset.Remove(p); } else { _context.CustodianAssets.DeleteObject(p); } } _context.DeleteObject(_custodian); _context.SaveChanges(); Close(); } catch (Exception) { ViewHelper.ShowErrorMessage("Unable to delete the selected custodian!"); } } }
public void DeleteObject() { try { _context = new FixedAssetEntities(); var d = _context.Custodians.First(ct => ct.CustodianId == _Custodian.CustodianId); _context.DeleteObject(d); _context.SaveChanges(); RefreshList(); } catch (Exception) { throw; } }
public void DeleteObject() { try { _context = new FixedAssetEntities(); var d = _context.AssetCategories.First(ct => ct.CategoryId == _assetCategory.CategoryId); _context.DeleteObject(d); _context.SaveChanges(); RefreshList(); } catch (Exception exception) { ViewHelper.ShowErrorMessage("Unable to delete the selected category.", exception); } }
private void DeleteAsset() { var result = ViewHelper.ShowConfirmDialog("Are you sure you want to delete this asset?"); if (result == DialogResult.Yes) { try { _context.DeleteObject(_asset); _context.SaveChanges(); this.Close(); } catch (Exception) { ViewHelper.ShowDeleteError(); return; } } }
private void DeleteAsset() { var asset = GetSelectedItem(); if (asset != null) { var result = ViewHelper.ShowConfirmDialog("Are you sure you want to delete this asset?"); if (result == DialogResult.Yes) { try { AuthorizeForm(); _context.DeleteObject(asset); _context.SaveChanges(); RefreshList(); } catch (Exception exception) { ViewHelper.ShowErrorMessage("Error deleting asset.", exception); } } } }