示例#1
0
        /// <summary>
        /// Вывод диалога запроса причины прекращения задачи согласования.
        /// </summary>
        /// <param name="activeText">Причина прекращения.</param>
        /// <returns>True, если пользователь нажал Ok.</returns>
        public bool GetReasonBeforeAbort(string activeText)
        {
            var dialog         = Dialogs.CreateInputDialog(ApprovalTasks.Resources.Confirmation);
            var abortingReason = dialog.AddMultilineString(_obj.Info.Properties.AbortingReason.LocalizedName, true, activeText);
            var document       = _obj.DocumentGroup.OfficialDocuments.FirstOrDefault();

            CommonLibrary.IBooleanDialogValue isDocumentClosed = null;
            if (document != null)
            {
                var textToMarkDocumentAsObsolete = Functions.OfficialDocument.GetTextToMarkDocumentAsObsolete(document);
                isDocumentClosed = dialog.AddBoolean(textToMarkDocumentAsObsolete, false);
                dialog.SetOnButtonClick(args =>
                {
                    if (string.IsNullOrWhiteSpace(abortingReason.Value))
                    {
                        args.AddError(ApprovalTasks.Resources.EmptyAbortingReason, abortingReason);
                    }
                });
            }

            if (dialog.Show() == DialogButtons.Ok)
            {
                _obj.AbortingReason = abortingReason.Value;
                if (isDocumentClosed != null && isDocumentClosed.Value.Value == true)
                {
                    var isActive = document.LifeCycleState == Sungero.Docflow.OfficialDocument.LifeCycleState.Active;
                    var isDraft  = document.LifeCycleState == Sungero.Docflow.OfficialDocument.LifeCycleState.Draft;

                    if (isActive || isDraft || document.LifeCycleState == null)
                    {
                        Sungero.Docflow.PublicFunctions.OfficialDocument.SetObsolete(document, isActive);
                        document.Save();
                    }
                }
                return(true);
            }
            return(false);
        }
        public override void BeforeExecute(Sungero.Reporting.Client.BeforeExecuteEventArgs e)
        {
            if (AssignmentCompletionReport.PeriodBegin.HasValue && AssignmentCompletionReport.PeriodEnd.HasValue)
            {
                return;
            }

            // Запросить параметры.
            var dialog = Dialogs.CreateInputDialog(Resources.AssignmentCompletionReportDialog);

            dialog.HelpCode = Constants.AssignmentCompletionReport.HelpCode;
            dialog.Buttons.AddOkCancel();

            CommonLibrary.IDateDialogValue periodBegin = null;
            CommonLibrary.IDateDialogValue periodEnd   = null;
            INavigationDialogValue <Company.IDepartment>   department   = null;
            INavigationDialogValue <Company.IEmployee>     performer    = null;
            INavigationDialogValue <Company.IBusinessUnit> businessUnit = null;

            CommonLibrary.IBooleanDialogValue loadOldAssignments = null;

            // Период.
            var today = Calendar.UserToday;

            if (!AssignmentCompletionReport.PeriodBegin.HasValue)
            {
                periodBegin = dialog.AddDate(Resources.DocumentUsagePeriodBegin, true, today.AddDays(-30));
            }
            if (!AssignmentCompletionReport.PeriodEnd.HasValue)
            {
                periodEnd = dialog.AddDate(Resources.DocumentUsagePeriodEnd, true, today);
            }

            // НОР.
            if (AssignmentCompletionReport.BusinessUnit == null)
            {
                businessUnit = dialog.AddSelect(Resources.BusinessUnit, false, Company.BusinessUnits.Null);
            }

            // Подразделение.
            if (AssignmentCompletionReport.Department == null)
            {
                department = dialog.AddSelect(Resources.Department, false, Company.Departments.Null);
            }

            // Сотрудник.
            if (AssignmentCompletionReport.Performer == null)
            {
                performer = dialog.AddSelect(Resources.Employee, false, Company.Employees.Null);
            }

            if (AssignmentCompletionReport.LoadOldAssignments == null)
            {
                loadOldAssignments = dialog.AddBoolean(Resources.AddAssignmentsWithDeadlineBeforePeriodBegins, true);
            }

            dialog.SetOnButtonClick((args) =>
            {
                Functions.Module.CheckReportDialogPeriod(args, periodBegin, periodEnd);
            });

            if (dialog.Show() != DialogButtons.Ok)
            {
                e.Cancel = true;
                return;
            }

            if (!AssignmentCompletionReport.PeriodBegin.HasValue)
            {
                AssignmentCompletionReport.PeriodBegin = periodBegin.Value;
            }
            if (!AssignmentCompletionReport.PeriodEnd.HasValue)
            {
                AssignmentCompletionReport.ClientPeriodEnd = periodEnd.Value.Value;
                AssignmentCompletionReport.PeriodEnd       = periodEnd.Value.Value.EndOfDay();
            }

            if (AssignmentCompletionReport.BusinessUnit == null)
            {
                AssignmentCompletionReport.BusinessUnit = businessUnit.Value;
            }

            if (AssignmentCompletionReport.Department == null)
            {
                AssignmentCompletionReport.Department = department.Value;
            }

            if (AssignmentCompletionReport.Performer == null)
            {
                AssignmentCompletionReport.Performer = Users.As(performer.Value);
            }

            if (AssignmentCompletionReport.LoadOldAssignments == null)
            {
                AssignmentCompletionReport.LoadOldAssignments = loadOldAssignments.Value;
            }
        }
