Exemplo n.º 1
0
        public override bool Save(IBusinessObject businessObject, BindingSourceNode bindingSourceNode, bool rebind)
        {
            Func <bool> preSaveCheck = () => PreSaveChecksOk(businessObject, bindingSourceNode.BindingSource);
            Action      saveAction   = () => ObjectBindingManager.SaveBO(businessObject, bindingSourceNode, rebind);

            return(Save(preSaveCheck, saveAction));
        }
Exemplo n.º 2
0
        private bool PreSaveChecksOk(object businessObject, BindingSource bindingSource)
        {
            if (!Enabled)
            {
                if (!TestMode)
                {
                    MessageBox.ShowInfo(SaveManagerMessages.SaveManagerDisabled,
                                        SaveManagerMessages.SaveManagerDisabledCaption);
                }
                return(false);
            }

            var stateAuthorization = businessObject as IObjectStateAuthorization;

            if (stateAuthorization != null)
            {
                if (!stateAuthorization.Authorization.AllowEdit())
                {
                    if (!TestMode)
                    {
                        MessageBox.ShowInfo(SaveManagerMessages.AllowEditFalse);
                    }
                    return(false);
                }
            }

            var trackStatus = businessObject as ITrackStatus;

            if (trackStatus != null)
            {
                ObjectBindingManager.EndEditBinding(bindingSource);
                if (!trackStatus.IsDirty)
                {
                    return(false);
                }

                if (!trackStatus.IsValid)
                {
                    if (!TestMode && ShowDataNotSavedErrorMessage)
                    {
                        MessageBox.ShowInfo(_dataNotSavedErrorMessage, SaveManagerMessages.DataNotSavedCaption);
                    }
                    return(false);
                }
            }

            if (!BusinessRules.HasPermission(AuthorizationActions.EditObject, businessObject))
            {
                MessageBox.ShowInfo(SaveManagerMessages.NotAuthorized);
                return(false);
            }

            return(true);
        }
Exemplo n.º 3
0
        public override void ValidateBO(IValidateBusiness businessObject, BindingSource bindingSource)
        {
            ObjectBindingManager.EndEditBinding(bindingSource);

            businessObject.Validate();
        }