public static void PrintAnex(Policy p) { List <Rate> ratesForPrint = Rate.GetByPolicyItemID(p.PolicyItems[0].ID); Broker.DataAccess.Facture f = PolicyItemFactureItem.GetByPolicyItemID(p.PolicyItems[0].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(" "); 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("Договорувач " + p.Client.Name + " " + "Експозитура " + p.Branch.Name); creator.SetTitleLeft8(" "); creator.SetTitle("ДОГОВОР " + p.PolicyItems[0].PolicyNumber); 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); 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; if (f != null) { valuesRates[3] = f.FactureNumber; } else { valuesRates[3] = ""; } 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}", p.PolicyItems[0].PremiumValue) + " ДЕН."; creator.AddDataRowForFactures(values, headersRates.Length, typeCodesRates); creator.AddTable(); creator.SetTitleLeft8("2.Доколку настане осигуран случај - штета, независно од тоа што е договорено плаќање на рати, премијата за осигурување стасува за наплата веднаш до висината на надоместокот што треба да се исплати и ќе се наплати по пат на компензација."); creator.SetTitleLeft8("3.Ако премијата не се плати во договорените рокови од овој Договор, ќе се пресметува камата."); creator.SetTitleLeft8("4.Договорот е составен од три еднообразни примероци, од кои еден за осигуреникот, а два за осигурувачот."); creator.SetTitle(" "); creator.SetTitle(" "); if (f != null) { creator.SetTitleCenter8("Во " + f.User.Branch.Municipality.Name + " на " + f.DateOfCreation.ToShortDateString()); } else { creator.SetTitleCenter8("Во " + p.Branch.Municipality.Name + " на " + p.ApplicationDate.ToShortDateString()); } creator.SetTitle(" "); creator.SetTitle(" "); string brokerName = BrokerHouseInformation.GetBrokerHouseName(); creator.SetTitleLeft8(" " + brokerName + " ДОГОВОРУВАЧ"); creator.SetTitleLeft8(" "); creator.SetTitleLeft8("_________________________ ____________________"); creator.FinishPDF_FileName("Aneks" + p.PolicyItems[0].PolicyNumber); }
public static string DeletePolicy(int piID) { DataClassesDataContext dc = new DataClassesDataContext(); string retString = "Полисата е избришана."; PolicyItem pi = PolicyItem.Get(piID); Distribution d = Distribution.GetByNumberAndSubTypeAndCompany(pi.InsuranceSubTypeID, pi.PolicyNumber, pi.Policy.InsuranceCompanyID); Policy p = Policy.Get(pi.PolicyID); List <RollBackDistributionItem> listRDI = RollBackDistributionItem.Table.Where(c => c.PolicyItemID == pi.ID).ToList(); if (listRDI.Count > 0) { retString = "Полисата е раздолжена и не може да се брише!"; return(retString); } List <Rate> lstRates = Rate.GetByPolicyItemID(pi.ID); if (lstRates.Count > 0) { List <Payment> lstPayments = Payment.GetByRateID(lstRates[0].ID); if (lstPayments.Count > 0) { if (lstPayments[0].IsFactured) { retString = "Полисата е фактурирана за брокеража и не може да се брише!"; return(retString); } } foreach (Rate r in lstRates) { List <Payment> lstP = Payment.GetByRateID(r.ID); foreach (Payment pay in lstP) { List <PaymentsPerInsSubType> lstPPIST = PaymentsPerInsSubType.GetByPayment(pay.ID); foreach (PaymentsPerInsSubType ppist in lstPPIST) { string queryppist = @"DELETE FROM PaymentsPerInsSubTypes WHERE ID = " + ppist.ID; dc.ExecuteCommand(queryppist); //ppist.Delete(); } string queryppay = @"DELETE FROM Payments WHERE ID = " + pay.ID; dc.ExecuteCommand(queryppay); //pay.Delete(); } string queryr = @"DELETE FROM Rates WHERE ID = " + r.ID; dc.ExecuteCommand(queryr); //r.Delete(); } string querypei = @"DELETE FROM PolicyExtendInformations WHERE PolicyItemID = " + pi.ID; dc.ExecuteCommand(querypei); Broker.DataAccess.Facture facture = PolicyItemFactureItem.GetByPolicyItemID(pi.ID); if (facture != null) { List <Broker.DataAccess.FactureItem> listFI = FactureItem.GetByFacture(facture.ID); foreach (FactureItem fi in listFI) { string querypifi = @"DELETE FROM PolicyItemFactureItems WHERE FactureItemID = " + fi.ID; dc.ExecuteCommand(querypifi); string queryfi = @"DELETE FROM FactureItems WHERE ID = " + fi.ID; dc.ExecuteCommand(queryfi); } string queryf = @"DELETE FROM Factures WHERE ID = " + facture.ID; dc.ExecuteCommand(queryf); } string querypi = @"DELETE FROM PolicyItems WHERE ID = " + pi.ID; dc.ExecuteCommand(querypi); //pi.Delete(); string queryp = @"DELETE FROM Policies WHERE ID = " + p.ID; dc.ExecuteCommand(queryp); //p.Delete(); string queryd = @"UPDATE Distributions SET IsUsed = 0 WHERE ID = " + d.ID; dc.ExecuteCommand(queryd); //d.IsUsed = false; //Distribution.Table.Context.SubmitChanges(); } return(retString); }