Exemplo n.º 1
0
        public ActionResult Prints(DataTable Dt)
        {
            try
            {
                // DataTable Dt = new DataTable();

                List <byte[]>     PdfStream = new List <byte[]>();
                DirectReportPrint drp       = new DirectReportPrint();
                byte[]            Pdf;
                Pdf = drp.DirectPrint(Dt, User.Identity.Name);
                PdfStream.Add(Pdf);


                PdfMerger pm = new PdfMerger();

                byte[] Merge = pm.MergeFiles(PdfStream);

                if (Merge != null)
                {
                    return(File(Merge, "application/pdf"));
                }
            }

            catch (Exception ex)
            {
                string message = _exception.HandleException(ex);
                return(Json(new { success = "Error", data = message }, JsonRequestBehavior.AllowGet));
            }


            return(Json(new { success = "Success" }, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 2
0
        public ActionResult GeneratePrints(string ActionName, int Id = 0)
        {
            string PrintProcedure = "";


            if (!string.IsNullOrEmpty(ActionName))
            {
                var Settings = new StockInHandSettingService(_unitOfWork).GetTrailBalanceSetting(User.Identity.Name);



                string SqlParameterGroupOn;
                string SqlParameterShowBalance;
                string SqlParameterProdType;



                string SqlParameterSiteId   = Settings.SiteIds;
                string DivisionId           = Settings.DivisionIds;
                string SqlParameterFromDate = Settings.FromDate.HasValue ? Settings.FromDate.Value.ToString("dd/MMM/yyyy") : "";
                string SqlParameterToDate   = Settings.ToDate.HasValue ? Settings.ToDate.Value.ToString("dd/MMM/yyyy") : "";


                SqlParameterProdType = Id.ToString();

                if (string.IsNullOrEmpty(Settings.GroupOn))
                {
                    SqlParameterGroupOn = "NULL";
                }
                else
                {
                    SqlParameterGroupOn = Settings.GroupOn.ToString();
                }

                if (string.IsNullOrEmpty(Settings.ShowBalance) || Settings.ShowBalance == StockInHandShowBalanceConstants.All)
                {
                    SqlParameterShowBalance = "NULL";
                }
                else
                {
                    SqlParameterShowBalance = Settings.ShowBalance.ToString();
                }


                if (ActionName == "StockInHand")
                {
                    PrintProcedure = "Web.spStockInHand  @ProductType ='" + SqlParameterProdType.ToString() + "', @Site='" + SqlParameterSiteId.ToString() + "', @FromDate='" + SqlParameterFromDate.ToString() + "', @ToDate='" + SqlParameterToDate.ToString() + "', @GroupOn='" + SqlParameterGroupOn.ToString() + "'";
                }



                try
                {
                    DataTable Dt = new DataTable();

                    List <byte[]>     PdfStream = new List <byte[]>();
                    DirectReportPrint drp       = new DirectReportPrint();
                    byte[]            Pdf;
                    Pdf = drp.DirectPrint(Dt, User.Identity.Name);
                    PdfStream.Add(Pdf);


                    PdfMerger pm = new PdfMerger();

                    byte[] Merge = pm.MergeFiles(PdfStream);

                    if (Merge != null)
                    {
                        return(File(Merge, "application/pdf"));
                    }
                }

                catch (Exception ex)
                {
                    string message = _exception.HandleException(ex);
                    return(Json(new { success = "Error", data = message }, JsonRequestBehavior.AllowGet));
                }


                return(Json(new { success = "Success" }, JsonRequestBehavior.AllowGet));
            }
            return(Json(new { success = "Error", data = "No Records Selected." }, JsonRequestBehavior.AllowGet));
        }