private void ReloadPolicyClasses(bool regenProcess) { var ids = regenProcess ? _selectedQuestionnaireFragments.Aggregate(string.Empty, (current, p) => current + p.Id + ";") : _wizardPresenter.ReadDocumentProperty(Constants.WordDocumentProperties.IncludedPolicyTypes); if (string.IsNullOrEmpty(ids)) { return; } var l = ids.Split(';'); foreach (var id in l) { var found = MinorItems.FirstOrDefault(x => x.Id == id); if (found == null) { continue; } foreach (var no in tvaPolicies.AllNodes) { if (string.Equals(no.Tag.ToString(), found.Title, StringComparison.OrdinalIgnoreCase)) { if (!regenProcess) { _selectedQuestionnaireFragments.Add(found); } var path = tvaPolicies.GetPath(no); var node = ((AdvancedTreeNode)path.LastNode); node.CheckState = CheckState.Checked; node.Checked = true; if (no.Parent != null) { no.Parent.ExpandAll(); } } } } }
private List <IPolicyClass> GetSelectedPolicies() { var policies = new List <IPolicyClass>(); foreach (var no in tvaPolicies.AllNodes) { foreach (var cno in no.Children) { var path = tvaPolicies.GetPath(cno); var node = ((AdvancedTreeNode)path.LastNode); if (node.Checked) { policies.Add(MinorItems.FirstOrDefault(i => i.Title == node.Text)); } } } return(policies); }
private void ReloadPolicyClasses(IInsuranceRenewalReport v) { if (v.SelectedDocumentFragments == null) { v = _presenter.LoadIncludedPolicyClasses(v); } //repopulate selected fields foreach (var f in v.SelectedDocumentFragments) { var found = MinorItems.FirstOrDefault(x => x.Id == f.Id); if (found != null) { foreach (var no in tvaPolicies.AllNodes) { if (String.Equals(no.Tag.ToString(), found.MajorClass, StringComparison.OrdinalIgnoreCase)) { foreach (var cno in no.Children) { if (String.Equals(cno.Tag.ToString(), found.Title, StringComparison.OrdinalIgnoreCase)) { var path = tvaPolicies.GetPath(cno); var node = ((AdvancedTreeNode)path.LastNode); node.CheckState = CheckState.Checked; node.Checked = true; no.Expand(false); //var item = MinorItems.FirstOrDefault(i => String.Equals(i.Title, found.Title, StringComparison.OrdinalIgnoreCase)); node.Current = found.CurrentInsurer; node.Reccommended = found.RecommendedInsurer; _selectedDocumentFragments.Add(found); } } } } } } }
private List <IPolicyClass> GetSelectedPolicies() { var policies = new List <IPolicyClass>(); // ReSharper disable LoopCanBeConvertedToQuery foreach (TreeNodeAdv no in tvaPolicies.AllNodes) // ReSharper restore LoopCanBeConvertedToQuery { // ReSharper disable LoopCanBeConvertedToQuery foreach (TreeNodeAdv cno in no.Children) // ReSharper restore LoopCanBeConvertedToQuery { var path = tvaPolicies.GetPath(cno); var node = ((AdvancedTreeNode)path.LastNode); if (node.Checked) { policies.Add(MinorItems.FirstOrDefault(i => i.Title == node.Text)); } } } return(policies); }
private void ReloadPolicyClasses(IInsuranceRenewalReport v, bool reload) { if (v.SelectedDocumentFragments == null) { v = _presenter.LoadIncludedPolicyClasses(v); } int reOrder = 0; //repopulate selected fields v.SelectedDocumentFragments.Sort((x, y) => y.Order.CompareTo(x.Order)); for (int index = v.SelectedDocumentFragments.Count - 1; index >= 0; index--) { var f = v.SelectedDocumentFragments[index]; var found = MinorItems.FirstOrDefault(x => x.Id == f.Id); if (found != null) { foreach (var no in tvaPolicies.AllNodes) { if (String.Equals(no.Tag.ToString(), found.MajorClass, StringComparison.OrdinalIgnoreCase)) { foreach (var cno in no.Children) { if (String.Equals(cno.Tag.ToString(), found.Title, StringComparison.OrdinalIgnoreCase)) { reOrder = reOrder + 1; var path = tvaPolicies.GetPath(cno); var node = ((AdvancedTreeNode)path.LastNode); node.CheckState = CheckState.Checked; node.Checked = true; no.Expand(false); if (reload) //on generate get them from cache as they're passed thru { node.Current = found.CurrentInsurer; node.Reccommended = found.RecommendedInsurer; node.OrderPolicy = reOrder.ToString(); node.ReccommendedId = found.RecommendedInsurerId; node.CurrentId = found.CurrentInsurerId; } else { node.Current = f.CurrentInsurer; node.Reccommended = f.RecommendedInsurer; node.OrderPolicy = reOrder.ToString(); node.ReccommendedId = f.RecommendedInsurerId; node.CurrentId = f.CurrentInsurerId; } } } //var item = // MinorItems.FirstOrDefault( // i => String.Equals(i.Title, f.Title, StringComparison.OrdinalIgnoreCase)); //if (item != null) //{ //_selectedDocumentFragments.Add(item); //} } } } } }
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; }
private void ReloadFields() { bool 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)_wizardPresenter.LoadData(template); policiesReference = _wizardPresenter.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(); string fgKeys = _wizardPresenter.ReadDocumentProperty(Constants.WordDocumentProperties.RlSubFragments); if (fgKeys != null) { string[] keys = fgKeys.Split(';'); foreach (string key in keys) { if (key.Equals(Constants.FragmentKeys.FinancialServicesGuideLetter, 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 (TreeNodeAdv no in tvaPolicies.AllNodes) { foreach (TreeNodeAdv cno in no.Children) { if (policiesReference != null && policiesReference.Count > 0) { IPolicyClass 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(); TreePath 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(); } }
private void ReloadPolicyClasses(IInsuranceManual v, bool reload) { if (v.SelectedPolicyClasses == null) { v = _wizardPresenter.LoadIncludedPolicyClasses(v); } var reOrder = 0; //repopulate selected fields v.SelectedPolicyClasses.Sort((x, y) => y.Order.CompareTo(x.Order)); var othercount = 1; var lastOtherFoundId = "-1"; var otherProcessed = false; for (var index = v.SelectedPolicyClasses.Count - 1; index >= 0; index--) { var f = v.SelectedPolicyClasses[index]; var found = MinorItems.FirstOrDefault(x => x.Id == f.Id); var isOther = false; if (found == null) { otherProcessed = false; //other renames need to handle. (holy moley) found = MinorItems.FirstOrDefault(x => x.Title.StartsWith("click me", StringComparison.OrdinalIgnoreCase) && x.Id != lastOtherFoundId); isOther = true; othercount++; } if (found == null) { continue; } foreach (var no in tvaPolicies.AllNodes) { lastOtherFoundId = found.Id; if (!String.Equals(no.Tag.ToString(), found.MajorClass, StringComparison.OrdinalIgnoreCase)) { continue; } foreach (var cno in no.Children) { if (!String.Equals(cno.Tag.ToString(), found.Title, StringComparison.OrdinalIgnoreCase)) { continue; } if (isOther && otherProcessed) { continue; } reOrder = reOrder + 1; var path = tvaPolicies.GetPath(cno); var node = ((AdvancedTreeNode)path.LastNode); node.CheckState = CheckState.Checked; node.Checked = true; no.Expand(false); if (isOther) { node.Text = f.Title; otherProcessed = true; } //if (reload) //on generate get them from cache as they're passed thru //{ // node.Current = found.CurrentInsurer; // node.Reccommended = found.RecommendedInsurer; // node.OrderPolicy = reOrder.ToString(); // node.ReccommendedId = found.RecommendedInsurerId; // node.CurrentId = found.CurrentInsurerId; //} //else //{ node.Insurer = f.RecommendedInsurer; node.OrderPolicy = reOrder.ToString(CultureInfo.InvariantCulture); node.InsurerId = f.RecommendedInsurerId; //} } //var item = // MinorItems.FirstOrDefault( // i => String.Equals(i.Title, f.Title, StringComparison.OrdinalIgnoreCase)); //if (item != null) //{ //_selectedPolicyClasses.Add(item); //} } } }