Exemplo n.º 1
0
        private void ReloadFields()
        {
            WizardBeingUpdated = true;


            var template = new RenewalLetter();

            try
            {
                string policyReference = null;

                if (Cache.Contains(Constants.CacheNames.RegenerateTemplate))
                {
                    MessageBox.Show(BusinessLogic.Helpers.Constants.Miscellaneous.RegenerateOnLoadMsg, String.Empty,
                                    MessageBoxButtons.OK, MessageBoxIcon.Information);

                    template = (RenewalLetter)Cache.Get(Constants.CacheNames.RegenerateTemplate);
                    Cache.Remove(Constants.CacheNames.RegenerateTemplate);

                    if (template.PolicyType != null)
                    {
                        policyReference = template.PolicyType.Title;
                    }

                    chkWarning.Checked  = template.IsWarningSelected;
                    chkFSG.Checked      = template.IsFSGSelected;
                    chkPrivacy.Checked  = template.IsPrivacySelected;
                    chkRisks.Checked    = template.IsRisksSelected;
                    chkSatutory.Checked = template.IsSatutorySelected;

                    chkContacted.Checked  = template.IsContactSelected;
                    chkNewInsurer.Checked = template.IsNewClientSelected;
                    chkFunding.Checked    = template.IsFundingSelected;
                    Reload = false; //behaviour like a new from this point
                }
                else
                {
                    template = (RenewalLetter)_presenter.LoadData(template);


                    policyReference = _presenter.ReadPolicyReference();

                    UpdateMainFragmentCheckBox(Constants.WordDocumentProperties.RlChkContacted, chkContacted);
                    UpdateMainFragmentCheckBox(Constants.WordDocumentProperties.RlChkFunding, chkFunding);
                    UpdateMainFragmentCheckBox(Constants.WordDocumentProperties.RlChkNewClient, chkNewInsurer);

                    var fgKeys = _presenter.ReadDocumentProperty(Constants.WordDocumentProperties.RlSubFragments);
                    if (fgKeys != null)
                    {
                        var keys = fgKeys.Split(';');
                        foreach (string key in keys)
                        {
                            if (key.Equals(Constants.FragmentKeys.FinancialServicesGuide, StringComparison.InvariantCultureIgnoreCase))
                            {
                                chkFSG.Checked = true;
                            }
                            else if (key.Equals(Constants.FragmentKeys.GeneralAdviceWarning, StringComparison.InvariantCultureIgnoreCase))
                            {
                                chkWarning.Checked = true;
                            }
                            else if (key.Equals(Constants.FragmentKeys.PrivacyStatement, StringComparison.InvariantCultureIgnoreCase))
                            {
                                chkPrivacy.Checked = true;
                            }
                            else if (key.Equals(Constants.FragmentKeys.StatutoryNotices, StringComparison.InvariantCultureIgnoreCase))
                            {
                                chkSatutory.Checked = true;
                            }
                            else if (key.Equals(Constants.FragmentKeys.UninsuredRisksReviewList, StringComparison.InvariantCultureIgnoreCase))
                            {
                                chkRisks.Checked = true;
                            }
                        }
                    }
                }

                txtAddressee.Text      = template.Addressee;
                txtSalutation.Text     = template.Salutation;
                txtClientAddress.Text  = template.ClientAddress;
                txtClientAddress2.Text = template.ClientAddressLine2;
                txtClientName.Text     = template.ClientName;

                txtPDSVersion.Text = template.PDSDescVersion;

                txtExecutiveName.Text       = template.ExecutiveName;
                txtExecutiveEmail.Text      = template.ExecutiveEmail;
                txtExecutiveMobile.Text     = template.ExecutiveMobile;
                txtExecutivePhone.Text      = template.ExecutivePhone;
                txtExecutiveTitle.Text      = template.ExecutiveTitle;
                txtExecutiveDepartment.Text = template.ExecutiveDepartment;

                txtBranchAddress1.Text = template.OAMPSBranchAddress;
                txtBranchAddress2.Text = template.OAMPSBranchAddressLine2;

                txtPostal1.Text = template.OAMPSPostalAddress;
                txtPostal2.Text = template.OAMPSPostalAddressLine2;

                txtBranchPhone.Text = template.OAMPSBranchPhone;

                lblLogoTitle.Text      = template.LogoTitle;
                lblCoverPageTitle.Text = template.CoverPageTitle;

                txtReference.Text = template.Reference;
                txtFax.Text       = template.Fax;

                datePayment.Text = template.PaymentDate;
                datePolicy.Text  = template.DatePolicyExpiry;
                dateReport.Text  = template.DatePrepared;

                foreach (var no in tvaPolicies.AllNodes)
                {
                    foreach (var cno in no.Children)
                    {
                        if (String.Equals(cno.Tag.ToString(), policyReference, StringComparison.OrdinalIgnoreCase))
                        {
                            no.Expand();
                            var path = tvaPolicies.GetPath(cno);

                            var node = ((AdvancedTreeNode)path.LastNode);
                            node.CheckState = CheckState.Checked;
                            node.Checked    = true;
                            _selectedPolicy = MinorItems.FirstOrDefault(i => i.Title == node.Text);
                        }
                    }
                }
            }
            catch (Exception)
            {
            }



            WizardBeingUpdated = false;
        }
