示例#1
0
        public static void LPI_view(string cmdtxt)
        {
            rpt_LPI         rpt    = new rpt_LPI();
            MySqlDataReader reader = null;
            DataTable       dt     = new DataTable();

            try
            {
                rpt.Load();
                setCommand(cmdtxt);
                reader = cmd.ExecuteReader();
                dt.Load(reader);
                rpt.SetDataSource(dt);
                rptviewer.crystalReportViewer1.ReportSource = rpt;
                rptviewer.crystalReportViewer1.Refresh();
                rptviewer.ShowDialog();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message + "\n" + ex.StackTrace);
            }
        }
示例#2
0
        public static void LPI_view(string cmdtxt, int id)
        {
            rpt_LPI         rpt    = new rpt_LPI();
            MySqlDataReader reader = null;
            DataTable       dt     = new DataTable();

            try
            {
                rpt.Load();
                setCommand(cmdtxt);
                cmd.Parameters.AddWithValue("ID", id);
                cmd.Parameters["@ID"].MySqlDbType = MySqlDbType.Int32;
                reader = cmd.ExecuteReader();
                dt.Load(reader);
                rpt.SetDataSource(dt);
                rptviewer.crystalReportViewer1.ReportSource = rpt;
                rptviewer.crystalReportViewer1.Refresh();
                rptviewer.ShowDialog();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message + "\n" + ex.StackTrace);
            }
        }
示例#3
0
        public static void LPI_export(string type, string cmdtxt, int id)
        {
            rpt_LPI         rpt    = new rpt_LPI();
            MySqlDataReader reader = null;
            DataTable       dt     = new DataTable();

            try
            {
                rpt.Load();
                setCommand(cmdtxt);
                cmd.Parameters.AddWithValue("ID", id);
                cmd.Parameters["@ID"].MySqlDbType = MySqlDbType.Int32;
                reader = cmd.ExecuteReader();
                dt.Load(reader);
                rpt.SetDataSource(dt);

                if (type == "pdf")
                {
                    SaveFileDialog save = new SaveFileDialog();
                    string         back_up_file_name = String.Format("{0:MM-dd-yyyy}", DateTime.Now);
                    save.FileName = back_up_file_name;
                    save.Filter   = "PDF(*.pdf)|*.pdf";
                    if (save.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                    {
                        DiskFileDestinationOptions dest = new DiskFileDestinationOptions();
                        dest.DiskFileName = save.FileName;
                        PdfFormatOptions formatOpt = new PdfFormatOptions();
                        formatOpt.FirstPageNumber = 0;
                        formatOpt.LastPageNumber  = 0;
                        formatOpt.UsePageRange    = false;
                        formatOpt.CreateBookmarksFromGroupTree = false;
                        ExportOptions ex = new ExportOptions();
                        ex.ExportDestinationType    = ExportDestinationType.DiskFile;
                        ex.ExportDestinationOptions = dest;
                        ex.ExportFormatType         = ExportFormatType.PortableDocFormat;
                        ex.ExportFormatOptions      = formatOpt;
                        rpt.Export(ex);
                        MessageBox.Show("Reports Save!");
                    }
                }
                else if (type == "excel")
                {
                    SaveFileDialog save = new SaveFileDialog();
                    string         back_up_file_name = String.Format("{0:MM-dd-yyyy}", DateTime.Now);
                    save.FileName = back_up_file_name;
                    save.Filter   = "Excel(*.xlsx)|*.xlsx";
                    if (save.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                    {
                        ExportToExcel(dt, save.FileName);
                    }
                }
                else
                {
                    SaveFileDialog save = new SaveFileDialog();
                    string         back_up_file_name = String.Format("{0:MM-dd-yyyy}", DateTime.Now);
                    save.FileName = back_up_file_name;
                    save.Filter   = "Word 2003(*.doc)|*.doc";
                    if (save.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                    {
                        DiskFileDestinationOptions dest = new DiskFileDestinationOptions();
                        dest.DiskFileName = save.FileName;
                        PdfRtfWordFormatOptions formatOpt = new PdfRtfWordFormatOptions();
                        formatOpt.FirstPageNumber = 0;
                        formatOpt.LastPageNumber  = 0;
                        formatOpt.UsePageRange    = false;
                        ExportOptions ex = new ExportOptions();
                        ex.ExportDestinationType    = ExportDestinationType.DiskFile;
                        ex.ExportDestinationOptions = dest;
                        ex.ExportFormatType         = ExportFormatType.WordForWindows;
                        ex.ExportFormatOptions      = formatOpt;
                        rpt.Export(ex);
                        MessageBox.Show("Reports Save!");
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message + "\n" + ex.StackTrace);
            }
        }