protected void btnSearch_Click(object sender, EventArgs e) { string policyNumber = tbPolicyNumber.Text; int insuranceCompanyID = int.Parse(ddlInsuranceCompany.SelectedValue); try { PolicyItem pi = PolicyItem.GetByNumberAndInsuranceCompany(policyNumber, insuranceCompanyID); if (pi != null) { UpdateTextBoxes(pi); lblFeedback.Text = string.Empty; GridViewRates.DataBind(); btnGenerate.Enabled = true; } else { lblFeedback.Text = "Не е пронајдена полиса!"; } odsPaidPayments.SelectParameters.Clear(); odsPaidPayments.SelectParameters.Add("policyItemID", pi.ID.ToString()); GridViewPayments.DataBind(); } catch (Exception ex) { pnlInsurancecSubType.Visible = true; ddlInsuranceSubTypes.DataBind(); lblFeedback.Text = "Изберете полиса!"; btnGenerate.Enabled = false; btnInsert.Enabled = false; // GridViewRates.DataBind(); // GridViewPayments.DataBind(); } }
public void Test01_RegisterSinglePolicy() { Assert.AreEqual(0, PolicyCacheManager.Instance.GetPolicies().Length); PolicyItem policy = new PolicyItem(); policy.UniqueId = "Policy1"; policy.Contents = File.ReadAllBytes(Path.Combine(TEST_PATH, "policy1.runtimepolicy")); policy.Users = new string[] { @"WSDEV\LNPAIR" }; //1 restricted target policy.RestrictedTargets = new RunAt[] { RunAt.Client }; PolicyCacheManager.Instance.RegisterPolicy(policy); Assert.AreEqual(1, PolicyCacheManager.Instance.InternalCollection.Count, "Unexpected collection size (expect size to equal total RestrictedTarget.Count)"); Assert.AreEqual(1, PolicyCacheManager.Instance.GetPolicies().Length, "Unexpected collection size (1 entry per registered policy)"); PolicyCacheManager.Instance.Clear(); //2 restricted targets policy.RestrictedTargets = new RunAt[] { RunAt.Client, RunAt.Server }; PolicyCacheManager.Instance.RegisterPolicy(policy); Assert.AreEqual(2, PolicyCacheManager.Instance.InternalCollection.Count, "Unexpected collection size (expect size to equal total RestrictedTarget.Count)"); Assert.AreEqual(1, PolicyCacheManager.Instance.GetPolicies().Length, "Unexpected collection size (1 entry per registered policy)"); PolicyCacheManager.Instance.Clear(); }
protected void dvDataSource_Inserted(object sender, ObjectDataSourceStatusEventArgs e) { object o = e.ReturnValue; IncomingFacture inFac = (IncomingFacture)o; if (inFac.IncomingFactureType.Code == IncomingFactureType.ZA_POLISI) { GridView gvNewPolicies = (GridView)DetailsView1.FindControl("gvNewPolicies"); List <FactureInfo> lastFactureInfos = listFactureInfos; GridViewRowCollection displayedRows = gvNewPolicies.Rows; foreach (GridViewRow gvRow in displayedRows) { CheckBox cbIsForFacturing = gvRow.FindControl("cbIsForFacturing") as CheckBox; int factureInfoID = Convert.ToInt32(gvNewPolicies.DataKeys[gvRow.RowIndex].Value); FactureInfo fi = lastFactureInfos.Where(f => f.ID == factureInfoID).SingleOrDefault(); fi.IsForFacturing = cbIsForFacturing.Checked; } listFactureInfos = lastFactureInfos; List <FactureInfo> listFactureInfo = listFactureInfos.Where(c => c.IsForFacturing == true).ToList(); foreach (FactureInfo fi in listFactureInfo) { IncomingFacturePolicyItem ifpi = new IncomingFacturePolicyItem(); ifpi.IncomingFactureID = inFac.ID; ifpi.PolicyItemID = fi.ID; ifpi.IsActive = true; ifpi.Insert(); PolicyItem pi = PolicyItem.Get(fi.ID); pi.PolicyIncomeFactureStatusID = PolicyIncomeFactureStatuse.GetByCode(PolicyIncomeFactureStatuse.CELOSNO_FAKTURIRANA).ID; PolicyItem.Table.Context.SubmitChanges(); } } }
protected void btnAddPolicyToList_Click(object sender, EventArgs e) { try { TextBox tbPolicyNumberToList = (TextBox)DetailsView1.FindControl("tbPolicyNumberToList"); DropDownList ddlInsuranceCompanies = (DropDownList)DetailsView1.FindControl("ddlInsuranceCompanies"); int icID = Convert.ToInt32(ddlInsuranceCompanies.SelectedValue); InsuranceCompany ic = InsuranceCompany.Get(icID); PolicyItem pi = PolicyItem.GetByNumberAndInsuranceCompany(tbPolicyNumberToList.Text, icID); if (pi != null) { GridView gvNewPolicies = (GridView)DetailsView1.FindControl("gvNewPolicies"); List <FactureInfo> lastFactureInfos = listFactureInfos; FactureInfo fi = listFactureInfos.Where(c => c.PolicyNumber == tbPolicyNumberToList.Text).SingleOrDefault(); if (fi != null) { RegisterStartupScript("myAlert", "<script>alert('Полисата постои во листата!')</script>"); return; } FactureInfo newFactureInfo = new FactureInfo(); newFactureInfo.PolicyNumber = tbPolicyNumberToList.Text; newFactureInfo.IsForFacturing = true; newFactureInfo.ID = pi.ID; lastFactureInfos.Add(newFactureInfo); listFactureInfos = lastFactureInfos; gvNewPolicies.DataSource = lastFactureInfos; gvNewPolicies.DataBind(); } else { RegisterStartupScript("myAlert", "<script>alert('Не постои полиса со избраниот број!')</script>"); } } catch { RegisterStartupScript("myAlert", "<script>alert('Грешка!')</script>"); } }
public static List <FinanceCardInfo> GetByPolicy(Policy p, decimal totSaldo) { List <FinanceCardInfo> retList = new List <FinanceCardInfo>(); List <PolicyItem> lstPI = PolicyItem.GetByPolicy(p.ID); foreach (PolicyItem pi in lstPI) { List <Rate> lstRates = Rate.GetByPolicyItemID(pi.ID); List <Payment> lstPayment = Payment.GetByPolicyItemID(pi.ID); foreach (Rate r in lstRates) { FinanceCardInfo fciRate = new FinanceCardInfo(); fciRate.DocumentDate = pi.Policy.ApplicationDate; fciRate.PaidDate = r.Date; if (lstRates.Count == 1) { fciRate.Description = "Продадена полиса " + pi.PolicyNumber; } else { fciRate.Description = r.Number.ToString() + "-ва рата по полиса " + pi.PolicyNumber; } fciRate.DebtValue = r.Value; fciRate.DemandValue = 0; fciRate.SaldoValue = totSaldo + (fciRate.DebtValue - fciRate.DemandValue); totSaldo = fciRate.SaldoValue; retList.Add(fciRate); } foreach (Payment payment in lstPayment) { FinanceCardInfo fciPayment = new FinanceCardInfo(); fciPayment.DocumentDate = payment.Date; fciPayment.PaidDate = payment.Rate.Date; if (lstRates.Count == 1) { fciPayment.Description = "Уплата по полиса " + pi.PolicyNumber; } else { fciPayment.Description = "Уплата за " + payment.Rate.Number + "-ва рата по полиса " + pi.PolicyNumber; } fciPayment.DebtValue = 0; fciPayment.DemandValue = payment.Value; fciPayment.SaldoValue = totSaldo + (fciPayment.DebtValue - fciPayment.DemandValue); totSaldo = fciPayment.SaldoValue; retList.Add(fciPayment); } } return(retList); }
protected void btnInsert_Click(object sender, EventArgs e) { DateTime startDate = DateTime.Parse(tbStartDate.Text); DateTime endDate = DateTime.Parse(tbEndDate.Text); List <FactureInfo> lastFactureInfos = listNewFactureInfos; GridViewRowCollection displayedRows = gvNewPolicies.Rows; foreach (GridViewRow gvRow in displayedRows) { CheckBox cbIsForFacturing = gvRow.FindControl("cbIsForFacturing") as CheckBox; int factureInfoID = Convert.ToInt32(gvNewPolicies.DataKeys[gvRow.RowIndex].Value); FactureInfo fi = lastFactureInfos.Where(facInfo => facInfo.ID == factureInfoID).SingleOrDefault(); fi.IsForFacturing = cbIsForFacturing.Checked; } listNewFactureInfos = lastFactureInfos; List <PolicyItem> items = new List <PolicyItem>(); foreach (FactureInfo fi in lastFactureInfos) { if (fi.IsForFacturing) { PolicyItem pi = PolicyItem.Get(fi.ID); items.Add(pi); } } if (items.Count > 0) { if (ddlClients.SelectedIndex != -1) { int clientID = int.Parse(ddlClients.SelectedValue); int factureID = Broker.DataAccess.Facture.CreateGroupFacture(this.PageUser.ID, clientID, startDate, endDate, items); FactureID = factureID; btnPrint.Visible = true; btnInsert.Visible = false; //btnPrintAnex.Visible = true; InsertClientInFinansovo(clientID); } else { lblError.Visible = true; btnPrint.Visible = false; } } else { lblError.Visible = true; btnPrint.Visible = false; } }
protected void DetailsView1_ItemInserting(object sender, DetailsViewInsertEventArgs e) { e.Values["EntryByUserID"] = this.PageUser.ID; TextBox tbPolicyNumber = DetailsView1.FindControl("tbPolicyNumber") as TextBox; string policyNumber = tbPolicyNumber.Text; DropDownList ddlInsuranceSubTypes = DetailsView1.FindControl("ddlInsuranceSubTypes") as DropDownList; int insuranceSubTypeID = Convert.ToInt32(ddlInsuranceSubTypes.SelectedValue); DropDownList ddlInsuranceCompanies = DetailsView1.FindControl("ddlInsuranceCompanies") as DropDownList; int insuranceCompanyID = Convert.ToInt32(ddlInsuranceCompanies.SelectedValue); PolicyItem pi = PolicyItem.Table.Where(pol => pol.PolicyNumber == policyNumber && pol.InsuranceSubTypeID == insuranceSubTypeID && pol.Policy.InsuranceCompanyID == insuranceCompanyID).SingleOrDefault(); if (pi != null) { e.Values["PolicyItemID"] = pi.ID; } }
protected void ddlInsuranceSubTypes_SelectedIndexChanged(object sender, EventArgs e) { odsRates.SelectParameters.Clear(); odsRates.TypeName = "Broker.DataAccess.Rate"; odsRates.DataObjectTypeName = "Broker.DataAccess.Rate"; odsRates.SelectMethod = "GetByPolicyNumberAndInsuranceSubTypeIDAndInsuranceCompanyID"; odsRates.SelectParameters.Add("policyNumber", tbPolicyNumber.Text); odsRates.SelectParameters.Add("insuranceSubTypeID", Convert.ToInt32(ddlInsuranceSubTypes.SelectedValue).ToString()); odsRates.SelectParameters.Add("insuranceCompanyID", Convert.ToInt32(ddlInsuranceCompany.SelectedValue).ToString()); GridViewRates.DataBind(); PolicyItem pi = PolicyItem.GetByNumberAndInsuranceSubType(tbPolicyNumber.Text, Convert.ToInt32(ddlInsuranceSubTypes.SelectedValue), int.Parse(ddlInsuranceCompany.SelectedValue)); odsPaidPayments.SelectParameters.Clear(); odsPaidPayments.SelectParameters.Add("policyItemID", pi.ID.ToString()); GridViewPayments.DataBind(); UpdateTextBoxes(pi); }
void LoadPoliciesForFacturing(int insuranceCompanyID) { GridView gvNewPolicies = (GridView)DetailsView1.FindControl("gvNewPolicies"); List <PolicyItem> newPiList = PolicyItem.GetNonIncomeFactured(insuranceCompanyID); List <FactureInfo> newFactureInfos = new List <FactureInfo>(); foreach (PolicyItem pi in newPiList) { FactureInfo fi = new FactureInfo(); fi.ID = pi.ID; fi.IsForFacturing = true; fi.PolicyNumber = pi.PolicyNumber; newFactureInfos.Add(fi); } listFactureInfos = newFactureInfos; gvNewPolicies.DataSource = newFactureInfos; gvNewPolicies.DataBind(); }
protected void btnInsertNewPayments_Click(object sender, EventArgs e) { Bankslip b = Bankslip.Get(Convert.ToInt32(dvBankslipForPayments.SelectedValue)); decimal totPaidValue = 0; foreach (GridViewRow gvr in gvNewPayments.Rows) { int polID = Convert.ToInt32(gvr.Cells[0].Text); PolicyItem pi = Policy.Get(polID).PolicyItems[0]; TextBox tbNewPayment = gvr.FindControl("tbNewPayment") as TextBox; decimal newPaidValue = 0; decimal.TryParse(tbNewPayment.Text, out newPaidValue); totPaidValue += newPaidValue; } decimal biDemandValue = 0; if (ViewState["gvForPaymentsSelectedValue"] != null) { BankslipItem bi = BankslipItem.Get(Convert.ToInt32(ViewState["gvForPaymentsSelectedValue"])); biDemandValue = bi.DemandValue; } if (totPaidValue != biDemandValue) { RegisterStartupScript("myAlert", "<script>alert('Вкупниот внесен износ по полиси се разликува од вредноста побарува од ставката на изводот!')</script>"); return; } foreach (GridViewRow gvr in gvNewPayments.Rows) { int polID = Convert.ToInt32(gvr.Cells[0].Text); PolicyItem pi = Policy.Get(polID).PolicyItems[0]; TextBox tbNewPayment = gvr.FindControl("tbNewPayment") as TextBox; decimal newPaidValue = 0; decimal.TryParse(tbNewPayment.Text, out newPaidValue); InsertPaymentsForPolicy(pi, newPaidValue, b.Date, b.BankslipNumber, b.BankID); } if (ViewState["gvForPaymentsSelectedValue"] != null) { BankslipItem bi = BankslipItem.Get(Convert.ToInt32(ViewState["gvForPaymentsSelectedValue"])); bi.IsPaid = true; BankslipItem.Table.Context.SubmitChanges(); } mvMain.SetActiveView(viewGrid); btnInsertNewPayments.Enabled = false; }
protected void btnSearch_Click(object sender, EventArgs e) { int insuranceCompanyID = Convert.ToInt32(ddlInsuranceCompany.SelectedValue); int insuranceTypeID = Convert.ToInt32(ddlInsuranceType.SelectedValue); int insuranceSubTypeID = Convert.ToInt32(ddlInsuranceSubTypes.SelectedValue); string policyNumber = tbPolicyNumber.Text; PolicyItem pi = PolicyItem.GetByNumberAndInsuranceSubType(policyNumber, insuranceSubTypeID, insuranceCompanyID); if (pi != null) { tbStartDate.Text = pi.Policy.StartDate.ToShortDateString(); tbEndDate.Text = pi.Policy.EndDate.ToShortDateString(); tbCoverage.Text = pi.PremiumValue.ToString(); tbOwnerEMBG.Text = pi.Policy.Client1.EMBG; tbOwnerName.Text = pi.Policy.Client1.Name; PolicyItemID = pi.ID; } lblError.Visible = false; lblSuccess.Visible = false; }
void BindPolForClient(int clientID) { DateTime startDate = DateTime.Parse(tbStartDate.Text); DateTime endDate = DateTime.Parse(tbEndDate.Text); List <PolicyItem> lstPolPerClient = PolicyItem.GetForGroupFactures(startDate, endDate, clientID); List <FactureInfo> lstFacInfo = new List <FactureInfo>(); foreach (PolicyItem pi in lstPolPerClient) { FactureInfo fi = new FactureInfo(); fi.ID = pi.ID; fi.PolicyNumber = pi.PolicyNumber; fi.IsForFacturing = true; fi.PremiumValue = pi.PremiumValue; lstFacInfo.Add(fi); } listNewFactureInfos = lstFacInfo; gvNewPolicies.DataSource = lstFacInfo; gvNewPolicies.DataBind(); }
internal static void AddItem(ComboBox cmbItem, TextBox txtDesc, TextBox txtValue) { try { PolicyItem pi = new PolicyItem(); pi.OrdNumber = policy.ItemList.Count + 1; pi.Type = cmbItem.SelectedItem as InsuranceType; pi.Description = txtDesc.Text; pi.Ammount = pi.Type.PricePremium; pi.Date = DateTime.Now; policy.Value += pi.Ammount; txtValue.Text = policy.Value.ToString("N02"); policy.ItemList.Add(pi); } catch (Exception) { } }
internal static void DeleteItem(DataGridView dataGridView1, TextBox txtValue) { try { PolicyItem pi = dataGridView1.CurrentRow.DataBoundItem as PolicyItem; policy.ItemList.Remove(pi); policy.Value -= pi.Ammount; txtValue.Text = policy.Value.ToString("N02"); int i = 1; foreach (PolicyItem p in policy.ItemList) { p.OrdNumber = i; i++; } } catch (Exception) { MessageBox.Show("No item selected!"); } }
protected void btnCheck_Click(object sender, EventArgs e) { DateTime fromDate = DateTime.Parse(tbFromDate.Text); DateTime toDate = DateTime.Parse(tbToDate.Text); List <PolicyItem> pList = PolicyItem.GetNonBrokerageSliped(Convert.ToInt32(ddlInsuranceCompanies.SelectedValue), fromDate, toDate); List <PolicyForSlipsInfo> fInfos = new List <PolicyForSlipsInfo>(); foreach (PolicyItem pi in pList) { PolicyForSlipsInfo pfsi = new PolicyForSlipsInfo(); pfsi.ID = pi.ID; pfsi.BrokerageID = pi.BrokerageID; pfsi.PacketBrokerageID = pi.PacketBrokerageID; pfsi.InsuranceSubTypeID = pi.InsuranceSubTypeID; pfsi.IsForFacturing = true; pfsi.PolicyNumber = pi.PolicyNumber; fInfos.Add(pfsi); } listPolicyForSlipsInfos = fInfos; gvNewPolicies.DataSource = fInfos; gvNewPolicies.DataBind(); }
private void InitPolicies() { PolicyItem item = new PolicyItem("AuditTest", File.ReadAllBytes(Path.Combine(TESTPATH, "AuditTest.runtimepolicy"))); item.RestrictedTargets = new RunAt[] { RunAt.Client }; GetPolicyCache().Add(item); /// policy1.runtimepolicy contains two policies (amongst others): /// Policy2 - text in email subject(custom routing): Block On Execution Error set to FALSE /// Policy1 - text in email subject: Block On Execution Error set to TRUE item = new PolicyItem("Policy1", File.ReadAllBytes(Path.Combine(TESTPATH, "policy1.runtimepolicy"))); item.RestrictedTargets = new RunAt[] { RunAt.Client }; GetPolicyCache().Add(item); item = new PolicyItem("Policy2", File.ReadAllBytes(Path.Combine(TESTPATH, "policy2.runtimepolicy"))); item.RestrictedTargets = new RunAt[] { RunAt.Client }; GetPolicyCache().Add(item); item = new PolicyItem("MTAtests", File.ReadAllBytes(Path.Combine(TESTPATH, "MTAtests.runtimepolicy"))); item.RestrictedTargets = new RunAt[] { RunAt.Server }; GetPolicyCache().Add(item); item = new PolicyItem("NetMon", File.ReadAllBytes(Path.Combine(TESTPATH, "NetMon.runtimepolicy"))); item.RestrictedTargets = new RunAt[] { RunAt.Server }; GetPolicyCache().Add(item); item = new PolicyItem("NetworkContentDiscovery", File.ReadAllBytes(Path.Combine(TESTPATH, "NetworkContentDiscovery.runtimepolicy"))); item.RestrictedTargets = new RunAt[] { RunAt.Server }; GetPolicyCache().Add(item); Assert.IsTrue(GetPolicyCache().Contains("Policy1")); Assert.IsTrue(GetPolicyCache().Contains("Policy2")); Assert.IsTrue(GetPolicyCache().Contains("MTAtests")); Assert.IsTrue(GetPolicyCache().Contains("NetMon")); Assert.IsTrue(GetPolicyCache().Contains("NetworkContentDiscovery")); Assert.IsTrue(GetPolicyCache().Contains("AuditTest")); }
public void TestFixtureSetUp() { m_results = new List<PerformanceTestResult>(); string[] setDirectories = new string[] { Workshare.TestUtils.TestFileUtils.MakeRootPathAbsolute(@"\projects\hygiene\Policies\Confidential Information"), Workshare.TestUtils.TestFileUtils.MakeRootPathAbsolute(@"\projects\hygiene\Policies\Hidden Data Management"), Workshare.TestUtils.TestFileUtils.MakeRootPathAbsolute(@"\projects\hygiene\Policies\Human Resources"), Workshare.TestUtils.TestFileUtils.MakeRootPathAbsolute(@"\projects\hygiene\Policies\Personal Identifiable Information") }; foreach (string dir in setDirectories) { DirectoryInfo dirInfo = new DirectoryInfo(dir); foreach (FileInfo file in dirInfo.GetFiles("*.runtimepolicy", SearchOption.TopDirectoryOnly)) { PolicyItem item = new PolicyItem(file.Name, File.ReadAllBytes(file.FullName)); item.RestrictedTargets = new RunAt[] { RunAt.Client }; GetPolicyCache().Add(item); } } }
protected void btnClientEMBGSearch_Click(object sender, EventArgs e) { Panel pnlClient = PoliciesDetailsView.FindControl("pnlClient") as Panel; DetailsView clientDetailsView = pnlClient.FindControl("ClientDetailsView") as DetailsView; ObjectDataSource clientdvDataSource = pnlClient.FindControl("ClientdvDataSource") as ObjectDataSource; if (PoliciesDetailsView.SelectedValue != null) { int policyItemID = Convert.ToInt32(PoliciesDetailsView.SelectedValue); PolicyItem policyItem = PolicyItem.Get(policyItemID); string clientEMBG = policyItem.Policy.Client.EMBG; pnlClient.Visible = true; clientdvDataSource.SelectParameters.Clear(); clientdvDataSource.SelectParameters.Add("embg", clientEMBG); clientDetailsView.DataBind(); } else { pnlClient.Visible = false; clientdvDataSource.SelectParameters.Clear(); clientDetailsView.DataBind(); } }
protected void btnSearch_Click(object sender, EventArgs e) { int insuranceCompanyID = Convert.ToInt32(ddlInsuranceCompany.SelectedValue); int insuranceTypeID = Convert.ToInt32(ddlInsuranceType.SelectedValue); int insuranceSubTypeID = Convert.ToInt32(ddlInsuranceSubTypes.SelectedValue); string policyNumber = tbPolicyNumber.Text; dvDataSource.SelectParameters.Clear(); dvDataSource.SelectParameters.Add("policyNumber", policyNumber); dvDataSource.SelectParameters.Add("insuranceSubTypeID", insuranceSubTypeID.ToString()); dvDataSource.SelectParameters.Add("insuranceCompanyID", insuranceCompanyID.ToString()); PoliciesDetailsView.DataBind(); PolicyItem pi = PolicyItem.GetByNumberAndInsuranceSubType(policyNumber, insuranceSubTypeID, insuranceCompanyID); if (pi != null) { btnUpdate.Visible = true; CreateChildControls(); } else { btnUpdate.Visible = false; } }
protected void btnCheck_Click(object sender, EventArgs e) { DateTime fromDate = DateTime.Parse(tbStartDate.Text); DateTime toDate = DateTime.Parse(tbEndDate.Text); List <PolicyItem> oldPiList = PolicyItem.GetFromPreivousMonthsForAccountFactures(fromDate, int.Parse(ddlInsuranceCompanies.SelectedValue)); List <FactureInfo> oldFactureInfos = new List <FactureInfo>(); foreach (PolicyItem pi in oldPiList) { FactureInfo fi = new FactureInfo(); fi.ID = pi.ID; fi.IsForFacturing = true; fi.PolicyNumber = pi.PolicyNumber; oldFactureInfos.Add(fi); } listFactureInfos = oldFactureInfos; gvOldPolicies.DataSource = oldFactureInfos; gvOldPolicies.Caption = "Полиси од претходни месеци (" + oldFactureInfos.Count.ToString() + ")"; gvOldPolicies.DataBind(); List <PolicyItem> newPiList = PolicyItem.GetForAccountFacturingFromCurrentMonth(fromDate, toDate, int.Parse(ddlInsuranceCompanies.SelectedValue)); List <FactureInfo> newFactureInfos = new List <FactureInfo>(); foreach (PolicyItem pi in newPiList) { FactureInfo fi = new FactureInfo(); fi.ID = pi.ID; fi.IsForFacturing = true; fi.PolicyNumber = pi.PolicyNumber; newFactureInfos.Add(fi); } listNewFactureInfos = newFactureInfos; gvNewPolicies.DataSource = newFactureInfos; gvNewPolicies.Caption = "Полиси од селектираниот период (" + newFactureInfos.Count.ToString() + ")"; gvNewPolicies.DataBind(); }
protected void btnInsert_Click(object sender, EventArgs e) { DateTime inputDate = Convert.ToDateTime(tbDateOfPayment.Text); int insuranceCompanyID = int.Parse(ddlInsuranceCompany.SelectedValue); PolicyItem pi; if (ddlInsuranceSubTypes.Items.Count > 0) { pi = PolicyItem.GetByNumberAndInsuranceSubType(tbPolicyNumber.Text, Convert.ToInt32(ddlInsuranceSubTypes.SelectedValue), insuranceCompanyID); } else { pi = PolicyItem.GetByNumber(tbPolicyNumber.Text, insuranceCompanyID); } if (inputDate.Date > DateTime.Today) { lblFeedback.Text = "Не е можно внесување на датуми поголеми од денешниот"; } else { List <Payment> listPayments = Payment.GetByPolicyItemID(pi.ID); decimal paymentTotalValue = 0; foreach (Payment payment in listPayments) { paymentTotalValue += payment.Value; } if (Convert.ToDecimal(tbValueOfPayment.Text) > (pi.PremiumValue - paymentTotalValue)) { lblFeedback.Text = "Поголем износ од преостанатиот износ за плаќање"; } else { decimal valueFromClient = Convert.ToDecimal(tbValueOfPayment.Text); while (valueFromClient > 0) { Rate currentRate = Rate.GetCurrentRateForPayment(pi.ID); Payment newPayment = new Payment(); newPayment.Date = Convert.ToDateTime(tbDateOfPayment.Text); newPayment.RateID = currentRate.ID; newPayment.IsCashReported = false; Broker.DataAccess.PaymentType pt = Broker.DataAccess.PaymentType.Get(Convert.ToInt32(ddlPaymentTypes.SelectedValue)); newPayment.PaymentTypeID = pt.ID; if (pt.Code == Broker.DataAccess.PaymentType.CREDITCARD) { newPayment.BankCreditCardID = BankCreditCard.GetByBankAndCard(Convert.ToInt32(ddlBank.SelectedValue), Convert.ToInt32(ddlCardTypes.SelectedValue)).ID; } newPayment.UserID = this.PageUser.ID; newPayment.BranchID = this.PageUser.BranchID; if (tbBankslipNumber.Text.Trim() != string.Empty) { newPayment.BankslipNumber = tbBankslipNumber.Text; newPayment.BankslipBankID = Convert.ToInt32(ddlBankslipBanks.SelectedValue); } if (valueFromClient >= currentRate.Value) { newPayment.Value = currentRate.Value - Payment.GetPaidValueForRate(currentRate.ID); newPayment.Insert(); decimal basicValue = newPayment.Value; decimal k = basicValue / newPayment.Rate.PolicyItem.PremiumValue; List <ControlAppropriateInsuranceSubType> listAppropriateIST = Broker.DataAccess.ControlAppropriateInsuranceSubType.Table.ToList(); foreach (ControlAppropriateInsuranceSubType c in listAppropriateIST) { PolicyExtendInformation pei = PolicyExtendInformation.GetByPolicyItemAndControl(pi.ID, c.ControlID); if (pei != null) { decimal peiValue = 0; decimal.TryParse(pei.Value, out peiValue); basicValue -= k * peiValue; if (peiValue > 0) { PaymentsPerInsSubType ppist = new PaymentsPerInsSubType(); ppist.PaymentID = newPayment.ID; ppist.InsuranceSubTypeID = c.InsuranceSubTypeID; ppist.PaidValue = k * peiValue; ppist.BrokerageValue = ppist.PaidValue * pi.BrokeragePercentage / 100; ppist.Insert(); } } } if (basicValue > 0) { PaymentsPerInsSubType ppist = new PaymentsPerInsSubType(); ppist.PaymentID = newPayment.ID; ppist.InsuranceSubTypeID = pi.InsuranceSubTypeID; ppist.PaidValue = basicValue; ppist.BrokerageValue = ppist.PaidValue * pi.BrokeragePercentage / 100; ppist.Insert(); } valueFromClient -= newPayment.Value; currentRate.PaidValue += newPayment.Value; Rate.Table.Context.SubmitChanges(); } else { if (valueFromClient <= (currentRate.Value - currentRate.PaidValue)) { newPayment.Value = valueFromClient; newPayment.Insert(); decimal basicValue = newPayment.Value; decimal k = basicValue / newPayment.Rate.PolicyItem.PremiumValue; List <ControlAppropriateInsuranceSubType> listAppropriateIST = Broker.DataAccess.ControlAppropriateInsuranceSubType.Table.ToList(); foreach (ControlAppropriateInsuranceSubType c in listAppropriateIST) { PolicyExtendInformation pei = PolicyExtendInformation.GetByPolicyItemAndControl(pi.ID, c.ControlID); if (pei != null) { decimal peiValue = 0; decimal.TryParse(pei.Value, out peiValue); basicValue -= k * peiValue; if (peiValue > 0) { PaymentsPerInsSubType ppist = new PaymentsPerInsSubType(); ppist.PaymentID = newPayment.ID; ppist.InsuranceSubTypeID = c.InsuranceSubTypeID; ppist.PaidValue = k * peiValue; ppist.BrokerageValue = ppist.PaidValue * pi.BrokeragePercentage / 100; ppist.Insert(); } } } if (basicValue > 0) { PaymentsPerInsSubType ppist = new PaymentsPerInsSubType(); ppist.PaymentID = newPayment.ID; ppist.InsuranceSubTypeID = pi.InsuranceSubTypeID; ppist.PaidValue = basicValue; ppist.BrokerageValue = ppist.PaidValue * pi.BrokeragePercentage / 100; ppist.Insert(); } currentRate.PaidValue += valueFromClient; Rate.Table.Context.SubmitChanges(); break; } else { newPayment.Value = (currentRate.Value - currentRate.PaidValue); newPayment.Insert(); decimal basicValue = newPayment.Value; decimal k = basicValue / newPayment.Rate.PolicyItem.PremiumValue; List <ControlAppropriateInsuranceSubType> listAppropriateIST = Broker.DataAccess.ControlAppropriateInsuranceSubType.Table.ToList(); foreach (ControlAppropriateInsuranceSubType c in listAppropriateIST) { PolicyExtendInformation pei = PolicyExtendInformation.GetByPolicyItemAndControl(pi.ID, c.ControlID); if (pei != null) { decimal peiValue = 0; decimal.TryParse(pei.Value, out peiValue); basicValue -= k * peiValue; if (peiValue > 0) { PaymentsPerInsSubType ppist = new PaymentsPerInsSubType(); ppist.PaymentID = newPayment.ID; ppist.InsuranceSubTypeID = c.InsuranceSubTypeID; ppist.PaidValue = k * peiValue; ppist.BrokerageValue = ppist.PaidValue * pi.BrokeragePercentage / 100; ppist.Insert(); } } } if (basicValue > 0) { PaymentsPerInsSubType ppist = new PaymentsPerInsSubType(); ppist.PaymentID = newPayment.ID; ppist.InsuranceSubTypeID = pi.InsuranceSubTypeID; ppist.PaidValue = basicValue; ppist.BrokerageValue = ppist.PaidValue * pi.BrokeragePercentage / 100; ppist.Insert(); } //currentRate.PaidValue += valueFromClient; //Rate.Table.Context.SubmitChanges(); currentRate.PaidValue += newPayment.Value; Rate.Table.Context.SubmitChanges(); valueFromClient -= newPayment.Value; } } } Broker.DataAccess.Facture.UpdatePaidStatusForFacture(pi.ID); } } GridViewPayments.DataSource = null; GridViewPayments.DataSourceID = odsPaidPayments.ID; odsPaidPayments.SelectParameters.Clear(); odsPaidPayments.SelectParameters.Add("policyItemID", pi.ID.ToString()); GridViewPayments.DataBind(); GridViewRates.DataSource = null; GridViewRates.DataSourceID = odsRates.ID; odsRates.SelectParameters.Clear(); odsRates.TypeName = "Broker.DataAccess.Rate"; odsRates.DataObjectTypeName = "Broker.DataAccess.Rate"; odsRates.SelectMethod = "GetByPolicyNumberAndInsuranceSubTypeIDAndInsuranceCompanyID"; odsRates.SelectParameters.Add("policyNumber", tbPolicyNumber.Text); odsRates.SelectParameters.Add("insuranceSubTypeID", pi.InsuranceSubType.ID.ToString()); odsRates.SelectParameters.Add("insuranceCompanyID", ddlInsuranceCompany.SelectedValue); //odsRates.SelectMethod = "Broker.DataAccess.PolicyItem.GetByNumberAndInsuranceSubType"; GridViewRates.DataBind(); UpdateTextBoxes(pi); }
public void Test07_RemovePolicy() { Assert.AreEqual(0, PolicyCacheManager.Instance.GetUserLookupRowCount()); Assert.AreEqual(0, PolicyCacheManager.Instance.GetPolicyTypeLookupRowCount()); PolicyItem policy1 = new PolicyItem(); policy1.UniqueId = "Policy1"; policy1.Contents = File.ReadAllBytes(Path.Combine(TEST_PATH, "policy1.runtimepolicy")); policy1.Users = new string[] { @"WSDEV\LNPAIR" }; policy1.RestrictedTargets = new RunAt[] { RunAt.Client }; PolicyCacheManager.Instance.RegisterPolicy(policy1); Assert.AreEqual(1, PolicyCacheManager.Instance.InternalCollection.Count, "Unexpected collection size (expect size to equal total RestrictedTarget.Count)"); Assert.AreNotEqual(0, PolicyCacheManager.Instance.GetUserLookupRowCount()); Assert.AreNotEqual(0, PolicyCacheManager.Instance.GetPolicyTypeLookupRowCount()); Assert.AreEqual(1, PolicyCacheManager.Instance.GetPolicies().Length, "Unexpected collection size (1 entry per registered policy)"); PolicyCacheManager.Instance.RemovePolicy("Policy1"); Assert.AreEqual(0, PolicyCacheManager.Instance.InternalCollection.Count, "We removed the policy so the internal collection should now be 0"); Assert.AreEqual(0, PolicyCacheManager.Instance.GetUserLookupRowCount()); Assert.AreEqual(0, PolicyCacheManager.Instance.GetPolicyTypeLookupRowCount()); Assert.AreEqual(0, PolicyCacheManager.Instance.GetPolicies().Length, "Unexpected collection size (1 entry per registered policy)"); }
public void Test09_UpdatePolicy_DoesNotExist() { Assert.AreEqual(0, PolicyCacheManager.Instance.InternalCollection.Count); try { PolicyItem policyHasNotBeenAdded = new PolicyItem("someUniqueId", File.ReadAllBytes(Path.Combine(TEST_PATH, "policy1.runtimepolicy"))); PolicyCacheManager.Instance.UpdatePolicy(policyHasNotBeenAdded); } catch (ArgumentException) { Assert.AreEqual(0, PolicyCacheManager.Instance.InternalCollection.Count); Assert.AreEqual(0, PolicyCacheManager.Instance.GetPolicies().Length, "Unexpected collection size (1 entry per registered policy)"); return; } Assert.Fail("Expected to throw an exception when trying to update a non-registered policy."); }
protected override void CreateChildControls() { if (PoliciesDetailsView.SelectedValue != null) { int policyItemID = Convert.ToInt32(PoliciesDetailsView.SelectedValue); PolicyItem policyItem = PolicyItem.Get(policyItemID); Panel pnlExtendControls = PoliciesDetailsView.FindControl("pnlExtendControls") as Panel; int j = 0; List <Broker.DataAccess.Control> listControls = Broker.DataAccess.Control.GetByInsuranceSubType(policyItem.InsuranceSubTypeID); pnlExtendControls.Controls.Clear(); lblFieldNames = new List <Label>(); tbValues = new List <TextBox>(); HtmlTable titleTable = new HtmlTable(); titleTable.Width = "695px"; HtmlTableRow firstTitleTableRow = new HtmlTableRow(); titleTable.Rows.Add(firstTitleTableRow); HtmlTableCell firstCellFirstRowInTitleTable = new HtmlTableCell(); firstTitleTableRow.Cells.Add(firstCellFirstRowInTitleTable); Label lblPremiumBrokerageTitle = new Label(); lblPremiumBrokerageTitle.ID = "lblPremiumBrokerageTitle"; lblPremiumBrokerageTitle.Font.Bold = true; lblPremiumBrokerageTitle.Text = "Премија и брокеража"; firstCellFirstRowInTitleTable.Controls.Add(lblPremiumBrokerageTitle); pnlExtendControls.Controls.Add(titleTable); HtmlTable defaultTable = new HtmlTable(); defaultTable.Width = "695px"; HtmlTableRow fourthDefaultTableRow = new HtmlTableRow(); fourthDefaultTableRow.BgColor = "#FAFAF8"; defaultTable.Rows.Add(fourthDefaultTableRow); HtmlTableCell firstCellFourthRowInDefaultTable = new HtmlTableCell(); firstCellFourthRowInDefaultTable.Width = "160px"; fourthDefaultTableRow.Cells.Add(firstCellFourthRowInDefaultTable); Label lblPolicyValue = new Label(); lblPolicyValue.ID = "lblPolicyValue" + (j + 1).ToString(); lblPolicyValue.Text = "Премија"; firstCellFourthRowInDefaultTable.Controls.Add(lblPolicyValue); HtmlTableCell secondCellFourthRowInDefaultTable = new HtmlTableCell(); secondCellFourthRowInDefaultTable.Width = "187px"; fourthDefaultTableRow.Cells.Add(secondCellFourthRowInDefaultTable); TextBox tbPolicyValue = new TextBox(); tbPolicyValue.ID = "tbPolicyValue" + (j + 1).ToString(); tbPolicyValue.AutoPostBack = true; tbPolicyValue.Text = policyItem.PremiumValue.ToString(); tbPolicyValue.ReadOnly = true; tbPolicyValue.TextChanged += new EventHandler(tbPolicyValue_TextChanged); RequiredFieldValidator rfvPolicyValue = new RequiredFieldValidator(); rfvPolicyValue.ID = "rfvPolicyValue" + (j + 1).ToString(); rfvPolicyValue.ErrorMessage = "*"; rfvPolicyValue.Display = ValidatorDisplay.Dynamic; rfvPolicyValue.ControlToValidate = tbPolicyValue.ID; CompareValidator cvPolicyValue = new CompareValidator(); cvPolicyValue.ID = "cvPolicyValue" + (j + 1).ToString(); cvPolicyValue.ErrorMessage = "*"; cvPolicyValue.Display = ValidatorDisplay.Dynamic; cvPolicyValue.ControlToValidate = tbPolicyValue.ID; cvPolicyValue.Operator = ValidationCompareOperator.DataTypeCheck; cvPolicyValue.Type = ValidationDataType.Double; secondCellFourthRowInDefaultTable.Controls.Add(tbPolicyValue); secondCellFourthRowInDefaultTable.Controls.Add(rfvPolicyValue); secondCellFourthRowInDefaultTable.Controls.Add(cvPolicyValue); HtmlTableCell thirdCellFourthRowInDefaultTable = new HtmlTableCell(); thirdCellFourthRowInDefaultTable.Width = "160px"; fourthDefaultTableRow.Cells.Add(thirdCellFourthRowInDefaultTable); HtmlTableCell fourthCellFourthRowInDefaultTable = new HtmlTableCell(); fourthCellFourthRowInDefaultTable.Width = "187px"; fourthDefaultTableRow.Cells.Add(fourthCellFourthRowInDefaultTable); HtmlTableRow fifthDefaultTableRow = new HtmlTableRow(); defaultTable.Rows.Add(fifthDefaultTableRow); HtmlTableCell firstCellFifthRowInDefaultTable = new HtmlTableCell(); firstCellFifthRowInDefaultTable.Width = "160px"; fifthDefaultTableRow.Cells.Add(firstCellFifthRowInDefaultTable); Label lblBrokeragePercentage = new Label(); lblBrokeragePercentage.ID = "lblBrokeragePercentage" + (j + 1).ToString(); lblBrokeragePercentage.Text = "Процент на брокеража"; firstCellFifthRowInDefaultTable.Controls.Add(lblBrokeragePercentage); HtmlTableCell secondCellFifthRowInDefaultTable = new HtmlTableCell(); secondCellFifthRowInDefaultTable.Width = "187px"; fifthDefaultTableRow.Cells.Add(secondCellFifthRowInDefaultTable); TextBox tbBrokeragePercentage = new TextBox(); tbBrokeragePercentage.ID = "tbBrokeragePercentage" + (j + 1).ToString(); tbBrokeragePercentage.Text = policyItem.BrokeragePercentage.ToString(); tbBrokeragePercentage.ReadOnly = true; secondCellFifthRowInDefaultTable.Controls.Add(tbBrokeragePercentage); HtmlTableCell thirdCellFifthRowInDefaultTable = new HtmlTableCell(); thirdCellFifthRowInDefaultTable.Width = "160px"; fifthDefaultTableRow.Cells.Add(thirdCellFifthRowInDefaultTable); HtmlTableCell fourthCellFifthRowInDefaultTable = new HtmlTableCell(); fourthCellFifthRowInDefaultTable.Width = "187px"; fifthDefaultTableRow.Cells.Add(fourthCellFifthRowInDefaultTable); HtmlTableRow sixthDefaultTableRow = new HtmlTableRow(); sixthDefaultTableRow.BgColor = "#FAFAF8"; defaultTable.Rows.Add(sixthDefaultTableRow); HtmlTableCell firstCellSixthRowInDefaultTable = new HtmlTableCell(); firstCellSixthRowInDefaultTable.Width = "160px"; sixthDefaultTableRow.Cells.Add(firstCellSixthRowInDefaultTable); Label lblBrokerageValue = new Label(); lblBrokerageValue.ID = "lblBrokerageValue" + (j + 1).ToString(); lblBrokerageValue.Text = "Брокеража"; firstCellSixthRowInDefaultTable.Controls.Add(lblBrokerageValue); HtmlTableCell secondCellSixthRowInDefaultTable = new HtmlTableCell(); secondCellSixthRowInDefaultTable.Width = "187px"; sixthDefaultTableRow.Cells.Add(secondCellSixthRowInDefaultTable); TextBox tbBrokerageValue = new TextBox(); tbBrokerageValue.ID = "tbBrokerageValue" + (j + 1).ToString(); tbBrokerageValue.ReadOnly = true; tbBrokerageValue.Text = policyItem.BrokerageValue.ToString(); secondCellSixthRowInDefaultTable.Controls.Add(tbBrokerageValue); HtmlTableCell thirdCellSixthRowInDefaultTable = new HtmlTableCell(); thirdCellSixthRowInDefaultTable.Width = "160px"; sixthDefaultTableRow.Cells.Add(thirdCellSixthRowInDefaultTable); HtmlTableCell fourthCellSixthRowInDefaultTable = new HtmlTableCell(); fourthCellSixthRowInDefaultTable.Width = "187px"; sixthDefaultTableRow.Cells.Add(fourthCellSixthRowInDefaultTable); pnlExtendControls.Controls.Add(defaultTable); HtmlTable titlePolicyTable = new HtmlTable(); titlePolicyTable.Width = "695px"; HtmlTableRow firstTitlePolicyTableRow = new HtmlTableRow(); titlePolicyTable.Rows.Add(firstTitlePolicyTableRow); HtmlTableCell firstCellFirstRowInTitlePolicyTable = new HtmlTableCell(); firstTitlePolicyTableRow.Cells.Add(firstCellFirstRowInTitlePolicyTable); Label lblPolicyDetailsTitle = new Label(); lblPolicyDetailsTitle.ID = "lblPolicyDetailsTitle"; lblPolicyDetailsTitle.Font.Bold = true; lblPolicyDetailsTitle.Text = "Детални информации за полиса"; firstCellFirstRowInTitlePolicyTable.Controls.Add(lblPolicyDetailsTitle); pnlExtendControls.Controls.Add(titlePolicyTable); HtmlTable table = new HtmlTable(); table.Width = "695px"; int counter = 0; foreach (Broker.DataAccess.Control c in listControls) { if (c.IsActive) { PolicyExtendInformation policyExtendInformation = PolicyExtendInformation.GetByPolicyItemAndControl(policyItem.ID, c.ID); if (listControls.Count == 1) { HtmlTableRow tableRow = new HtmlTableRow(); tableRow.BgColor = "#FAFAF8"; table.Rows.Add(tableRow); HtmlTableCell tableCell = new HtmlTableCell(); tableCell.Width = "160px"; tableRow.Cells.Add(tableCell); Label label = new Label(); label.ID = c.LabelID; label.Text = c.LabelName; lblFieldNames.Add(label); tableCell.Controls.Add(label); HtmlTableCell tableCellSecond = new HtmlTableCell(); tableCellSecond.Width = "187px"; tableRow.Cells.Add(tableCellSecond); TextBox textbox = new TextBox(); textbox.ID = c.TextBoxID; if (policyExtendInformation != null) { textbox.Text = policyExtendInformation.Value; } if (c.IsLatin != null) { if ((bool)c.IsLatin == true) { textbox.Attributes.Add("onkeyup", "toEnglish(this.id)"); } } tbValues.Add(textbox); tableCellSecond.Controls.Add(textbox); if (c.HasRequredFieldValidator) { RequiredFieldValidator rfv = new RequiredFieldValidator(); rfv.ID = "rfv" + textbox.ID; rfv.ErrorMessage = "*"; rfv.Display = ValidatorDisplay.Dynamic; rfv.ControlToValidate = textbox.ID; tableCellSecond.Controls.Add(rfv); } if (c.HasCompareValidator) { CompareValidator cv = new CompareValidator(); cv.ID = "cv" + textbox.ID; cv.ErrorMessage = "*"; cv.Display = ValidatorDisplay.Dynamic; cv.ControlToValidate = textbox.ID; cv.Operator = ValidationCompareOperator.DataTypeCheck; cv.Type = Broker.DataAccess.VariableType.GetForVariableType(c.VariableTypeID); tableCellSecond.Controls.Add(cv); } HtmlTableCell tableCellThird = new HtmlTableCell(); tableCellThird.Width = "160px"; tableRow.Cells.Add(tableCellThird); HtmlTableCell tableCellForth = new HtmlTableCell(); tableCellForth.Width = "187px"; tableRow.Cells.Add(tableCellForth); } else { if (counter % 2 == 0) { HtmlTableRow tableRow = new HtmlTableRow(); if ((counter % 4 == 0) || (counter % 4 == 1)) { tableRow.BgColor = "#FAFAF8"; } table.Rows.Add(tableRow); HtmlTableCell tableCell = new HtmlTableCell(); tableCell.Width = "160px"; tableRow.Cells.Add(tableCell); Label label = new Label(); label.ID = c.LabelID; label.Text = c.LabelName; lblFieldNames.Add(label); tableCell.Controls.Add(label); HtmlTableCell tableCellSecond = new HtmlTableCell(); tableCellSecond.Width = "187px"; tableRow.Cells.Add(tableCellSecond); TextBox textbox = new TextBox(); textbox.ID = c.TextBoxID; if (policyExtendInformation != null) { textbox.Text = policyExtendInformation.Value; } if (c.IsLatin != null) { if ((bool)c.IsLatin == true) { textbox.Attributes.Add("onkeyup", "toEnglish(this.id)"); } } tbValues.Add(textbox); tableCellSecond.Controls.Add(textbox); if (c.HasRequredFieldValidator) { RequiredFieldValidator rfv = new RequiredFieldValidator(); rfv.ID = "rfv" + textbox.ID; rfv.ErrorMessage = "*"; rfv.Display = ValidatorDisplay.Dynamic; rfv.ControlToValidate = textbox.ID; tableCellSecond.Controls.Add(rfv); } if (c.HasCompareValidator) { CompareValidator cv = new CompareValidator(); cv.ID = "cv" + textbox.ID; cv.ErrorMessage = "*"; cv.Display = ValidatorDisplay.Dynamic; cv.ControlToValidate = textbox.ID; cv.Operator = ValidationCompareOperator.DataTypeCheck; cv.Type = Broker.DataAccess.VariableType.GetForVariableType(c.VariableTypeID); tableCellSecond.Controls.Add(cv); } } else if (counter % 2 == 1) { HtmlTableRow tableRow = table.Rows[counter / 2]; if ((counter % 4 == 0) || (counter % 4 == 1)) { tableRow.BgColor = "#FAFAF8"; } HtmlTableCell tableCellThird = new HtmlTableCell(); tableCellThird.Width = "160px"; tableRow.Cells.Add(tableCellThird); Label label = new Label(); label.ID = c.LabelID; label.Text = c.LabelName; lblFieldNames.Add(label); tableCellThird.Controls.Add(label); HtmlTableCell tableCellForth = new HtmlTableCell(); tableCellForth.Width = "187px"; tableRow.Cells.Add(tableCellForth); TextBox textbox = new TextBox(); textbox.ID = c.TextBoxID; if (policyExtendInformation != null) { textbox.Text = policyExtendInformation.Value; } if (c.IsLatin != null) { if ((bool)c.IsLatin) { textbox.Attributes.Add("onkeyup", "toEnglish(this.id)"); } } tbValues.Add(textbox); tableCellForth.Controls.Add(textbox); if (c.HasRequredFieldValidator) { RequiredFieldValidator rfv = new RequiredFieldValidator(); rfv.ID = "rfv" + textbox.ID; rfv.ErrorMessage = "*"; rfv.Display = ValidatorDisplay.Dynamic; rfv.ControlToValidate = textbox.ID; tableCellForth.Controls.Add(rfv); } if (c.HasCompareValidator) { CompareValidator cv = new CompareValidator(); cv.ID = "cv" + textbox.ID; cv.ErrorMessage = "*"; cv.Display = ValidatorDisplay.Dynamic; cv.ControlToValidate = textbox.ID; cv.Operator = ValidationCompareOperator.DataTypeCheck; cv.Type = Broker.DataAccess.VariableType.GetForVariableType(c.VariableTypeID); tableCellForth.Controls.Add(cv); } } } counter++; } } pnlExtendControls.Controls.Add(table); } }
public void Test_14_ClientEmail_ActionThatSupportsOnlyEmail() { //Even if an action only supports the email file type, //It must still be triggered in the scanner when an email *attachment* satisfies the trigger condition. try { GetPolicyCache().Clear(); IContentScanner scannerService = GetContentScanner(); PolicyItem policy = new PolicyItem("ActionThatSupportsOnlyEmail", File.ReadAllBytes(Path.Combine(TESTPATH, "ActionThatSupportsOnlyEmail.runtimepolicy"))); policy.RestrictedTargets = new RunAt[] {RunAt.Client}; GetPolicyCache().Clear(); GetPolicyCache().Add(policy); using (var cs = new ContractSerialization()) { Request request = cs.LoadRequest(Path.Combine(TESTPATH, "ActionThatSupportsOnlyEmail.request")); Response response = scannerService.Scan(request, string.Empty, ProcessLevel.Actions, RunAt.Client); AssertValid(response, ProcessLevel.Actions); Assert.AreEqual(2, response.Contents.Length); Assert.AreEqual(FileType.Email.ToString(), response.Contents[0].ContentType); Assert.AreEqual(FileType.XMLDocument.ToString(), response.Contents[1].ContentType); //Single policyset, single policy... Assert.AreEqual(1, response.Contents[0].PolicySets.Length); Assert.AreEqual(1, response.Contents[0].PolicySets[0].Policies.Length); Assert.AreEqual(1, response.Contents[1].PolicySets.Length); Assert.AreEqual(1, response.Contents[1].PolicySets[0].Policies.Length); Assert.IsFalse(response.Contents[0].PolicySets[0].Policies[0].Triggered, "The violation is not in the email body, this should not have triggered."); Assert.IsTrue(response.Contents[1].PolicySets[0].Policies[0].Triggered, "The violation is in the attachment - this should have triggered."); Assert.AreEqual(0, response.Contents[0].PolicySets[0].Policies[0].Actions.Length, "No violations in content item 0, so no actions expected."); Assert.AreEqual(1, response.Contents[1].PolicySets[0].Policies[0].Actions.Length); Assert.AreEqual(1, response.ResolvedActions.Length); } } finally { GetPolicyCache().Clear(); InitPolicies(); } }
protected void btnCalculateCurrentState_Click(object sender, EventArgs e) { if (rblInsuranceLifeType.SelectedValue == "NoLife") { DateTime startDate = DateTime.Parse(tbStartDate.Text); DateTime endDate = DateTime.Parse(tbEndDate.Text); InsuranceCompany company = InsuranceCompany.Get(int.Parse(ddlInsuranceCompanies.SelectedValue)); DateTime fromDate = DateTime.Parse(tbStartDate.Text); DateTime toDate = DateTime.Parse(tbEndDate.Text); List <FactureInfo> lastFactureInfos = listNewFactureInfos; GridViewRowCollection displayedRows = gvNewPolicies.Rows; foreach (GridViewRow gvRow in displayedRows) { CheckBox cbIsForFacturing = gvRow.FindControl("cbIsForFacturing") as CheckBox; int factureInfoID = Convert.ToInt32(gvNewPolicies.DataKeys[gvRow.RowIndex].Value); FactureInfo fi = lastFactureInfos.Where(facInfo => facInfo.ID == factureInfoID).SingleOrDefault(); fi.IsForFacturing = cbIsForFacturing.Checked; } listNewFactureInfos = lastFactureInfos; lastFactureInfos = listFactureInfos; displayedRows = gvOldPolicies.Rows; foreach (GridViewRow gvRow in displayedRows) { CheckBox cbIsForFacturing = gvRow.FindControl("cbIsForFacturing") as CheckBox; int factureInfoID = Convert.ToInt32(gvOldPolicies.DataKeys[gvRow.RowIndex].Value); FactureInfo fi = lastFactureInfos.Where(facInfo => facInfo.ID == factureInfoID).SingleOrDefault(); fi.IsForFacturing = cbIsForFacturing.Checked; } listFactureInfos = lastFactureInfos; List <PolicyItem> policiesToRemove = new List <PolicyItem>(); List <FactureInfo> listOldPolicies = (List <FactureInfo>)listFactureInfos; foreach (FactureInfo fi in listOldPolicies) { if (!fi.IsForFacturing) { policiesToRemove.Add(PolicyItem.Get(fi.ID)); } } List <FactureInfo> listNewPolicies = (List <FactureInfo>)listNewFactureInfos; foreach (FactureInfo fi in listNewPolicies) { if (!fi.IsForFacturing) { PolicyItem pi = PolicyItem.Get(fi.ID); if (!policiesToRemove.Contains(pi)) { policiesToRemove.Add(pi); } } } List <Payment> paymentList = Payment.GetForFactureByDateAndInsuranceCompany(endDate, company.ID); decimal brokerageValue = 0; decimal totalSum = 0; decimal currentBrokerageValue = 0; Dictionary <int, decimal[]> dictionary = new Dictionary <int, decimal[]>(); List <PolicyItem> policyItemList = new List <PolicyItem>(); foreach (Payment p in paymentList) { PolicyItem policyItem = p.Rate.PolicyItem; if (!policiesToRemove.Contains(policyItem)) { if (!policyItemList.Contains(policyItem)) { policyItemList.Add(policyItem); } if (policyItem.Policy.PacketID != null) { if (policyItem.Policy.Client.IsLaw) { currentBrokerageValue = p.Value * policyItem.PacketsInsuranceSubType.BrokeragePecentageForLaws / 100; } else { currentBrokerageValue = p.Value * policyItem.PacketsInsuranceSubType.BrokeragePecentageForPrivates / 100; } } else { if (policyItem.Policy.Client.IsLaw) { currentBrokerageValue = p.Value * policyItem.Brokerage.PercentageForLaws / 100; } else { currentBrokerageValue = p.Value * policyItem.Brokerage.PercentageForPrivates / 100; } } brokerageValue += currentBrokerageValue; if (dictionary.ContainsKey(policyItem.InsuranceSubTypeID)) { dictionary[policyItem.InsuranceSubTypeID][0] += currentBrokerageValue; dictionary[policyItem.InsuranceSubTypeID][1] += p.Value; // dictionary[policyItem.InsuranceSubTypeID][2] += 1; } else { decimal[] newValues = { currentBrokerageValue, p.Value /*, 1 */ }; dictionary.Add(policyItem.InsuranceSubTypeID, newValues); } totalSum += p.Value; } } tbCurrentBrokerageValue.Text = String.Format("{0:#,0.00}", brokerageValue); tbCurrentPremiumValue.Text = String.Format("{0:#,0.00}", totalSum); } else if (rblInsuranceLifeType.SelectedValue == "Life") { } }
void UpdateTextBoxes(PolicyItem pi) { tbPolicyPremiumCost.Text = pi.PremiumValue.ToString(); tbPolicyTotalPaidValue.Text = Rate.PaidRatesValue(pi.ID).ToString(); tbPolicyForPaidValue.Text = (Convert.ToDecimal(tbPolicyPremiumCost.Text) - Convert.ToDecimal(tbPolicyTotalPaidValue.Text)).ToString(); }
public void Test18_LegacyPolicy_Remove() { PolicyItem item = new PolicyItem(); item.UniqueId = "LegacyPolicy"; item.Users = null; item.RestrictedTargets = new RunAt[] { RunAt.Client }; item.Contents = File.ReadAllBytes(Path.Combine(TEST_PATH, "legacy.runtimepolicy")); Assert.AreEqual(0, CacheManager.PolicyCacheManager.Instance.GetPolicyTypeLookupRowCount()); CacheManager.PolicyCacheManager.Instance.RegisterPolicy(item); Array enumArray = Enum.GetValues(typeof(PolicyType)); // -7, because only AClientEmail scanners are loaded. Assert.AreEqual(enumArray.Length - 7, CacheManager.PolicyCacheManager.Instance.InternalCollection.Count, "After adding the legacy policy, the internal count should equal the amount of different policy types"); Assert.AreEqual(1, CacheManager.PolicyCacheManager.Instance.GetPolicies().Length, "After adding the legacy policy, the internal count should equal the amount of different policy types"); // -7, because only ClientEmail scanners are loaded. Assert.AreEqual(enumArray.Length - 7, CacheManager.PolicyCacheManager.Instance.GetPolicyTypeLookupRowCount()); CacheManager.PolicyCacheManager.Instance.RemovePolicy(item.UniqueId); Assert.AreEqual(0, CacheManager.PolicyCacheManager.Instance.InternalCollection.Count, "Unexpected amount of scanners"); Assert.AreEqual(0, CacheManager.PolicyCacheManager.Instance.GetPolicies().Length, "Unexpected amount of policies"); Assert.AreEqual(0, CacheManager.PolicyCacheManager.Instance.GetPolicyTypeLookupRowCount()); }
public void Test17_LegacyPolicy_Update() { PolicyItem item = new PolicyItem(); item.UniqueId = "LegacyPolicy"; item.Users = null; item.RestrictedTargets = new RunAt[] { RunAt.Client }; item.Contents = File.ReadAllBytes(Path.Combine(TEST_PATH, "legacy.runtimepolicy")); CacheManager.PolicyCacheManager.Instance.RegisterPolicy(item); Array enumArray = Enum.GetValues(typeof(PolicyType)); // -7, because only ClientEmail scanners are loaded. Assert.AreEqual(enumArray.Length - 7, CacheManager.PolicyCacheManager.Instance.InternalCollection.Count, "After adding the legacy policy, the internal count should equal the amount of different policy types"); Assert.AreEqual(1, CacheManager.PolicyCacheManager.Instance.GetPolicies().Length, "After adding the legacy policy, the internal count should equal the amount of different policy types"); //DE7088 requirements have changed, legacy policies should be updateable now //try //{ using (RegistryRestorer rr = new RegistryRestorer(RegistryHive.LocalMachine, @"SOFTWARE\Workshare\Installed Product", "")) { rr.SetValue("Workshare"); // make professional "installed". CacheManager.PolicyCacheManager.Instance.UpdatePolicy(item); } //}HKEY_LOCAL_MACHINE\ //catch (ArgumentException) //{ // -7, because only ClientEmail scanners are loaded. Assert.AreEqual(enumArray.Length - 7, CacheManager.PolicyCacheManager.Instance.InternalCollection.Count, "After adding the legacy policy, the internal count should equal the amount of different policy types"); Assert.AreEqual(1, CacheManager.PolicyCacheManager.Instance.GetPolicies().Length, "After adding the legacy policy, the internal count should equal the amount of different policy types"); // return; //} //Assert.Fail("Trying to call update with a legacy policy should not be permitted."); }
public void Test12_GetScanners_Users() { PolicyItem policy1 = new PolicyItem(); policy1.UniqueId = "Policy1"; policy1.Contents = File.ReadAllBytes(Path.Combine(TEST_PATH, "ClientEmail.runtimepolicy")); policy1.Users = new string[] { @"WSDEV\LNPAIR" }; policy1.RestrictedTargets = new RunAt[] { RunAt.Client }; PolicyCacheManager.Instance.RegisterPolicy(policy1); PolicyItem policy2 = new PolicyItem(); policy2.UniqueId = "Policy2"; policy2.Contents = File.ReadAllBytes(Path.Combine(TEST_PATH, "ClientEmail.runtimepolicy")); policy2.Users = new string[] { @"WSDEV\PAIRADM" }; policy2.RestrictedTargets = new RunAt[] { RunAt.Client }; PolicyCacheManager.Instance.RegisterPolicy(policy2); Collection<Lease<EngineLookupKey, IBaseContentScanner>> scanners = PolicyCacheManager.Instance.GetScanners( PolicyType.ClientEmail, new string[] { @"WSDEV\lnpair" }, RunAt.Client.ToString()); Assert.AreEqual(1, scanners.Count, "CacheManager returned incorrect amount of content scanner items"); scanners[0].Dispose(); scanners = PolicyCacheManager.Instance.GetScanners( PolicyType.ClientEmail, new string[] { @"WSDEV\pairadm" }, RunAt.Client.ToString()); Assert.AreEqual(1, scanners.Count, "CacheManager returned incorrect amount of content scanner items"); scanners[0].Dispose(); scanners = PolicyCacheManager.Instance.GetScanners( PolicyType.ClientEmail, new string[] { @"WSDEV\pairadm", @"WSDEV\lnpair" }, RunAt.Client.ToString()); Assert.AreEqual(2, scanners.Count, "CacheManager returned incorrect amount of content scanner items"); scanners[0].Dispose(); scanners[1].Dispose(); scanners = PolicyCacheManager.Instance.GetScanners( PolicyType.ClientEmail, null, RunAt.Client.ToString()); Assert.AreEqual(2, scanners.Count, "CacheManager returned incorrect amount of content scanner items"); scanners[0].Dispose(); scanners[1].Dispose(); //register some stuff for any user. PolicyCacheManager.Instance.Clear(); policy1.Users = null; PolicyCacheManager.Instance.RegisterPolicy(policy1); scanners = PolicyCacheManager.Instance.GetScanners( PolicyType.ClientEmail, new string[] { @"WSDEV\lnpair" }, RunAt.Client.ToString()); Assert.AreEqual(1, scanners.Count, "CacheManager returned incorrect amount of content scanner items"); scanners[0].Dispose(); }
public void Test11_UpdatePolicy_UpdatedPolicyIsNotValid_InvalidBytes() { Assert.AreEqual(0, PolicyCacheManager.Instance.InternalCollection.Count); PolicyItem policy1 = new PolicyItem(); policy1.UniqueId = "Policy1"; policy1.Contents = File.ReadAllBytes(Path.Combine(TEST_PATH, "policy1.runtimepolicy")); policy1.Users = new string[] { @"WSDEV\LNPAIR" }; policy1.RestrictedTargets = new RunAt[] { RunAt.Client }; PolicyCacheManager.Instance.RegisterPolicy(policy1); try { policy1.Contents = File.ReadAllBytes(Path.Combine(TEST_PATH, "this_is_not_a.runtimepolicy")); PolicyCacheManager.Instance.UpdatePolicy(policy1); }//TODO Added this exception type as UpdatePolicy now throws it, instead of // ApplicationException. Need to see where/why the exception type changed // without the test changing. catch (System.ArgumentException) { Assert.AreEqual(1, PolicyCacheManager.Instance.GetPolicies().Length, "Unexpected collection size (1 entry per registered policy)"); return; } catch (ApplicationException) { Assert.AreEqual(1, PolicyCacheManager.Instance.GetPolicies().Length, "Unexpected collection size (1 entry per registered policy)"); return; } Assert.Fail("Expected to throw an exception when trying to update a non-registered policy."); }
public void Test10_UpdatePolicy_UpdatedPolicyIsNotValid_NullBytes() { Assert.AreEqual(0, PolicyCacheManager.Instance.InternalCollection.Count); PolicyItem policy1 = new PolicyItem(); policy1.UniqueId = "Policy1"; policy1.Contents = File.ReadAllBytes(Path.Combine(TEST_PATH, "policy1.runtimepolicy")); policy1.Users = new string[] { @"WSDEV\LNPAIR" }; policy1.RestrictedTargets = new RunAt[] { RunAt.Client }; PolicyCacheManager.Instance.RegisterPolicy(policy1); try { policy1.Contents = null; PolicyCacheManager.Instance.UpdatePolicy(policy1); } catch (ArgumentException) { Assert.AreEqual(1, PolicyCacheManager.Instance.GetPolicies().Length, "Unexpected collection size (1 entry per registered policy)"); return; } Assert.Fail("Expected to throw an exception when trying to update a non-registered policy."); }
protected void btnCreate_Click(object sender, EventArgs e) { DateTime startDate = DateTime.Parse(tbStartDate.Text); DateTime endDate = DateTime.Parse(tbEndDate.Text); DateTime dateOfPayment = DateTime.Now.AddDays(15); if (tbDateOfPayment.Text.Trim() != string.Empty) { DateTime.TryParse(tbDateOfPayment.Text, out dateOfPayment); } InsuranceCompany company = InsuranceCompany.Get(int.Parse(ddlInsuranceCompanies.SelectedValue)); Broker.DataAccess.User u = this.PageUser; DateTime fromDate = DateTime.Parse(tbStartDate.Text); DateTime toDate = DateTime.Parse(tbEndDate.Text); if (rblInsuranceLifeType.SelectedValue == "NoLife") { //List<PolicyItem> piList = PolicyItem.GetFromPreivousMonths(fromDate, company.ID); List <FactureInfo> lastFactureInfos = listNewFactureInfos; GridViewRowCollection displayedRows = gvNewPolicies.Rows; foreach (GridViewRow gvRow in displayedRows) { CheckBox cbIsForFacturing = gvRow.FindControl("cbIsForFacturing") as CheckBox; int factureInfoID = Convert.ToInt32(gvNewPolicies.DataKeys[gvRow.RowIndex].Value); FactureInfo fi = lastFactureInfos.Where(facInfo => facInfo.ID == factureInfoID).SingleOrDefault(); fi.IsForFacturing = cbIsForFacturing.Checked; } listNewFactureInfos = lastFactureInfos; lastFactureInfos = listFactureInfos; displayedRows = gvOldPolicies.Rows; foreach (GridViewRow gvRow in displayedRows) { CheckBox cbIsForFacturing = gvRow.FindControl("cbIsForFacturing") as CheckBox; int factureInfoID = Convert.ToInt32(gvOldPolicies.DataKeys[gvRow.RowIndex].Value); FactureInfo fi = lastFactureInfos.Where(facInfo => facInfo.ID == factureInfoID).SingleOrDefault(); fi.IsForFacturing = cbIsForFacturing.Checked; } listFactureInfos = lastFactureInfos; List <PolicyItem> policiesToRemove = new List <PolicyItem>(); List <FactureInfo> listOldPolicies = (List <FactureInfo>)listFactureInfos; foreach (FactureInfo fi in listOldPolicies) { if (!fi.IsForFacturing) { policiesToRemove.Add(PolicyItem.Get(fi.ID)); } } List <FactureInfo> listNewPolicies = (List <FactureInfo>)listNewFactureInfos; foreach (FactureInfo fi in listNewPolicies) { if (!fi.IsForFacturing) { PolicyItem pi = PolicyItem.Get(fi.ID); if (!policiesToRemove.Contains(pi)) { policiesToRemove.Add(pi); } } } Broker.DataAccess.Facture f = Broker.DataAccess.Facture.Generate(startDate, endDate, company, u, dateOfPayment, policiesToRemove); // f.Insert(); //int number = 1; //List<FactureItem> fiList = new List<FactureItem>(); //List<FactureItem.FactureItemGrouped> factureItemGroupedList = FactureItem.GetFactureItemsForCompany(company.ID, startDate, endDate); //foreach (FactureItem.FactureItemGrouped fifig in factureItemGroupedList) { // FactureItem fi = new FactureItem(); // fi.PremiumValue = fifig.TotalValue; // fi.Count = fifig.PaymentsCount; // fi.FactureID = f.ID; // fi.InsuranceSubTypeID = fifig.InsuranceSubTypeID; // fi.Number = number; // ++number; // fi.Description = InsuranceSubType.Get(fifig.InsuranceSubTypeID).ShortDescription; // fi.Insert(); // fiList.Add(fi); //} //List<PolicyItem> pItemList = PolicyItem.GetForFacture(f, company.ID); //PolicyItemFactureItem.InsertForFacture(fiList, pItemList); //List<FactureItem> fiListCash = new List<FactureItem>(); //List<FactureItem.FactureItemGrouped> factureItemGroupedCashList = FactureItem.GetForCashPayments(company.ID, startDate, endDate); //foreach (FactureItem.FactureItemGrouped fifig in factureItemGroupedCashList) { // FactureItem fi = new FactureItem(); // fi.PremiumValue = fifig.TotalValue; // fi.Count = fifig.PaymentsCount; // fi.FactureID = f.ID; // fi.InsuranceSubTypeID = fifig.InsuranceSubTypeID; // fi.Number = number; // ++number; // fi.Description = InsuranceSubType.Get(fifig.InsuranceSubTypeID).ShortDescription; // fi.Insert(); // fiListCash.Add(fi); //} //List<PolicyItem> pItemListCash = PolicyItem.GetForFactureCash(f, company.ID); //PolicyItemFactureItem.InsertForFacture(fiListCash, pItemListCash); if (f != null) { lblError.Visible = false; odsFacturePreview.SelectParameters.Clear(); odsFacturePreview.SelectParameters.Add("id", f.ID.ToString()); odsFactureItems.SelectParameters.Clear(); odsFactureItems.SelectParameters.Add("factureID", f.ID.ToString()); mvMain.SetActiveView(viewFactureItems); } else { lblError.Visible = true; lblError.Font.Bold = true; lblError.Text = "Не постојат нефактурирани износи"; } } else if (rblInsuranceLifeType.SelectedValue == "Life") { List <FactureInfo> lastFactureInfos = listNewFactureInfos; GridViewRowCollection displayedRows = gvNewPolicies.Rows; foreach (GridViewRow gvRow in displayedRows) { CheckBox cbIsForFacturing = gvRow.FindControl("cbIsForFacturing") as CheckBox; int factureInfoID = Convert.ToInt32(gvNewPolicies.DataKeys[gvRow.RowIndex].Value); FactureInfo fi = lastFactureInfos.Where(facInfo => facInfo.ID == factureInfoID).SingleOrDefault(); fi.IsForFacturing = cbIsForFacturing.Checked; } listNewFactureInfos = lastFactureInfos; lastFactureInfos = listFactureInfos; displayedRows = gvOldPolicies.Rows; foreach (GridViewRow gvRow in displayedRows) { CheckBox cbIsForFacturing = gvRow.FindControl("cbIsForFacturing") as CheckBox; int factureInfoID = Convert.ToInt32(gvOldPolicies.DataKeys[gvRow.RowIndex].Value); FactureInfo fi = lastFactureInfos.Where(facInfo => facInfo.ID == factureInfoID).SingleOrDefault(); fi.IsForFacturing = cbIsForFacturing.Checked; } listFactureInfos = lastFactureInfos; List <LifePolicy> policiesToRemove = new List <LifePolicy>(); List <FactureInfo> listOldPolicies = (List <FactureInfo>)listFactureInfos; foreach (FactureInfo fi in listOldPolicies) { if (!fi.IsForFacturing) { policiesToRemove.Add(LifePolicy.Get(fi.ID)); } } List <FactureInfo> listNewPolicies = (List <FactureInfo>)listNewFactureInfos; foreach (FactureInfo fi in listNewPolicies) { if (!fi.IsForFacturing) { LifePolicy pi = LifePolicy.Get(fi.ID); if (!policiesToRemove.Contains(pi)) { policiesToRemove.Add(pi); } } } Broker.DataAccess.Facture f = Broker.DataAccess.Facture.GenerateForLife(startDate, endDate, company, u, dateOfPayment, policiesToRemove); if (f != null) { lblError.Visible = false; odsFacturePreview.SelectParameters.Clear(); odsFacturePreview.SelectParameters.Add("id", f.ID.ToString()); odsFactureItems.SelectParameters.Clear(); odsFactureItems.SelectParameters.Add("factureID", f.ID.ToString()); mvMain.SetActiveView(viewFactureItems); } else { lblError.Visible = true; lblError.Font.Bold = true; lblError.Text = "Не постојат нефактурирани износи"; } } }
public void Test19_UserNameWithApostrophe() { PolicyCacheManager cache = PolicyCacheManager.Instance; PolicyItem policy1 = new PolicyItem() { UniqueId = "Policy1", Contents = File.ReadAllBytes(Path.Combine(TEST_PATH, "ClientEmail.runtimepolicy")), Users = new string[] { @"WSQA\test'test" }, RestrictedTargets = new RunAt[] { RunAt.Client } }; cache.RegisterPolicy(policy1); Collection<Lease<EngineLookupKey, IBaseContentScanner>> scanners = cache.GetScanners( PolicyType.ClientEmail, new string[] { @"WSQA\test'test" }, RunAt.Client.ToString()); Assert.AreEqual(1, scanners.Count, @"CacheManager failed to find content scanner for user WSQA\test'test"); scanners[0].Dispose(); //register some stuff for any user. policy1.UniqueId = "Policy2"; policy1.Users = null; cache.RegisterPolicy(policy1); scanners = cache.GetScanners( PolicyType.ClientEmail, new string[] { @"wsqa\TEST'test" }, RunAt.Client.ToString()); Assert.AreEqual(2, scanners.Count, @"CacheManager returned wrong number of content scanners for user wsqa\TEST'test"); scanners[0].Dispose(); scanners[1].Dispose(); }
protected void btnGenerate_Click(object sender, EventArgs e) { DateTime inputDate = Convert.ToDateTime(tbDateOfPayment.Text); PolicyItem pi; List <Payment> newPayments = new List <Payment>(); if (ddlInsuranceSubTypes.Items.Count > 0) { pi = PolicyItem.GetByNumberAndInsuranceSubType(tbPolicyNumber.Text, Convert.ToInt32(ddlInsuranceSubTypes.SelectedValue), int.Parse(ddlInsuranceCompany.SelectedValue)); } else { pi = PolicyItem.GetByNumber(tbPolicyNumber.Text, int.Parse(ddlInsuranceCompany.SelectedValue)); } if (inputDate.Date > DateTime.Today) { lblFeedback.Text = "Не е можно внесување на датуми поголеми од денешниот"; } else { lblFeedback.Text = string.Empty; List <Payment> listPayments = Payment.GetByPolicyItemID(pi.ID); newPayments.AddRange(listPayments); decimal paymentTotalValue = 0; foreach (Payment payment in listPayments) { paymentTotalValue += payment.Value; } if (Convert.ToDecimal(tbValueOfPayment.Text) > (pi.PremiumValue - paymentTotalValue)) { lblFeedback.Text = "Поголем износ од преостанатиот износ за плаќање"; } else { lblFeedback.Text = string.Empty; decimal valueFromClient = Convert.ToDecimal(tbValueOfPayment.Text); Broker.DataAccess.PaymentType pt = Broker.DataAccess.PaymentType.Get(Convert.ToInt32(ddlPaymentTypes.SelectedValue)); Rate currentRate = Rate.GetCurrentRateForPayment(pi.ID); while (valueFromClient > 0) { Payment newPayment = new Payment(); newPayment.Date = Convert.ToDateTime(tbDateOfPayment.Text); newPayment.RateID = currentRate.ID; newPayment.Rate = currentRate; newPayment.IsCashReported = false; newPayment.PaymentTypeID = pt.ID; if (pt.Code == Broker.DataAccess.PaymentType.CREDITCARD) { newPayment.BankCreditCardID = BankCreditCard.GetByBankAndCard(Convert.ToInt32(ddlBank.SelectedValue), Convert.ToInt32(ddlCardTypes.SelectedValue)).ID; } newPayment.UserID = this.PageUser.ID; newPayment.BranchID = this.PageUser.BranchID; if (tbBankslipNumber.Text.Trim() != string.Empty) { newPayment.BankslipNumber = tbBankslipNumber.Text; newPayment.BankslipBankID = Convert.ToInt32(ddlBankslipBanks.SelectedValue); } if (valueFromClient >= currentRate.Value) { newPayment.Value = currentRate.Value - Payment.GetPaidValueForRate(currentRate.ID); valueFromClient -= newPayment.Value; currentRate.PaidValue += newPayment.Value; newPayments.Add(newPayment); int currentRateNumber = currentRate.Number; int nextNumber; int maxNumber = Rate.Table.Where(r => r.PolicyItemID == pi.ID).OrderBy(r => r.Number).Select(r => r.Number).ToList().Last(); if (currentRateNumber < maxNumber) { nextNumber = ++currentRateNumber; } else { nextNumber = currentRateNumber; } currentRate = Rate.Table.Where(r => r.PolicyItemID == pi.ID && r.Number == nextNumber).SingleOrDefault(); } else { if (valueFromClient <= (currentRate.Value - currentRate.PaidValue)) { newPayment.Value = valueFromClient; currentRate.PaidValue = valueFromClient; newPayments.Add(newPayment); break; } else { newPayment.Value = (currentRate.Value - currentRate.PaidValue); currentRate.PaidValue = currentRate.PaidValue; newPayments.Add(newPayment); valueFromClient -= newPayment.Value; int currentRateNumber = currentRate.Number; int nextNumber; int maxNumber = Rate.Table.Where(r => r.PolicyItemID == pi.ID).OrderBy(r => r.Number).Select(r => r.Number).ToList().Last(); if (currentRateNumber < maxNumber) { nextNumber = ++currentRateNumber; } else { nextNumber = currentRateNumber; } currentRate = Rate.Table.Where(r => r.PolicyItemID == pi.ID && r.Number == nextNumber).SingleOrDefault(); } } } btnInsert.Enabled = true; } } odsPaidPayments.SelectParameters.Clear(); GridViewPayments.DataSourceID = null; GridViewPayments.DataSource = newPayments; GridViewPayments.DataBind(); }
public void Test03_RegisterPolicy_DuplicatePolicy() { PolicyItem policy1 = new PolicyItem(); policy1.UniqueId = "Policy1"; policy1.Contents = File.ReadAllBytes(Path.Combine(TEST_PATH, "policy1.runtimepolicy")); policy1.Users = new string[] { @"WSDEV\LNPAIR" }; policy1.RestrictedTargets = new RunAt[] { RunAt.Client }; try { PolicyCacheManager.Instance.RegisterPolicy(policy1); Assert.AreEqual(1, PolicyCacheManager.Instance.InternalCollection.Count); Assert.AreEqual(1, PolicyCacheManager.Instance.GetPolicies().Length, "Unexpected collection size (1 entry per registered policy)"); //Register it again... not allowed PolicyCacheManager.Instance.RegisterPolicy(policy1); } catch (ArgumentException) { Assert.AreEqual(1, PolicyCacheManager.Instance.InternalCollection.Count, "Internal collection should not have increased in size."); Assert.AreEqual(1, PolicyCacheManager.Instance.GetPolicies().Length, "Unexpected collection size (1 entry per registered policy)"); return; } Assert.Fail("Expected to throw an argument exception in this case."); }
protected void btnCheck_Click(object sender, EventArgs e) { DateTime fromDate = DateTime.Parse(tbStartDate.Text); DateTime toDate = DateTime.Parse(tbEndDate.Text); if (rblInsuranceLifeType.SelectedValue == "NoLife") { List <PolicyItem> oldPiList = PolicyItem.GetFromPreivousMonths(fromDate, int.Parse(ddlInsuranceCompanies.SelectedValue)); List <FactureInfo> oldFactureInfos = new List <FactureInfo>(); foreach (PolicyItem pi in oldPiList) { FactureInfo fi = new FactureInfo(); fi.ID = pi.ID; fi.IsForFacturing = true; fi.PolicyNumber = pi.PolicyNumber; //fi.PremiumValue = pi.PremiumValue; fi.PremiumValue = pi.RealPremiumValue; //fi.PaidValue = Payment.GetPaidValueForPolicyItem(pi.ID); oldFactureInfos.Add(fi); } listFactureInfos = oldFactureInfos; gvOldPolicies.DataSource = oldFactureInfos; gvOldPolicies.Caption = "Полиси од претходни месеци (" + oldFactureInfos.Count.ToString() + ")"; gvOldPolicies.DataBind(); List <PolicyItem> newPiList = PolicyItem.GetForFacturingFromCurrentMonth(fromDate, toDate, int.Parse(ddlInsuranceCompanies.SelectedValue)); List <FactureInfo> newFactureInfos = new List <FactureInfo>(); foreach (PolicyItem pi in newPiList) { FactureInfo fi = new FactureInfo(); fi.ID = pi.ID; fi.IsForFacturing = true; fi.PolicyNumber = pi.PolicyNumber; //fi.PremiumValue = pi.PremiumValue; fi.PremiumValue = pi.RealPremiumValue; //fi.PaidValue = Payment.GetPaidValueForPolicyItem(pi.ID); newFactureInfos.Add(fi); } listNewFactureInfos = newFactureInfos; gvNewPolicies.DataSource = newFactureInfos; gvNewPolicies.Caption = "Полиси од селектираниот период (" + newFactureInfos.Count.ToString() + ")"; gvNewPolicies.DataBind(); } else if (rblInsuranceLifeType.SelectedValue == "Life") { List <LifePolicy> oldPiList = LifePolicy.GetFromPreviousMonths(fromDate, int.Parse(ddlInsuranceCompanies.SelectedValue)); List <FactureInfo> oldFactureInfos = new List <FactureInfo>(); foreach (LifePolicy pi in oldPiList) { FactureInfo fi = new FactureInfo(); fi.ID = pi.ID; fi.IsForFacturing = true; fi.PolicyNumber = pi.PolicyNumber; //fi.PremiumValue = pi.PremiumValue; fi.PremiumValue = pi.TotalPremumValue; //fi.PaidValue = Payment.GetPaidValueForPolicyItem(pi.ID); oldFactureInfos.Add(fi); } listFactureInfos = oldFactureInfos; gvOldPolicies.DataSource = oldFactureInfos; gvOldPolicies.Caption = "Полиси од претходни месеци (" + oldFactureInfos.Count.ToString() + ")"; gvOldPolicies.DataBind(); List <LifePolicy> newPiList = LifePolicy.GetForFacturingFromCurrentMonth(fromDate, toDate, int.Parse(ddlInsuranceCompanies.SelectedValue)); List <FactureInfo> newFactureInfos = new List <FactureInfo>(); foreach (LifePolicy pi in newPiList) { FactureInfo fi = new FactureInfo(); fi.ID = pi.ID; fi.IsForFacturing = true; fi.PolicyNumber = pi.PolicyNumber; //fi.PremiumValue = pi.PremiumValue; fi.PremiumValue = pi.TotalPremumValue; //fi.PaidValue = Payment.GetPaidValueForPolicyItem(pi.ID); newFactureInfos.Add(fi); } listNewFactureInfos = newFactureInfos; gvNewPolicies.DataSource = newFactureInfos; gvNewPolicies.Caption = "Полиси од селектираниот период (" + newFactureInfos.Count.ToString() + ")"; gvNewPolicies.DataBind(); } }
public static void PrintFacture(Broker.DataAccess.Facture f) { string brokerName = BrokerHouseInformation.GetBrokerHouseName(); if (f.DocumentSubType.Code == DocumentSubType.FAKTURA_PROVIZIJA || f.DocumentSubType.Code == DocumentSubType.IZLEZNA_FAKTURA_ZA_PROVZIJA_ZA_ZIVOTNO_OSUGURUVANjE) { PDFCreators creator = new PDFCreators(true, 25, 25, 15, 15); creator.SetDocumentHeaderFooter(); creator.OpenPDF(); creator.GetContentByte(); creator.AddJDBLogoForFactures(10, 775); creator.SetTitleLeft8(" "); creator.SetTitleLeft8(" "); creator.SetTitleLeft8(" "); creator.SetTitleLeft8(" "); if (f.DocumentSubType.Code == DocumentSubType.FAKTURA_PROVIZIJA) { creator.SetTitleLeft8(" Жиро-сметка : " + Broker.DataAccess.Parameter.GetByCode(Broker.DataAccess.Parameter.ZIRO_SMETKA_ZA_OSIG_KOMPANII).Value); } else if (f.DocumentSubType.Code == DocumentSubType.FAKTURA_KLIENT) { creator.SetTitleLeft8(" Жиро-сметка : " + Broker.DataAccess.Parameter.GetByCode(Broker.DataAccess.Parameter.ZIRO_SMETKA).Value); } creator.SetTitleLeft8(" Депонент : " + Broker.DataAccess.Parameter.GetByCode(Broker.DataAccess.Parameter.DEPONENT).Value); creator.SetTitleLeft8(" ЕДБ : " + Broker.DataAccess.Parameter.GetByCode(Broker.DataAccess.Parameter.EDB).Value + " " + "Матичен број : " + Broker.DataAccess.Parameter.GetByCode(Broker.DataAccess.Parameter.MATICEN_BROJ).Value); creator.SetTitleLeft8(" "); if (f.Discard) { creator.SetTitleCenterForFactureNumber("СТОРНИРАНА Ф-ра бр. " + f.FactureNumber); } else { creator.SetTitleCenterForFactureNumber("Фактура бр. " + f.FactureNumber); } string internalCode = ""; try { FinansovoDataClassesDataContext fdc = new FinansovoDataClassesDataContext(); List <Client> listCLients = fdc.Clients.Where(c => c.EMBG == f.Client.EMBG).ToList(); if (listCLients.Count > 0) { internalCode = listCLients[0].Code; } } catch { } if (internalCode != string.Empty) { creator.SetTitleLeftWithFontSize10(internalCode); } creator.SetTitleLeftWithFontSize10(ConvertToMacedonian.ConvertToMACEDONIAN(f.Client.Name).ToUpper()); creator.SetTitleLeftWithFontSize10(ConvertToMacedonian.ConvertToMACEDONIAN(f.Client.Address).ToUpper()); //creator.SetTitleLeftWithFontSize10(ConvertToMacedonian.ConvertToMACEDONIAN(f.Client.Place.Municipality.Name).ToUpper()); creator.SetTitleLeftWithFontSize10(ConvertToMacedonian.ConvertToMACEDONIAN(f.Client.Place.Name).ToUpper()); creator.SetTitleLeft10("Датум на фактура: " + f.DateOfCreation.ToShortDateString()); creator.SetTitleLeft10("Рок на плаќање: " + f.DateOfPayment.ToShortDateString()); //creator.SetTitleLeft8("Период: " + f.FromDate.ToShortDateString() + " - " + f.ToDate.ToShortDateString()); string[] headers = { "Ред. бр.", "Опис", "Количина", "Премија", "Брокеража" }; float[] widthPercentages = { 8, 45, 15, 17, 15 }; TypeCode[] typeCodes = { TypeCode.Int32, TypeCode.String, TypeCode.Int32, TypeCode.Decimal, TypeCode.Decimal }; creator.CreateTable_Facture(headers.Length, headers, widthPercentages); object[] values; foreach (FactureItem fi in f.FactureItems) { values = new object[headers.Length]; values[0] = fi.Number.ToString(); values[1] = fi.Description; values[2] = fi.Count.ToString(); values[3] = String.Format("{0:#,0.00}", fi.PremiumValue); values[4] = String.Format("{0:#,0.00}", fi.BrokerageValue); creator.AddDataRowForFactures(values, headers.Length, typeCodes); } values = new object[headers.Length]; values[0] = ""; values[1] = ""; values[2] = ""; values[3] = "Вкупно"; values[4] = String.Format("{0:#,0.00}", f.BrokerageValue); creator.AddDataRowForFactures(values, headers.Length, typeCodes); creator.AddTable(); creator.SetTitleLeftBold14(" "); creator.SetTitleLeftItalic10("Со букви: " + NumberToTextController.Konvertiranje(f.BrokerageValue)); creator.SetTitleLeft8(" "); creator.SetTitleLeft10("Ве молиме фактурираниот износ да го платите до назначениот рок на плаќање."); creator.SetTitleLeft8(" "); creator.SetTitleLeft10("Доколку износот за фактурата не биде платен до наведениот датум, се пресметува затезна камата од денот на стасаност до денот на плаќањето."); creator.SetTitleLeft8(" "); creator.SetTitleLeft10("Согласно со член 23, точка 6 од Законот за ДДВ дејноста осигурување е ослободена од плаќање данок без право на одбиток на претходниот данок."); creator.SetTitleLeft8(" "); creator.SetTitleLeft8(" "); creator.SetTitleLeft8(" "); creator.SetTitleLeft8(" "); creator.SetTitleLeft10(" Фактурирал Примил Одобрил"); creator.SetTitleLeft10(" _________________ __________________ ____________________"); creator.AddPage(); creator.SetTitleCenterForFactureNumber("Спецификација за фактура бр. " + f.FactureNumber); string[] headersSpecifications = { "Ред. бр.", "Број на полиса", "Почеток", "Истек", "Дата на издавање", "Премија" }; float[] widthPercentagesSpecifications = { 10, 20, 19, 19, 19, 13 }; TypeCode[] typeCodesSpecifications = { TypeCode.Int32, TypeCode.String, TypeCode.String, TypeCode.String, TypeCode.String, TypeCode.Decimal }; object[] valuesSpecifications; foreach (FactureItem fi in f.FactureItems) { creator.SetTitleLeft10Bold(fi.InsuranceSubType.Description); creator.CreateTable_Facture(headersSpecifications.Length, headersSpecifications, widthPercentagesSpecifications); if (f.DocumentSubType.Code == DocumentSubType.FAKTURA_PROVIZIJA) { List <PolicyItemFactureItem> pifiList = PolicyItemFactureItem.GetByFactureItemID(fi.ID); int ordinalNumber = 1; foreach (PolicyItemFactureItem pifi in pifiList) { valuesSpecifications = new object[6]; valuesSpecifications[0] = ordinalNumber; valuesSpecifications[1] = pifi.PolicyItem.PolicyNumber; valuesSpecifications[2] = pifi.PolicyItem.Policy.StartDate.ToShortDateString(); valuesSpecifications[3] = pifi.PolicyItem.Policy.EndDate.ToShortDateString(); valuesSpecifications[4] = pifi.PolicyItem.Policy.ApplicationDate.ToShortDateString(); valuesSpecifications[5] = pifi.PolicyItem.PremiumValue; creator.AddDataRowForFacturesExtend(valuesSpecifications, headersSpecifications.Length, typeCodesSpecifications, headersSpecifications, widthPercentagesSpecifications); ordinalNumber++; } } if (f.DocumentSubType.Code == DocumentSubType.IZLEZNA_FAKTURA_ZA_PROVZIJA_ZA_ZIVOTNO_OSUGURUVANjE) { List <LifePolicyFactureItem> pifiList = LifePolicyFactureItem.GetByFactureItemID(fi.ID); int ordinalNumber = 1; foreach (LifePolicyFactureItem pifi in pifiList) { valuesSpecifications = new object[6]; valuesSpecifications[0] = ordinalNumber; valuesSpecifications[1] = pifi.LifePolicy.PolicyNumber; valuesSpecifications[2] = pifi.LifePolicy.StartDate.ToShortDateString(); valuesSpecifications[3] = pifi.LifePolicy.EndDate.ToShortDateString(); valuesSpecifications[4] = pifi.LifePolicy.ApplicationDate.ToShortDateString(); valuesSpecifications[5] = pifi.LifePolicy.TotalPremumValue; creator.AddDataRowForFacturesExtend(valuesSpecifications, headersSpecifications.Length, typeCodesSpecifications, headersSpecifications, widthPercentagesSpecifications); ordinalNumber++; } } creator.AddTable(); creator.SetTitleCenterForFactureNumber(" "); } creator.FinishPDF_FileName("Factura" + f.FactureNumber); } if (f.DocumentSubType.Code == DocumentSubType.FAKTURA_KLIENT) { PDFCreators creator = new PDFCreators(true, 25, 25, 15, 15); creator.SetDocumentHeaderFooter(); creator.OpenPDF(); creator.GetContentByte(); creator.AddJDBLogoForFactures(10, 775); creator.SetTitleLeft8(" "); creator.SetTitleLeft8(" "); creator.SetTitleLeft8(" "); creator.SetTitleLeft8(" "); creator.SetTitleLeft8(" Жиро-сметка : " + Broker.DataAccess.Parameter.GetByCode(Broker.DataAccess.Parameter.ZIRO_SMETKA).Value); creator.SetTitleLeft8(" Депонент : " + Broker.DataAccess.Parameter.GetByCode(Broker.DataAccess.Parameter.DEPONENT).Value); creator.SetTitleLeft8(" ЕДБ : " + Broker.DataAccess.Parameter.GetByCode(Broker.DataAccess.Parameter.EDB).Value + " " + "Матичен број : " + Broker.DataAccess.Parameter.GetByCode(Broker.DataAccess.Parameter.MATICEN_BROJ).Value); creator.SetTitleLeft8(" "); if (f.Discard) { creator.SetTitleCenterForFactureNumber("СТОРНИРАНА Ф-ра бр. " + f.FactureNumber); } else { creator.SetTitleCenterForFactureNumber("Фактура бр. " + f.FactureNumber); } string internalCode = ""; try { FinansovoDataClassesDataContext fdc = new FinansovoDataClassesDataContext(); List <Client> listCLients = fdc.Clients.Where(c => c.EMBG == f.Client.EMBG).ToList(); if (listCLients.Count > 0) { internalCode = listCLients[0].Code; } } catch { } if (internalCode != string.Empty) { creator.SetTitleLeftWithFontSize10(internalCode); } creator.SetTitleLeftWithFontSize10(ConvertToMacedonian.ConvertToMACEDONIAN(f.Client.Name).ToUpper()); creator.SetTitleLeftWithFontSize10(ConvertToMacedonian.ConvertToMACEDONIAN(f.Client.Address).ToUpper()); creator.SetTitleLeftWithFontSize10(ConvertToMacedonian.ConvertToMACEDONIAN(f.Client.Place.Municipality.Name).ToUpper()); creator.SetTitleLeft10("Датум на фактура: " + f.DateOfCreation.ToShortDateString()); creator.SetTitleLeft10("Рок на плаќање: " + f.DateOfPayment.ToShortDateString()); //creator.SetTitleLeft8("Период: " + f.FromDate.ToShortDateString() + " - " + f.ToDate.ToShortDateString()); string[] headers = { "Ред. бр.", "Број на полиса", "Осиг. комапнија", "Тип на осигурување", "Премија" }; float[] widthPercentages = { 8, 17, 30, 30, 15 }; TypeCode[] typeCodes = { TypeCode.Int32, TypeCode.String, TypeCode.String, TypeCode.String, TypeCode.Decimal }; creator.CreateTable_Facture(headers.Length, headers, widthPercentages); object[] values; foreach (FactureItem fi in f.FactureItems) { List <PolicyItemFactureItem> pifi = PolicyItemFactureItem.GetByFactureItemID(fi.ID); values = new object[headers.Length]; values[0] = fi.Number.ToString(); values[1] = pifi[0].PolicyItem.PolicyNumber; values[2] = pifi[0].PolicyItem.Policy.InsuranceCompany.ShortName; values[3] = pifi[0].PolicyItem.InsuranceSubType.ShortDescription; values[4] = String.Format("{0:#,0.00}", fi.PremiumValue) + " ДЕН."; creator.AddDataRowForFactures(values, headers.Length, typeCodes); } values = new object[headers.Length]; values[0] = ""; values[1] = ""; values[2] = ""; values[3] = "Вкупно"; values[4] = String.Format("{0:#,0.00}", f.TotalCost) + " ДЕН."; creator.AddDataRowForFactures(values, headers.Length, typeCodes); creator.AddTable(); creator.SetTitleLeftBold14(" "); creator.SetTitleLeftItalic10("Со букви: " + NumberToTextController.Konvertiranje(f.TotalCost)); creator.SetTitleLeft8(" "); creator.SetTitleLeft10("Ве молиме фактурираниот износ да го платите до назначениот рок на плаќање."); creator.SetTitleLeft8(" "); creator.SetTitleLeft10("Доколку износот за фактурата не биде платен до наведениот датум, се пресметува затезна камата од денот на стасаност до денот на плаќањето."); creator.SetTitleLeft8(" "); creator.SetTitleLeft10("Согласно со член 23, точка 6 од Законот за ДДВ дејноста осигурување е ослободена од плаќање данок без право на одбиток на претходниот данок."); creator.SetTitleLeft8(" "); creator.SetTitleLeft8(" "); creator.SetTitleLeft8(" "); creator.SetTitleLeft8(" "); creator.SetTitleLeft10(" Фактурирал Примил Одобрил"); creator.SetTitleLeft10(" _________________ __________________ ____________________"); Broker.DataAccess.Parameter pSE_PECATI_SPECIFIKACIJA_NA_F_RA_ZA_KLIENT = Broker.DataAccess.Parameter.GetByCode(Broker.DataAccess.Parameter.SE_PECATI_SPECIFIKACIJA_NA_F_RA_ZA_KLIENT); bool fpSE_PECATI_SPECIFIKACIJA_NA_F_RA_ZA_KLIENT = true; if (pSE_PECATI_SPECIFIKACIJA_NA_F_RA_ZA_KLIENT != null) { if (Convert.ToBoolean(pSE_PECATI_SPECIFIKACIJA_NA_F_RA_ZA_KLIENT.Value) == false) { fpSE_PECATI_SPECIFIKACIJA_NA_F_RA_ZA_KLIENT = false; } } if (fpSE_PECATI_SPECIFIKACIJA_NA_F_RA_ZA_KLIENT) { string facItemDescriptionStart = "Полиса - "; creator.AddPage(); foreach (FactureItem fi in f.FactureItems) { string polNumber = fi.Description.Substring(facItemDescriptionStart.Length); creator.SetTitleLeft10(facItemDescriptionStart + polNumber); string[] headersRates = { "Рата бр.", "Дата за плаќање", "Износ" }; float[] widthPercentagesRates = { 15, 50, 35 }; TypeCode[] typeCodesRates = { TypeCode.Int32, TypeCode.String, TypeCode.Decimal }; creator.CreateTable_Facture(headersRates.Length, headersRates, widthPercentagesRates); PolicyItem pi = PolicyItem.GetByNumberAndInsuranceSubType(polNumber, fi.InsuranceSubTypeID, (int)fi.Facture.InsuranceCompanyID); List <Rate> rates = Rate.GetByPolicyItemID(pi.ID); rates = rates.OrderBy(c => c.Number).ToList(); foreach (Rate r in rates) { object[] valuesRates = new object[headersRates.Length]; valuesRates[0] = r.Number; valuesRates[1] = r.Date.ToShortDateString(); valuesRates[2] = String.Format("{0:#,0.00}", r.Value); creator.AddDataRowForFactures(valuesRates, headersRates.Length, typeCodes); } creator.AddTable(); } } creator.FinishPDF_FileName("Factura" + f.FactureNumber); } if (f.DocumentSubType.Code == DocumentSubType.GRUPNA_FAKTURA) { PDFCreators creator = new PDFCreators(true, 25, 25, 15, 15); creator.SetDocumentHeaderFooter(); creator.OpenPDF(); creator.GetContentByte(); creator.AddJDBLogoForFactures(10, 775); creator.SetTitleLeft8(" "); creator.SetTitleLeft8(" "); creator.SetTitleLeft8(" "); creator.SetTitleLeft8(" "); creator.SetTitleLeft8(" Жиро-сметка : " + Broker.DataAccess.Parameter.GetByCode(Broker.DataAccess.Parameter.ZIRO_SMETKA).Value); creator.SetTitleLeft8(" Депонент : " + Broker.DataAccess.Parameter.GetByCode(Broker.DataAccess.Parameter.DEPONENT).Value); creator.SetTitleLeft8(" ЕДБ : " + Broker.DataAccess.Parameter.GetByCode(Broker.DataAccess.Parameter.EDB).Value + " " + "Матичен број : " + Broker.DataAccess.Parameter.GetByCode(Broker.DataAccess.Parameter.MATICEN_BROJ).Value); creator.SetTitleLeft8(" "); if (f.Discard) { creator.SetTitleCenterForFactureNumber("СТОРНИРАНА Фактура бр. " + f.FactureNumber); } else { creator.SetTitleCenterForFactureNumber("Фактура бр. " + f.FactureNumber); } string internalCode = ""; try { FinansovoDataClassesDataContext fdc = new FinansovoDataClassesDataContext(); List <Client> listCLients = fdc.Clients.Where(c => c.EMBG == f.Client.EMBG).ToList(); if (listCLients.Count > 0) { internalCode = listCLients[0].Code; } } catch { } if (internalCode != string.Empty) { creator.SetTitleLeftWithFontSize10(internalCode); } creator.SetTitleLeftWithFontSize10(ConvertToMacedonian.ConvertToMACEDONIAN(f.Client.Name).ToUpper()); creator.SetTitleLeftWithFontSize10(ConvertToMacedonian.ConvertToMACEDONIAN(f.Client.Address).ToUpper()); creator.SetTitleLeftWithFontSize10(ConvertToMacedonian.ConvertToMACEDONIAN(f.Client.Place.Municipality.Name).ToUpper()); creator.SetTitleLeft10("Датум на фактура: " + f.DateOfCreation.ToShortDateString()); creator.SetTitleLeft10("Рок на плаќање: " + f.DateOfPayment.ToShortDateString()); string[] headers = { "Ред. бр.", "Број на полиса", "Осиг. компанија", "Тип на осигурување", "Премија" }; float[] widthPercentages = { 8, 17, 30, 30, 15 }; TypeCode[] typeCodes = { TypeCode.Int32, TypeCode.String, TypeCode.String, TypeCode.String, TypeCode.Decimal }; creator.CreateTable_Facture(headers.Length, headers, widthPercentages); object[] values; foreach (FactureItem fi in f.FactureItems) { List <PolicyItemFactureItem> pifi = PolicyItemFactureItem.GetByFactureItemID(fi.ID); values = new object[headers.Length]; values[0] = fi.Number.ToString(); values[1] = pifi[0].PolicyItem.PolicyNumber; values[2] = pifi[0].PolicyItem.Policy.InsuranceCompany.ShortName; values[3] = pifi[0].PolicyItem.InsuranceSubType.ShortDescription; values[4] = String.Format("{0:#,0.00}", fi.PremiumValue) + " ДЕН."; creator.AddDataRowForFactures(values, headers.Length, typeCodes); } values = new object[headers.Length]; values[0] = ""; values[1] = ""; values[2] = ""; values[3] = "Вкупно"; values[4] = String.Format("{0:#,0.00}", f.TotalCost) + " ДЕН."; creator.AddDataRowForFactures(values, headers.Length, typeCodes); creator.AddTable(); creator.SetTitleLeftBold14(" "); creator.SetTitleLeftItalic10("Со букви: " + NumberToTextController.Konvertiranje(f.TotalCost)); creator.SetTitleLeft8(" "); creator.SetTitleLeft10("Ве молиме фактурираниот износ да го платите до назначениот рок на плаќање."); creator.SetTitleLeft8(" "); creator.SetTitleLeft10("Доколку износот за фактурата не биде платен до наведениот датум, се пресметува затезна камата од денот на стасаност до денот на плаќањето."); creator.SetTitleLeft8(" "); creator.SetTitleLeft10("Согласно со член 23, точка 6 од Законот за ДДВ дејноста осигурување е ослободена од плаќање данок без право на одбиток на претходниот данок."); creator.SetTitleLeft8(" "); creator.SetTitleLeft8(" "); creator.SetTitleLeft8(" "); creator.SetTitleLeft8(" "); creator.SetTitleLeft10(" Фактурирал Примил Одобрил"); creator.SetTitleLeft10(" _________________ __________________ ____________________"); bool fpSE_PECATI_SPECIFIKACIJA_NA_F_RA_ZA_KLIENT = true; if (Broker.DataAccess.Parameter.GetByCode(Broker.DataAccess.Parameter.SE_PECATI_SPECIFIKACIJA_NA_F_RA_ZA_KLIENT) != null) { fpSE_PECATI_SPECIFIKACIJA_NA_F_RA_ZA_KLIENT = Boolean.Parse(Broker.DataAccess.Parameter.GetByCode(Broker.DataAccess.Parameter.SE_PECATI_SPECIFIKACIJA_NA_F_RA_ZA_KLIENT).Value); } if (fpSE_PECATI_SPECIFIKACIJA_NA_F_RA_ZA_KLIENT) { string facItemDescriptionStart = "Полиса бр. "; creator.AddPage(); foreach (FactureItem fi in f.FactureItems) { string polNumber = fi.Description.Substring(facItemDescriptionStart.Length); creator.SetTitleLeft10(facItemDescriptionStart + polNumber); string[] headersRates = { "Рата бр.", "Дата за плаќање", "Износ" }; float[] widthPercentagesRates = { 15, 50, 35 }; TypeCode[] typeCodesRates = { TypeCode.Int32, TypeCode.String, TypeCode.Decimal }; creator.CreateTable_Facture(headersRates.Length, headersRates, widthPercentagesRates); PolicyItem pi = PolicyItem.GetByNumberAndInsuranceSubType(polNumber, fi.InsuranceSubTypeID, (int)fi.Facture.InsuranceCompanyID); List <Rate> rates = Rate.GetByPolicyItemID(pi.ID); rates = rates.OrderBy(c => c.Number).ToList(); foreach (Rate r in rates) { object[] valuesRates = new object[headersRates.Length]; valuesRates[0] = r.Number; valuesRates[1] = r.Date.ToShortDateString(); valuesRates[2] = String.Format("{0:#,0.00}", r.Value); creator.AddDataRowForFactures(valuesRates, headersRates.Length, typeCodes); } creator.AddTable(); } } creator.FinishPDF_FileName("Factura" + f.FactureNumber); } }
public void Test15_TotalAttachmentSize() { PolicyItem item = new PolicyItem("AttachSize", File.ReadAllBytes(Path.Combine(TESTPATH, "Attachment Size Policy Set.runtimepolicy"))); item.RestrictedTargets = new RunAt[] { RunAt.Client }; GetPolicyCache().Add(item); IContentScanner scannerService = GetContentScanner(); using (LocalCopyOfFileManager lcofm = new LocalCopyOfFileManager()) { Request request = CreateRequest_Email("", "some message body", "<html><body>some message body</body></html>", "Outlook", "*****@*****.**"); List<CustomProperty> props = new List<CustomProperty>(request.Properties); props.Add(new CustomProperty(RequestAdaptor.PassContentAsFileProperty, string.Empty)); request.Properties = props.ToArray(); AddEmailRecipient(request, "*****@*****.**", true); string filepath = lcofm.GetLocalCopyOfFileTarget("TriggerPolicy3.doc"); File.Copy(Path.Combine(TESTPATH, "TriggerPolicy3.doc"), filepath); AddAttachment(request, filepath, true, "application/msword"); string filepath2 = lcofm.GetLocalCopyOfFileTarget("TriggerPolicy2.doc"); File.Copy(Path.Combine(TESTPATH, "TriggerPolicy2.doc"), filepath2); AddAttachment(request, filepath2, true, "application/msword"); scannerService.TotalAttachmentSize = 48L; Response response = scannerService.Scan(request, null, ProcessLevel.Expressions, RunAt.Client); Assert.AreEqual("TriggerPolicy3.doc", response.Contents[1].DisplayName, "Should be the friendly name only. Not the full path"); Assert.IsNull(response.Contents[1].Content, "Content should be empty as its passed by file"); foreach (ContentItem contentItem in response.Contents) { foreach (PolicySet policySet in contentItem.PolicySets) { if (policySet.Name == "Attachment Size Policy Set") { foreach (Policy policy in policySet.Policies) { if (policy.Name == "Attachment Size Policy") { Assert.IsTrue(policy.Triggered); } } } } } } GetPolicyCache().Remove(item.UniqueId); }
protected void btnUpdate_Click(object sender, EventArgs e) { if (PoliciesDetailsView.SelectedValue != null) { int policyItemID = Convert.ToInt32(PoliciesDetailsView.SelectedValue); PolicyItem policyItem = PolicyItem.Get(policyItemID); DropDownList ddlStatuses = PoliciesDetailsView.FindControl("ddlStatuses") as DropDownList; policyItem.StatusID = Convert.ToInt32(ddlStatuses.SelectedValue); Policy policy = Policy.Get(policyItem.PolicyID); TextBox tbStartDate = PoliciesDetailsView.FindControl("tbStartDate") as TextBox; TextBox tbEndDate = PoliciesDetailsView.FindControl("tbEndDate") as TextBox; TextBox tbApplicationDate = PoliciesDetailsView.FindControl("tbApplicationDate") as TextBox; policy.StartDate = Convert.ToDateTime(tbStartDate.Text); policy.EndDate = Convert.ToDateTime(tbEndDate.Text); policy.ApplicationDate = Convert.ToDateTime(tbApplicationDate.Text); Policy.Table.Context.SubmitChanges(); Panel pnlExtendControls = PoliciesDetailsView.FindControl("pnlExtendControls") as Panel; List <Broker.DataAccess.Control> listControls = Broker.DataAccess.Control.GetActiveByInsuranceSubType(policyItem.InsuranceSubTypeID); foreach (Broker.DataAccess.Control c in listControls) { PolicyExtendInformation pei = PolicyExtendInformation.GetByPolicyItemAndControl(policyItem.ID, c.ID); TextBox tbControl = (TextBox)pnlExtendControls.FindControl(c.TextBoxID); ControlCollection cc = pnlExtendControls.Controls; if (pei != null) { pei.Value = tbControl.Text; if (c.HasCompareValidator) { CompareValidator cv = (CompareValidator)pnlExtendControls.FindControl("cv" + c.TextBoxID); if (cv.Type == ValidationDataType.Double) { if (tbControl.Text == string.Empty) { pei.Value = "0"; } } } PolicyExtendInformation.Table.Context.SubmitChanges(); } else { PolicyExtendInformation newpei = new PolicyExtendInformation(); newpei.ControlID = c.ID; newpei.PolicyItemID = policyItem.ID; newpei.Value = tbControl.Text; if (c.HasCompareValidator) { CompareValidator cv = (CompareValidator)pnlExtendControls.FindControl("cv" + c.TextBoxID); if (cv.Type == ValidationDataType.Double) { if (tbControl.Text == string.Empty) { pei.Value = "0"; } } } pei.Insert(); } btnSearch.Enabled = false; } } }
public static void PrintBillInfoForPolicy(PolicyItem pi) { string brokerName = BrokerHouseInformation.GetBrokerHouseName(); PDFCreators creator = new PDFCreators(true, 25, 25, 15, 15); creator.SetDocumentHeaderFooter(); creator.OpenPDF(); creator.GetContentByte(); creator.AddJDBLogoForFactures(10, 775); creator.SetTitleLeft8(" "); creator.SetTitleLeft8(" "); creator.SetTitleLeft8(" "); creator.SetTitleLeft8(" "); creator.SetTitleLeft8(" Жиро-сметка : " + Broker.DataAccess.Parameter.GetByCode(Broker.DataAccess.Parameter.ZIRO_SMETKA).Value); creator.SetTitleLeft8(" Депонент : " + Broker.DataAccess.Parameter.GetByCode(Broker.DataAccess.Parameter.DEPONENT).Value); creator.SetTitleLeft8(" ЕДБ : " + Broker.DataAccess.Parameter.GetByCode(Broker.DataAccess.Parameter.EDB).Value + " " + "Матичен број : " + Broker.DataAccess.Parameter.GetByCode(Broker.DataAccess.Parameter.MATICEN_BROJ).Value); creator.SetTitleLeft8(" "); creator.SetTitle("ПОТВРДА"); creator.SetTitle("(за продадена полиса)"); creator.SetTitle("Полиса бр. " + pi.PolicyNumber); creator.SetTitleLeft8(" "); creator.SetTitleLeftWithFontSize10(ConvertToMacedonian.ConvertToMACEDONIAN(pi.Policy.Client.Name).ToUpper()); creator.SetTitleLeftWithFontSize10(ConvertToMacedonian.ConvertToMACEDONIAN(pi.Policy.Client.Address).ToUpper()); creator.SetTitleLeftWithFontSize10(ConvertToMacedonian.ConvertToMACEDONIAN(pi.Policy.Client.Place.Municipality.Name).ToUpper()); creator.SetTitleLeft10("Датум на полиса: " + pi.Policy.ApplicationDate.ToShortDateString()); string nacinNaPlakanje = ""; if (pi.IsPaidInBrokerHouse) { nacinNaPlakanje = "ЕДНОКРАТНО"; List <Rate> lstRates = Rate.GetByPolicyItemID(pi.ID); if (lstRates.Count > 1) { nacinNaPlakanje = "НА РАТИ"; } } else { nacinNaPlakanje = "ДИРЕКТНО ВО ОСИГУРИТЕЛНА КОМПАНИЈА"; } creator.SetTitleLeft10("Начин на плаќање на полиса: " + nacinNaPlakanje); string[] headers = { "Ред. бр.", "Број на полиса", "Осиг. компанија", "Тип на осигурување", "Премија" }; float[] widthPercentages = { 8, 17, 30, 30, 15 }; TypeCode[] typeCodes = { TypeCode.Int32, TypeCode.String, TypeCode.String, TypeCode.String, TypeCode.Decimal }; creator.CreateTable_Facture(headers.Length, headers, widthPercentages); object[] values; values = new object[headers.Length]; values[0] = "1"; values[1] = pi.PolicyNumber; values[2] = pi.Policy.InsuranceCompany.ShortName; values[3] = pi.InsuranceSubType.ShortDescription; values[4] = String.Format("{0:#,0.00}", pi.PremiumValue) + " ДЕН."; creator.AddDataRowForFactures(values, headers.Length, typeCodes); values = new object[headers.Length]; values[0] = ""; values[1] = ""; values[2] = ""; values[3] = "Вкупно"; values[4] = String.Format("{0:#,0.00}", pi.PremiumValue) + " ДЕН."; creator.AddDataRowForFactures(values, headers.Length, typeCodes); creator.AddTable(); creator.SetTitleLeftBold14(" "); creator.SetTitleLeftItalic10("Со букви: " + NumberToTextController.Konvertiranje(pi.PremiumValue)); creator.SetTitleLeft8(" "); creator.SetTitleLeft10("Согласно со член 23, точка 6 од Законот за ДДВ дејноста осигурување е ослободена од плаќање данок без право на одбиток на претходниот данок."); creator.SetTitleLeft8(" "); creator.SetTitleLeft8(" "); creator.SetTitleLeft8(" "); creator.SetTitleLeft8(" "); creator.SetTitleLeft8(" " + brokerName + " ДОГОВОРУВАЧ"); creator.SetTitleLeft8(" "); creator.SetTitleLeft8("_________________________ ____________________"); creator.FinishPDF_FileName("Potvrda" + pi.PolicyNumber); }
public void Test_12_MailClientProfanity() { try { IContentScanner scannerService = GetContentScanner(); PolicyItem hrPolicy = new PolicyItem("HRPolicy", File.ReadAllBytes(Path.Combine(TESTPATH, "Human Resources.runtimepolicy"))); hrPolicy.RestrictedTargets = new RunAt[] { RunAt.Client }; GetPolicyCache().Clear(); GetPolicyCache().Add(hrPolicy); using (var cs = new ContractSerialization()) { Request request = cs.LoadRequest(Path.Combine(TESTPATH, "TestProfanityIsTriggered.request")); Response response = scannerService.Scan(request, string.Empty, ProcessLevel.Actions, RunAt.Client); AssertValid(response, ProcessLevel.Actions); } } finally { GetPolicyCache().Clear(); InitPolicies(); } }
public static void PrintAnex(Broker.DataAccess.Facture f) { List <PolicyItemFactureItem> lstPIFI = PolicyItemFactureItem.GetByFactureID(f.ID); PDFCreators creator = new PDFCreators(true, 25, 25, 15, 15); creator.SetDocumentHeaderFooter(); creator.OpenPDF(); creator.GetContentByte(); creator.AddJDBLogoForFactures(10, 775); creator.SetTitleLeft8(" "); creator.SetTitleLeft8(" "); creator.SetTitleLeft8(" "); creator.SetTitleLeft8(" "); if (f.DocumentSubType.Code == Broker.DataAccess.DocumentSubType.FAKTURA_PROVIZIJA) { creator.SetTitleLeft8(" Жиро-сметка : " + Broker.DataAccess.Parameter.GetByCode(Broker.DataAccess.Parameter.ZIRO_SMETKA_ZA_OSIG_KOMPANII).Value); } else if (f.DocumentSubType.Code == DocumentSubType.FAKTURA_KLIENT) { creator.SetTitleLeft8(" Жиро-сметка : " + Broker.DataAccess.Parameter.GetByCode(Broker.DataAccess.Parameter.ZIRO_SMETKA).Value); } creator.SetTitleLeft8(" Депонент : " + Broker.DataAccess.Parameter.GetByCode(Broker.DataAccess.Parameter.DEPONENT).Value); creator.SetTitleLeft8(" ЕДБ : " + Broker.DataAccess.Parameter.GetByCode(Broker.DataAccess.Parameter.EDB).Value + " " + "Матичен број : " + Broker.DataAccess.Parameter.GetByCode(Broker.DataAccess.Parameter.MATICEN_BROJ).Value); creator.SetTitleLeft8(" "); creator.SetTitleLeft8("Договорувач " + f.Client.Name + " " + "Експозитура " + f.User.Branch.Name); creator.SetTitleLeft8(" "); creator.SetTitle("ДОГОВОР " + f.FactureNumber); creator.SetTitle("за плаќање на должна премија за осигурување"); creator.SetTitle("(плаќање на рати)"); creator.SetTitleLeft8(" "); creator.SetTitleLeft8(" "); creator.SetTitleLeft8("1.Премијата за осигурување ќе се плати на рати, како што следи:"); string[] headersRates = { "Реден број", "Рок за плаќање", "Полиса", "Фактура број", "Износ" }; float[] widthPercentagesRates = { 10, 25, 25, 20, 20 }; TypeCode[] typeCodesRates = { TypeCode.Int32, TypeCode.String, TypeCode.String, TypeCode.String, TypeCode.Decimal }; creator.CreateTable_Facture(headersRates.Length, headersRates, widthPercentagesRates); List <Rate> ratesForPrint = new List <Rate>(); foreach (FactureItem fi in f.FactureItems) { List <PolicyItemFactureItem> list = lstPIFI.Where(p => p.FactureItemID == fi.ID).ToList(); foreach (PolicyItemFactureItem pifi in list) { string polNumber = PolicyItem.Get(pifi.PolicyItemID).PolicyNumber; List <Rate> rates = Rate.GetByPolicyItemID(pifi.PolicyItemID); rates = rates.OrderBy(c => c.Number).ToList(); ratesForPrint.AddRange(rates); } } ratesForPrint = ratesForPrint.OrderBy(c => c.Date).ToList(); int counter = 1; foreach (Rate r in ratesForPrint) { object[] valuesRates = new object[headersRates.Length]; valuesRates[0] = counter; valuesRates[1] = r.Date.ToShortDateString(); valuesRates[2] = r.PolicyItem.PolicyNumber; valuesRates[3] = f.FactureNumber; valuesRates[4] = String.Format("{0:#,0.00}", r.Value) + " ДЕН."; creator.AddDataRowForFactures(valuesRates, headersRates.Length, typeCodesRates); counter++; } object[] values = new object[headersRates.Length]; values[0] = ""; values[1] = ""; values[2] = ""; values[3] = "Вкупно"; values[4] = String.Format("{0:#,0.00}", f.TotalCost) + " ДЕН."; creator.AddDataRowForFactures(values, headersRates.Length, typeCodesRates); creator.AddTable(); creator.SetTitleLeft8("2.Доколку настане осигуран случај - штета, независно од тоа што е договорено плаќање на рати, премијата за осигурување стасува за наплата веднаш до висината на надоместокот што треба да се исплати и ќе се наплати по пат на компензација."); creator.SetTitleLeft8("3.Ако премијата не се плати во договорените рокови од овој Договор, ќе се пресметува камата."); creator.SetTitleLeft8("4.Договорот е составен од три еднообразни примероци, од кои еден за осигуреникот, а два за осигурувачот."); creator.SetTitle(" "); creator.SetTitle(" "); creator.SetTitleCenter8("Во " + f.User.Branch.Municipality.Name + " на " + f.DateOfCreation.ToShortDateString()); creator.SetTitle(" "); creator.SetTitle(" "); string brokerName = BrokerHouseInformation.GetBrokerHouseName(); creator.SetTitleLeft8(" " + brokerName + " ДОГОВОРУВАЧ"); creator.SetTitleLeft8(" "); creator.SetTitleLeft8("_________________________ ____________________"); creator.FinishPDF_FileName("Aneks" + f.FactureNumber); }
public void Test08_UpdatePolicy() { Assert.AreEqual(0, PolicyCacheManager.Instance.InternalCollection.Count); PolicyItem policy1 = new PolicyItem(); policy1.UniqueId = "Policy1"; policy1.Contents = File.ReadAllBytes(Path.Combine(TEST_PATH, "policy1.runtimepolicy")); policy1.Users = new string[] { @"WSDEV\LNPAIR" }; policy1.RestrictedTargets = new RunAt[] { RunAt.Client }; PolicyCacheManager.Instance.RegisterPolicy(policy1); Assert.AreEqual(1, PolicyCacheManager.Instance.InternalCollection.Count); Assert.AreEqual(1, PolicyCacheManager.Instance.GetPolicies().Length, "Unexpected collection size (1 entry per registered policy)"); byte[] updatedBytes = File.ReadAllBytes(Path.Combine(TEST_PATH, "Policy1_update.runtimepolicy")); policy1.Contents = updatedBytes; PolicyCacheManager.Instance.UpdatePolicy(policy1); Assert.AreEqual(1, PolicyCacheManager.Instance.InternalCollection.Count); Assert.AreEqual(1, PolicyCacheManager.Instance.GetPolicies().Length, "Unexpected collection size (1 entry per registered policy)"); }
protected void btnCreate_Click(object sender, EventArgs e) { DateTime fromDate = DateTime.Parse(tbFromDate.Text); DateTime toDate = DateTime.Parse(tbToDate.Text); int insuranceCompanyID = Convert.ToInt32(ddlInsuranceCompanies.SelectedValue); List <PolicyForSlipsInfo> lastPolicyForSlipsInfos = listPolicyForSlipsInfos; GridViewRowCollection displayedRows = gvNewPolicies.Rows; foreach (GridViewRow gvRow in displayedRows) { CheckBox cbIsForFacturing = gvRow.FindControl("cbIsForFacturing") as CheckBox; int factureInfoID = Convert.ToInt32(gvNewPolicies.DataKeys[gvRow.RowIndex].Value); PolicyForSlipsInfo pfsi = lastPolicyForSlipsInfos.Where(f => f.ID == factureInfoID).SingleOrDefault(); pfsi.IsForFacturing = cbIsForFacturing.Checked; } listPolicyForSlipsInfos = lastPolicyForSlipsInfos; List <PolicyForSlipsInfo> listFactureInfo = listPolicyForSlipsInfos.Where(c => c.IsForFacturing == true).ToList(); if (listFactureInfo.Count > 0) { BrokerageSlip bs = new BrokerageSlip(); bs.BasisForCompensation = tbBasisForCompensation.Text; bs.Date = DateTime.Today; bs.Description = tbDescription.Text; bs.FromDate = fromDate; bs.InsuranceCompanyID = insuranceCompanyID; bs.InsuranceRisks = tbInsuranceRisks.Text; bs.InsuranceThings = tbInsuranceThings.Text; if (listFactureInfo.Count == 1) { PolicyItem tmpPol = PolicyItem.Get(listFactureInfo[0].ID); if (tmpPol != null) { bs.Insurer = tmpPol.Policy.Client1.Name; } else { bs.Insurer = "ПО ПРИЛОГ ПОЛИСИ"; } } else { bs.Insurer = "ПО ПРИЛОГ ПОЛИСИ"; } bs.Number = BrokerageSlip.GetNextNumber(insuranceCompanyID); bs.OtherConditions = tbOtherConditions.Text; bs.ToDate = toDate; bs.Insert(); Dictionary <int, List <decimal> > dic = new Dictionary <int, List <decimal> >(); foreach (PolicyForSlipsInfo pfsi in listFactureInfo) { if (!dic.Keys.Contains(pfsi.InsuranceSubTypeID)) { List <decimal> brokPercentages = new List <decimal>(); if (pfsi.BrokerageID != null) { Brokerage brokerage = Brokerage.Get(pfsi.BrokerageID); brokPercentages.Add(brokerage.PercentageForPrivates); brokPercentages.Add(brokerage.PercentageForLaws); } else if (pfsi.PacketBrokerageID != null) { PacketsInsuranceSubType pist = PacketsInsuranceSubType.Get(pfsi.PacketBrokerageID); brokPercentages.Add(pist.BrokeragePecentageForPrivates); brokPercentages.Add(pist.BrokeragePecentageForLaws); } dic.Add(pfsi.InsuranceSubTypeID, brokPercentages); } BrokerageSlipPolicyItem bspi = new BrokerageSlipPolicyItem(); bspi.BrokerageSlipID = bs.ID; bspi.PolicyItemID = pfsi.ID; bspi.Insert(); PolicyItem pItem = PolicyItem.Get(pfsi.ID); pItem.IsBrokerageSliped = true; PolicyItem.Table.Context.SubmitChanges(); } foreach (KeyValuePair <int, List <decimal> > kvPair in dic) { BrokerageSlipInsuranceSubType bsist = new BrokerageSlipInsuranceSubType(); bsist.BrokerageSlipID = bs.ID; bsist.BrokeragePercentagePrivates = kvPair.Value[0]; bsist.BrokeragePercentageLaws = kvPair.Value[1]; bsist.InsuranceSubTypeID = kvPair.Key; bsist.Insert(); } btnPrBrokSlip.Enabled = true; ViewState["BrokerageSlipID"] = bs.ID; GXGridView1SelectedValue = bs.ID; } }
public RegDiffItemInfo() { OldItem = new PolicyItem(); NewItem = new PolicyItem(); }
public void Test15_GetScanners_DifferentPolicyTypes() { PolicyItem policy1 = new PolicyItem(); policy1.UniqueId = "Policy1"; policy1.Contents = File.ReadAllBytes(Path.Combine(TEST_PATH, "ClientEmail.runtimepolicy")); policy1.Users = null; policy1.RestrictedTargets = new RunAt[] { RunAt.Client }; PolicyCacheManager.Instance.RegisterPolicy(policy1); PolicyItem policy2 = new PolicyItem(); policy2.UniqueId = "Policy2"; policy2.Contents = File.ReadAllBytes(Path.Combine(TEST_PATH, "ClientEmail.runtimepolicy")); policy2.Users = null; policy2.RestrictedTargets = new RunAt[] { RunAt.Client }; PolicyCacheManager.Instance.RegisterPolicy(policy2); Collection<Lease<EngineLookupKey, IBaseContentScanner>> scanners = PolicyCacheManager.Instance.GetScanners(PolicyType.ClientEmail, null, RunAt.Client.ToString()); Assert.AreEqual(2, scanners.Count, "Unexpected amount of items returned"); scanners = PolicyCacheManager.Instance.GetScanners(PolicyType.ActiveContent, null, RunAt.Client.ToString()); Assert.AreEqual(0, scanners.Count, "Unexpected amount of items returned"); PolicyItem policy3 = new PolicyItem("Policy3", File.ReadAllBytes(Path.Combine(TEST_PATH, "ActiveContent.runtimepolicy"))); policy3.RestrictedTargets = new RunAt[] { RunAt.Client }; PolicyCacheManager.Instance.RegisterPolicy(policy3); scanners = PolicyCacheManager.Instance.GetScanners(PolicyType.ActiveContent, null, RunAt.Client.ToString()); Assert.AreEqual(1, scanners.Count, "Unexpected amount of items returned"); }
public void Test06_RegisterPolicy_ZeroItemRestrictedTarget() { PolicyItem policy1 = new PolicyItem(); policy1.UniqueId = "Policy1"; policy1.Contents = File.ReadAllBytes(Path.Combine(TEST_PATH, "policy1.runtimepolicy")); policy1.Users = new string[] { @"WSDEV\LNPAIR" }; policy1.RestrictedTargets = new RunAt[] { }; try { PolicyCacheManager.Instance.RegisterPolicy(policy1); } catch (ArgumentException) { Assert.AreEqual(0, PolicyCacheManager.Instance.InternalCollection.Count, "Exception should have been thrown and no content scanners added"); Assert.AreEqual(0, PolicyCacheManager.Instance.GetPolicies().Length, "Unexpected collection size (1 entry per registered policy)"); return; } Assert.Fail("An invalid policy was registered, an thrown exception was expected."); }