コード例 #1
0
        public IHttpActionResult PrintCreditNote(int id, string fileTypeID)
        {
            Library.DTO.Notification notification;

            // authentication
            Module.Framework.BLL fwBll = new Module.Framework.BLL();
            if (!fwBll.CanPerformAction(ControllerContext.GetAuthUserId(), moduleCode, Library.DTO.ModuleAction.CanPrint))
            {
                return(InternalServerError(new Exception(Properties.Resources.NOT_AUTHORIZED)));
            }
            //GET DATA
            BLL.CreditNoteMng bll = new BLL.CreditNoteMng();
            DTO.ECommercialInvoiceMng.InvoiceContainerPrintout dtoPrintout = bll.GetCreditNotePrintout(id, ControllerContext.GetAuthUserId(), out notification);

            //CREATE PRINTOUT
            string printoutFileName = string.Empty;

            if (dtoPrintout != null && dtoPrintout.Invoices != null && dtoPrintout.InvoiceDetails != null)
            {
                Microsoft.Reporting.WebForms.LocalReport lr = new Microsoft.Reporting.WebForms.LocalReport();
                lr.ReportPath = FrameworkSetting.Setting.AbsoluteReportFolder + "CreditNotePrint.rdlc";

                Microsoft.Reporting.WebForms.ReportDataSource rsInvoice = new Microsoft.Reporting.WebForms.ReportDataSource();
                rsInvoice.Name  = "Invoice";
                rsInvoice.Value = dtoPrintout.Invoices;
                lr.DataSources.Add(rsInvoice);

                Microsoft.Reporting.WebForms.ReportDataSource rsInvoiceDetail = new Microsoft.Reporting.WebForms.ReportDataSource();
                rsInvoiceDetail.Name  = "InvoiceDetail";
                rsInvoiceDetail.Value = dtoPrintout.InvoiceDetails;
                lr.DataSources.Add(rsInvoiceDetail);

                printoutFileName = PrintoutHelper.BuildPrintoutFile(lr, fileTypeID);
            }
            return(Ok(new Library.DTO.ReturnData <string>()
            {
                Data = printoutFileName, Message = notification
            }));
        }
コード例 #2
0
        public DTO.ECommercialInvoiceMng.InvoiceContainerPrintout DB2DTO_Printout(CreditNoteMng_CreditNote_ReportView dbItem)
        {
            DTO.ECommercialInvoiceMng.InvoiceContainerPrintout dtoItem = new DTO.ECommercialInvoiceMng.InvoiceContainerPrintout();
            dtoItem.Invoices       = new List <DTO.ECommercialInvoiceMng.InvoicePrintout>();
            dtoItem.InvoiceDetails = new List <DTO.ECommercialInvoiceMng.InvoiceDetailPrintout>();

            //COPY INVOICE DATA
            DTO.ECommercialInvoiceMng.InvoicePrintout dtoInvoice = AutoMapper.Mapper.Map <CreditNoteMng_CreditNote_ReportView, DTO.ECommercialInvoiceMng.InvoicePrintout>(dbItem);
            dtoItem.Invoices.Add(dtoInvoice);

            //COPY INVOICEDETAIL DATA
            DTO.ECommercialInvoiceMng.InvoiceDetailPrintout dtoInvoiceDetail;

            foreach (CreditNoteMng_CreditNoteDetail_ReportView dbDetail in dbItem.CreditNoteMng_CreditNoteDetail_ReportView)
            {
                //CREATE ITEM ROW
                dtoInvoiceDetail             = new DTO.ECommercialInvoiceMng.InvoiceDetailPrintout();
                dtoInvoiceDetail.Description = dbDetail.Description;
                dtoInvoiceDetail.TotalAmount = dbDetail.Amount;
                dtoItem.InvoiceDetails.Add(dtoInvoiceDetail);
            }
            return(dtoItem);
        }
コード例 #3
0
        public IHttpActionResult PrintInvoice(int id, string formatFile, string reportName, int invoiceType)
        {
            BLL.ECommercialInvoiceMng bll = new BLL.ECommercialInvoiceMng();
            Library.DTO.Notification  notification;
            // authentication
            Module.Framework.BLL fwBll = new Module.Framework.BLL();
            if (!fwBll.CanPerformAction(ControllerContext.GetAuthUserId(), moduleCode, Library.DTO.ModuleAction.CanPrint))
            {
                return(InternalServerError(new Exception(Properties.Resources.NOT_AUTHORIZED)));
            }
            //CREATE PRINTOUT
            string printoutFileName = string.Empty;
            int?   companyID        = fwBll.GetCompanyID(ControllerContext.GetAuthUserId());

            /*
             * get report file base on format of report
             * Excel format is special, we will use one function to get report base on excel
             * Another format we will use microsoft report tool to create report
             */
            if (formatFile == "Excel")
            {
                //switch (companyID)
                //{
                //    case 13:
                //        printoutFileName = bll.GetOrangePiePrintout(id, out notification);
                //        break;
                //    default:

                //        break;
                //}

                printoutFileName = bll.GetInvoicePrintoutInExcel(id, reportName, invoiceType, out notification);
            }
            else
            {
                DTO.ECommercialInvoiceMng.InvoiceContainerPrintout dtoPrintout = bll.GetInvoicePrintoutData(id, ControllerContext.GetAuthUserId(), out notification);
                if (dtoPrintout != null && dtoPrintout.Invoices != null && dtoPrintout.InvoiceDetails != null)
                {
                    reportName = reportName + ".rdlc";
                    //switch (companyID)
                    //{
                    //    case 13:
                    //        reportName = reportName + "_OrangePine.rdlc";
                    //        break;
                    //    default:
                    //        reportName = reportName + ".rdlc";
                    //        break;
                    //}
                    Microsoft.Reporting.WebForms.LocalReport lr = new Microsoft.Reporting.WebForms.LocalReport();
                    lr.ReportPath = FrameworkSetting.Setting.AbsoluteReportFolder + reportName;

                    Microsoft.Reporting.WebForms.ReportDataSource rsInvoice = new Microsoft.Reporting.WebForms.ReportDataSource();
                    rsInvoice.Name  = "Invoice";
                    rsInvoice.Value = dtoPrintout.Invoices;
                    lr.DataSources.Add(rsInvoice);

                    Microsoft.Reporting.WebForms.ReportDataSource rsInvoiceDetail = new Microsoft.Reporting.WebForms.ReportDataSource();
                    rsInvoiceDetail.Name  = "InvoiceDetail";
                    rsInvoiceDetail.Value = dtoPrintout.InvoiceDetails;
                    lr.DataSources.Add(rsInvoiceDetail);
                    printoutFileName = PrintoutHelper.BuildPrintoutFile(lr, formatFile);
                }
            }
            return(Ok(new Library.DTO.ReturnData <string>()
            {
                Data = printoutFileName, Message = notification
            }));
        }