コード例 #1
0
        public byte[] CreateReport(NirReportViewModel model)
        {
            _model = model;

            #region page
            _document = new Document(PageSize.A4, 0f, 0f, 0f, 0f);
            _document.SetPageSize(PageSize.A4);
            _document.SetMargins(20f, 20f, 20f, 20f);
            _pdfPTable.WidthPercentage     = 100;
            _pdfPTable.HorizontalAlignment = Element.ALIGN_LEFT;
            _fontStyle = FontFactory.GetFont("Tahoma", 8f, 1);
            writer     = PdfWriter.GetInstance(_document, _memoryStream);
            _document.Open();
            _pdfPTable.SetWidths(new float[] { 40f, 150f, 80f, 80f, 80f });

            paymentTable.WidthPercentage     = 100;
            paymentTable.HorizontalAlignment = Element.ALIGN_LEFT;
            paymentTable.SetWidths(new float[] { 100f, 100f });

            this.reportHeader();
            this.reportBody();

            _pdfPTable.HeaderRows = 2;
            _document.Add(paymentTable);
            _document.Add(_pdfPTable);
            _document.Close();
            return(_memoryStream.ToArray());

            #endregion
        }
コード例 #2
0
        public ActionResult NirDoc(int nirId, int style)
        {
            if (storeSettingRepository.All().Count() == 0)
            {
                TempData["Msg"] = "Seteaza inainte detalii firmei tale";
                return(RedirectToAction("Index"));
            }
            var store = storeSettingRepository.All().FirstOrDefault();

            var nir = nirRepository.All().Include(x => x.SupplierModel).SingleOrDefault(x => x.Id == nirId);

            nir.Items = nirItemRepository.All().Where(x => x.NirId == nirId).ToList();
            if (nir != null)
            {
                var nirs = new NirReportViewModel
                {
                    company = store,
                    Nirs    = nir
                };
                if (style == 1)
                {
                    NirReport paymentReport = new NirReport(configuration);
                    byte[]    bytes         = paymentReport.CreateReport(nirs);
                    return(File(bytes, "application/pdf"));
                }
            }
            return(RedirectToAction("index"));
        }