protected void btnDiscard_Click(object sender, EventArgs e) { if (GXGridView1SelectedValue > 0) { mvMain.SetActiveView(viewDiscardPolicy); LifePolicy p = LifePolicy.Get(GXGridView1SelectedValue); tbDiscardPolicyNumber.Text = p.PolicyNumber; tbDiscardInsuranceCompany.Text = p.InsuranceCompany.ShortName; tbDiscardInsuranceSubType.Text = p.InsuranceSubType.ShortDescription; } }
protected void btnDiscardPol_Click(object sender, EventArgs e) { if (GXGridView1.SelectedIndex != -1) { LifePolicy p = LifePolicy.Get(GXGridView1SelectedValue); if (p != null) { p.Discard = true; LifePolicy.Table.Context.SubmitChanges(); } GXGridView1.DataBind(); } }
protected void dvDataSource_Inserted(object sender, ObjectDataSourceStatusEventArgs e) { LifePolicy p = (LifePolicy)e.ReturnValue; if (p != null) { LifeDeal lifeDeal = LifeDeal.Get(DealID); decimal totalBrokerageValue = (p.InsuranceCoverageOne * (lifeDeal.PercentageFromSumForRestLiving / 100)) + (p.YearlyPremiumValueForAccident * (lifeDeal.PercentageFromPremiumForAccident / 100)); List <LifeDealBrokerage> lstLPBrokerage = LifeDealBrokerage.GetByLifeDeal(lifeDeal.ID); int counter = 1; foreach (LifeDealBrokerage ldb in lstLPBrokerage) { LifePolicyBrokerage lpb = new LifePolicyBrokerage(); lpb.FromDate = p.ApplicationDate.AddYears(counter - 1); lpb.IsFactured = false; lpb.LifePolicyID = p.ID; lpb.OrdinalNumber = counter; lpb.ToDate = p.ApplicationDate.AddYears(counter); lpb.Value = (ldb.BrokeragePecentForYear / 100) * totalBrokerageValue; lpb.Insert(); counter++; } for (int i = 1; i <= PolicyDurationYears; i++) { LifePolicyPremiumValue lppv = new LifePolicyPremiumValue(); lppv.FromDate = p.StartDate.AddYears(i - 1); lppv.LifePolicyID = p.ID; lppv.OrdinalNumberYear = i; lppv.PremiumValueForAccident = p.YearlyPremiumValueForAccident; lppv.PremiumValueForAccidentEuro = p.YearlyPremiumValueForAccidentEuro; lppv.PremiumValueForLife = p.YearlyPremiumValueForLife; lppv.PremiumValueForLifeEuro = p.YearlyPremiumValueForLifeEuro; lppv.ToDate = p.StartDate.AddYears(i); lppv.Insert(); } Distribution d = Distribution.GetByNumberAndSubTypeAndCompany(p.InsuranceSubTypeID, p.PolicyNumber, p.InsuranceCompanyID); if (d != null) { d.IsUsed = true; } else { RightRestrictionDistribution rrd = RightRestrictionDistribution.GetForCompanyAndType(p.InsuranceCompanyID, p.PolicyNumber, DistributionDocumentType.GetByCode(DistributionDocumentType.BLANKO).ID); rrd.IsUsed = true; } Policy.Table.Context.SubmitChanges(); } }
void SetInsuranceDurationInYears() { if (this.PageUser.Role.Name == RolesInfo.BROKERAdmin) { pnlBrokerageInformationsPerYears.Visible = true; } else { pnlBrokerageInformationsPerYears.Visible = false; } TextBox tbPolicyDurationYears = (TextBox)PoliciesDetailsView.FindControl("tbPolicyDurationYears"); if (GXGridView1SelectedValue > 0) { LifePolicy p = LifePolicy.Get(GXGridView1SelectedValue); tbPolicyDurationYears.Text = ((p.EndDate - p.StartDate).Days / 365.15).ToString(); gvLifePolicyPremiumValue.DataBind(); gvLifePolicyBrokerage.DataBind(); } }
protected void dvDataSource_Inserting(object sender, ObjectDataSourceMethodEventArgs e) { if ((ViewState["ClientID"] == null) || (ViewState["OwnerID"] == null)) { RegisterStartupScript("myAlert", "<script>alert('НЕ Е ИЗБРАН ДОГОВОРУВАЧ ИЛИ ОСИГУРЕНИК!')</script>"); return; } LifePolicy p = e.InputParameters["entityToInsert"] as LifePolicy; p.InsertDate = DateTime.Now; p.BranchID = this.PageUser.BranchID; p.ClientID = (int)ViewState["ClientID"]; p.OwnerID = (int)ViewState["OwnerID"]; p.InsuranceSubTypeID = InsuranceSubtypeID; p.UserID = this.PageUser.ID; p.LifeDealID = DealID; TextBox tbPolicyNumber = PoliciesDetailsView.FindControl("tbPolicyNumber") as TextBox; p.PolicyNumber = tbPolicyNumber.Text; p.ValidateSinglePolicyNumber(p.InsuranceCompanyID, InsuranceSubtypeID, p.PolicyNumber, p.BranchID); }
public async Task <LifePolicy> GetLifePolicyAsync(string accessToken, string policyNumber) { LifePolicy _lifPolicy = new LifePolicy(); try { var client = new HttpClient(); client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("bearer", accessToken); var json = await client.GetStringAsync(Path + "/MobileAuthWS/api/Life/Get_GET_POLICY_DETAILS?polNo=" + policyNumber.Trim()); /* * _lifPolicy.PolicyNumber = "0456544"; * _lifPolicy.InsuredName = "Saman Perera"; * _lifPolicy.Address = new List<string> { "No 01", "Hevelock Road", "Colombo 06" }; * _lifPolicy.ComDate = "2017/02/03"; * _lifPolicy.PolTable = "19"; * _lifPolicy.PolTerm = "20"; * _lifPolicy.PolDesc = "Divi Thilina"; * _lifPolicy.SumInsured = "5000000"; * _lifPolicy.PayTypeDesc = "Monthly"; * _lifPolicy.PolStatus = "Inforce"; * _lifPolicy.Premium = "20000"; * _lifPolicy.MobileNumber = "0774567643"; * */ _lifPolicy = JsonConvert.DeserializeObject <LifePolicy>(json); } catch (Exception e) { } return(_lifPolicy); //----------------------------------------------------------------------------------- }
public static void PrintLifePolicyReportController(DateTime fromDate, DateTime toDate) { PDFCreators creator = new PDFCreators(true, 10, 10, 15, 15); creator.SetDocumentHeaderFooter(); creator.OpenPDF(); creator.GetContentByte(); creator.SetTitleLeftWithFontSize10("ИЗВЕШТАЈ ЗА ЖИВОТНО ОСИГУРУВАЊЕ"); List <LifePolicy> lstLifePolicies = LifePolicy.GetUndiscardedInPeriod(fromDate, toDate); //GetNumberOfBrokerageYears int numberOfYearBrok = 4; foreach (LifePolicy lp in lstLifePolicies) { List <LifePolicyBrokerage> lstLPB = LifePolicyBrokerage.GetByLifePolicy(lp.ID); if (lstLPB.Count > numberOfYearBrok) { numberOfYearBrok = lstLPB.Count; } } int totHeadersCount = 9 + numberOfYearBrok; string[] headers = new string[totHeadersCount]; headers[0] = "Р.б."; headers[1] = "Полиса бр."; headers[2] = "Понуда бр."; headers[3] = "Датум на продажба"; headers[4] = "Годишна премија (живот)"; headers[5] = "Годишна премија (незгода)"; headers[6] = "Годишна премија"; headers[7] = "Вкупна премија"; for (int i = 0; i < numberOfYearBrok; i++) { headers[8 + i] = "Брокеража за " + (i + 1) + " година"; } headers[totHeadersCount - 1] = "Вкупна брокеража"; float[] widthPercentages = new float[totHeadersCount]; widthPercentages[0] = 4; widthPercentages[1] = 8; widthPercentages[2] = 6; widthPercentages[3] = 10; widthPercentages[4] = 7; widthPercentages[5] = 7; widthPercentages[6] = 7; widthPercentages[7] = 7; float perc = (float)36 / (float)numberOfYearBrok; for (int i = 0; i < numberOfYearBrok; i++) { widthPercentages[8 + i] = perc; } widthPercentages[totHeadersCount - 1] = 8; TypeCode[] typeCodes = new TypeCode[totHeadersCount]; typeCodes[0] = TypeCode.Int32; typeCodes[1] = TypeCode.String; typeCodes[2] = TypeCode.String; typeCodes[3] = TypeCode.DateTime; typeCodes[4] = TypeCode.Decimal; typeCodes[5] = TypeCode.Decimal; typeCodes[6] = TypeCode.Decimal; typeCodes[7] = TypeCode.Decimal; for (int i = 0; i < numberOfYearBrok; i++) { typeCodes[8 + i] = TypeCode.Decimal; } typeCodes[totHeadersCount - 1] = TypeCode.Decimal; creator.CreateTableWithFontSize(headers.Length, headers, widthPercentages, 8); object[] values; int counter = 1; decimal totalYearlyPremiumValueForLife = 0; decimal totalYearlyPremiumValueForAccident = 0; decimal totalYearlyPremiumValue = 0; decimal totalTotalPremumValue = 0; decimal totalBrokerage = 0; Dictionary <int, decimal> totalBrokValuesPerYear = new Dictionary <int, decimal>(); foreach (LifePolicy lp in lstLifePolicies) { values = new object[headers.Length]; values[0] = counter; values[1] = lp.PolicyNumber; values[2] = lp.OfferNumber; values[3] = lp.ApplicationDate.ToShortDateString(); values[4] = String.Format("{0:#,0.00}", lp.YearlyPremiumValueForLife); totalYearlyPremiumValueForLife += lp.YearlyPremiumValueForLife; values[5] = String.Format("{0:#,0.00}", lp.YearlyPremiumValueForAccident); totalYearlyPremiumValueForAccident += lp.YearlyPremiumValueForAccident; values[6] = String.Format("{0:#,0.00}", (lp.YearlyPremiumValueForAccident + lp.YearlyPremiumValueForLife)); totalYearlyPremiumValue += (lp.YearlyPremiumValueForAccident + lp.YearlyPremiumValueForLife); values[7] = String.Format("{0:#,0.00}", lp.TotalPremumValue); totalTotalPremumValue += lp.TotalPremumValue; List <LifePolicyBrokerage> lstLPBrok = LifePolicyBrokerage.GetByLifePolicy(lp.ID); decimal totalBrokeragePerPolicy = 0; for (int j = 0; j < lstLPBrok.Count; j++) { values[8 + j] = String.Format("{0:#,0.00}", lstLPBrok[j].Value); totalBrokeragePerPolicy += lstLPBrok[j].Value; if (!totalBrokValuesPerYear.Keys.Contains(j)) { totalBrokValuesPerYear.Add(j, lstLPBrok[j].Value); } else { totalBrokValuesPerYear[j] += lstLPBrok[j].Value; } } values[totHeadersCount - 1] = String.Format("{0:#,0.00}", totalBrokeragePerPolicy); totalBrokerage += totalBrokeragePerPolicy; creator.AddDataRowForFactures(values, headers.Length, typeCodes); counter++; } values = new object[headers.Length]; values[0] = ""; values[1] = ""; values[2] = ""; values[3] = "Вкупно"; values[4] = String.Format("{0:#,0.00}", totalYearlyPremiumValueForLife); values[5] = String.Format("{0:#,0.00}", totalYearlyPremiumValueForAccident); values[6] = String.Format("{0:#,0.00}", totalYearlyPremiumValue); values[7] = String.Format("{0:#,0.00}", totalTotalPremumValue); int k = 0; foreach (KeyValuePair <int, decimal> kvp in totalBrokValuesPerYear) { values[8 + k] = String.Format("{0:#,0.00}", kvp.Value); k++; } values[totHeadersCount - 1] = String.Format("{0:#,0.00}", totalBrokerage); creator.AddDataRowForFactures(values, headers.Length, typeCodes); creator.AddTable(); creator.FinishPDF_FileName("IzvestajZaZivotnoOsiguruvanje"); }
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 = "Не постојат нефактурирани износи"; } } }
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(); } }