public override void DocumentKindChanged(Sungero.Docflow.Shared.OfficialDocumentDocumentKindChangedEventArgs e)
        {
            base.DocumentKindChanged(e);

            // Заполнить имя.
            Functions.OfficialDocument.FillName(_obj);
        }
        public override void DocumentKindChanged(Sungero.Docflow.Shared.OfficialDocumentDocumentKindChangedEventArgs e)
        {
            base.DocumentKindChanged(e);

            // Проставить корректно жизненный цикл для договора после смены типа.
            if (_obj.LifeCycleState == Docflow.OfficialDocument.LifeCycleState.Obsolete)
            {
                if (_obj.ExchangeState == Docflow.OfficialDocument.ExchangeState.Obsolete)
                {
                    _obj.LifeCycleState = ContractBase.LifeCycleState.Obsolete;
                }
                if (_obj.ExchangeState == Docflow.OfficialDocument.ExchangeState.Terminated)
                {
                    _obj.LifeCycleState = ContractBase.LifeCycleState.Terminated;
                }
            }
        }
Example #3
0
        public override void DocumentKindChanged(Sungero.Docflow.Shared.OfficialDocumentDocumentKindChangedEventArgs e)
        {
            base.DocumentKindChanged(e);

            if (e.NewValue != null && e.NewValue.NumberingType != Docflow.DocumentKind.NumberingType.NotNumerable)
            {
                if (_obj.BusinessUnit == null)
                {
                    _obj.BusinessUnit = Docflow.PublicFunctions.Module.GetDefaultBusinessUnit(Company.Employees.Current);
                }

                _obj.State.Properties.BusinessUnit.IsVisible = true;
                _obj.State.Properties.Department.IsVisible   = true;
            }
            else
            {
                _obj.State.Properties.BusinessUnit.IsVisible = false;
                _obj.State.Properties.Department.IsVisible   = false;
            }
        }
        public override void DocumentKindChanged(Sungero.Docflow.Shared.OfficialDocumentDocumentKindChangedEventArgs e)
        {
            base.DocumentKindChanged(e);

            var documentKind = e.NewValue;

            if (documentKind == null)
            {
                return;
            }

            // Очистить категорию, если она не соответствует виду документа.
            var availableCategory = Docflow.PublicFunctions.DocumentGroupBase.GetAvailableDocumentGroup(documentKind).Where(g => ContractCategories.Is(g));

            if (_obj.DocumentGroup != null && !availableCategory.Contains(_obj.DocumentGroup))
            {
                _obj.DocumentGroup = null;
            }

            // Заполнить категорию, если для выбранного вида доступна только одна.
            if (_obj.DocumentGroup == null && availableCategory.Count() == 1)
            {
                _obj.DocumentGroup = availableCategory.First();
            }

            // Проставить корректно жизненный цикл для договора после смены типа.
            if (_obj.LifeCycleState == Docflow.OfficialDocument.LifeCycleState.Obsolete)
            {
                if (_obj.ExchangeState == Docflow.OfficialDocument.ExchangeState.Obsolete)
                {
                    _obj.LifeCycleState = ContractBase.LifeCycleState.Obsolete;
                }
                if (_obj.ExchangeState == Docflow.OfficialDocument.ExchangeState.Terminated)
                {
                    _obj.LifeCycleState = ContractBase.LifeCycleState.Terminated;
                }
            }
        }