Exemplo n.º 2
0
        private void ReloadFields()
        {
            var auto = false;

            WizardBeingUpdated = true;
            var template = new RenewalLetter();
            List <IPolicyClass> policiesReference = null;

            _selectedPolicies = new List <IPolicyClass>();

            if (Cache.Contains(Constants.CacheNames.RegenerateTemplate))
            {
                template = (RenewalLetter)Cache.Get(Constants.CacheNames.RegenerateTemplate);
                Cache.Remove(Constants.CacheNames.RegenerateTemplate);

                if (template.Policies != null)
                {
                    policiesReference = template.Policies;
                }

                chkWarning.Checked  = template.IsAdviceWarningSelected;
                chkFSG.Checked      = template.IsFSGSelected;
                chkPrivacy.Checked  = template.IsPrivacySelected;
                chkRisks.Checked    = template.IsRisksSelected;
                chkSatutory.Checked = template.IsSatutorySelected;

                chkGAW.Checked        = template.IsGAWSelected;
                chkContacted.Checked  = template.IsContactSelected;
                chkNewInsurer.Checked = template.IsNewClientSelected;
                chkFunding.Checked    = template.IsFundingSelected;


                if (template.IsPrePrintSelected)
                {
                    chkPrePrint.Checked = template.IsPrePrintSelected;
                }


                Reload = false; //behaviour like a new from this point

                auto = true;
            }
            else
            {
                template          = (RenewalLetter)_presenter.LoadData(template);
                policiesReference = _presenter.ReadPoliciesInDocument();

                UpdateMainFragmentCheckBox(Constants.WordDocumentProperties.RlChkContacted, chkContacted);
                UpdateMainFragmentCheckBox(Constants.WordDocumentProperties.RlChkFunding, chkFunding);
                UpdateMainFragmentCheckBox(Constants.WordDocumentProperties.RlChkNewClient, chkNewInsurer);
                UpdateMainFragmentCheckBox(Constants.WordDocumentProperties.RlChkGAW, chkGAW);



                //var value = _presenter.ReadDocumentProperty(Constants.WordDocumentProperties.RlRdoPreprint);
                //bool isSelected;
                //if (Boolean.TryParse(value, out isSelected))
                //{
                //    rdoPrePrintYes.Checked = isSelected;
                //}


                UpdatePrePrintedCheckBoxChecked();

                var fgKeys = _presenter.ReadDocumentProperty(Constants.WordDocumentProperties.RlSubFragments);
                if (fgKeys != null)
                {
                    var keys = fgKeys.Split(';');
                    foreach (string key in keys)
                    {
                        if (key.Equals(Constants.FragmentKeys.FinancialServicesGuide, StringComparison.InvariantCultureIgnoreCase))
                        {
                            chkFSG.Checked = true;
                        }
                        else if (key.Equals(Constants.FragmentKeys.GeneralAdviceWarning, StringComparison.InvariantCultureIgnoreCase))
                        {
                            chkWarning.Checked = true;
                        }
                        else if (key.Equals(Constants.FragmentKeys.PrivacyStatement, StringComparison.InvariantCultureIgnoreCase))
                        {
                            chkPrivacy.Checked = true;
                        }
                        else if (key.Equals(Constants.FragmentKeys.StatutoryNotices, StringComparison.InvariantCultureIgnoreCase))
                        {
                            chkSatutory.Checked = true;
                        }
                        else if (key.Equals(Constants.FragmentKeys.UninsuredRisksReviewList, StringComparison.InvariantCultureIgnoreCase))
                        {
                            chkRisks.Checked = true;
                        }
                    }
                }
            }


            var processedTitles = new List <string>();

            foreach (var no in tvaPolicies.AllNodes)
            {
                foreach (var cno in no.Children)
                {
                    if (policiesReference != null && policiesReference.Count > 0)
                    {
                        var p = policiesReference.Find(i => i.Title.Replace("\r\a", string.Empty).Equals(cno.Tag.ToString().Replace("\r\a", string.Empty), StringComparison.OrdinalIgnoreCase));
                        if (p != null)
                        {
                            if (!processedTitles.Contains(cno.Tag.ToString()))
                            {
                                if (String.Equals(cno.Tag.ToString(), p.Title.Replace("\r\a", string.Empty), StringComparison.OrdinalIgnoreCase))
                                {
                                    processedTitles.Add(cno.Tag.ToString());
                                    no.Expand();
                                    var path = tvaPolicies.GetPath(cno);

                                    var node = ((AdvancedTreeNode)path.LastNode);
                                    node.CheckState = CheckState.Checked;
                                    node.Checked    = true;

                                    if ((_selectedPolicies.Find(j => j.Title == node.Text) == null))
                                    {
                                        _selectedPolicies.Add(MinorItems.FirstOrDefault(i => i.Title == node.Text));
                                    }
                                }
                            }
                        }
                    }
                }
            }

            txtAddressee.Text      = template.Addressee;
            txtSalutation.Text     = template.Salutation;
            txtClientAddress.Text  = template.ClientAddress;
            txtClientAddress2.Text = template.ClientAddressLine2;
            txtClientAddress3.Text = template.ClientAddressLine3;
            txtClientName.Text     = template.ClientName;

            txtPDSVersion.Text = template.PDSDescVersion;

            txtExecutiveName.Text       = template.ExecutiveName;
            txtExecutiveEmail.Text      = template.ExecutiveEmail;
            txtExecutiveMobile.Text     = template.ExecutiveMobile;
            txtExecutivePhone.Text      = template.ExecutivePhone;
            txtExecutiveTitle.Text      = template.ExecutiveTitle;
            txtExecutiveDepartment.Text = template.ExecutiveDepartment;

            txtBranchAddress1.Text = template.OAMPSBranchAddress;
            txtBranchAddress2.Text = template.OAMPSBranchAddressLine2;

            txtPostal1.Text = template.OAMPSPostalAddress;
            txtPostal2.Text = template.OAMPSPostalAddressLine2;

            txtBranchPhone.Text = template.OAMPSBranchPhone;

            lblLogoTitle.Text      = template.LogoTitle;
            lblCoverPageTitle.Text = template.CoverPageTitle;

            txtReference.Text = template.Reference;
            txtFax.Text       = template.Fax;

            DateTime outDate;

            datePolicy.Value = DateTime.TryParse(template.DatePolicyExpiry, out outDate)
                                   ? outDate
                                   : DateTime.Today;

            datePayment.Value = DateTime.TryParse(template.PaymentDate, out outDate)
                                            ? outDate
                                            : DateTime.Today;

            dateReport.Value = DateTime.TryParse(template.DatePrepared, out outDate)
                                            ? outDate
                                            : DateTime.Today;



            WizardBeingUpdated = false;

            if (auto)
            {
                base.StartTimer();
            }
        }