コード例 #1
0
ファイル: ReportWindow.xaml.cs プロジェクト: latys/report
        private void GenReport_Click(object sender, RoutedEventArgs e)
        {
            //Common.ExportToExcel<RateView, List<RateView>> exporttoexcel =
            //new Common.ExportToExcel<RateView, List<RateView>>();
            ////实例化exporttoexcel对象
            //exporttoexcel.DataToPrint = (List<RateView>)dataGrid.ItemsSource;


            // create an instance of pdf export filter
            FastReport.Export.Pdf.PDFExport export = new FastReport.Export.Pdf.PDFExport();
            // show the export options dialog and do the export
            //if (export.ShowDialog())
            //    report.Export(export, "result.pdf");
            Microsoft.Win32.SaveFileDialog dlg = new Microsoft.Win32.SaveFileDialog();
            dlg.FileName   = "报表";               // Default file name
            dlg.DefaultExt = ".pdf";             // Default file extension
            dlg.Filter     = "pdf (.pdf)|*.pdf"; // Filter files by extension

            // Show save file dialog box
            Nullable <bool> result   = dlg.ShowDialog();
            string          filename = string.Empty;

            // Process save file dialog box results
            if (result == true)
            {
                report.Export(export, dlg.FileName);
                LogHelper.WriteLog("导出报表成功:" + dlg.FileName);
            }
            else
            {
                return;
            }
        }
コード例 #2
0
        public ActionResult GetReport(string patNo, string patName, string nationalityId, string lastepisode, string arrivaldate, string gender, string year, string nationality)
        {
            var arabicname = repository.GetArabicName(patNo);
            //var dtT12201 = repository.GetReport(patid);
            DataTable dtT12201 = new DataTable();

            dtT12201.TableName = "T12201";

            dtT12201.Columns.Add("Pat_BarCode", typeof(Bitmap));
            dtT12201.Columns.Add("patNo", typeof(string));
            dtT12201.Columns.Add("patName", typeof(string));
            dtT12201.Columns.Add("arabicname", typeof(string));
            dtT12201.Columns.Add("nationalityId", typeof(string));
            dtT12201.Columns.Add("lastepisode", typeof(string));
            dtT12201.Columns.Add("arrivaldate", typeof(string));
            dtT12201.Columns.Add("gender", typeof(string));
            dtT12201.Columns.Add("year", typeof(string));
            dtT12201.Columns.Add("nationality", typeof(string));
            Image   myimg = Code128Rendering.MakeBarcodeImage(patNo, int.Parse("2"), true);
            DataRow dr    = dtT12201.NewRow();

            dtT12201.Rows.Add(dr);
            dtT12201.Rows[0]["Pat_BarCode"]   = myimg;
            dtT12201.Rows[0]["patNo"]         = patNo;
            dtT12201.Rows[0]["patName"]       = patName;
            dtT12201.Rows[0]["arabicname"]    = arabicname;
            dtT12201.Rows[0]["nationalityId"] = nationalityId;
            dtT12201.Rows[0]["lastepisode"]   = lastepisode;
            dtT12201.Rows[0]["arrivaldate"]   = arrivaldate;
            dtT12201.Rows[0]["gender"]        = gender;
            dtT12201.Rows[0]["year"]          = year;
            dtT12201.Rows[0]["nationality"]   = nationality;

            //dtT12201.WriteXmlSchema(Server.MapPath("~/Report/xml/T12201.xml"));
            //return View();
            using (var Report = new FastReport.Report())
            {
                Report.Report.Load(Server.MapPath("~/Report/Report/R12201.frx"));
                System.Data.DataSet dataSet = new System.Data.DataSet();
                Report.Report.RegisterData(dtT12201, "T12201");
                Report.Report.Prepare();
                using (var strm = new MemoryStream())
                {
                    // var excelExport = new Excel2007Export();
                    // webReport.Report.Export(excelExport, strm);
                    // var pdfExport = new PDFExport();
                    // Report.Report.Export(pdfExport, strm);
                    // Response.ClearContent();
                    // Response.ClearHeaders();
                    // Response.Buffer = true;
                    //// Response.ContentType = "Application/vnd.ms-excel";
                    // Response.ContentType = "Application/PDF";
                    // Response.BinaryWrite(strm.ToArray());
                    // Response.End();

                    var pdfExport = new PDFExport();
                    Report.Export(pdfExport, strm);
                    Response.ClearContent();
                    Response.ClearHeaders();
                    Response.Buffer      = true;
                    Response.ContentType = "Application/PDF";
                    Response.BinaryWrite(strm.ToArray());
                    Response.End();
                }
                ViewBag.WebReport = Report;
            }

            return(View());
        }
