Ejemplo n.º 1
0
 private bool _isDeletable()
 {
     if (_ReadOnly)
     {
         return(false);
     }
     if (gridView.SelectedRowsCount != 1)
     {
         return(false);
     }
     if (ReferenceEquals(_bs, null))
     {
         return(true);
     }
     if (ReferenceEquals(_bs.Current, null))
     {
         return(true);
     }
     if (_bs.Current is IVocabularyElement)
     {
         IVocabularyElement voc = (IVocabularyElement)_bs.Current;
         if (voc.GetOccorrenze() > 0 || !voc.IsDeletable())
         {
             return(false);
         }
     }
     else if (_bs.Current is IPreventDelete)
     {
         if (!((IPreventDelete)_bs.Current).IsDeletable())
         {
             return(false);
         }
     }
     return(true);
 }
Ejemplo n.º 2
0
        protected void deleteRowGeneric <T>(object what) where T : class
        {
            if (gridView.SelectedRowsCount != 1)
            {
                return;
            }
            if (ReferenceEquals(null, what))
            {
                return;
            }
            if (what is IVocabularyElement)
            {
                IVocabularyElement voc = (IVocabularyElement)what;
                if (voc.GetOccorrenze() > 0 || !voc.IsDeletable())
                {
                    return;
                }
            }
            else if (_bs.Current is IPreventDelete)
            {
                if (!((IPreventDelete)_bs.Current).IsDeletable())
                {
                    return;
                }
            }
            _wes_BeforeRowDelete?.Raise(this, new RowDeleteEventArgs()
            {
                Data = what
            });

            // stop events for infinite getters recursion
            // SEventProxy.BlockModelEvents();
            _host.DataCtx.DeleteRowGeneric <T>(_propertyName, what as T);
            // SEventProxy.AllowModelEvents();

            RefreshGrid(0);
        }