Esempio n. 1
0
        public IHttpActionResult PrintPackingListExtend(int id, int template)
        {
            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.ECommercialInvoiceMng bll = new BLL.ECommercialInvoiceMng();
            DTO.ECommercialInvoiceMng.PackingListContainerPrintout dtoPrintout = bll.GetPackingListPrintoutData(id, ControllerContext.GetAuthUserId(), out notification);

            //CREATE PRINTOUT
            string printoutFileName = string.Empty;

            if (dtoPrintout != null && dtoPrintout.PackingListPrintouts != null && dtoPrintout.PackingListDetailPrintouts != null)
            {
                string reportName = "";
                //int? companyID = fwBll.GetCompanyID(ControllerContext.GetAuthUserId());
                switch (template)
                {
                case 1:
                    reportName = "PackingListPrint_OrangePine.rdlc";
                    break;

                default:
                    reportName = "PackingListPrint.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  = "PackingList";
                rsInvoice.Value = dtoPrintout.PackingListPrintouts;
                lr.DataSources.Add(rsInvoice);

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

                printoutFileName = PrintoutHelper.BuildPrintoutFile(lr, "PDF");
            }
            return(Ok(new Library.DTO.ReturnData <string>()
            {
                Data = printoutFileName, Message = notification
            }));
        }
        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
            }));
        }
Esempio n. 3
0
        public IHttpActionResult PrintNewPickingList(int id)
        {
            Library.DTO.Notification notification;

            // authentication
            Module.Framework.BLL fwBll = new Module.Framework.BLL();
            if (!fwBll.CanPerformAction(ControllerContext.GetAuthUserId(), getModuleCode(), Library.DTO.ModuleAction.CanPrint))
            {
                return(InternalServerError(new Exception(Properties.Resources.NOT_AUTHORIZED)));
            }

            //GET DATA
            BLL.WarehousePickingListMng bll = new BLL.WarehousePickingListMng();
            DTO.WarehousePickingListMng.PickingListContainerPrintout dtoPrintout = bll.GetNewPickingListPrintData(id, ControllerContext.GetAuthUserId(), out notification);

            //CREATE PRINTOUT
            Microsoft.Reporting.WebForms.LocalReport lr = new Microsoft.Reporting.WebForms.LocalReport();
            lr.ReportPath = FrameworkSetting.Setting.AbsoluteReportFolder + "PickingListPrint.rdlc";

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

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

            string printoutFileName = PrintoutHelper.BuildPrintoutFile(lr, "PDF");


            return(Ok(new Library.DTO.ReturnData <string>()
            {
                Data = printoutFileName, Message = notification
            }));
        }
Esempio n. 4
0
        public IHttpActionResult PrintPackingList(int id, string formatType, string reportName)
        {
            Library.DTO.Notification notification = new Library.DTO.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)));
            }
            BLL.ECommercialInvoiceMng bll = new BLL.ECommercialInvoiceMng();
            string printoutFileName       = string.Empty;

            if (reportName == "PackingListPrint")
            {
                if (formatType == "PDF")
                {
                    DTO.ECommercialInvoiceMng.PackingListContainerPrintout dtoPrintout = bll.GetPackingListPrintoutData(id, ControllerContext.GetAuthUserId(), out notification);

                    reportName = reportName + ".rdlc";
                    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  = "PackingList";
                    rsInvoice.Value = dtoPrintout.PackingListPrintouts;
                    lr.DataSources.Add(rsInvoice);

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

                    printoutFileName = PrintoutHelper.BuildPrintoutFile(lr, "PDF");
                }
                else
                {
                    printoutFileName = bll.GetPEUackingListPrintoutData(id, reportName, out notification);
                }
            }
            else
            {
                if (reportName == "PackingListPrint_PerCont")
                {
                    if (formatType == "PDF")
                    {
                        List <DTO.ECommercialInvoiceMng.PackingListContainerPrintout> listDtoPrintout = bll.GetPackingListPrintoutData_PerCont(id, ControllerContext.GetAuthUserId(), out notification);
                        foreach (var dtoPrintout in listDtoPrintout)
                        {
                            //DTO.ECommercialInvoiceMng.PackingListContainerPrintout dtoPrintout = bll.GetPackingListPrintoutData(id, ControllerContext.GetAuthUserId(), out notification);

                            reportName = reportName + ".rdlc";
                            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  = "PackingList";
                            rsInvoice.Value = dtoPrintout.PackingListPrintouts;
                            lr.DataSources.Add(rsInvoice);

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

                            if (printoutFileName != string.Empty)
                            {
                                printoutFileName = printoutFileName + "," + PrintoutHelper.BuildPrintoutFile(lr, "PDF");
                            }
                            else
                            {
                                printoutFileName = PrintoutHelper.BuildPrintoutFile(lr, "PDF");
                            }
                            reportName = "PackingListPrint_PerCont";
                        }
                    }
                    else
                    {
                        printoutFileName = bll.GetEUPackingListPrintoutData_PerCont(id, reportName, out notification);
                    }
                }
                else
                {
                    printoutFileName = bll.GetOrangePiePrintout(id, out notification);
                }
            }

            return(Ok(new Library.DTO.ReturnData <string>()
            {
                Data = printoutFileName, Message = notification
            }));
        }