示例#3
0
        /// <summary>
        /// Диалог заполнения информации о покупателе.
        /// </summary>
        public virtual void BuyerTitlePropertiesFillingDialog()
        {
            var taxDocumentClassifier = Functions.AccountingDocumentBase.Remote.GetTaxDocumentClassifier(_obj);
            var isAct    = _obj.FormalizedServiceType == Docflow.AccountingDocumentBase.FormalizedServiceType.Act;
            var isTorg12 = _obj.FormalizedServiceType == Docflow.AccountingDocumentBase.FormalizedServiceType.Waybill;
            var isDpt    = _obj.FormalizedServiceType == Docflow.AccountingDocumentBase.FormalizedServiceType.GoodsTransfer &&
                           taxDocumentClassifier == Exchange.PublicConstants.Module.TaxDocumentClassifier.GoodsTransferSeller;
            var isDprr = _obj.FormalizedServiceType == Docflow.AccountingDocumentBase.FormalizedServiceType.WorksTransfer &&
                         taxDocumentClassifier == Exchange.PublicConstants.Module.TaxDocumentClassifier.WorksTransferSeller;
            var isUtdAny           = _obj.FormalizedServiceType == Docflow.AccountingDocumentBase.FormalizedServiceType.GeneralTransfer;
            var isUtdCorrection    = isUtdAny && _obj.IsAdjustment == true;
            var isUtdNotCorrection = isUtdAny && _obj.IsAdjustment != true;
            var isWaybill          = isTorg12 || isDpt;
            var isContractStatment = isAct || isDprr;

            if (!isUtdAny && !isWaybill && !isContractStatment)
            {
                return;
            }

            var dialog = Dialogs.CreateInputDialog(AccountingDocumentBases.Resources.PropertiesFillingDialog_Title);

            if (isTorg12)
            {
                dialog.HelpCode = Constants.AccountingDocumentBase.HelpCodes.Waybill;
            }
            else if (isAct)
            {
                dialog.HelpCode = Constants.AccountingDocumentBase.HelpCodes.ContractStatement;
            }
            else if (isDpt)
            {
                dialog.HelpCode = Constants.AccountingDocumentBase.HelpCodes.GoodsTransfer;
            }
            else if (isDprr)
            {
                dialog.HelpCode = Constants.AccountingDocumentBase.HelpCodes.WorksTransfer;
            }
            else if (isUtdNotCorrection)
            {
                dialog.HelpCode = Constants.AccountingDocumentBase.HelpCodes.UniversalTransfer;
            }
            else if (isUtdCorrection)
            {
                dialog.HelpCode = Constants.AccountingDocumentBase.HelpCodes.UniversalCorrectionTransfer;
            }

            Action <CommonLibrary.InputDialogRefreshEventArgs> refresh = null;
            var signatories = Functions.OfficialDocument.Remote.GetSignatories(_obj);

            var dialogText = string.Empty;

            if (isUtdNotCorrection)
            {
                dialogText = AccountingDocumentBases.Resources.PropertiesFillingDialog_Text_Universal;
            }

            if (isUtdCorrection)
            {
                dialogText = AccountingDocumentBases.Resources.PropertiesFillingDialog_Text_UniversalCorrection;
            }

            if (isWaybill)
            {
                dialogText = AccountingDocumentBases.Resources.PropertiesFillingDialog_Text_Waybill;
            }

            if (isContractStatment)
            {
                dialogText = AccountingDocumentBases.Resources.PropertiesFillingDialog_Text_Act;
            }

            dialog.Text = dialogText;

            var defaultSignatory = Company.Employees.Null;

            if (signatories.Any(s => _obj.OurSignatory != null && Equals(s.EmployeeId, _obj.OurSignatory.Id)))
            {
                defaultSignatory = _obj.OurSignatory;
            }
            else if (signatories.Any(s => Company.Employees.Current != null && Equals(s.EmployeeId, Company.Employees.Current.Id)))
            {
                defaultSignatory = Company.Employees.Current;
            }
            else if (signatories.Select(s => s.EmployeeId).Distinct().Count() == 1)
            {
                defaultSignatory = Functions.AccountingDocumentBase.Remote.GetEmployeesByIds(signatories.Select(s => s.EmployeeId).ToList()).FirstOrDefault();
            }

            // Поле Подписал.
            var defaultEmployees = Functions.AccountingDocumentBase.Remote.GetEmployeesByIds(signatories.Select(s => s.EmployeeId).ToList());
            var signatory        = dialog.AddSelect(AccountingDocumentBases.Resources.PropertiesFillingDialog_SignedBy, true, Company.Employees.Null)
                                   .From(defaultEmployees.Distinct());

            // Поле Полномочия.
            CommonLibrary.IDropDownDialogValue hasAuthority = null;
            if (!isAct && !isTorg12)
            {
                hasAuthority = dialog.AddSelect(AccountingDocumentBases.Resources.PropertiesFillingDialog_HasAuthority, true, 0)
                               .From(AccountingDocumentBases.Resources.PropertiesFillingDialog_HasAuthority_Register,
                                     AccountingDocumentBases.Resources.PropertiesFillingDialog_HasAuthority_Deal,
                                     AccountingDocumentBases.Resources.PropertiesFillingDialog_HasAuthority_DealAndRegister);
                hasAuthority.IsEnabled = !isUtdCorrection;
            }

            // Поле Основание и связанные с ним Доверенность/Документ.
            CommonLibrary.IDropDownDialogValue        basis           = null;
            INavigationDialogValue <IPowerOfAttorney> powerOfAttorney = null;

            CommonLibrary.IDropDownDialogValue basisDocument = null;
            if (!isTorg12)
            {
                basis           = dialog.AddSelect(AccountingDocumentBases.Resources.PropertiesFillingDialog_Basis, true, 0);
                powerOfAttorney = dialog.AddSelect(PowerOfAttorneys.Info.LocalizedName, false, PowerOfAttorneys.Null);

                if (!isAct)
                {
                    basisDocument = dialog.AddSelect(AccountingDocumentBases.Resources.PropertiesFillingDialog_Document, false, null);
                }
            }

            // Дата подписания (Дата согласования, если УКД).
            var signingLable = isUtdCorrection ?
                               AccountingDocumentBases.Resources.PropertiesFillingDialog_DateApproving :
                               AccountingDocumentBases.Resources.PropertiesFillingDialog_SigningDate;
            var signingDate = dialog.AddDate(signingLable, true, Calendar.UserToday);

            // Результат и Разногласия.
            CommonLibrary.IDropDownDialogValue        result       = null;
            CommonLibrary.IMultilineStringDialogValue disagreement = null;
            if (!isUtdCorrection && !isContractStatment)
            {
                result = dialog.AddSelect(AccountingDocumentBases.Resources.PropertiesFillingDialog_Result, true, 0)
                         .From(AccountingDocumentBases.Resources.PropertiesFillingDialog_Result_Accepted,
                               AccountingDocumentBases.Resources.PropertiesFillingDialog_Result_AcceptedWithDisagreement);
                disagreement = dialog.AddMultilineString(AccountingDocumentBases.Resources.PropertiesFillingDialog_Disagreement, false);
            }

            // Поле Результат для УКД.
            CommonLibrary.IDropDownDialogValue adjustmentResult = null;
            if (isUtdCorrection)
            {
                adjustmentResult = dialog.AddSelect(AccountingDocumentBases.Resources.PropertiesFillingDialog_Result, true, 0)
                                   .From(AccountingDocumentBases.Resources.PropertiesFillingDialog_AdjustmentResult_AgreedChanges);
                adjustmentResult.IsEnabled = false;
            }

            // Груз принял получатель груза.
            CommonLibrary.IBooleanDialogValue          isSameConsignee = null;
            INavigationDialogValue <Company.IEmployee> consignee       = null;

            CommonLibrary.IDropDownDialogValue        consigneeBasis    = null;
            INavigationDialogValue <IPowerOfAttorney> consigneeAttorney = null;

            CommonLibrary.IStringDialogValue consigneeDocument = null;
            if (isWaybill || isUtdNotCorrection)
            {
                isSameConsignee = dialog.AddBoolean(AccountingDocumentBases.Resources.PropertiesFillingDialog_SameConsignee, true);
                consignee       = dialog.AddSelect(AccountingDocumentBases.Resources.PropertiesFillingDialog_Consignee, false, Company.Employees.Null)
                                  .Where(x => Equals(x.Status, CoreEntities.DatabookEntry.Status.Active));
                consigneeBasis    = dialog.AddSelect(AccountingDocumentBases.Resources.PropertiesFillingDialog_ConsigneeBasis, false, 0);
                consigneeAttorney = dialog.AddSelect(PowerOfAttorneys.Info.LocalizedName, false, PowerOfAttorneys.Null);
                consigneeDocument = dialog.AddString(AccountingDocumentBases.Resources.PropertiesFillingDialog_Document, false);
            }

            CommonLibrary.CustomDialogButton saveAndSignButton = null;
            if (signatories.Any(s => Users.Current != null && Equals(s.EmployeeId, Users.Current.Id)))
            {
                saveAndSignButton = dialog.Buttons.AddCustom(AccountingDocumentBases.Resources.PropertiesFillingDialog_SaveAndSign);
            }

            var saveButton = dialog.Buttons.AddCustom(AccountingDocumentBases.Resources.PropertiesFillingDialog_Save);

            dialog.Buttons.Default = saveAndSignButton ?? saveButton;
            var cancelButton = dialog.Buttons.AddCancel();

            string[]                 basisValues           = null;
            IPowerOfAttorney[]       powerOfAttorneyValues = null;
            string[]                 basisDocumentValues   = null;
            List <ISignatureSetting> settings = null;

            IPowerOfAttorney[] consigneePowerOfAttorneyValues = null;

            if (basis != null)
            {
                basis.SetOnValueChanged(bv => FillBasisDocuments(bv.NewValue, powerOfAttorney, basisDocument, powerOfAttorneyValues, basisDocumentValues));
            }

            signatory.SetOnValueChanged(
                (sc) =>
            {
                settings = Functions.OfficialDocument.Remote.GetSignatureSettings(_obj, sc.NewValue);
                if (basis != null)
                {
                    basisValues = settings.Select(s => s.Reason).Distinct()
                                  .Where(r => !isAct || r != SignatureSetting.Reason.Other)
                                  .OrderBy(r => r != SignatureSetting.Reason.Duties)
                                  .ThenBy(r => r != SignatureSetting.Reason.PowerOfAttorney)
                                  .Select(r => SignatureSettings.Info.Properties.Reason.GetLocalizedValue(r)).ToArray();
                    basis.From(basisValues);
                    basis.IsEnabled  = sc.NewValue != null;
                    basis.IsRequired = sc.NewValue != null;
                }
                if (powerOfAttorney != null)
                {
                    powerOfAttorneyValues = settings.Where(s => s.Reason == SignatureSetting.Reason.PowerOfAttorney)
                                            .Select(s => s.Document).OfType <IPowerOfAttorney>().Where(d => d.AccessRights.CanRead(Users.Current)).ToArray();
                    powerOfAttorney.From(powerOfAttorneyValues);
                }
                if (basisDocument != null)
                {
                    basisDocumentValues = settings.Where(s => s.Reason == SignatureSetting.Reason.Other).Select(s => s.DocumentInfo).ToArray();
                    basisDocument.From(basisDocumentValues);
                }
                if (basis != null)
                {
                    basis.Value = basisValues.FirstOrDefault();
                    FillBasisDocuments(basis.Value, powerOfAttorney, basisDocument, powerOfAttorneyValues, basisDocumentValues);
                }
            });
            signatory.Value = defaultSignatory;

            Action <CommonLibrary.InputDialogValueChangedEventArgs <string> > consigneeBasisChanged =
                cb =>
            {
                var basisIsDuties   = cb.NewValue == SignatureSettings.Info.Properties.Reason.GetLocalizedValue(SignatureSetting.Reason.Duties);
                var basisIsAttorney = cb.NewValue == SignatureSettings.Info.Properties.Reason.GetLocalizedValue(SignatureSetting.Reason.PowerOfAttorney);
                var basisIsOther    = cb.NewValue == SignatureSettings.Info.Properties.Reason.GetLocalizedValue(SignatureSetting.Reason.Other);

                if (consigneeAttorney != null)
                {
                    consigneeAttorney.IsVisible  = !basisIsOther;
                    consigneeAttorney.IsRequired = basisIsAttorney;
                    consigneeAttorney.IsEnabled  = basisIsAttorney;
                    if (!consigneeAttorney.IsEnabled)
                    {
                        consigneeAttorney.Value = null;
                    }
                    else
                    {
                        consigneeAttorney.Value = consigneePowerOfAttorneyValues.Length == 1 ? consigneePowerOfAttorneyValues.SingleOrDefault() : null;
                    }
                }

                if (consigneeDocument != null)
                {
                    consigneeDocument.IsVisible  = basisIsOther;
                    consigneeDocument.IsRequired = basisIsOther;
                    if (!consigneeDocument.IsVisible)
                    {
                        consigneeDocument.Value = null;
                    }
                }
            };

            if (consignee != null)
            {
                consignee.SetOnValueChanged(
                    ce =>
                {
                    var cbValues = new List <string>();
                    if (ce.NewValue != null)
                    {
                        cbValues.Add(SignatureSettings.Info.Properties.Reason.GetLocalizedValue(SignatureSetting.Reason.Duties));
                        cbValues.Add(SignatureSettings.Info.Properties.Reason.GetLocalizedValue(SignatureSetting.Reason.PowerOfAttorney));
                        if (!isTorg12)
                        {
                            cbValues.Add(SignatureSettings.Info.Properties.Reason.GetLocalizedValue(SignatureSetting.Reason.Other));
                        }

                        consigneePowerOfAttorneyValues = Functions.PowerOfAttorney.Remote.GetActivePowerOfAttorneys(ce.NewValue, signingDate.Value).ToArray();
                    }
                    else
                    {
                        consigneePowerOfAttorneyValues = new IPowerOfAttorney[0];
                    }

                    consigneeBasis.From(cbValues.ToArray());
                    consigneeAttorney.From(consigneePowerOfAttorneyValues);

                    consigneeBasis.Value = cbValues.OrderBy(v => v != consigneeBasis.Value).FirstOrDefault();
                    consigneeBasisChanged.Invoke(new CommonLibrary.InputDialogValueChangedEventArgs <string>(null, consigneeBasis.Value));
                });
            }

            if (consigneeBasis != null)
            {
                consigneeBasis.SetOnValueChanged(consigneeBasisChanged);
            }

            signingDate.SetOnValueChanged(
                sd =>
            {
                if (consigneeAttorney != null)
                {
                    if (sd.NewValue.HasValue && consignee.Value != null)
                    {
                        consigneePowerOfAttorneyValues = Functions.PowerOfAttorney.Remote.GetActivePowerOfAttorneys(consignee.Value, signingDate.Value).ToArray();
                    }
                    else
                    {
                        consigneePowerOfAttorneyValues = new IPowerOfAttorney[0];
                    }

                    consigneeAttorney.From(consigneePowerOfAttorneyValues);
                    consigneeBasisChanged.Invoke(new CommonLibrary.InputDialogValueChangedEventArgs <string>(null, consigneeBasis.Value));
                }
            });

            refresh = (r) =>
            {
                if (disagreement != null)
                {
                    disagreement.IsEnabled = result.Value == AccountingDocumentBases.Resources.PropertiesFillingDialog_Result_AcceptedWithDisagreement;
                }

                if (isSameConsignee != null)
                {
                    var needConsignee = !isSameConsignee.Value.Value;
                    consignee.IsEnabled       = needConsignee;
                    consignee.IsRequired      = needConsignee;
                    consigneeBasis.IsEnabled  = needConsignee && consignee.Value != null;
                    consigneeBasis.IsRequired = needConsignee && consignee.Value != null;

                    if (!needConsignee)
                    {
                        consignee.Value      = Company.Employees.Null;
                        consigneeBasis.Value = string.Empty;
                    }
                }
            };

            dialog.SetOnRefresh(refresh);
            dialog.SetOnButtonClick(
                (b) =>
            {
                if (b.Button == saveAndSignButton || b.Button == saveButton)
                {
                    if (!b.IsValid)
                    {
                        return;
                    }

                    var consigneeValue = isSameConsignee != null ? (isSameConsignee.Value == true ? signatory.Value : consignee.Value) : null;
                    var signatoryPowerOfAttorneyValue = powerOfAttorney != null ? powerOfAttorney.Value : null;
                    var signatoryOtherReasonValue     = basisDocument != null ? basisDocument.Value : null;
                    var consigneePowerOfAttorneyValue = consigneeAttorney != null ? consigneeAttorney.Value : null;
                    var consigneeOtherReasonValue     = consigneeDocument != null ? consigneeDocument.Value : null;
                    var errorlist = Functions.AccountingDocumentBase.Remote
                                    .TitleDialogValidationErrors(_obj, signatory.Value, consignee != null ? consignee.Value : null,
                                                                 signatoryPowerOfAttorneyValue, consigneePowerOfAttorneyValue,
                                                                 signatoryOtherReasonValue, consigneeOtherReasonValue);
                    foreach (var errors in errorlist.GroupBy(e => e.Text))
                    {
                        var controls = new List <CommonLibrary.IDialogControl>();
                        foreach (var error in errors)
                        {
                            if (error.Type == Constants.AccountingDocumentBase.GenerateTitleTypes.Signatory)
                            {
                                controls.Add(signatory);
                            }
                            if (error.Type == Constants.AccountingDocumentBase.GenerateTitleTypes.Consignee)
                            {
                                controls.Add(consignee);
                            }
                            if (error.Type == Constants.AccountingDocumentBase.GenerateTitleTypes.SignatoryPowerOfAttorney)
                            {
                                controls.Add(powerOfAttorney);
                            }
                            if (error.Type == Constants.AccountingDocumentBase.GenerateTitleTypes.ConsigneePowerOfAttorney)
                            {
                                controls.Add(consigneeAttorney);
                            }
                        }
                        b.AddError(errors.Key, controls.ToArray());
                    }

                    if (b.IsValid)
                    {
                        var signed = (result != null && result.IsVisible) ?
                                     result.Value != AccountingDocumentBases.Resources.PropertiesFillingDialog_Result_AcceptedWithDisagreement :
                                     true;
                        var consigneeBasisValue      = isSameConsignee != null && basis != null ? (isSameConsignee.Value == true ? basis.Value : consigneeBasis.Value) : string.Empty;
                        var disagreementValue        = disagreement != null ? disagreement.Value : string.Empty;
                        var basisValue               = basis != null ? basis.Value : string.Empty;
                        var hasAuthorityValue        = hasAuthority != null ? hasAuthority.Value : string.Empty;
                        var signatoryPowerOfAttorney = Structures.AccountingDocumentBase.Attorney.Create(signatoryPowerOfAttorneyValue, signatoryOtherReasonValue);
                        var consigneePowerOfAttorney = Structures.AccountingDocumentBase.Attorney.Create(consigneePowerOfAttorneyValue, consigneeOtherReasonValue);
                        var title = Structures.AccountingDocumentBase.BuyerTitle.Create();
                        title.ActOfDisagreement        = disagreementValue;
                        title.Signatory                = signatory.Value;
                        title.SignatoryPowersBase      = basisValue;
                        title.Consignee                = consigneeValue;
                        title.ConsigneePowersBase      = consigneeBasisValue;
                        title.SignResult               = signed;
                        title.SignatoryPowers          = hasAuthorityValue;
                        title.AcceptanceDate           = signingDate.Value;
                        title.SignatoryPowerOfAttorney = signatoryPowerOfAttorney.Document;
                        title.SignatoryOtherReason     = signatoryPowerOfAttorney.OtherReason;
                        title.ConsigneePowerOfAttorney = consigneePowerOfAttorney.Document;
                        title.ConsigneeOtherReason     = consigneePowerOfAttorney.OtherReason;

                        try
                        {
                            Functions.AccountingDocumentBase.Remote.GenerateAnswer(_obj, title, false);
                        }
                        catch (AppliedCodeException ex)
                        {
                            b.AddError(ex.Message);
                            return;
                        }
                        catch (ValidationException ex)
                        {
                            b.AddError(ex.Message);
                            return;
                        }
                        catch (Exception ex)
                        {
                            Logger.ErrorFormat("Error generation title: ", ex);
                            b.AddError(Sungero.Docflow.AccountingDocumentBases.Resources.ErrorBuyerTitlePropertiesFilling);
                            return;
                        }

                        if (b.Button == saveAndSignButton)
                        {
                            try
                            {
                                Functions.Module.ApproveWithAddenda(_obj, null, null, null, false, true, string.Empty);
                            }
                            catch (Exception ex)
                            {
                                b.AddError(ex.Message);
                            }
                        }
                    }
                }
            });
            dialog.Show();
        }