コード例 #3
0
        public FileResult DepoIslemYazdir(string ID = "")
        {
            FastReport.Utils.Config.WebMode = true;
            FastReport.Report report1 = new FastReport.Report();

            report1.Prepare(true);
            DataTable dtDetay = new DataTable();

            try
            {
                report1.Load(Path.Combine(Server.MapPath("~/REPORTS/" + Session["FirmaID"].ToString()), "depo.frx"));
            }
            catch {
                report1.Load(Path.Combine(Server.MapPath("~/REPORTS/Default"), "depo.frx"));
            }

            using (SqlConnection bag = new SqlConnection(AyarMetot.strcon))
            {
                if (bag.State == ConnectionState.Closed)
                {
                    bag.Open();
                }
                using (SqlCommand servisgetir = new SqlCommand("Select * From STORE_PROCESS where ID='" + ID + "'", bag))
                {
                    using (SqlDataReader dt = servisgetir.ExecuteReader())
                    {
                        while (dt.Read())
                        {
                            dtDetay = AyarMetot.DepoIslemDetayBil(ID);


                            report1.RegisterData(AyarMetot.DepoIslemBil(ID), "Depo_İşlem");
                            report1.RegisterData(dtDetay, "Depo_İşlem_Detay");
                            report1.RegisterData(AyarMetot.FirmaBil(), "FirmaBilgileri");

                            report1.GetDataSource("Depo_İşlem").Enabled       = true;
                            report1.GetDataSource("Depo_İşlem_Detay").Enabled = true;
                            report1.GetDataSource("FirmaBilgileri").Enabled   = true;
                        }
                    }
                }
            }

            using (FastReport.Export.Pdf.PDFExport pdf = new FastReport.Export.Pdf.PDFExport())
            {
                try
                {
                    ReportPage page1 = report1.Pages[0] as ReportPage;
                    page1.PaperHeight = page1.PaperHeight + (dtDetay.Rows.Count * ((float)6.5));
                }
                catch { }

                report1.Prepare(true);
                try {
                    report1.Export(pdf, Path.Combine(Server.MapPath("~/REPORTS/" + Session["FirmaID"].ToString()), "depo.pdf"));
                }
                catch
                {
                    report1.Export(pdf, Path.Combine(Server.MapPath("~/REPORTS/Default"), "depo.pdf"));
                }
                dtDetay.Dispose();

                //System.IO.MemoryStream ms = new System.IO.MemoryStream();
                //report1.Save(Path.Combine(Server.MapPath("~/REPORTS/ATTACHMENT"), "depoyeni.frx"));

                byte[] dosya;
                report1.Dispose();
                try {
                    dosya = System.IO.File.ReadAllBytes(Path.Combine(Server.MapPath("~/REPORTS/" + Session["FirmaID"].ToString()), "depo.pdf"));
                }
                catch
                {
                    dosya = System.IO.File.ReadAllBytes(Path.Combine(Server.MapPath("~/REPORTS/Default"), "depo.pdf"));
                }
                return(File(dosya, "application/pdf"));
            }
        }
コード例 #4
0
        public FileResult CekSenetYazdir(string ID = "")
        {
            FastReport.Utils.Config.WebMode = true;
            FastReport.Report report1 = new FastReport.Report();

            report1.Prepare(true);

            try
            {
                report1.Load(Path.Combine(Server.MapPath("~/REPORTS/" + Session["FirmaID"].ToString()), "Cek.frx"));
            }
            catch
            {
                report1.Load(Path.Combine(Server.MapPath("~/REPORTS/Default"), "Cek.frx"));
            }

            using (SqlConnection conp = new SqlConnection(AyarMetot.strcon))
            {
                if (conp.State == ConnectionState.Closed)
                {
                    conp.Open();
                }
                using (SqlCommand getir = new SqlCommand("Select CariID  From CASH_PAY where ID='" + ID + "'", conp))
                {
                    using (SqlDataReader dr = getir.ExecuteReader())
                    {
                        while (dr.Read())
                        {
                            using (DataTable Teklifler = GetDataTable("set dateformat dmy;SELECT * ,(Select Adi+' '+Soyadi from Personel where ID=PersonelID) as PersonelAdi From CASH_PAY where ID = '" + ID + "'"))
                            {
                                report1.RegisterData(Teklifler.DefaultView.ToTable(), "NakitHavale");
                                report1.GetDataSource("NakitHavale").Enabled = true;
                            }

                            report1.RegisterData(AyarMetot.CariBil(Convert.ToInt32(dr["CariID"]), "Tümü", "", "Tümü", "Tümü"), "CariBilgileri");
                            report1.RegisterData(AyarMetot.FirmaBil(), "FirmaBilgileri");


                            report1.GetDataSource("CariBilgileri").Enabled  = true;
                            report1.GetDataSource("FirmaBilgileri").Enabled = true;
                        }
                    }
                }
            }

            using (FastReport.Export.Pdf.PDFExport pdf = new FastReport.Export.Pdf.PDFExport())
            {
                byte[] dosya;
                try
                {
                    dosya =
                        System.IO.File.ReadAllBytes(Path.Combine(Server.MapPath("~/REPORTS/" + Session["FirmaID"].ToString()),
                                                                 "Cek.pdf"));
                }
                catch
                {
                    dosya =
                        System.IO.File.ReadAllBytes(Path.Combine(Server.MapPath("~/REPORTS/Defaut"),
                                                                 "Cek.pdf"));
                }



                try
                {
                    report1.Prepare(true);

                    try
                    {
                        report1.Export(pdf, Path.Combine(Server.MapPath("~/REPORTS/" + Session["FirmaID"].ToString()), "Cek.pdf"));
                    }
                    catch
                    {
                        report1.Export(pdf, Path.Combine(Server.MapPath("~/REPORTS/Default"), "Cek.pdf"));
                    }

                    System.IO.MemoryStream ms = new System.IO.MemoryStream();
                    //report1.Save(Path.Combine(Server.MapPath("~/REPORTS/ATTACHMENT"),"b.frx"));
                    report1.Dispose();

                    return(File(dosya, "application/pdf"));
                }
                catch (Exception e)
                {
                    return(File(dosya, "application/pdf"));
                }
            }
        }
