예제 #1
0
파일: Patient.cs 프로젝트: wadee44/EyesSys
        //Bitmap bmp;

        //private DataTable getDataTableFromDataGrid(DataGridView _DataGridView)
        //{
        //    try
        //    {
        //        if (_DataGridView.ColumnCount == 0) return null;
        //        DataTable dtSource = new DataTable();
        //        //////create columns
        //        foreach (DataGridViewColumn col in _DataGridView.Columns)
        //        {
        //            if (col.ValueType == null) dtSource.Columns.Add(col.Name, typeof(string));
        //            else dtSource.Columns.Add(col.Name, col.ValueType);
        //            dtSource.Columns[col.Name].Caption = col.HeaderText;
        //        }
        //        ///////insert row data
        //        foreach (DataGridViewRow row in _DataGridView.Rows)
        //        {
        //            DataRow drNewRow = dtSource.NewRow();
        //            foreach (DataColumn col in dtSource.Columns)
        //            {
        //                drNewRow[col.ColumnName] = row.Cells[col.ColumnName].Value;
        //            }
        //            dtSource.Rows.Add(drNewRow);
        //        }
        //        return dtSource;
        //    }
        //    catch
        //    {
        //        return null;
        //    }
        //}
        private void btnPrint_Click(object sender, EventArgs e)
        {
            try
            {
                DevExpress.XtraGrid.Views.Grid.GridView view = dataGridView1.MainView as DevExpress.XtraGrid.Views.Grid.GridView;
                if (view != null)
                {
                    view.ExportToPdf("بيانات المرضى.pdf");
                }
                Process pdfExport = new Process();

                pdfExport.StartInfo.FileName  = "AcroRd32.exe";
                pdfExport.StartInfo.Arguments = "بيانات المرضى.pdf";
                pdfExport.Start();
            }
            catch (Exception)
            { }

            //RP.FormPatientReport fr = new RP.FormPatientReport();
            //fr.ShowDialog();
            //using (
            //      SaveFileDialog ofd = new SaveFileDialog() { FileName = "My_Export.xlsx", Filter = "Excel Workbook|*.xlsx", ValidateNames = true }
            //   )
            //{
            //    if (ofd.ShowDialog() == DialogResult.OK)
            //    {
            //        this.Cursor = Cursors.WaitCursor;

            //        string filePath = ofd.FileName;

            //         get the sheet page and set it to the dataTable
            //        BL.ExcelFile excel = new BL.ExcelFile();
            //        DataTable theDT = excel.GetSheetTable(excel.currentSheetIndex);


            //        DataTable theDT = new DataTable();

            //        theDT = (DataTable)dataGridView1.DataSource;

            //        if (theDT == null || theDT.Columns.Count == 0)
            //            theDT = getDataTableFromDataGrid(dataGridView1);


            //        BL.ExcelFile excel = new BL.ExcelFile();
            //        excel.ExportToExcel(theDT, filePath);

            //        this.Cursor = Cursors.Default;
            //    }
            //}

            /*
             * int height = dataGridView1.Height ;
             * dataGridView1.Height = dataGridView1.RowCount * dataGridView1.RowTemplate.Height * 2;
             *
             * bmp = new Bitmap(dataGridView1.Width * 10, dataGridView1.Height);
             * dataGridView1.DrawToBitmap(bmp, new Rectangle(0, 0, dataGridView1.Width * 10, dataGridView1.Height));
             * dataGridView1.Height = height;
             * printPreviewDialog1.ShowDialog();*/
        }
예제 #2
0
        private void userButton2_Click(object sender, EventArgs e)
        {
            DevExpress.XtraGrid.Views.Grid.GridView View = gridControl1.MainView as DevExpress.XtraGrid.Views.Grid.GridView;

            if (View != null)
            {
                View.ExportToPdf("ShowData.pdf");//pdf的文件名必须是英文
            }
            try
            {
                Process pdfExport = new Process();

                pdfExport.StartInfo.FileName = "AcroRd32.exe";

                pdfExport.StartInfo.Arguments = "ShowData.pdf";

                pdfExport.Start();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }