예제 #1
0
 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!");
         }
     }
 }
예제 #2
0
 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;
     }
 }
예제 #3
0
 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);
     }
 }
예제 #4
0
        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;
                }
            }
        }
예제 #5
0
        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);
                    }
                }
            }
        }