예제 #1
0
        public int UploadFileToFolder(int Id)
        {
            string pdfname = "";

            try
            {
                ReportDocument Report = new ReportDocument();
                Report.Load(Server.MapPath("~/Reports/LPO-Invoice/LPOInvoice.rpt"));

                List <IT.Web.Models.CompnayModel>           compnayModels     = new List <IT.Web.Models.CompnayModel>();
                List <IT.Web.Models.LPOInvoiceModel>        lPOInvoiceModels  = new List <IT.Web.Models.LPOInvoiceModel>();
                List <IT.Web.Models.LPOInvoiceDetailsModel> lPOInvoiceDetails = new List <IT.Web.Models.LPOInvoiceDetailsModel>();
                List <VenderModel> venderModels = new List <VenderModel>();

                int CompanyId = Convert.ToInt32(Session["CompanyId"]);

                var lPOInvoiceModel = new IT.Web.Models.LPOInvoiceModel
                {
                    Id       = Id,
                    detailId = CompanyId,
                };

                var LPOInvoice = webServices.Post(lPOInvoiceModel, "Bill/EditReport");
                lPOInvoiceModel = (new JavaScriptSerializer()).Deserialize <IT.Web.Models.LPOInvoiceModel>(LPOInvoice.Data.ToString());

                lPOInvoiceDetails = lPOInvoiceModel.lPOInvoiceDetailsList;
                compnayModels     = lPOInvoiceModel.compnays;
                lPOInvoiceModels.Insert(0, lPOInvoiceModel);
                venderModels = lPOInvoiceModel.venders;

                Report.Database.Tables[0].SetDataSource(compnayModels);
                Report.Database.Tables[1].SetDataSource(venderModels);
                Report.Database.Tables[2].SetDataSource(lPOInvoiceModels);
                Report.Database.Tables[3].SetDataSource(lPOInvoiceDetails);

                Report.SetParameterValue("ImageUrl", "http://itmolen-001-site8.htempurl.com/ClientDocument/" + lPOInvoiceModel.compnays[0].LogoUrl);
                Report.SetParameterValue("Heading", "Invoice");

                Stream stram = Report.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);
                stram.Seek(0, SeekOrigin.Begin);

                string companyName = Id + "-" + lPOInvoiceModels[0].PONumber;

                var root = Server.MapPath("/PDF/");
                pdfname = String.Format("{0}.pdf", companyName);
                var path = Path.Combine(root, pdfname);
                path = Path.GetFullPath(path);

                Report.ExportToDisk(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat, path);

                stram.Close();

                return(1);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
예제 #2
0
        public ActionResult PrintInvoice(int Id)
        {
            string pdfname = "";

            try
            {
                ReportDocument Report = new ReportDocument();
                Report.Load(Server.MapPath("~/Reports/LPO-Invoice/LPOInvoice.rpt"));

                List <IT.Web.Models.CompnayModel>           compnayModels     = new List <Web.Models.CompnayModel>();
                List <IT.Web.Models.LPOInvoiceModel>        lPOInvoiceModels  = new List <Web.Models.LPOInvoiceModel>();
                List <IT.Web.Models.LPOInvoiceDetailsModel> lPOInvoiceDetails = new List <LPOInvoiceDetailsModel>();
                List <VenderModel> venderModels = new List <VenderModel>();
                var lPOInvoiceModel             = new IT.Web.Models.LPOInvoiceModel();

                int CompanyId = Convert.ToInt32(Session["CompanyId"]);

                lPOInvoiceModel.Id       = Id;
                lPOInvoiceModel.detailId = CompanyId;

                var LPOInvoice = webServices.Post(lPOInvoiceModel, "Invoice/EditReport");


                if (LPOInvoice.Data != "[]")
                {
                    lPOInvoiceModel = (new JavaScriptSerializer()).Deserialize <IT.Web.Models.LPOInvoiceModel>(LPOInvoice.Data.ToString());
                }

                lPOInvoiceModels.Insert(0, lPOInvoiceModel);
                compnayModels     = lPOInvoiceModel.compnays;
                lPOInvoiceDetails = lPOInvoiceModel.lPOInvoiceDetailsList;
                venderModels      = lPOInvoiceModel.venders;

                Report.Database.Tables[0].SetDataSource(compnayModels);
                Report.Database.Tables[1].SetDataSource(venderModels);
                Report.Database.Tables[2].SetDataSource(lPOInvoiceModels);
                Report.Database.Tables[3].SetDataSource(lPOInvoiceDetails);

                string companyName;
                if (lPOInvoiceModels.Count > 0)
                {
                    companyName = Id + "-" + lPOInvoiceModels[0].PONumber;
                }
                else
                {
                    companyName = "Data Not Found";
                }
                var root = Server.MapPath("/PDF/");
                pdfname = String.Format("{0}.pdf", companyName);
                var path = Path.Combine(root, pdfname);
                path = Path.GetFullPath(path);

                Report.ExportToDisk(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat, path);

                //stram.Close();

                byte[] fileBytes = System.IO.File.ReadAllBytes(path);
                string fileName  = companyName + ".PDF";
                //return File(fileBytes, System.Net.Mime.MediaTypeNames.Application.Octet, fileName);

                Stream stram = Report.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);
                stram.Seek(0, SeekOrigin.Begin);

                return(new FileStreamResult(stram, "application/pdf"));
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
예제 #3
0
        public int UploadFileToFolder(int Id)
        {
            string pdfname = "";

            try
            {
                ReportDocument Report = new ReportDocument();
                Report.Load(Server.MapPath("~/Reports/LPO-Invoice/LPOInvoice.rpt"));

                List <IT.Web.Models.CompnayModel>           compnayModels     = new List <Web.Models.CompnayModel>();
                List <IT.Web.Models.LPOInvoiceModel>        lPOInvoiceModels  = new List <Web.Models.LPOInvoiceModel>();
                List <IT.Web.Models.LPOInvoiceDetailsModel> lPOInvoiceDetails = new List <LPOInvoiceDetailsModel>();
                List <VenderModel> venderModels = new List <VenderModel>();

                var LPOInvoice = webServices.Post(new IT.Web.Models.LPOInvoiceModel(), "LPO/EditReport/" + Id);

                var LPOInvoiceModel = new IT.Web.Models.LPOInvoiceModel();
                if (LPOInvoice.Data != "[]")
                {
                    LPOInvoiceModel = (new JavaScriptSerializer()).Deserialize <IT.Web.Models.LPOInvoiceModel>(LPOInvoice.Data.ToString());
                }
                int CompanyId = Convert.ToInt32(Session["CompanyId"]);

                lPOInvoiceModels.Insert(0, LPOInvoiceModel);
                compnayModels     = LPOInvoiceModel.compnays;
                lPOInvoiceDetails = LPOInvoiceModel.lPOInvoiceDetailsList;
                venderModels      = LPOInvoiceModel.venders;

                Report.Database.Tables[0].SetDataSource(compnayModels);
                Report.Database.Tables[1].SetDataSource(venderModels);
                Report.Database.Tables[2].SetDataSource(lPOInvoiceModels);
                Report.Database.Tables[3].SetDataSource(lPOInvoiceDetails);

                Stream stram = Report.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);
                stram.Seek(0, SeekOrigin.Begin);

                string companyName;
                if (lPOInvoiceModels.Count > 0)
                {
                    companyName = Id + "-" + lPOInvoiceModels[0].PONumber;
                }
                else
                {
                    companyName = "Data Not Found";
                }
                var root = Server.MapPath("/PDF/");
                pdfname = String.Format("{0}.pdf", companyName);
                var path = Path.Combine(root, pdfname);
                path = Path.GetFullPath(path);

                Report.ExportToDisk(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat, path);

                stram.Close();

                return(1);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
예제 #4
0
        public ActionResult LPOAllLByDateRange()
        {
            int CompanyId = Convert.ToInt32(Session["CompanyId"]);

            SearchViewModel searchViewModel = new SearchViewModel
            {
                FromDate  = "2020-01-29",
                ToDate    = "2020-01-30",
                CompanyId = CompanyId,
            };
            string pdfname = "";

            try
            {
                ReportDocument Report = new ReportDocument();
                Report.Load(Server.MapPath("~/Reports/LPO-Invoice/LPOInvoiceList.rpt"));

                List <IT.Web.Models.CompnayModel>    compnayModels    = new List <Web.Models.CompnayModel>();
                List <IT.Web.Models.LPOInvoiceModel> lPOInvoiceModels = new List <Web.Models.LPOInvoiceModel>();



                var LPOInvoice = webServices.Post(searchViewModel, "LPO/LPOAllLByDateRange");

                var LPOInvoiceModel = new IT.Web.Models.LPOInvoiceModel();
                if (LPOInvoice.Data != "[]")
                {
                    lPOInvoiceModels = (new JavaScriptSerializer()).Deserialize <List <IT.Web.Models.LPOInvoiceModel> >(LPOInvoice.Data.ToString());
                }

                compnayModels = lPOInvoiceModels[0].compnays;

                Report.Database.Tables[0].SetDataSource(compnayModels);
                Report.Database.Tables[1].SetDataSource(lPOInvoiceModels);

                Report.SetParameterValue("ImageUrl", "http://itmolen-001-site8.htempurl.com/ClientDocument/" + compnayModels[0].LogoUrl);
                Report.SetParameterValue("ReportHeading", "LPO List");

                Stream stram = Report.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);
                stram.Seek(0, SeekOrigin.Begin);

                string companyName;

                if (lPOInvoiceModels.Count > 0)
                {
                    companyName = "LPO-" + lPOInvoiceModels[0].PONumber;
                }
                else
                {
                    companyName = "Data Not Found";
                }
                var root = Server.MapPath("/PDF/");
                pdfname = String.Format("{0}.pdf", companyName);
                var path = Path.Combine(root, pdfname);
                path = Path.GetFullPath(path);

                Report.ExportToDisk(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat, path);

                //stram.Close();
                //byte[] fileBytes = System.IO.File.ReadAllBytes(path);
                // string fileName = companyName + ".PDF";
                //return File(fileBytes, System.Net.Mime.MediaTypeNames.Application.Octet, fileName);

                // Stream stram = Report.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);
                stram.Seek(0, SeekOrigin.Begin);

                return(new FileStreamResult(stram, "application/pdf"));
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }