Esempio n. 1
0
        /// <summary>
        /// 验证控件 如果控件为空验证全部规则
        /// </summary>
        /// <param name="control">控件</param>
        /// <returns>验证成功返回true</returns>
        public bool ValidateControl(BaseEdit control)
        {
            ValidateRule rule = GetFirstValidateRule(control);

            if (rule != null)
            {
                if (rule.Message.IsNotEmpty())
                {
                    XtraMessageBoxHelper.ShowWarning(rule.Message);
                }
                if (rule.IsFocusControl)
                {
                    rule.Control.SelectAll();
                    rule.Control.Select();
                }
                return(false);
            }
            return(true);
        }
Esempio n. 2
0
        /// <summary>
        /// 删除方法
        /// </summary>
        public void DeleteMethod()
        {
            DeleteEventArgs beforeArgs = new DeleteEventArgs();

            SetEditEventArgs(beforeArgs);
            OnBeforeDelete(beforeArgs);
            if (!beforeArgs.IsSuccess)
            {
                return;
            }
            if (CurrentEntity == null)
            {
                return;
            }

            XtraMessageBoxHelper.ShowYesNoAndWarning(DeleteConfirmMessage, d =>
            {
                try
                {
                    if (!Grid.IsAutoDeleteChild && Grid.FocusedNode.HasChildren)
                    {
                        XtraMessageBoxHelper.ShowWarning("此节点有下级 不允许删除");
                        return;
                    }
                    Service.Delete(CurrentEntity);
                    Grid.Delete(Grid.GetSelected());

                    DeleteEventArgs afterArgs = new DeleteEventArgs();
                    SetEditEventArgs(afterArgs);
                    OnAfterDelete(afterArgs);
                    if (afterArgs.IsSuccess)
                    {
                        BindMethod(SelectedEntityCopy);
                        SetButtonStatus();
                    }
                }
                catch (Exception ex)
                {
                    XtraMessageBoxHelper.ShowError(ex.Message);
                }
            });
        }