protected void Page_Load(object sender, EventArgs e)
        {
            string          reportDataHandle = Request.QueryString["reportContainerHandle"];
            ReportsModuleV2 module           = ReportsModuleV2.FindReportsModule(ApplicationReportObjectSpaceProvider.ContextApplication.Modules);

            if (!String.IsNullOrEmpty(reportDataHandle) && module != null)
            {
                XtraReport report = null;
                try {
                    report = ReportDataProvider.ReportsStorage.GetReportContainerByHandle(reportDataHandle).Report;
                    module.ReportsDataSourceHelper.SetupBeforePrint(report, null, null, false, null, false);
                    using (MemoryStream ms = new MemoryStream()) {
                        report.CreateDocument();
                        PdfExportOptions options = new PdfExportOptions();
                        options.ShowPrintDialogOnOpen = true;
                        report.ExportToPdf(ms, options);
                        ms.Seek(0, SeekOrigin.Begin);
                        byte[] reportContent = ms.ToArray();
                        Response.ContentType = "application/pdf";
                        Response.AddHeader("Content-Disposition", "attachment; filename=MyFileName.pdf");
                        Response.Clear();
                        Response.OutputStream.Write(reportContent, 0, reportContent.Length);
                        Response.End();
                    }
                }
                finally {
                    if (report != null)
                    {
                        report.Dispose();
                    }
                }
            }
        }
Пример #2
0
        void DisposeReportSource(XRSubreport subreport)
        {
            XtraReport report = subreport.ReportSource;

            if (report != null && !report.IsDisposed)
            {
                report.Dispose();
            }
        }
Пример #3
0
        void GiderYazdir(bool Disigner)
        {
            try
            {
                System.Data.DataSet ds      = new DataSet("Test");
                DataTable           dtliste = (DataTable)gcGiderler.DataSource;

                dtliste.TableName = "dtliste";
                ds.Tables.Add(dtliste);
                //şirket bilgileri
                DataTable Sirket = DB.GetData(@"select * from Sirketler with(nolock)");
                Sirket.TableName = "Sirket";
                ds.Tables.Add(Sirket);

                string exedizini = Path.GetDirectoryName(Application.ExecutablePath);

                string RaporDosyasi = exedizini + "\\Raporlar\\Giderler.repx";
                if (!File.Exists(RaporDosyasi))
                {
                    MessageBox.Show("Giderler.repx Dosya Bulunamadı");
                    return;
                }
                XtraReport rapor = new XtraReport();

                rapor.LoadLayout(RaporDosyasi);
                rapor.FindControl("label3", true).Text = deBasGelir.Text + "         " + deBitGelir.Text;

                rapor.Name = "Giderler";

                rapor.Report.Name = "Giderler";

                rapor.DataSource = ds;

                if (Disigner)
                {
                    rapor.ShowDesignerDialog();
                }
                else
                {
                    rapor.ShowPreviewDialog();
                }
                //ds.Dispose();
                ds.Tables.Remove(dtliste);
                ds.Tables.Remove(Sirket);


                dtliste.Dispose();
                ds.Dispose();
                rapor.Dispose();
            }
            catch (Exception exp)
            {
                MessageBox.Show("Hata Oluştu " + exp.Message);
            }
        }
        protected static byte[] SerializeControls(XRControl[] controls)
        {
            XtraReport tempReport = new XtraReport();
            DetailBand tempBand   = new DetailBand();

            tempReport.Bands.Add(tempBand);

            using (XtraReport cloneReport = new XtraReport()) {
                using (MemoryStream stream = new MemoryStream()) {
                    controls[0].RootReport.SaveLayoutToXml(stream);
                    stream.Position = 0;

                    cloneReport.LoadLayoutFromXml(stream);
                }
                foreach (XRControl control in controls)
                {
                    XRControl clone = cloneReport.FindControl(control.Name, true);
                    if (clone != null)
                    {
                        tempBand.Controls.Add(clone);
                    }
                }
            }

            float topMost  = float.MaxValue;
            float leftMost = float.MaxValue;

            foreach (XRControl control in tempBand.Controls)
            {
                topMost  = Math.Min(topMost, control.TopF);
                leftMost = Math.Min(leftMost, control.LeftF);
            }

            foreach (XRControl control in tempBand.Controls)
            {
                control.LocationF = new PointF(control.LeftF - leftMost, control.TopF - topMost);
            }

            byte[] layoutBytes = null;

            using (MemoryStream stream = new MemoryStream()) {
                tempReport.SaveLayoutToXml(stream);
                layoutBytes = stream.ToArray();
            }

            tempReport.Dispose();
            return(layoutBytes);
        }
