Пример #1
0
        private void Next_Click(object sender, EventArgs e)
        {
            if (String.Equals(btnNext.Text, "&Finish", StringComparison.CurrentCultureIgnoreCase))
            {
                if (Validation.HasValidationErrors(this.Controls))
                {
                    MessageBox.Show(@"Please ensure all required fields are populated", @"Required fields are missing",
                                    MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    return;
                }

                var letter = new RenewalLetter
                {
                    Addressee          = txtAddressee.Text,
                    Salutation         = txtSalutation.Text,
                    ClientAddress      = txtClientAddress.Text,
                    ClientAddressLine2 = txtClientAddress2.Text,

                    ClientName       = txtClientName.Text,
                    DatePolicyExpiry = datePolicy.Text,
                    DatePrepared     = dateReport.Text,
                    ExecutiveName    = txtExecutiveName.Text,
                    ExecutiveEmail   = txtExecutiveEmail.Text,
                    ExecutiveMobile  = txtExecutiveMobile.Text,
                    ExecutivePhone   = txtExecutivePhone.Text,
                    ExecutiveTitle   = txtExecutiveTitle.Text,

                    ExecutiveDepartment = txtExecutiveDepartment.Text,
                    PaymentDate         = datePayment.Text,
                    OAMPSBranchPhone    = txtBranchPhone.Text,
                    Reference           = txtReference.Text,
                    Fax                 = txtFax.Text,
                    PolicyType          = _selectedPolicy,
                    IsContactSelected   = chkContacted.Checked,
                    IsFundingSelected   = chkFunding.Checked,
                    IsNewClientSelected = chkNewInsurer.Checked,

                    IsFSGSelected           = chkFSG.Checked,
                    IsPrivacySelected       = chkPrivacy.Checked,
                    IsRisksSelected         = chkRisks.Checked,
                    IsSatutorySelected      = chkSatutory.Checked,
                    IsWarningSelected       = chkWarning.Checked,
                    OAMPSBranchAddress      = txtBranchAddress1.Text,
                    OAMPSBranchAddressLine2 = txtBranchAddress2.Text,
                    PDSDescVersion          = txtPDSVersion.Text
                };
                TabPage logoTab      = tbcWizardScreens.TabPages[BusinessLogic.Helpers.Constants.ControlNames.TabPageLogosName];
                var     baseTemplate = (BaseTemplate)letter;
                PopulateLogosToTemplate(logoTab, ref baseTemplate);


                if (_generateNewTemplate)
                {
                    Cache.Add(Constants.CacheNames.RegenerateTemplate, letter, new CacheItemPolicy());

                    _presenter.GenerateNewTemplate(Constants.CacheNames.RegenerateTemplate, Settings.Default.TemplateInsuranceRenewalLetter);
                }
                else
                {
                    _presenter.PopulatePolicy(letter.PolicyType);

                    PopulateAddress(letter);

                    if (!Reload)
                    {
                        AddMainFragment(letter);
                    }

                    //call presenter to populate
                    PopulateDocument(letter);

                    //thie information panel loads when a document is in sharePoint that has metadata
                    //clients don't wish to see this so force the close of the panel once the wizard completes.
                    //Presenter.CloseInformationPanel();
                    if (!Reload)
                    {
                        AddAttachments(letter);
                    }

                    if (isPrePrintedStationary)
                    {
                        _presenter.DeleteDocumentHeaderAndFooter();
                    }
                }


                Close();
            }
            else
            {
                SwitchTab(tbcWizardScreens.SelectedIndex + 1);
            }
        }
Пример #2
0
        private void Next_Click(object sender, EventArgs e)
        {
            try
            {
                this.Cursor = Cursors.WaitCursor;
                //   BasePresenter.SwitchScreenUpdating(false);

                if (String.Equals(btnNext.Text, "&Finish", StringComparison.CurrentCultureIgnoreCase))
                {
                    _selectedPolicies = GetSelectedPolicies();

                    if (Validation.HasValidationErrors(this.Controls))
                    {
                        MessageBox.Show(@"Please ensure all required fields are populated", @"Required fields are missing", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                        return;
                    }

                    _presenter.CloseInformationPanel(true); //has to be here to close as the presenter opens new word documents taht become active.

                    var letter = new RenewalLetter
                    {
                        Addressee          = txtAddressee.Text,
                        Salutation         = txtSalutation.Text,
                        ClientAddress      = txtClientAddress.Text,
                        ClientAddressLine2 = txtClientAddress2.Text,
                        ClientAddressLine3 = txtClientAddress3.Text,

                        ClientName       = txtClientName.Text,
                        DatePolicyExpiry = datePolicy.Value.ToShortDateString(),
                        DatePrepared     = dateReport.Value.ToShortDateString(),
                        ExecutiveName    = txtExecutiveName.Text,
                        ExecutiveEmail   = txtExecutiveEmail.Text,
                        ExecutiveMobile  = txtExecutiveMobile.Text,
                        ExecutivePhone   = txtExecutivePhone.Text,
                        ExecutiveTitle   = txtExecutiveTitle.Text,

                        ExecutiveDepartment = txtExecutiveDepartment.Text,
                        PaymentDate         = datePayment.Value.ToShortDateString(),
                        OAMPSBranchPhone    = txtBranchPhone.Text,
                        Reference           = txtReference.Text,
                        Fax                 = txtFax.Text,
                        Policies            = _selectedPolicies,
                        IsContactSelected   = chkContacted.Checked,
                        IsFundingSelected   = chkFunding.Checked,
                        IsNewClientSelected = chkNewInsurer.Checked,

                        IsFSGSelected           = chkFSG.Checked,
                        IsPrivacySelected       = chkPrivacy.Checked,
                        IsRisksSelected         = chkRisks.Checked,
                        IsSatutorySelected      = chkSatutory.Checked,
                        IsAdviceWarningSelected = chkWarning.Checked,
                        IsGAWSelected           = chkGAW.Checked,
                        OAMPSBranchAddress      = txtBranchAddress1.Text,
                        OAMPSBranchAddressLine2 = txtBranchAddress2.Text,
                        PDSDescVersion          = txtPDSVersion.Text,
                        OAMPSPostalAddress      = txtPostal1.Text,
                        OAMPSPostalAddressLine2 = txtPostal2.Text,
                        IsPrePrintSelected      = chkPrePrint.Checked
                    };

                    _presenter.CreateOrUpdateDocumentProperty(Constants.WordDocumentProperties.RlRdoPreprint, chkPrePrint.Checked.ToString());

                    TabPage logoTab      = tbcWizardScreens.TabPages[BusinessLogic.Helpers.Constants.ControlNames.TabPageLogosName];
                    var     baseTemplate = (BaseTemplate)letter;
                    PopulateLogosToTemplate(logoTab, ref baseTemplate);



                    if (_generateNewTemplate)
                    {
                        Cache.Add(Constants.CacheNames.RegenerateTemplate, letter, new CacheItemPolicy());
                        _presenter.GenerateNewTemplate(Constants.CacheNames.RegenerateTemplate, Settings.Default.TemplateInsuranceRenewalLetter);
                    }
                    else
                    {
                        if (!Reload)
                        {
                            _presenter.PopulatePolicy(letter.Policies, letter.DatePolicyExpiry, chkNewInsurer.Checked);
                        }

                        PopulateAddress(letter);

                        if (!Reload)
                        {
                            AddMainFragment(letter);
                        }

                        //call presenter to populate
                        PopulateDocument(letter, lblCoverPageTitle.Text, lblLogoTitle.Text);

                        //thie information panel loads when a document is in sharePoint that has metadata
                        //clients don't wish to see this so force the close of the panel once the wizard completes.
                        //Presenter.CloseInformationPanel();
                        if (!Reload)
                        {
                            AddAttachments(letter);
                        }

                        if (chkPrePrint.Checked)
                        {
                            _presenter.DeleteDocumentHeaderAndFooter();
                        }

                        //tracking
                        LogUsage(letter,
                                 _loadType == Helpers.Enums.FormLoadType.RegenerateTemplate
                                     ? Helpers.Enums.UsageTrackingType.RegenerateDocument
                                     : Helpers.Enums.UsageTrackingType.NewDocument);
                    }

                    //_presenter.CloseInformationPanel(true);
                    Close();

                    //foreach (Microsoft.Office.Interop.Word.Document doc in Globals.ThisAddIn.Application.Documents)
                    //{
                    //    doc.Application.DisplayDocumentInformationPanel = false;
                    //}
                }
                else
                {
                    SwitchTab(tbcWizardScreens.SelectedIndex + 1);
                }
            }

            catch (AggregateException aggregateException)
            {
                OnError(aggregateException);
            }
            catch (Exception ex)
            {
                OnError(ex);
            }
            finally
            {
                this.Cursor = Cursors.Default;
                // BasePresenter.SwitchScreenUpdating(true);
            }
        }