public ActionResult GetPaymentTemplatePdf(Guid id) { var payRepo = new OBKPaymentRepository(); string name = "Счет на оплату.pdf"; StiReport report = new StiReport(); try { report.Load(Server.MapPath("~/Reports/Mrts/OBK/1c/ObkInvoicePayment.mrt")); foreach (var data in report.Dictionary.Databases.Items.OfType <StiSqlDatabase>()) { data.ConnectionString = UserHelper.GetCnString(); } report.Dictionary.Variables["ContractId"].ValueObject = id; //итого var totalPriceWithCount = payRepo.GetTotalPriceCount(id); report.Dictionary.Variables["TotalPriceWithCount"].ValueObject = totalPriceWithCount; //в том числе НДС var totalPriceNDS = payRepo.GetTotalPriceNDS(totalPriceWithCount); report.Dictionary.Variables["TotalPriceNDS"].ValueObject = totalPriceNDS; //прописью var priceText = RuDateAndMoneyConverter.CurrencyToTxtTenge(Convert.ToDouble(totalPriceWithCount), false); report.Dictionary.Variables["TotalPriceWithCountName"].ValueObject = priceText; //report.Dictionary.Variables["ChiefAccountant"].ValueObject = payRepo.GetEmpoloyee(Guid.Parse("E1EE3658-0C35-41EB-99FD-FDDC4D07CEC4")); //report.Dictionary.Variables["Executor"].ValueObject = payRepo.GetEmpoloyee(Guid.Parse("55377FAC-A5F0-4093-BBB6-18BD28E53BE1")); report.Render(false); } catch (Exception ex) { LogHelper.Log.Error("ex: " + ex.Message + " \r\nstack: " + ex.StackTrace); } var stream = new MemoryStream(); var contractId = payRepo.GetContractIdGuid(id); var directionToPayment = payRepo.GetDirectionToPayments(contractId); var signPayment = payRepo.GetDirectionSignData(directionToPayment.Id); if (signPayment.ChiefAccountantSign != null && signPayment.ExecutorSign != null) { try { report.ExportDocument(StiExportFormat.Word2007, stream); stream.Position = 0; Aspose.Words.Document doc = new Aspose.Words.Document(stream); doc.InserQrCodesToEnd("ChiefAccountantSign", signPayment.ChiefAccountantSign); var pdfFile = new MemoryStream(); doc.Save(pdfFile, SaveFormat.Pdf); pdfFile.Position = 0; stream.Close(); return(new FileStreamResult(pdfFile, "application/pdf")); } catch (Exception e) { Console.WriteLine(e); } } report.ExportDocument(StiExportFormat.Pdf, stream); stream.Position = 0; return(new FileStreamResult(stream, "application/pdf")); }
public ActionResult ActExportFilePdf(Guid id) { string name = "Акт выполненных работ.pdf"; StiReport report = new StiReport(); try { report.Load(Server.MapPath("~/Reports/Mrts/OBK/1c/ObkCertificateOfCompletion.mrt")); foreach (var data in report.Dictionary.Databases.Items.OfType <StiSqlDatabase>()) { data.ConnectionString = UserHelper.GetCnString(); } report.Dictionary.Variables["AssessmentDeclarationId"].ValueObject = id; report.Dictionary.Variables["ContractId"].ValueObject = expRepo.GetAssessmentDeclaration(id).ContractId; report.Dictionary.Variables["ValueAddedTax"].ValueObject = expRepo.GetValueAddedTax(); var totalCount = expRepo.GetContractPrice(expRepo.GetAssessmentDeclaration(id).ContractId); report.Dictionary.Variables["TotalCount"].ValueObject = totalCount; var priceText = RuDateAndMoneyConverter.CurrencyToTxtTenge(Convert.ToDouble(totalCount), false); report.Dictionary.Variables["TotalCountText"].ValueObject = priceText; report.Render(false); } catch (Exception ex) { LogHelper.Log.Error("ex: " + ex.Message + " \r\nstack: " + ex.StackTrace); } var stream = new MemoryStream(); report.ExportDocument(StiExportFormat.Pdf, stream); stream.Position = 0; return(File(stream, "application/pdf", name)); }
public string GetSignData(Guid id) { var payment = AppContext.OBK_DirectionToPayments.FirstOrDefault(e => e.Id == id); var contract = AppContext.OBK_Contract.FirstOrDefault(e => e.Id == payment.ContractId); var unitsBank = AppContext.UnitsBanks.FirstOrDefault(e => e.UnitsId == contract.ExpertOrganization); if (payment?.OBK_DirectionSignData.ExecutorSign != null) { var xmlData = SerializeHelper.SerializeDataContract(payment.OBK_DirectionSignData.ExecutorSign); return(xmlData.Replace("utf-16", "utf-8")); } else { List <ContractPriceSignData> contractPriceSign = AppContext.OBK_ContractPrice .Where(e => e.ContractId == contract.Id) .Select(e => new ContractPriceSignData() { ContractPriceName = e.OBK_RS_Products.NameRu, ContractPriceDicName = e.OBK_Ref_PriceList.NameRu, ContractPrice = e.OBK_Ref_PriceList.Price * 1.12, ContractPriceCount = e.Count, ContractPriceTotal = e.OBK_Ref_PriceList.Price * 1.12 * e.Count, }) .ToList(); var result = new OBKPaymentSignData { Id = id, ContractId = payment?.ContractId, ContactNumber = contract?.Number, ContactStartDate = contract?.StartDate, ContactTypeName = contract?.OBK_Ref_Type.NameRu, UnitsName = contract?.Unit.Name, UnitsAddress = contract?.Unit.LegalAddress, UnitsPhone = contract?.Unit.Phone, UnitsBin = contract?.Unit.Bin, UnitsIIk = unitsBank?.IIK, UnitsKbe = unitsBank?.KBE, UnitsBankName = unitsBank?.BankNameRu, UnitsBankSwift = unitsBank?.SWIFT, UnitsBankCode = unitsBank?.Code, InvoiceNuber1C = payment?.InvoiceNumber1C, InvoiceDate1C = payment?.InvoiceDatetime1C, DeclarantBin = contract?.OBK_Declarant.Bin, DeclarantOrgName = GetDictionary(contract?.OBK_Declarant.OrganizationFormId).Name, DeclarantName = contract?.OBK_Declarant.NameRu, DeclarantCountryName = GetDictionary(contract?.OBK_DeclarantContact.CurrencyId).Name, DeclarantAddressLegal = contract?.OBK_DeclarantContact.AddressLegalRu, ContractPriceNds = GetTotalPriceCount(payment.ContractId), ContractPriceTotalText = RuDateAndMoneyConverter.CurrencyToTxtTenge( Convert.ToDouble(GetTotalPriceCount(payment.ContractId)), false), ChiefAccountant = null, //GetEmpoloyee(Guid.Parse("E1EE3658-0C35-41EB-99FD-FDDC4D07CEC4"))?.ShortName, Executor = null, //GetEmpoloyee(Guid.Parse("55377FAC-A5F0-4093-BBB6-18BD28E53BE1"))?.ShortName, ContractPriceSignDatas = contractPriceSign }; var xmlData = SerializeHelper.SerializeDataContract(result); return(xmlData.Replace("utf-16", "utf-8")); } }
/// <summary> /// Акт выполненных работ /// </summary> /// <returns></returns> public ActionResult CertOfComplectFilePdf(Guid id) { OBKExpDocumentRepository expRepo = new OBKExpDocumentRepository(); string name = "Акт выполненных работ.pdf"; StiReport report = new StiReport(); try { report.Load(Server.MapPath("~/Reports/Mrts/OBK/1c/ObkCertificateOfCompletion.mrt")); foreach (var data in report.Dictionary.Databases.Items.OfType <StiSqlDatabase>()) { data.ConnectionString = UserHelper.GetCnString(); } report.Dictionary.Variables["AssessmentDeclarationId"].ValueObject = id; var declaration = expRepo.GetAssessmentDeclaration(id); report.Dictionary.Variables["ContractId"].ValueObject = declaration.ContractId; report.Dictionary.Variables["ValueAddedTax"].ValueObject = expRepo.GetValueAddedTax(); var refType = db.OBK_Ref_Type.FirstOrDefault(o => o.Id == declaration.TypeId); var expDocument = db.OBK_StageExpDocument.FirstOrDefault(o => o.AssessmentDeclarationId == id); decimal totalCount = 0; if (CodeConstManager.OBK_SA_PARTY.Equals(refType.Code) && expDocument.ExpResult == false) { totalCount = expRepo.GetContractPriceMotivationRefuse(expRepo.GetAssessmentDeclaration(id).ContractId); } else { totalCount = expRepo.GetContractPrice(expRepo.GetAssessmentDeclaration(id).ContractId); } report.Dictionary.Variables["TotalCount"].ValueObject = totalCount; var priceText = RuDateAndMoneyConverter.CurrencyToTxtTenge(Convert.ToDouble(totalCount), false); report.Dictionary.Variables["TotalCountText"].ValueObject = priceText; report.Render(false); } catch (Exception ex) { LogHelper.Log.Error("ex: " + ex.Message + " \r\nstack: " + ex.StackTrace); } var stream = new MemoryStream(); report.ExportDocument(StiExportFormat.Pdf, stream); stream.Position = 0; return(new FileStreamResult(stream, "application/pdf")); //return File(stream, "application/pdf", name); }
public ActionResult CertOfComplectFilePdf(Guid zbkCopyId) { OBKExpDocumentRepository expRepo = new OBKExpDocumentRepository(); string name = "Акт выполненных работ.pdf"; var copy = db.OBK_ZBKCopy.FirstOrDefault(o => o.Id == zbkCopyId); var expDocument = db.OBK_StageExpDocument.FirstOrDefault(o => o.Id == copy.OBK_StageExpDocumentId); StiReport report = new StiReport(); try { if (copy.ExpApplication == false) { report.Load(Server.MapPath("~/Reports/Mrts/OBK/1c/ObkCertificateOfCompletionCopyZbkApplication.mrt")); } else { report.Load(Server.MapPath("~/Reports/Mrts/OBK/1c/ObkCertificateOfCompletionCopyZbk.mrt")); } foreach (var data in report.Dictionary.Databases.Items.OfType <StiSqlDatabase>()) { data.ConnectionString = UserHelper.GetCnString(); } report.Dictionary.Variables["AssessmentDeclarationId"].ValueObject = expDocument.AssessmentDeclarationId; report.Dictionary.Variables["ContractId"].ValueObject = expRepo.GetAssessmentDeclaration((Guid)expDocument.AssessmentDeclarationId).ContractId; var totalCount = payRepo.GetTotalPriceZbkCopy(zbkCopyId); report.Dictionary.Variables["TotalCount"].ValueObject = totalCount; var priceText = RuDateAndMoneyConverter.CurrencyToTxtTenge(Convert.ToDouble(totalCount), false); report.Dictionary.Variables["TotalCountText"].ValueObject = priceText; report.Dictionary.Variables["ZBKCopyId"].ValueObject = copy.Id; report.Dictionary.Variables["PriceNds"].ValueObject = repository.GetZbkCopyNds(zbkCopyId); report.Render(false); } catch (Exception ex) { LogHelper.Log.Error("ex: " + ex.Message + " \r\nstack: " + ex.StackTrace); } var stream = new MemoryStream(); report.ExportDocument(StiExportFormat.Pdf, stream); stream.Position = 0; return(new FileStreamResult(stream, "application/pdf")); }