コード例 #1
0
        /// <summary>
        /// 根据当前实体的状态控制工具拦的状态。
        /// </summary>
        protected virtual void OnToolsButtonValidate()
        {
            if (!_BindingSource.CheckExistsCurrentItem())
            {
                return;
            }

            object entity = _BindingSource.Current;

            if (entity is DataRow)
            {
                throw new MB.Util.APPException("目前框架的实现还不支持DataRow 的绑定编辑处理。");
            }

            bntMoveFirstItem.Enabled    = !_MainBindingGridView.IsFirstRow; // _BindingSource.Position > 0;
            bntMovePreviousItem.Enabled = !_MainBindingGridView.IsFirstRow; // _BindingSource.Position > 0;
            bntMoveLastItem.Enabled     = !_MainBindingGridView.IsLastRow;  // _BindingSource.Position < _BindingSource.Count - 1;
            bntMoveNextItem.Enabled     = !_MainBindingGridView.IsLastRow;  // _BindingSource.Position < _BindingSource.Count - 1;
            // bntPositionItem.Text = _MainBindingGridView.FocusedRowHandle.ToString();// (_BindingSource.Position + 1).ToString();
            bntPositionItem.Text = string.Format("{0}/{1}", _MainBindingGridView.FocusedRowHandle + 1, _MainBindingGridView.RowCount);

            MB.WinBase.Common.ObjectState objectState = MB.WinBase.UIDataEditHelper.Instance.GetObjectState(entity);
            bntAddNewItem.Enabled       = notRejectCommand(UICommandType.AddNew) && true && this.CurrentEditType != ObjectEditType.OpenReadOnly;
            bntCancelItem.Enabled       = ((objectState == ObjectState.New && _BindingSource.Count > 1) || objectState == ObjectState.Modified);
            bntDeleteItem.Enabled       = notRejectCommand(UICommandType.Delete) && (objectState == ObjectState.Modified || objectState == ObjectState.Unchanged) && _BindingSource.Count > 1 && this.CurrentEditType != ObjectEditType.OpenReadOnly;
            bntSaveItem.Enabled         = notRejectCommand(UICommandType.Save) && (objectState == ObjectState.New || objectState == ObjectState.Modified);
            bntSubmitItem.Enabled       = notRejectCommand(UICommandType.Submit) && (objectState == ObjectState.Unchanged);
            bntCancelSubmitItem.Enabled = notRejectCommand(UICommandType.CancelSubmit) && objectState == ObjectState.Validated;

            //根据实体对象的状态变化设置相应的信息.
            MB.Util.Model.EntityState entityState = MB.WinBase.UIDataEditHelper.Instance.GetEntityState(entity);

            //判断是否存在单据状态属性
            bool exists = MB.WinBase.UIDataEditHelper.Instance.CheckExistsDocState(entity);

            if (exists)
            {
                MB.Util.Model.DocState docState = MB.WinBase.UIDataEditHelper.Instance.GetEntityDocState(entity);
                MB.WinBase.Binding.BindingSourceHelper.Instance.SetCtlReadOnly(_EditColumnCtlBinding, docState != MB.Util.Model.DocState.Progress);

                OnDocStateChanged(_BindingSource.Current, docState);
            }
            else
            {
                bntSubmitItem.Enabled       = false;
                bntCancelSubmitItem.Enabled = false;
            }
            MB.WinBase.Binding.BindingSourceHelper.Instance.SetCtlByAllowEditStates(_EditColumnCtlBinding, entityState);

            //根据模块的需要重新初始化操作菜单项。
            refreshFormatButtonItem();
        }
コード例 #2
0
        /// <summary>
        /// 根据当前实体的状态控制工具拦的状态。
        /// </summary>
        protected virtual void OnToolsButtonValidate()
        {
            if (!_MainGridBindingSource.CheckExistsCurrentItem())
            {
                return;
            }

            object entity = _EditBindingSource.Current;

            if (entity is DataRow)
            {
                throw new MB.Util.APPException("目前框架的实现还不支持DataRow 的绑定编辑处理。");
            }

            bntMoveFirstItem.Enabled    = _MainBindingGridView != null && !_MainBindingGridView.IsFirstRow;
            bntMovePreviousItem.Enabled = _MainBindingGridView != null && !_MainBindingGridView.IsFirstRow;
            bntMoveLastItem.Enabled     = _MainBindingGridView != null && !_MainBindingGridView.IsLastRow;
            bntMoveNextItem.Enabled     = _MainBindingGridView != null && !_MainBindingGridView.IsLastRow;
            if (_MainBindingGridView != null)
            {
                bntPositionItem.Caption = string.Format("{0}/{1}", _MainBindingGridView.FocusedRowHandle + 1, _MainBindingGridView.RowCount);
            }

            MB.WinBase.Common.ObjectState objectState = MB.WinBase.UIDataEditHelper.Instance.GetObjectState(entity);
            bntAddNewItem.Enabled = true && this.CurrentEditType != ObjectEditType.OpenReadOnly;
            //判断是否为扩展的操作类型
            bool isExtendDocState = objectState == ObjectState.OverDocState;

            bntDeleteItem.Enabled = !isExtendDocState && (objectState == ObjectState.Modified || objectState == ObjectState.Unchanged) &&
                                    _MainGridBindingSource.Count > 1 && this.CurrentEditType != ObjectEditType.OpenReadOnly;
            bntSaveItem.Enabled         = !isExtendDocState && (objectState == ObjectState.New || objectState == ObjectState.Modified);
            bntSubmitItem.Enabled       = !isExtendDocState && (objectState == ObjectState.Unchanged);
            bntCancelSubmitItem.Enabled = !isExtendDocState && objectState == ObjectState.Validated;

            _BusinessOperateTrace.ResetDocEntity(entity);

            //根据实体对象的状态变化设置相应的信息.
            MB.Util.Model.EntityState entityState = MB.WinBase.UIDataEditHelper.Instance.GetEntityState(entity);

            //判断是否存在单据状态属性
            bool exists = MB.WinBase.UIDataEditHelper.Instance.CheckExistsDocState(entity);

            if (exists)
            {
                MB.Util.Model.DocState docState = MB.WinBase.UIDataEditHelper.Instance.GetEntityDocState(entity);
                if (bntDeleteItem.Enabled)
                {
                    //只有在录入中的数据才可以进行删除
                    bntDeleteItem.Enabled = docState == MB.Util.Model.DocState.Progress;
                }
                MB.WinBase.Binding.BindingSourceHelper.Instance.SetCtlReadOnly(_EditColumnCtlBinding, docState != MB.Util.Model.DocState.Progress);

                OnDocStateChanged(_EditBindingSource.Current, docState);
            }
            else
            {
                bntSubmitItem.Enabled       = false;
                bntCancelSubmitItem.Enabled = false;
            }
            MB.WinBase.Binding.BindingSourceHelper.Instance.SetCtlByAllowEditStates(_EditColumnCtlBinding, entityState);
            //设置当前编辑Form 为只读属性
            if (_CurrentEditType == ObjectEditType.OpenReadOnly)
            {
                MB.WinBase.Binding.BindingSourceHelper.Instance.SetCtlReadOnly(_EditColumnCtlBinding, true);
            }
            //根据模块的需要重新初始化操作菜单项。
            OnAfterRefreshButtonItem();
        }