Пример #5
0
        public static void InitPrint()
        {
            report.Parameters["pAmountPaid"].Value = parameters.Balance;
            report.Parameters["pSalesId"].Value    = parameters.AmountPaid;
            report.Parameters["pCashierId"].Value  = parameters.Cashier;
            report.Parameters["pChange"].Value     = parameters.SalesId;
            report.Parameters["pShopName"].Value   = parameters.ShopName;
            //var picBox = report.AllControls<XRPictureBox>().FirstOrDefault();
            //picBox.Image = Image.FromFile(Directory.GetFiles(@"Logo\")[0]);
            ReportPrintTool printTool = new ReportPrintTool(report);

            printTool.PrintingSystem.ShowPrintStatusDialog = false;
            report.RequestParameters = false;
            report.CreateDocument(false);
            printTool.Print();
            printTool.Dispose();
            report.Dispose();
        }
Пример #6
0
 /// <summary>
 /// 释放资源
 /// </summary>
 public void Dispose()
 {
     //if (m_frm != null)
     //{
     //   m_frm.Dispose();
     //   m_frm = null;
     //}
     if (_currentReport != null)
     {
         _currentReport.Dispose();
         _currentReport = null;
     }
     if (_ds != null)
     {
         _ds.Dispose();
         _ds = null;
     }
 }
Пример #7
0
        public override byte[] GetData(string url)
        {
            byte[] reportBytes;
            if (HttpContextAccessor.HttpContext.Session.TryGetValue(url, out reportBytes))
            {
                return(reportBytes);
            }
            XtraReport report = PredefinedReports.GetReport(url);

            if (report == null)
            {
                throw new Exception("Report was not found.");
            }

            using (var stream = new MemoryStream()) {
                report.SaveLayoutToXml(stream);
                report.Dispose();
                return(stream.ToArray());
            }
        }
Пример #8
0
        public override byte[] GetData(string url)
        {
            byte[] reportBytes;
            lock (sync) {
                var storedReports = Session.GetObjectFromJson <Dictionary <string, string> >(ReportExtensionSessionKey);
                if (storedReports != null && storedReports.ContainsKey(url) && Session.TryGetValue(url, out reportBytes))
                {
                    return(reportBytes);
                }
            }
            XtraReport report = PredefinedReports.GetReport(url);

            if (report == null)
            {
                throw new Exception("Report was not found.");
            }

            using (var stream = new MemoryStream()) {
                report.SaveLayoutToXml(stream);
                report.Dispose();
                return(stream.ToArray());
            }
        }
Пример #9
0
        public void Yazdirr(string DosyaAdi, Nasil NasilAcsin)
        {
            try
            {
                //using (
                Rapor = new XtraReport();
                {
                    Rapor.LoadLayout(DosyaAdi);
                    Rapor.DataSource = ds;
                    using (ReportPrintTool pt = new ReportPrintTool(Rapor))
                    {
                        pt.PrinterSettings.Copies = (Int16)NumberOfCopy;

                        //Rapor.PrintingSystem.ShowMarginsWarning = false;
                        //pt.PrintingSystem.ShowMarginsWarning = false;
                        //pt.PrintingSystem.StartPrint += PrintingSystem_StartPrint;



                        if (!string.IsNullOrEmpty(YaziciAdi))
                        {
                            pt.PrinterSettings.PrinterName = YaziciAdi;
                            try
                            {
                                pt.PrinterSettings.DefaultPageSettings.PaperSource = pt.PrinterSettings.PaperSources[KagitKaynagiIndex];
                            }
                            catch (Exception)
                            {
                            }
                        }


                        //Rapor.prin
                        switch (NasilAcsin)
                        {
                        case Nasil.dizayn:
                            FormuDuzenle(DosyaAdi);
                            //XRDesignFormEx XrDesigner = new XRDesignFormEx();
                            //XrDesigner.FileName = DosyaAdi;
                            //XrDesigner.OpenReport();
                            ////XrDesigner.OpenReport(DosyaAdi);
                            //XrDesigner.Show();
                            break;

                        case Nasil.Goster:
                            pt.ShowPreviewDialog();
                            break;

                        case Nasil.Yazdir:
                            pt.Print();
                            break;

                        case Nasil.YazdirmaDiyalogu:
                            pt.PrintDialog();
                            break;
                        }
                    }
                }
            }
            catch (Exception hata)
            {
                throw hata;
                //frmHataBildir frmHataBildir = new frmHataBildir(hata.Message, hata.StackTrace);
                //frmHataBildir.ShowDialog();
            }
            finally
            {
                Rapor.Dispose();
            }
        }