コード例 #5
0
        public FileResult IadeYazdir(string ID = "")
        {
            try
            {
                FastReport.Utils.Config.WebMode = true;
                FastReport.Report report1 = new FastReport.Report();

                report1.Prepare(true);
                DataTable dtDetay = new DataTable();

                try {
                    report1.Load(Path.Combine(Server.MapPath("~//REPORTS/" + Session["FirmaID"].ToString()), "Iade.frx"));
                }
                catch
                {
                    report1.Load(Path.Combine(Server.MapPath("~//REPORTS/Default"), "Iade.frx"));
                }
                using (SqlConnection bag = new SqlConnection(AyarMetot.strcon))
                {
                    if (bag.State == ConnectionState.Closed)
                    {
                        bag.Open();
                    }
                    using (SqlCommand servisgetir = new SqlCommand("Select * From INVOICE where ID='" + ID + "'", bag))
                    {
                        using (SqlDataReader dt = servisgetir.ExecuteReader())
                        {
                            while (dt.Read())
                            {
                                string KDVdh = "Dahil";

                                dtDetay = AyarMetot.FaturaDetayBil(ID, KDVdh, Convert.ToDecimal(dt["FKuru"]));

                                if (dt["KdvDH"].ToString() != "D")
                                {
                                    KDVdh = "Hariç";
                                }
                                report1.RegisterData(AyarMetot.FaturaBil(ID), "FaturaBilgileri");
                                report1.RegisterData(dtDetay, "UrunBilgileri");
                                report1.RegisterData(AyarMetot.CariBil(Convert.ToInt32(dt["CariID"]), "Tümü", "Tümü", "Tümü", "Tümü"), "CariBilgileri");
                                report1.RegisterData(AyarMetot.FirmaBil(), "FirmaBilgileri");

                                report1.GetDataSource("FaturaBilgileri").Enabled = true;
                                report1.GetDataSource("UrunBilgileri").Enabled   = true;
                                report1.GetDataSource("CariBilgileri").Enabled   = true;
                                report1.GetDataSource("FirmaBilgileri").Enabled  = true;
                            }
                        }
                    }
                }



                using (FastReport.Export.Pdf.PDFExport pdf = new FastReport.Export.Pdf.PDFExport())
                {
                    ReportPage page1 = report1.Pages[0] as ReportPage;
                    page1.PaperHeight = page1.PaperHeight + (dtDetay.Rows.Count * ((float)5));

                    report1.Prepare(true);

                    try {
                        report1.Export(pdf, Path.Combine(Server.MapPath("~//REPORTS/" + Session["FirmaID"].ToString()), "Iade.pdf"));
                    }
                    catch
                    {
                        report1.Export(pdf, Path.Combine(Server.MapPath("~//REPORTS/Default"), "Iade.pdf"));
                    }
                    dtDetay.Dispose();
                    System.IO.MemoryStream ms = new System.IO.MemoryStream();
                    //report1.Save(Path.Combine(Server.MapPath("~/REPORTS/ATTACHMENT"),"Irs.frx"));
                    // page1.Dispose();
                    report1.Dispose();
                    byte[] dosya;
                    try {
                        dosya = System.IO.File.ReadAllBytes(Path.Combine(Server.MapPath("~/REPORTS/" + Session["FirmaID"].ToString()), "Iade.pdf"));
                    }
                    catch
                    {
                        dosya = System.IO.File.ReadAllBytes(Path.Combine(Server.MapPath("~/REPORTS/Default"), "Iade.pdf"));
                    }
                    return(File(dosya, "application/pdf"));
                }
            }
            catch (Exception e1)
            {
                try {
                    System.IO.File.WriteAllText(Path.Combine(@"C:\Users\ilhan\AppData\Local\Sayazilim", "sonuç.xml"), e1.ToString());
                }
                catch
                {
                }
                byte[] dosya = null;
                return(File(dosya, "application/pdf"));
            }
        }