Exemple #1
0
        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));
        }
Exemple #2
0
        /// <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);
        }