Пример #10
0
        void FisYazdir(bool Disigner)
        {
            string sql = "";

            //@"select convert(bit,'1') as Sec,f.pkFirma,Firmaadi,OzelKod,Tel,Cep,Adres,
            //satis.SatisTutari,isnull(kh.Borc,0),isnull(kh.Alacak,0),
            //(isnull(kh.Alacak,0)+satis.SatisTutari+f.Devir)-isnull(kh.Borc,0) as Bakiye from Firmalar f
            //inner join
            //(select s.fkFirma,sum(sd.Adet*(sd.SatisFiyati-sd.iskontotutar)) as SatisTutari from Satislar s
            //inner join SatisDetay sd on sd.fkSatislar=s.pkSatislar group by s.fkFirma)  satis
            //on satis.fkFirma=f.pkFirma
            //left join (select fkFirma,sum(Borc) as Borc,SUM(Alacak) as Alacak from KasaHareket group by fkFirma) kh on kh.fkFirma=f.pkFirma
            //where isnull(kh.Borc,0)-(isnull(kh.Alacak,0)+satis.SatisTutari+f.Devir)<>0";

            sql = "exec sp_MusterilereGenelBakis";
            try
            {
                System.Data.DataSet ds      = new DataSet("Test");
                DataTable           dtliste = (DataTable)gridControl1.DataSource;//DB.GetData(sql);
                if (gridView1.Columns["Firmaadi"].FilterInfo.Value != null)
                {
                    string aranan = gridView1.Columns["Firmaadi"].FilterInfo.Value.ToString();
                    dtliste = dtliste.Select("Firmaadi like'%" + aranan + "%'").CopyToDataTable();
                }
                dtliste.TableName = "dtliste";
                ds.Tables.Add(dtliste);
                //şirket bilgileri
                DataTable Sirket = DB.GetData(@"select * from Sirketler with(nolock)");
                Sirket.TableName = "Sirket";
                ds.Tables.Add(Sirket);

                string exedizini = Path.GetDirectoryName(Application.ExecutablePath);

                string RaporDosyasi = exedizini + "\\Raporlar\\MusteriBorcListesi.repx";
                if (!File.Exists(RaporDosyasi))
                {
                    MessageBox.Show("MusteriBorcListesi.repx Dosya Bulunamadı");
                    return;
                }
                XtraReport rapor = new XtraReport();


                rapor.LoadLayout(RaporDosyasi);

                rapor.Name = "MusteriBorcListesi";

                rapor.Report.Name = "MusteriBorcListesi";

                rapor.DataSource = ds;

                if (Disigner)
                {
                    rapor.ShowDesignerDialog();
                }
                else
                {
                    rapor.ShowPreviewDialog();
                }
                //ds.Dispose();
                ds.Tables.Remove(dtliste);
                ds.Tables.Remove(Sirket);


                dtliste.Dispose();
                ds.Dispose();
                rapor.Dispose();
            }
            catch (Exception exp)
            {
                MessageBox.Show("Hata Oluştu " + exp.Message);
            }
        }
 void IDocumentContent.OnClose(CancelEventArgs e)
 {
     Report.Dispose();
 }
Пример #12
0
        private void sbtGelirMail_Click(object sender, EventArgs e)
        {
            if (lUEKullanicilar.EditValue.ToString().Length < 10)
            {
                return;
            }

            DialogResult secim;

            secim = DevExpress.XtraEditors.XtraMessageBox.Show("Gider Raporu " +
                                                               lUEKullanicilar.EditValue.ToString() + " E-Posta(pdf) Gönderilsin mi?", Degerler.mesajbaslik, MessageBoxButtons.YesNo, MessageBoxIcon.Question, System.Windows.Forms.MessageBoxDefaultButton.Button2);
            if (secim == DialogResult.No)
            {
                return;
            }

            System.Data.DataSet ds      = new DataSet("Test");
            DataTable           dtliste = (DataTable)gcGelirler.DataSource;//DB.GetData(sql);

            dtliste.TableName = "dtliste";
            ds.Tables.Add(dtliste);
            //şirket bilgileri
            DataTable Sirket = DB.GetData(@"select * from Sirketler with(nolock)");

            Sirket.TableName = "Sirket";
            ds.Tables.Add(Sirket);

            string exedizini = Path.GetDirectoryName(Application.ExecutablePath);

            string RaporDosyasi = exedizini + "\\Raporlar\\Gelirler.repx";

            if (!File.Exists(RaporDosyasi))
            {
                MessageBox.Show("Giderler.repx Dosya Bulunamadı");
                return;
            }
            XtraReport rapor = new XtraReport();

            rapor.LoadLayout(RaporDosyasi);
            rapor.FindControl("label3", true).Text = deBasGelir.Text + "         " + deBitGelir.Text;

            rapor.Name = "Gelirler";

            rapor.Report.Name = "Gelirler";

            rapor.DataSource = ds;
            string dosyaadi = Application.StartupPath + "\\Gelirler.pdf";

            rapor.ExportToPdf(dosyaadi);

            //ds.Dispose();
            ds.Tables.Remove(dtliste);
            ds.Tables.Remove(Sirket);


            dtliste.Dispose();
            ds.Dispose();
            rapor.Dispose();

            DB.epostagonder(lUEKullanicilar.EditValue.ToString(), "Gelirler Raporu", dosyaadi, "Gün Sonu Raporu");

            formislemleri.Mesajform("E-Posta Gönderildi.", "S", 200);
        }