Example #5
0
 public override bool NeedClearProject(Sungero.Docflow.Shared.OfficialDocumentDocumentKindChangedEventArgs e)
 {
     return(false);
 }
        public virtual void DocumentKindChanged(Sungero.Docflow.Shared.OfficialDocumentDocumentKindChangedEventArgs e)
        {
            var paramName      = string.Format("doc{0}_ConvertingFrom", _obj.Id);
            var isTypeChanging = e.Params.Contains(paramName);

            if (isTypeChanging)
            {
                // Записать имя документа до смены типа в примечание, если:
                //   - имя уже заполнено;
                //   - новый вид документа с автоформированием имени;
                //   - предыдущий вид документа без автоформирования имени;
                //   - документ не находится на верификации.
                if (!string.IsNullOrWhiteSpace(_obj.Name) &&
                    e.NewValue != null && e.NewValue.GenerateDocumentName == true &&
                    (e.OriginalValue == null || e.OriginalValue.GenerateDocumentName != true) &&
                    _obj.VerificationState != OfficialDocument.VerificationState.InProcess)
                {
                    var nameBeforeChangingType = OfficialDocuments.Resources.DocumentNameBeforeChangingTypeNoteFormat(_obj.Name);
                    if (string.IsNullOrWhiteSpace(_obj.Subject))
                    {
                        _obj.Subject = _obj.Name;
                    }
                    else
                    {
                        _obj.Note = string.IsNullOrWhiteSpace(_obj.Note) ?
                                    nameBeforeChangingType :
                                    string.Format("{0}{1}{1}{2}", nameBeforeChangingType, Environment.NewLine, _obj.Note);
                    }
                }

                // Очистить имя документа, если:
                //   - новый вид документа без автоформирования имени;
                //   - предыдущий вид документа с автоформированием имени.
                if (e.NewValue != null && e.NewValue.GenerateDocumentName != true &&
                    e.OriginalValue != null && e.OriginalValue.GenerateDocumentName == true)
                {
                    _obj.Name    = _obj.Subject;
                    _obj.Subject = string.Empty;
                }

                // Сбросить жизненный цикл для действующего не нумеруемого документа.
                if (e.OriginalValue != null && e.OriginalValue.NumberingType == DocumentKind.NumberingType.NotNumerable &&
                    _obj.LifeCycleState == OfficialDocument.LifeCycleState.Active)
                {
                    _obj.LifeCycleState = LifeCycleState.Draft;
                }
            }

            // Если при смене типа документ находится на верификации, то номер и дату регистрации очищать не нужно.
            if (isTypeChanging && _obj.VerificationState != VerificationState.InProcess ||
                e.NewValue != null && e.NewValue.NumberingType == Docflow.DocumentKind.NumberingType.NotNumerable)
            {
                // Очистить свойства.
                _obj.RegistrationNumber = null;
                _obj.RegistrationDate   = null;
            }

            if (isTypeChanging || (e.NewValue != null && e.NewValue.NumberingType == Docflow.DocumentKind.NumberingType.NotNumerable))
            {
                _obj.DocumentRegister  = null;
                _obj.RegistrationState = RegistrationState.NotRegistered;

                // При смене типа документа сохранить значения полей Дело, Дата помещения в дело, Способ доставки.
                if (!isTypeChanging)
                {
                    _obj.DeliveryMethod       = null;
                    _obj.CaseFile             = null;
                    _obj.PlacedToCaseFileDate = null;
                }

                // Отменить необходимость, т.к. рег.данные очищены.
                e.Params.AddOrUpdate(Sungero.Docflow.Constants.OfficialDocument.NeedRegistration, false);
            }

            // См.55345. Смена типа.
            // Obsolete остается Obsolete.
            // Для ненумеруемого вида устанавливается в Active.
            // Для регистрируемого или нумеруемого устанавливается Draft.
            // Ф-я SetLifeCycleState() может быть переопределена в наследниках.
            if (!isTypeChanging && _obj.State.IsInserted == true && e.NewValue != null && _obj.LifeCycleState != LifeCycleState.Obsolete)
            {
                Functions.OfficialDocument.SetLifeCycleState(_obj);
            }

            // Очистить поле Проект, если нужно.
            if (Functions.OfficialDocument.NeedClearProject(_obj, e))
            {
                _obj.Project = null;
            }

            if (e.NewValue != null && (e.OldValue == null || e.OldValue != null && e.NewValue.NumberingType != e.OldValue.NumberingType))
            {
                e.Params.Remove(Sungero.Docflow.Constants.OfficialDocument.ShowParam);
            }

            Functions.OfficialDocument.RefreshDocumentForm(_obj);
            Functions.OfficialDocument.SetRequiredProperties(_obj);
            this.FillName();

            Functions.OfficialDocument.FillOrganizationStructure(_obj);
            Functions.OfficialDocument.ClearBusinessUnit(_obj, e.NewValue);

            e.Params.Remove(paramName);
        }