Esempio n. 5
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
            }));
        }
        public IHttpActionResult PrintPI(int id, string reportName)
        {
            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.SaleOrderMng bll = new BLL.SaleOrderMng();
            DTO.SaleOrderMng.PIContainerPrintout dtoPrintout = bll.GetPrintoutData(id, ControllerContext.GetAuthUserId(), out notification);

            //CREATE PRINTOUT
            if (reportName == null)
            {
                reportName = dtoPrintout.ReportName;
            }

            //int? companyID = fwBll.GetCompanyID(ControllerContext.GetAuthUserId());
            //switch (companyID)
            //{
            //    case 13:
            //        reportName = reportName + "_OrangePine.rdlc";
            //        break;
            //    default:
            //        reportName = reportName + ".rdlc";
            //        break;
            //}
            reportName = reportName + ".rdlc";
            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  = "Order";
            rsInvoice.Value = dtoPrintout.PIPrintouts;
            lr.DataSources.Add(rsInvoice);

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

            string printoutFileName = PrintoutHelper.BuildPrintoutFile(lr, "PDF");

            //
            // author: TheMy
            // description: add disclaimer (using iTextSharp)
            //
            string   finalFile = System.Guid.NewGuid().ToString().Replace("-", "") + ".pdf";
            FileInfo fInfo     = new FileInfo(FrameworkSetting.Setting.AbsoluteReportFolder + reportName);

            if (File.Exists(FrameworkSetting.Setting.AbsoluteReportFolder + fInfo.Name.Replace(fInfo.Extension, "") + "_bottom.pdf"))
            {
                try
                {
                    Document document = new Document();
                    PdfCopy  writer   = new PdfCopy(document, new FileStream(FrameworkSetting.Setting.AbsoluteReportTmpFolder + finalFile, FileMode.Create));
                    if (writer == null)
                    {
                        throw new Exception("Can not create Pdf object");
                    }
                    document.Open();
                    writer.AddDocument(new PdfReader(FrameworkSetting.Setting.AbsoluteReportTmpFolder + printoutFileName));
                    writer.AddDocument(new PdfReader(FrameworkSetting.Setting.AbsoluteReportFolder + fInfo.Name.Replace(fInfo.Extension, "") + "_bottom.pdf"));
                    writer.Close();
                    document.Close();
                }
                catch (Exception ex)
                {
                    notification.Type    = Library.DTO.NotificationType.Error;
                    notification.Message = "Adding general condition failed: " + ex.Message;
                    finalFile            = printoutFileName;
                }
            }
            else
            {
                finalFile = printoutFileName;
            }
            //
            //
            //

            return(Ok(new Library.DTO.ReturnData <string>()
            {
                Data = finalFile, Message = notification
            }));
        }