protected void btnPrBrokSlip_Click(object sender, EventArgs e) { if (ViewState["BrokerageSlipID"] != null) { BrokerageSlip bs = BrokerageSlip.Get(Convert.ToInt32(ViewState["BrokerageSlipID"])); PrintBrokerageSlips.PrintBrokerageSlip(bs); } }
protected void btnPrintBrokerageSlip_Click(object sender, EventArgs e) { int id = GXGridView1SelectedValue; if (id > 0) { BrokerageSlip bs = BrokerageSlip.Get(id); PrintBrokerageSlips.PrintBrokerageSlip(bs); } }
public static void PrintBrokerageSlip(BrokerageSlip bs) { PDFCreators creator = new PDFCreators(true, 15, 15, 15, 15); creator.OpenPDF(); creator.GetContentByte(); creator.AddJDBLogoForFactures(10, 775); creator.SetTitleLeft8(" "); creator.SetTitleLeft8(" "); creator.SetTitleLeft8(" "); creator.SetTitleLeft8(" "); creator.SetTitle("БРОКЕРСКИ СЛИП ЗА ОСИГУРУВАЊЕ"); creator.SetTitle(bs.Number); string[] headers = { "", "" }; float[] widthPercentages = { 30, 70 }; TypeCode[] typeCodes = { TypeCode.String, TypeCode.String }; creator.CreateTable_Facture(headers.Length, headers, widthPercentages); object[] values; values = new object[headers.Length]; values[0] = "ОСИГУРЕНИК"; values[1] = bs.Insurer; creator.AddDataRowForBrokerageSlips(values, headers.Length, typeCodes); values = new object[headers.Length]; values[0] = ""; values[1] = ""; creator.AddDataRowForBrokerageSlips(values, headers.Length, typeCodes); values = new object[headers.Length]; values[0] = "ОСИГУРУВАЧ"; values[1] = bs.InsuranceCompany.Name; creator.AddDataRowForBrokerageSlips(values, headers.Length, typeCodes); values = new object[headers.Length]; values[0] = ""; values[1] = ""; creator.AddDataRowForBrokerageSlips(values, headers.Length, typeCodes); values = new object[headers.Length]; values[0] = "ПЕРИОД НА ИЗДАДЕНИ ПОЛИСИ"; values[1] = bs.FromDate.ToShortDateString() + " до " + bs.ToDate.ToShortDateString(); creator.AddDataRowForBrokerageSlips(values, headers.Length, typeCodes); values = new object[headers.Length]; values[0] = ""; values[1] = ""; creator.AddDataRowForBrokerageSlips(values, headers.Length, typeCodes); values = new object[headers.Length]; values[0] = "КЛАСИ НА ОСИГУРУВАЊЕ"; int ordinalNumber = 1; string nested = ""; foreach (BrokerageSlipInsuranceSubType bsist in bs.BrokerageSlipInsuranceSubTypes) { nested += (ordinalNumber + ". " + bsist.InsuranceSubType.ShortDescription + "\n"); ordinalNumber++; } values[1] = nested; creator.AddDataRowForBrokerageSlips(values, headers.Length, typeCodes); values = new object[headers.Length]; values[0] = ""; values[1] = ""; creator.AddDataRowForBrokerageSlips(values, headers.Length, typeCodes); values = new object[headers.Length]; values[0] = "ОСИГУРЕНИ ОПАСНОСТИ"; values[1] = bs.InsuranceRisks; creator.AddDataRowForBrokerageSlips(values, headers.Length, typeCodes); values = new object[headers.Length]; values[0] = ""; values[1] = ""; creator.AddDataRowForBrokerageSlips(values, headers.Length, typeCodes); values = new object[headers.Length]; values[0] = "ОСИГУРЕНИ СТВАРИ"; values[1] = bs.InsuranceThings; creator.AddDataRowForBrokerageSlips(values, headers.Length, typeCodes); values = new object[headers.Length]; values[0] = ""; values[1] = ""; creator.AddDataRowForBrokerageSlips(values, headers.Length, typeCodes); int ordNumberPerInsSubType = 1; foreach (BrokerageSlipInsuranceSubType bsist in bs.BrokerageSlipInsuranceSubTypes) { object[] valINST = new object[2]; valINST[0] = "ПОДКЛАСА НА ОСИГУРУВАЊЕ"; valINST[1] = ordNumberPerInsSubType + ". " + bsist.InsuranceSubType.ShortDescription; creator.AddDataRowForBrokerageSlips(valINST, headers.Length, typeCodes); decimal totPrem = 0; List <BrokerageSlipPolicyItem> tmpList = BrokerageSlipPolicyItem.GetByBrokerageSlip(bs.ID); List <BrokerageSlipPolicyItem> tmpListPer = tmpList.Where(c => c.PolicyItem.InsuranceSubTypeID == bsist.InsuranceSubTypeID).ToList(); List <PolicyItem> lstPolItems = tmpListPer.Select(c => c.PolicyItem).ToList(); lstPolItems = lstPolItems.OrderBy(c => c.PolicyNumber).ToList(); foreach (PolicyItem pi in lstPolItems) { object[] valPol = new object[2]; string polPremValue = String.Format("{0:#,0.00}", pi.PremiumValue); valPol[0] = ""; valPol[1] = pi.PolicyNumber + " - " + pi.Policy.Client.Name + " - " + polPremValue; creator.AddDataRowForBrokerageSlips(valPol, headers.Length, typeCodes); if (!pi.Policy.Discard) { totPrem += pi.PremiumValue; } } object[] valTotPerIST = new object[2]; valTotPerIST[0] = ""; valTotPerIST[1] = "ВКУПНО ПРЕМИЈА: " + String.Format("{0:#,0.00}", totPrem) + " ДЕНАРИ"; creator.AddDataRowForBrokerageSlips(valTotPerIST, headers.Length, typeCodes); ordNumberPerInsSubType++; } //values = new object[headers.Length]; //values[0] = "ПРЕМИЈА"; //values[1] = ""; creator.AddDataRowForBrokerageSlips(values, headers.Length, typeCodes); values = new object[headers.Length]; values[0] = ""; values[1] = ""; creator.AddDataRowForBrokerageSlips(values, headers.Length, typeCodes); values = new object[headers.Length]; values[0] = "ОСНОВ ЗА ОБЕШТЕТУВАЊЕ"; values[1] = bs.BasisForCompensation; creator.AddDataRowForBrokerageSlips(values, headers.Length, typeCodes); values = new object[headers.Length]; values[0] = ""; values[1] = ""; creator.AddDataRowForBrokerageSlips(values, headers.Length, typeCodes); values = new object[headers.Length]; values[0] = "БРОКЕРАЖА"; int ordNumber = 1; string nestedB = ""; foreach (BrokerageSlipInsuranceSubType bsist in bs.BrokerageSlipInsuranceSubTypes) { nestedB += (ordNumber + ". " + bsist.InsuranceSubType.ShortDescription + " " + bsist.BrokeragePercentagePrivates + "% ЗА ФИЗИЧКИ ЛИЦА, " + bsist.BrokeragePercentageLaws + "% ЗА ПРАВНИ ЛИЦА ОД БРУТО ПРЕМИЈА" + "\n"); ordNumber++; } values[1] = nestedB; creator.AddDataRowForBrokerageSlips(values, headers.Length, typeCodes); values = new object[headers.Length]; values[0] = ""; values[1] = ""; creator.AddDataRowForBrokerageSlips(values, headers.Length, typeCodes); values = new object[headers.Length]; values[0] = "ДРУГИ УСЛОВИ"; values[1] = bs.OtherConditions; creator.AddDataRowForBrokerageSlips(values, headers.Length, typeCodes); values = new object[headers.Length]; values[0] = ""; values[1] = ""; creator.AddDataRowForBrokerageSlips(values, headers.Length, typeCodes); values = new object[headers.Length]; values[0] = "БРОКЕР"; values[1] = BrokerHouseInformation.GetBrokerHouseNameByCode(BrokerHouseInformation.FIRST_ROW); creator.AddDataRowForBrokerageSlips(values, headers.Length, typeCodes); values = new object[headers.Length]; values[0] = ""; values[1] = ""; creator.AddDataRowForBrokerageSlips(values, headers.Length, typeCodes); values = new object[headers.Length]; values[0] = ""; values[1] = Broker.DataAccess.Parameter.GetByCode(Broker.DataAccess.Parameter.MESTO).Value; creator.AddDataRowForBrokerageSlips(values, headers.Length, typeCodes); values = new object[headers.Length]; values[0] = ""; values[1] = bs.Date.ToShortDateString(); creator.AddDataRowForBrokerageSlips(values, headers.Length, typeCodes); values = new object[headers.Length]; values[0] = ""; values[1] = ""; creator.AddDataRowForBrokerageSlips(values, headers.Length, typeCodes); creator.AddTable(); creator.SetTitle(" "); creator.SetTitle(" "); string brokerName = BrokerHouseInformation.GetBrokerHouseName(); creator.SetTitleLeft8(" " + brokerName + " " + bs.InsuranceCompany.Name); creator.SetTitleLeft8(" "); creator.SetTitleLeft8("_________________________ ____________________"); creator.FinishPDF_FileName("BrokerskiSlip" + bs.ID); }
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; } }