Esempio n. 1
0
        private void GenerateGrid()
        {
            CompositeLink composLink = new CompositeLink(new PrintingSystem());
            PrintableComponentLink pcLink1 = new PrintableComponentLink();
            Link linkMainReport = new Link();
            Link linkGrid1Report = new Link();
            linkGrid1Report.CreateDetailArea += new CreateAreaEventHandler(linkGrid1Report_CreateDetailArea);

            // Assign the controls to the printing links.
            pcLink1.Component = this.ThirdGridIncomeAnalysis;

            // Populate the collection of links in the composite link.
            // The order of operations corresponds to the document structure.
            composLink.Links.Add(linkGrid1Report);
            composLink.Links.Add(pcLink1);
            composLink.Links.Add(linkMainReport);

            // Create the report and show the preview window.
            //composLink.PrintingSystem.PreviewFormEx.AutoScale = true;
            composLink.PrintingSystem.PageSettings.Landscape = true;
            composLink.CreateDocument(printingSystem1);
            printingSystem1.PreviewFormEx.PrintingSystem.PageSettings.LeftMargin = 0;
            printingSystem1.PreviewFormEx.PrintingSystem.PageSettings.TopMargin = 30;
            //printingSystem1.PreviewFormEx.AutoScale = true;
            printingSystem1.PageSettings.Landscape = true;
            printingSystem1.PreviewFormEx.ForeColor = System.Drawing.Color.Black;
            printingSystem1.PreviewFormEx.Owner = this;
            printingSystem1.PreviewFormEx.PrintingSystem.Print();
        }
Esempio n. 2
0
        /// <summary>
        /// 预览当前设计Bom信息
        /// </summary>
        private void btnPreview_Click(object sender, EventArgs e)
        {
            try
            {
                if (!FrmMainDAO.QueryUserButtonPower(this.Name, this.Text, sender, true))
                {
                    return;
                }

                if (treeListDesignBom.Nodes.Count > 0)
                {
                    //treeListDesignBom.ShowPrintPreview();

                    CompositeLink          compLink     = new CompositeLink(new PrintingSystem());
                    PrintableComponentLink treeListLink = new PrintableComponentLink();
                    treeListLink.Component = treeListDesignBom;
                    compLink.PaperKind     = System.Drawing.Printing.PaperKind.A4;//设置纸张大小
                    System.Drawing.Printing.Margins margins = new System.Drawing.Printing.Margins(50, 50, 100, 50);
                    compLink.Margins = margins;

                    PageHeaderFooter phf = compLink.PageHeaderFooter as PageHeaderFooter;
                    phf.Header.Content.Clear();
                    phf.Header.Content.AddRange(new string[] { "", "设计Bom登记单", "" });
                    phf.Header.Font          = new System.Drawing.Font("宋体", 22, System.Drawing.FontStyle.Bold);
                    phf.Header.LineAlignment = BrickAlignment.Center;

                    phf.Footer.Content.AddRange(new string[] { "", String.Format("打印时间: {0:g}", DateTime.Now), "" });

                    Link headerLink = new Link();
                    headerLink.CreateDetailArea += new CreateAreaEventHandler(HeaderLink_CreateDetailArea);
                    compLink.Links.Add(headerLink);
                    compLink.Links.Add(treeListLink);

                    compLink.ShowRibbonPreviewDialog(treeListDesignBom.LookAndFeel);
                }
            }
            catch (Exception ex)
            {
                ExceptionHandler.HandleException(this.Text + "--预览当前设计Bom信息错误。", ex);
            }
        }
Esempio n. 3
0
        public void ExportTOExcel(string path)
        {
            CompositeLink          complink = new CompositeLink(new PrintingSystem()); //复合链路
            PrintableComponentLink link     = new PrintableComponentLink();            //可打印组件链接

            link.Component = gridControl1;
            complink.Links.Add(link);//Links:获取一个合成基对象的链接的集合;Add:添加指定的DevExpress.XtraPrinting对象到集合


            FileInfo fileInfo;


            complink.ExportToXls(path, new XlsExportOptions()
            {
                ExportMode = XlsExportMode.SingleFile, ShowGridLines = true
            });
            fileInfo = new FileInfo(path);
            //fileInfo.IsReadOnly = true;//只读文件

            //Close();
        }
Esempio n. 4
0
        private void ExportOrderHistory()
        {
            try
            {
                SplashScreenManager.ShowForm(this, typeof(Masters.WaitForm1), true, true, false);
                PrintingSystem         ps               = new PrintingSystem();
                CompositeLink          compositeLink    = new CompositeLink(ps);
                PrintableComponentLink LinkOrderhistory = new PrintableComponentLink();
                LinkOrderhistory.Component = gridControlOrderHistory;
                PrintableComponentLink LinkOrderStatusHistory = new PrintableComponentLink();
                LinkOrderStatusHistory.Component = gridControlOrderStatusHistory;

                ps.SetCommandVisibility(PrintingSystemCommand.Open, CommandVisibility.All);
                ps.SetCommandVisibility(new PrintingSystemCommand[] { PrintingSystemCommand.ExportCsv, PrintingSystemCommand.ExportTxt,
                                                                      PrintingSystemCommand.ExportXlsx, PrintingSystemCommand.ExportDocx, PrintingSystemCommand.ExportXls }, CommandVisibility.All);
                compositeLink.Links.AddRange(new object[]
                {
                    LinkOrderhistory, LinkOrderStatusHistory
                });
                string ReportName = "Order History";
                string folderPath = "C:\\Temp\\";
                string Path1      = folderPath + DateTime.Now.ToString("dd-MM-yyyy-hh-mm-ss") + "-" + ReportName + ".xlsx";
                compositeLink.CreatePageForEachLink();
                ps.XlSheetCreated += PrintingSystem_XlSheetCreated;
                compositeLink.PrintingSystem.ExportToXlsx(Path1, new XlsxExportOptions()
                {
                    ExportMode = XlsxExportMode.SingleFilePageByPage, ExportHyperlinks = false, TextExportMode = TextExportMode.Value, IgnoreErrors = XlIgnoreErrors.NumberStoredAsText
                });
                System.Diagnostics.Process.Start(Path1);
            }
            catch (Exception e)
            {
                throw e;
            }
            finally
            {
                SplashScreenManager.CloseForm(false);
            }
        }
        private void printExportItem_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            var ps       = new PrintingSystem();
            var gridLink = new PrintableComponentLink(ps)
            {
                Component = eventGrid
            };
            var schedulerLink = new PrintableComponentLink(ps)
            {
                Component = scheduler
            };
            var combinedLink = new CompositeLink(ps)
            {
                PaperKind = PaperKind.A4
            };

            combinedLink.Links.AddRange(new[] {
                schedulerLink,
                gridLink
            });

            combinedLink.ShowPreviewDialog();
        }
    private void ExportToPdf()
    {
        PrintingSystem ps = new PrintingSystem();

        PrintableComponentLink link1 = new PrintableComponentLink();

        //link1.Component = ASPxPivotGridExporter1;
        link1.PrintingSystem = ps;

        PrintableComponentLink link2 = new PrintableComponentLink();

        WebChartControl1.DataBind();
        link2.Component      = ((IChartContainer)WebChartControl1).Chart;
        link2.PrintingSystem = ps;

        CompositeLink compositeLink = new CompositeLink();

        compositeLink.Links.AddRange(new object[] { link1, link2 });
        compositeLink.PrintingSystem = ps;

        compositeLink.CreateDocument();
        compositeLink.PrintingSystem.ExportOptions.Pdf.DocumentOptions.Author = "Test";
        using (MemoryStream stream = new MemoryStream())
        {
            compositeLink.PrintingSystem.ExportToPdf(stream);
            Response.Clear();
            Response.Buffer = false;
            Response.AppendHeader("Content-Type", "application/pdf");
            Response.AppendHeader("Content-Transfer-Encoding", "binary");
            Response.AppendHeader("Content-Disposition", "attachment; filename=test.pdf");
            Response.BinaryWrite(stream.GetBuffer());
            Response.End();
        }

        ps.Dispose();
    }
Esempio n. 7
0
        private static void DefineTablesForDataInAllWorksheets(ExcelPackage excel, CompositeLink link)
        {
            for (var i = 1; i <= excel.Workbook.Worksheets.Count; i++)
            {
                var ws = excel.Workbook.Worksheets[i];

                if (ws.Dimension == null || !CanDefineTable(link, i))
                {
                    continue;
                }

                var tableRange = new ExcelAddress(ws.Dimension.Address);
                tableRange = new ExcelAddress(tableRange.Start.Row, tableRange.Start.Column,
                                              tableRange.End.Row, tableRange.End.Column);

                // Check if there is any row in the table. Otherwise, don't create one.
                if (tableRange.Start.Row != tableRange.End.Row)
                {
                    var table = ws.Tables.Add(tableRange, ws.Name);
                    table.ShowHeader = true;
                    table.TableStyle = TableStyles.Medium23;
                }
            }
        }
Esempio n. 8
0
        public void SaveDataToExcel()
        {
            CompositeLink          complink = new CompositeLink(new PrintingSystem()); //复合链路
            PrintableComponentLink link     = new PrintableComponentLink();            //可打印组件链接

            link.Component = gridControl1;
            complink.Links.Add(link);//Links:获取一个合成基对象的链接的集合;Add:添加指定的DevExpress.XtraPrinting对象到集合
            //complink.CreatePageForEachLink();

            string path = "./excel\\";

            if (!Directory.Exists(path))
            {
                Directory.CreateDirectory(path);
            }

            FileInfo fileInfo;

            if (File.Exists(path + excelName + ".xls"))
            {
                //fileInfo = new FileInfo(path + excelName + ".xls");
                //fileInfo.IsReadOnly = false;
                //fileInfo.Delete();
            }

            complink.ExportToXls(path + excelName + ".xls", new XlsExportOptions()
            {
                ExportMode = XlsExportMode.SingleFile, ShowGridLines = true
            });
            //complink.ExportToXlsx(path + casenumber + ".xlsx", new XlsxExportOptions() { ExportMode = XlsExportMode.SingleFile, ShowGridLines = true });
            fileInfo = new FileInfo(path + excelName + ".xls");
            //fileInfo.IsReadOnly = true;//只读文件
            XtraMessageBox.Show("保存成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);

            //Close();
        }
        private void xuatExcel()
        {
            string ten_cautruyvan = "";

            if (this.lookUpEditCauTruyVan.EditValue.ToString() != "Tên Câu Truy Vấn")
            {
                ten_cautruyvan = this.lookUpEditCauTruyVan.Text.ToString();
            }


            SaveFileDialog f = new SaveFileDialog();

            f.Filter   = "Excel file (*.xlsx)|*.xlsx";
            f.FileName = "PhanTichMau14a_" + ten_cautruyvan + "_" + DateTime.Now.Second.ToString() + DateTime.Now.Minute.ToString() + DateTime.Now.Hour.ToString() + DateTime.Now.Day.ToString() + DateTime.Now.Month.ToString() + DateTime.Now.Year.ToString();



            if (f.ShowDialog() == DialogResult.OK)
            {
                CompositeLink          complink = new CompositeLink(new PrintingSystem());
                PrintableComponentLink link     = new PrintableComponentLink(new PrintingSystem());
                link.Component = this.gridControlKetQua;
                link.CreateMarginalHeaderArea += new CreateAreaEventHandler(Link_CreateMarginalHeaderArea);
                complink.Links.Add(link);


                //Rename Sheet
                complink.PrintingSystem.XlSheetCreated += PrintingSystem_XlSheetCreated;
                complink.CreatePageForEachLink();
                XlsxExportOptions options = new XlsxExportOptions();
                options.ExportMode = XlsxExportMode.SingleFilePageByPage;
                complink.ExportToXlsx(f.FileName, options);

                MessageBox.Show("Xuất Excel Thành Công!");
            }
        }
Esempio n. 10
0
 protected virtual void CreateDocument(CompositeLink link)
 {
     link.CreateDocument();
 }
Esempio n. 11
0
 protected abstract bool Export(CompositeLink link, string path, ExportOptions options);
        private void truyVanTheoCSKCBVoiCacDieuKien(string _MaCSKCB)
        {
            string MaCSKCB = _MaCSKCB;

            complinkMain = new CompositeLink(new PrintingSystem());

            int soluongGridControl = this.gridViewDieuKien.GetSelectedRows().Length;

            int i_sl = 0;

            GridControl[]            gridcontrolTemps = new GridControl[soluongGridControl + 1];
            PrintableComponentLink[] linkTemps        = new PrintableComponentLink[soluongGridControl + 1];
            DataTable[] dt_Temps = new DataTable[soluongGridControl + 1];

            maDieuKiens  = new string[soluongGridControl];
            tenDieuKiens = new string[soluongGridControl];
            DieuKiens    = new string[soluongGridControl];
            string _ngayBatDau             = this.tbThoiGianBatDau.Text;
            string _ngayKetThuc            = this.tbThoiGianKetThuc.Text;
            string _menhDeWhereKyQuyetToan = "KY_QT BETWEEN " + _ngayBatDau + " AND " + _ngayKetThuc;

            _menhDeWhereKyQuyetToan = " AND (" + _menhDeWhereKyQuyetToan + ")";


            string queryTongHopTatCaCacDieuKien = "";
            int    soLuongSheet = 0;

            if (this.gridViewDieuKien.GetSelectedRows().Length > 0)
            {
                string DieuKien = "";

                //////////////////////////////////////////////////////////////////////////////////////////////////////////
                //////////////////////////////////////////////////////////////////////////////////////////////////////////
                //////////////////////////////////////////////////////////////////////////////////////////////////////////
                //Query Tổng hợp tất cả các điều kiện
                //SHEET 1 trong EXCEL xuất ra

                //Truy Vấn Theo GridControl

                /*foreach (int i in this.gridViewCSKCB.GetSelectedRows())
                 * {
                 *
                 *  string MaCSKCB = this.gridViewCSKCB.GetDataRow(i)["Mã CSKCB"].ToString();
                 * }*/
                //Truy Vấn Theo Look Up Edit
                queryTongHopTatCaCacDieuKien = traVeChuoiCacDieuKienDuocChonTheoMaCSKCB(MaCSKCB);

                //string queryTemp = "SELECT HO_TEN as 'Họ tên',MA_THE as 'Mã thẻ',NGAY_SINH as 'Ngày sinh',(CASE WHEN GIOI_TINH = '1' THEN 'Nam' ELSE 'Nu' END) as 'Giới tính',MA_DKBD as 'Mã ĐKBĐ',NGAY_VAO as 'Ngày vào',NGAY_RA as 'Ngày ra',MA_BENH as 'Mã bệnh',MA_BENHKHAC as 'Mã bệnh khác',TEN_BENH as 'Tên bệnh',ma_cp as 'Mã CP',TEN_CP as 'Tên CP',SO_LUONG_BV as 'Số lượng',don_gia as 'Đơn giá', thanh_tien as 'Thành tiền',NGAY_YL as 'Ngày y lệnh'";
                string queryTemp = "SELECT HO_TEN as 'Họ tên',MA_THE as 'Mã thẻ',NGAY_SINH as 'Ngày sinh',(CASE WHEN GIOI_TINH = '1' THEN 'Nam' ELSE 'Nu' END) as 'Giới tính',MA_DKBD as 'Mã ĐKBĐ',NGAY_VAO as 'Ngày vào',NGAY_RA as 'Ngày ra',MA_BENH as 'Mã bệnh',MA_BENHKHAC as 'Mã bệnh khác',TEN_BENH as 'Tên bệnh'";
                for (int j = 0; j < maDieuKiens.Length; j++)
                {
                    //queryTemp = queryTemp + ", SUM(" + '"' + maDieuKiens[j] + '"' + ") as " + "'" + maDieuKiens[j] + "'";
                    queryTemp = queryTemp + ",( CASE WHEN SUM(" + '"' + maDieuKiens[j] + '"' + ") >= 1 THEN 'x' ELSE '' END) as " + "'" + maDieuKiens[j] + "'";

                    //(CASE WHEN GIOI_TINH = '1' THEN 'Nam' ELSE 'Nu' END) as 'Giới tính'
                }

                //queryTongHopTatCaCacDieuKien = queryTemp + " FROM " + "(" + queryTongHopTatCaCacDieuKien + ")" + " as test GROUP BY HO_TEN,MA_THE,NGAY_SINH,GIOI_TINH,MA_DKBD,NGAY_VAO,NGAY_RA,MA_BENH,MA_BENHKHAC,TEN_BENH,ma_cp,TEN_CP,SO_LUONG_BV,don_gia, thanh_tien,NGAY_YL";

                queryTongHopTatCaCacDieuKien = queryTemp + " FROM " + "(" + queryTongHopTatCaCacDieuKien + ")" + " as test GROUP BY HO_TEN,MA_THE,NGAY_SINH,GIOI_TINH,MA_DKBD,NGAY_VAO,NGAY_RA,MA_BENH,MA_BENHKHAC,TEN_BENH";

                SqlConnection conn = DBUtils.GetDBConnection();
                conn.Open();
                try
                {
                    dt_Temps[soluongGridControl] = DBUtils.GetDBTable(queryTongHopTatCaCacDieuKien, conn);
                    DataColumn Col = dt_Temps[soluongGridControl].Columns.Add("STT");
                    Col.SetOrdinal(0);
                    for (int i = 0; i < dt_Temps[soluongGridControl].Rows.Count; i++)
                    {
                        dt_Temps[soluongGridControl].Rows[i]["STT"] = i + 1;
                    }

                    if (dt_Temps[soluongGridControl].Rows.Count > 0)
                    {
                        gridcontrolTemps[soluongGridControl] = new GridControl();
                        gridcontrolTemps[soluongGridControl].BindingContext = new System.Windows.Forms.BindingContext();
                        gridcontrolTemps[soluongGridControl].DataSource     = dt_Temps[soluongGridControl];

                        //Hiển thị gridcontrol
                        this.gridViewKetQua.Columns.Clear();
                        this.gridControlKetQua.DataSource = gridcontrolTemps[soluongGridControl].DataSource;;
                        this.gridControlKetQua.Refresh();

                        Form frm = new Form();
                        frm.Controls.Add(gridcontrolTemps[soluongGridControl]);
                        gridcontrolTemps[soluongGridControl].ForceInitialize();


                        linkTemps[soluongGridControl]           = new PrintableComponentLink(new PrintingSystem());
                        linkTemps[soluongGridControl].Component = gridcontrolTemps[soluongGridControl];
                        linkTemps[soluongGridControl].CreateMarginalHeaderArea += new CreateAreaEventHandler(Link_CreateMarginalHeaderArea);


                        complinkMain.Links.Add(linkTemps[soluongGridControl]);
                    }
                }
                catch (SqlException ex)
                {
                    MessageBox.Show("Error: " + ex.ToString());
                }
                finally
                {
                    conn.Close();
                    conn.Dispose();
                }
                //////////////////////////////////////////////////////////////////////////////////////////////////////////
                //////////////////////////////////////////////////////////////////////////////////////////////////////////
                //////////////////////////////////////////////////////////////////////////////////////////////////////////



                /////////////////////////////////////////////
                string query = "";
                foreach (int j in this.gridViewDieuKien.GetSelectedRows())
                {
                    //BẮT ĐẦU ĐIỀU KIỆN
                    DieuKien = this.gridViewDieuKien.GetDataRow(j)["Điều Kiện"].ToString() + _menhDeWhereKyQuyetToan;

                    maDieuKiens[i_sl]  = this.gridViewDieuKien.GetDataRow(j)["Mã Điều Kiện"].ToString();
                    tenDieuKiens[i_sl] = this.gridViewDieuKien.GetDataRow(j)["Tên Tiêu Chí"].ToString();


                    /*Truy vấn theo nhiều Cơ sở khám chữa bệnh + Grid Control
                     * query = "";
                     * if (this.gridViewCSKCB.GetSelectedRows().Length > 0)
                     * {
                     *  bool flag_MaCSKCB = true;
                     *  //MessageBox.Show("Sl CSKCB: " + this.gridViewCSKCB.GetSelectedRows().Length.ToString());
                     *  foreach (int i in this.gridViewCSKCB.GetSelectedRows())
                     *  {
                     *      string MaCSKCB = this.gridViewCSKCB.GetDataRow(i)["Mã CSKCB"].ToString();
                     *      //query = "(SELECT HO_TEN as 'Họ tên',MA_THE as 'Mã thẻ',NGAY_SINH as 'Ngày sinh',(CASE WHEN GIOI_TINH='1' THEN 'Nam' ELSE 'Nu' END) as 'Giới tính',MA_DKBD as 'Mã ĐKBĐ',NGAY_VAO as 'Ngày vào',NGAY_RA as 'Ngày ra',MA_BENH as 'Mã bệnh',MA_BENHKHAC as 'Mã bệnh khác',TEN_BENH as 'Tên bệnh',ma_cp as 'Mã CP',TEN_CP as 'Tên CP',SO_LUONG_BV as 'Số lượng',don_gia as 'Đơn giá', thanh_tien as 'Thành tiền',NGAY_YL as 'Ngày y lệnh' FROM xml123_" + MaCSKCB + " WHERE " + DieuKien + ")";
                     *      if (flag_MaCSKCB)
                     *      {
                     *          flag_MaCSKCB = false;
                     *          query = "(SELECT HO_TEN as 'Họ tên',MA_THE as 'Mã thẻ',NGAY_SINH as 'Ngày sinh',(CASE WHEN GIOI_TINH='1' THEN 'Nam' ELSE 'Nu' END) as 'Giới tính',MA_DKBD as 'Mã ĐKBĐ',NGAY_VAO as 'Ngày vào',NGAY_RA as 'Ngày ra',MA_BENH as 'Mã bệnh',MA_BENHKHAC as 'Mã bệnh khác',TEN_BENH as 'Tên bệnh',ma_cp as 'Mã CP',TEN_CP as 'Tên CP',SO_LUONG_BV as 'Số lượng',don_gia as 'Đơn giá', thanh_tien as 'Thành tiền',NGAY_YL as 'Ngày y lệnh' FROM xml123_" + MaCSKCB + " WHERE " + DieuKien + ")";
                     *
                     *      }
                     *      else
                     *      {
                     *          query = query + " UNION (SELECT HO_TEN as 'Họ tên',MA_THE as 'Mã thẻ',NGAY_SINH as 'Ngày sinh',(CASE WHEN GIOI_TINH='1' THEN 'Nam' ELSE 'Nu' END) as 'Giới tính',MA_DKBD as 'Mã ĐKBĐ',NGAY_VAO as 'Ngày vào',NGAY_RA as 'Ngày ra',MA_BENH as 'Mã bệnh',MA_BENHKHAC as 'Mã bệnh khác',TEN_BENH as 'Tên bệnh',ma_cp as 'Mã CP',TEN_CP as 'Tên CP',SO_LUONG_BV as 'Số lượng',don_gia as 'Đơn giá', thanh_tien as 'Thành tiền',NGAY_YL as 'Ngày y lệnh' FROM xml123_" + MaCSKCB + " WHERE " + DieuKien + ")";
                     *      }
                     *  }
                     *
                     *
                     * }
                     * else
                     * {
                     *  MessageBox.Show("Chưa Chọn Cơ Sở KCB");
                     * }
                     */////////////////////////////////////////////////////////////////////////////////////////////////

                    /*Truy vấn theo 1 Cơ sở khám chữa bệnh + Look Up Edit*/
                    query = "(SELECT HO_TEN as 'Họ tên',MA_THE as 'Mã thẻ',NGAY_SINH as 'Ngày sinh',(CASE WHEN GIOI_TINH='1' THEN 'Nam' ELSE 'Nu' END) as 'Giới tính',MA_DKBD as 'Mã ĐKBĐ',NGAY_VAO as 'Ngày vào',NGAY_RA as 'Ngày ra',MA_BENH as 'Mã bệnh',MA_BENHKHAC as 'Mã bệnh khác',TEN_BENH as 'Tên bệnh',ma_cp as 'Mã CP',TEN_CP as 'Tên CP',SO_LUONG_BV as 'Số lượng',don_gia as 'Đơn giá', thanh_tien as 'Thành tiền',NGAY_YL as 'Ngày y lệnh' FROM xml123_" + MaCSKCB + " WHERE " + DieuKien + ")";
                    //////////////////////////////////////////////////////////////////////////////////////////////////

                    //Gridv
                    conn = DBUtils.GetDBConnection();
                    conn.Open();
                    try
                    {
                        dt_Temps[i_sl] = DBUtils.GetDBTable(query, conn);
                        DataColumn Col = dt_Temps[i_sl].Columns.Add("STT");
                        Col.SetOrdinal(0);
                        for (int i = 0; i < dt_Temps[i_sl].Rows.Count; i++)
                        {
                            dt_Temps[i_sl].Rows[i]["STT"] = i + 1;
                        }

                        //MessageBox.Show(dt_Temps[i_sl].Rows.Count.ToString());

                        if (dt_Temps[i_sl].Rows.Count > 0)
                        {
                            gridcontrolTemps[i_sl] = new GridControl();
                            gridcontrolTemps[i_sl].BindingContext = new System.Windows.Forms.BindingContext();
                            gridcontrolTemps[i_sl].DataSource     = dt_Temps[i_sl];

                            Form frm = new Form();
                            frm.Controls.Add(gridcontrolTemps[i_sl]);
                            gridcontrolTemps[i_sl].ForceInitialize();

                            linkTemps[i_sl]           = new PrintableComponentLink(new PrintingSystem());
                            linkTemps[i_sl].Component = gridcontrolTemps[i_sl];

                            //Bảng đổi tên
                            soLuongSheets[soLuongSheet]           = tenDieuKiens[i_sl];
                            soLuongMaDieuKienSheets[soLuongSheet] = maDieuKiens[i_sl];
                            soLuongSheet++;
                            linkTemps[i_sl].CreateMarginalHeaderArea += new CreateAreaEventHandler(Link_CreateMarginalHeaderArea);

                            complinkMain.Links.Add(linkTemps[i_sl]);
                        }
                    }
                    catch (SqlException ex)
                    {
                        MessageBox.Show("Error: " + ex.ToString());
                    }
                    finally
                    {
                        conn.Close();
                        conn.Dispose();
                    }

                    //KẾT THÚC ĐIỀU KIỆN
                    i_sl++;
                }
            }//END
            MessageBox.Show("Truy vấn xong!");
        }
Esempio n. 13
0
        public void CreateReport()
        {
            var link = new CompositeLink(new PrintingSystem());

            var link1 = new PrintableComponentLink();
            var pcLink1 = new PrintableComponentLink();
            var footer = new PageFooterArea();
            footer.Content.Add("Printed on " + "[Date Printed]" + " by " + Utils.Username);
            footer.LineAlignment = BrickAlignment.Near;
            var header = new PageHeaderArea();
            link.CreateMarginalHeaderArea += CreateMarginalHeaderArea;
            link.PageHeaderFooter = new PageHeaderFooter(header, footer);
            link.PrintingSystem.SetCommandVisibility(PrintingSystemCommand.Save, CommandVisibility.None);
            link.PrintingSystem.SetCommandVisibility(PrintingSystemCommand.Watermark, CommandVisibility.None);
            link.PrintingSystem.SetCommandVisibility(PrintingSystemCommand.FillBackground, CommandVisibility.None);
            link.PrintingSystem.SetCommandVisibility(PrintingSystemCommand.HandTool, CommandVisibility.None);
            link.PrintingSystem.SetCommandVisibility(PrintingSystemCommand.Open, CommandVisibility.None);
            link.PrintingSystem.SetCommandVisibility(PrintingSystemCommand.Customize, CommandVisibility.None);
            link.PrintingSystem.SetCommandVisibility(PrintingSystemCommand.Scale, CommandVisibility.None);
            link.PrintingSystem.SetCommandVisibility(PrintingSystemCommand.Parameters, CommandVisibility.None);
            link.PrintingSystem.SetCommandVisibility(PrintingSystemCommand.SubmitParameters, CommandVisibility.None);
            link.PrintingSystem.SetCommandVisibility(PrintingSystemCommand.Background, CommandVisibility.None);
            link.PrintingSystem.SetCommandVisibility(PrintingSystemCommand.None, CommandVisibility.None);
            link.PrintingSystem.SetCommandVisibility(PrintingSystemCommand.DocumentMap, CommandVisibility.None);
  


            link.PrintingSystem.PreviewRibbonFormEx.RibbonControl.Pages["Print Preview"].Groups["Document"].Visible = false;
            link.PrintingSystem.PreviewRibbonFormEx.RibbonControl.Pages["Print Preview"].Groups["Background"].Visible =false;
            link.PrintingSystem.PreviewRibbonFormEx.RibbonControl.Pages["Print Preview"].Groups["Zoom"].Visible =false;


            link.Margins.Left = 100;
            link.Margins.Right = 100;
            link.Margins.Top = 100;
            link.Margins.Bottom = 90;
            link.PaperKind = PaperKind.A4;

            var linkGrid1Report = new Link();
            linkGrid1Report.CreateDetailArea += linkGrid1Report_CreateDetailArea;


            var linkGrid2Report = new Link();

           // link.PrintingSystem.Document.AutoFitToPagesWidth = 1;

            link1.Component = gridControl1;
            

             
            link.Links.Add(link1);

            link.Links.Add(linkGrid1Report);
            pcLink1.Component = gridControl2;
            link.Links.Add(pcLink1);
            

            link.CreateDocument();

            //if (string.IsNullOrEmpty(watermark))
            //    link.PrintingSystemBase.Watermark.Text = "Draft";
            //else
            //{
            //    link.PrintingSystemBase.Watermark.Text = "watermark";
            //}
            link.ShowRibbonPreview(UserLookAndFeel.Default);


        }
 private void m_cmd_xuat_pdf_Click(object sender, EventArgs e)
 {
     try
     {
         DevExpress.XtraPrinting.PrintingSystem ps = new DevExpress.XtraPrinting.PrintingSystem();
         CompositeLink cl = new CompositeLink(ps);
         PrintableComponentLink pclChart = new PrintableComponentLink();
         PrintableComponentLink pclPivot = new PrintableComponentLink();
         pclChart.Component = chartControl1;
         pclPivot.Component = m_pivot_ty_le_qua_mon;
         cl.Links.AddRange(new object[] { pclChart, pclPivot });
         cl.ShowPreviewDialog();
         cl.PrintingSystem.ExportToPdf(Application.StartupPath + "\\..\\..\\BaoCao.pdf");
     }
     catch
     {
         MessageBox.Show("Đã xảy ra lỗi hệ thống!");
     }
 }
Esempio n. 15
0
        private void previewToolStripMenuItem_Click_1(object sender, EventArgs e)
        {
            CompositeLink compositeLink = CreateCompositeLink(pivotGridControl1, chartControl1);

            compositeLink.ShowPreview();
        }
Esempio n. 16
0
        /// <summary>
        /// DevExpress通用导出Excel,支持多个控件同时导出在同一个Sheet表
        /// eg:ExportToXlsx("",gridControl1,gridControl2);
        /// 将gridControl1和gridControl2的数据一同导出到同一张工作表
        /// </summary>
        /// <param name="title">文件名</param>
        /// <param name="panels">控件集</param>
        public static void ExportToExcel(string title, params IPrintable [] panels)
        {
            SaveFileDialog saveFileDialog = new SaveFileDialog( );

            saveFileDialog.FileName = title;
            saveFileDialog.Title    = "导出Excel";
            saveFileDialog.Filter   = "Excel文件(*.xlsx)|*.xlsx|Excel文件(*.xls)|*.xls";
            DialogResult dialogResult = saveFileDialog.ShowDialog( );

            if (dialogResult == DialogResult.Cancel)
            {
                return;
            }
            string         FileName = saveFileDialog.FileName;
            PrintingSystem ps       = new PrintingSystem( );
            CompositeLink  link     = new CompositeLink(ps);

            ps.Links.Add(link);
            foreach (IPrintable panel in panels)
            {
                link.Links.Add(CreatePrintableLink(panel));
            }
            link.Landscape = true;  //横向
            //判断是否有标题,有则设置
            //link.CreateDocument(); //建立文档
            try
            {
                int count = 1;
                //在重复名称后加(序号)
                while (File.Exists(FileName))
                {
                    if (FileName.Contains(")."))
                    {
                        int start = FileName.LastIndexOf("(");
                        int end   = FileName.LastIndexOf(").") - FileName.LastIndexOf("(") + 2;
                        FileName = FileName.Replace(FileName.Substring(start, end), string.Format("({0}).", count));
                    }
                    else
                    {
                        FileName = FileName.Replace(".", string.Format("({0}).", count));
                    }
                    count++;
                }

                if (FileName.LastIndexOf(".xlsx") >= FileName.Length - 5)
                {
                    XlsxExportOptions options = new XlsxExportOptions( );
                    link.ExportToXlsx(FileName, options);
                }
                else
                {
                    XlsExportOptions options = new XlsExportOptions( );
                    link.ExportToXls(FileName, options);
                }
                if (DevExpress.XtraEditors.XtraMessageBox.Show("保存成功,是否打开文件?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes)
                {
                    System.Diagnostics.Process.Start(FileName);         //打开指定路径下的文件
                }
            }
            catch (Exception ex)
            {
                DevExpress.XtraEditors.XtraMessageBox.Show(ex.Message);
            }
        }
Esempio n. 17
0
 protected override bool Export(CompositeLink link, string path, ExportOptions options)
 {
     link.ExportToPdf(path, new PdfExportOptions());
     return(true);
 }
Esempio n. 18
0
        private void exportToolStripMenuItem_Click(object sender, EventArgs e)
        {
            CompositeLink          cLink = new CompositeLink(new PrintingSystem());
            PrintableComponentLink pcl1  = new PrintableComponentLink();

            pcl1.Component = accExtreGridControl;
            PrintableComponentLink pcl2 = new PrintableComponentLink();

            pcl2.Component = accExtreOztGridControl;

            cLink.Links.Add(pcl1);
            cLink.Links.Add(pcl2);

            cLink.PaperKind      = System.Drawing.Printing.PaperKind.A4;
            cLink.Landscape      = true;
            cLink.Margins.Left   = 50;
            cLink.Margins.Right  = 50;
            cLink.Margins.Top    = 50;
            cLink.Margins.Bottom = 50;

            var Font = new Font("Tahoma", 12, FontStyle.Bold);

            PageHeaderFooter phf  = cLink.PageHeaderFooter as PageHeaderFooter;
            string           mdlH = string.Format("{0} Firma Extresi [{1:dd.MM.yyyy} - {2:dd.MM.yyyy}]", firma, dateEdit1.DateTime, dateEdit2.DateTime.AddDays(-1));

            //string mdlH = string.Format("{0} {1:MMMM yyyy} Ekstresi", firma, dateEdit1.DateTime);
            phf.Header.Content.AddRange(new string[] { "", mdlH, "" });
            phf.Header.LineAlignment = BrickAlignment.Far;
            phf.Header.Font          = Font;

            phf.Footer.Content.AddRange(new string[] { "[Date Printed] [Time Printed]", "", Program.USR });
            phf.Footer.LineAlignment = BrickAlignment.Near;

            cLink.ShowPreviewDialog();

            /*
             * PrintingSystem ps = new PrintingSystem();
             * PrintableComponentLink link = new PrintableComponentLink();
             * link.Component = accExtreGridControl;
             * PrintableComponentLink link2 = new PrintableComponentLink();
             * link2.Component = accExtreOzetGridControl;
             * ps.Links.Add(link);
             * ps.Links.Add(link2);
             *
             *
             * link.PaperKind = System.Drawing.Printing.PaperKind.A4;
             * link.Landscape = false;
             * link.Margins.Left = 50;
             * link.Margins.Right = 50;
             * link.Margins.Top = 50;
             * link.Margins.Bottom = 50;
             *
             * var Font = new Font("Tahoma", 12, FontStyle.Bold);
             *
             * PageHeaderFooter phf = link.PageHeaderFooter as PageHeaderFooter;
             * string mdlH = string.Format("Firma Extre");
             * phf.Header.Content.AddRange(new string[] { "", mdlH, "" });
             * phf.Header.LineAlignment = BrickAlignment.Far;
             * phf.Header.Font = Font;
             *
             * phf.Footer.Content.AddRange(new string[] { "[Date Printed] [Time Printed]", "", Program.USR });
             * phf.Footer.LineAlignment = BrickAlignment.Near;
             *
             * link.CreateDocument();
             * link.ShowPreview();*/
        }
Esempio n. 19
0
        public static void PrintPreview(ChartControl chartControl, GridControl grid)
        {
            chartControl.OptionsPrint.SizeMode = DevExpress.XtraCharts.Printing.PrintSizeMode.Zoom;
            CompositeLink composLink = new CompositeLink(new PrintingSystem());
            PrintableComponentLink pcLink1 = new PrintableComponentLink();
            PrintableComponentLink pcLink2 = new PrintableComponentLink();
            Link linkMainReport = new Link();

            linkMainReport.CreateDetailArea += new CreateAreaEventHandler(linkMainReport_CreateDetailArea);
            Link linkGrid1Report = new Link();
            linkGrid1Report.CreateDetailArea += new CreateAreaEventHandler(linkGrid1Report_CreateDetailArea);
            Link linkGrid2Report = new Link();
            linkGrid2Report.CreateDetailArea += new CreateAreaEventHandler(linkChartReport_CreateDetailArea);

            pcLink1.Component = grid;
            pcLink2.Component = chartControl;

            composLink.Links.Add(linkGrid2Report);
            composLink.Links.Add(pcLink2);
            composLink.Links.Add(linkGrid1Report);
            composLink.Links.Add(pcLink1);
            composLink.Links.Add(linkMainReport);
            composLink.ShowPreviewDialog();
        }
        private void m_cmd_xuat_pdf_Click(object sender, EventArgs e)
        {
            try
            {
                DevExpress.XtraPrinting.PrintingSystem ps = new DevExpress.XtraPrinting.PrintingSystem();
                CompositeLink cl = new CompositeLink(ps);
                PrintableComponentLink pclChart = new PrintableComponentLink();
                PrintableComponentLink pclPivot = new PrintableComponentLink();
                pclChart.Component = m_chart_gpa_cpa;
                pclPivot.Component = m_pivot_kq_sinh_vien;
                cl.Links.AddRange(new object[] { pclChart, pclPivot });
                cl.ShowPreviewDialog();
                cl.PrintingSystem.ExportToPdf(Application.StartupPath + "\\..\\..\\CPA_GPA.pdf");

            }
            catch (Exception v)
            {

                MessageBox.Show("Đã xảy ra lỗi hệ thống!");
            }
        }
Esempio n. 21
0
        /// <summary>
        /// 匯出Excel
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected override void ToExcelButton_Click(object sender, EventArgs e)
        {
            base.ToExcelButton_Click(sender, e);
            if (tabControl1.SelectedIndex == 0)
            {
                if (gridView1.RowCount <= 0)
                {
                    MessageBox.Show("無內容,請重新查詢", "取消儲存");
                    return;
                }
            }
            else
            {
                if (gridView3.RowCount <= 0)
                {
                    MessageBox.Show("無內容,請重新查詢", "取消儲存");
                    return;
                }
            }
            SaveFileDialog OFD = new SaveFileDialog();

            OFD.InitialDirectory = "D:\\";
            OFD.RestoreDirectory = true;
            OFD.Title            = "儲存檔案";
            OFD.DefaultExt       = "xls";
            OFD.Filter           = "Microsoft Office Excel 活頁簿 (*.xls)|*.xls";

            GridControl[] grids;

            if (tabControl1.SelectedIndex == 0)
            {
                //合併兩個gridcontrol到同一個報表
                grids = new GridControl[] { gridControl1 };
            }
            else
            {
                grids = new GridControl[] { gridControl3 };
            }

            OFD.FileName = FileName_OutPutExcel;
            DialogResult chooseOutPut = OFD.ShowDialog();

            if (chooseOutPut == DialogResult.Cancel)
            {
                return;
            }

            //gridview排版
            gridView1.OptionsView.ColumnAutoWidth = false;
            gridView1.OptionsPrint.AutoWidth      = false;
            gridView1.BestFitColumns();
            gridView2.OptionsView.ColumnAutoWidth = false;
            gridView2.OptionsPrint.AutoWidth      = false;
            gridView2.BestFitColumns();
            gridView3.OptionsView.ColumnAutoWidth = false;
            gridView3.OptionsPrint.AutoWidth      = false;
            gridView3.BestFitColumns();
            gridView1.AppearancePrint.Row.Font            = new Font("Arial Unicode MS", 12);
            gridView1.AppearancePrint.Row.Options.UseFont = true;
            gridView2.AppearancePrint.Row.Font            = new Font("Arial Unicode MS", 12);
            gridView2.AppearancePrint.Row.Options.UseFont = true;
            gridView3.AppearancePrint.Row.Font            = new Font("Arial Unicode MS", 12);
            gridView3.AppearancePrint.Row.Options.UseFont = true;

            PrintingSystem ps            = new PrintingSystem();
            CompositeLink  compositeLink = new CompositeLink();

            compositeLink.PrintingSystem = ps;

            foreach (GridControl gc in grids)
            {
                PrintableComponentLink link = new PrintableComponentLink();
                link.Component = gc;

                compositeLink.Links.Add(link);
            }
            compositeLink.CreateDocument();

            //準備輸出
            DevExpress.XtraPrinting.XlsExportOptions XEO = new DevExpress.XtraPrinting.XlsExportOptions();
            XEO.TextExportMode = DevExpress.XtraPrinting.TextExportMode.Text;
            XEO.ExportMode     = XlsExportMode.SingleFile;
            XEO.SheetName      = FileName_OutPutExcel;

            DevExpress.XtraPrinting.PdfExportOptions PEO = new PdfExportOptions();
            //PEO.PasswordSecurityOptions.OpenPassword = "******";

            #region 檢查檔案是否能寫入
            bool IsFileLocked = false;
            if (File.Exists(OFD.FileName))
            {
                FileInfo   filepath = new FileInfo(OFD.FileName);
                FileStream steam    = null;
                try
                {
                    steam = filepath.Open(FileMode.Open, FileAccess.ReadWrite, FileShare.None);
                }
                catch (IOException e1)
                {
                    IsFileLocked = true;
                }
                finally
                {
                    if (steam != null)
                    {
                        steam.Close();
                    }
                }
            }
            #endregion
            if (IsFileLocked)
            {
                MessageBox.Show("檔案被鎖定,請檢查是否有其他程式正在開啟", "匯出失敗");
                return;
            }
            compositeLink.ExportToXls(OFD.FileName, XEO);
            //gridView1.ExportToXls(OFD.FileName, XEO);
            MessageBox.Show("檔案匯出至 " + OFD.FileName + " 完畢", "匯出成功");

            //gridview排版
            gridView1.OptionsView.ColumnAutoWidth = true;
            gridView1.OptionsPrint.AutoWidth      = true;
            gridView1.BestFitColumns();
            gridView2.OptionsView.ColumnAutoWidth = true;
            gridView2.OptionsPrint.AutoWidth      = true;
            gridView2.BestFitColumns();
            gridView3.OptionsView.ColumnAutoWidth = true;
            gridView3.OptionsPrint.AutoWidth      = true;
            gridView3.BestFitColumns();
        }
Esempio n. 22
0
        private void btnPrintAsPdf_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            this.Cursor        = Cursors.WaitCursor;
            this.UseWaitCursor = true;
            //ProdPrint
            if (tcMain.SelectedTab.Name == "tpProd")
            {
                checkDirectory();
                fileName = "-Production";
                checkPdf();

                CompositeLink          comp  = new CompositeLink(new PrintingSystem());
                PrintableComponentLink link1 = new PrintableComponentLink();
                PrintableComponentLink link2 = new PrintableComponentLink();
                link1.Component = gcProd;
                link1.CreateReportHeaderArea += new CreateAreaEventHandler(link1_CreateReportHeaderArea);
                comp.Links.Add(link2);
                comp.Links.Add(link1);
                comp.Landscape = true;
                comp.PaperKind = System.Drawing.Printing.PaperKind.A2;
                comp.ExportToPdf(pdfName);
            }

            if (tcMain.SelectedTab.Name == "tpTramming")
            {
                //TrammingPrint
                checkDirectory();
                fileName = "-Tramming";
                checkPdf();

                CompositeLink          comp  = new CompositeLink(new PrintingSystem());
                PrintableComponentLink link1 = new PrintableComponentLink();
                PrintableComponentLink link2 = new PrintableComponentLink();
                link1.Component = gcTramming;
                link1.CreateReportHeaderArea += new CreateAreaEventHandler(link1_CreateReportHeaderArea);
                comp.Links.Add(link2);
                comp.Links.Add(link1);
                comp.Landscape = true;
                comp.PaperKind = System.Drawing.Printing.PaperKind.A2;
                comp.ExportToPdf(pdfName);
            }

            if (tcMain.SelectedTab.Name == "tpSB")
            {
                //SBPrint
                checkDirectory();
                fileName = "-ShiftBoss";
                checkPdf();

                CompositeLink          comp  = new CompositeLink(new PrintingSystem());
                PrintableComponentLink link1 = new PrintableComponentLink();
                PrintableComponentLink link2 = new PrintableComponentLink();
                link1.Component = gcSB;
                link1.CreateReportHeaderArea += new CreateAreaEventHandler(link1_CreateReportHeaderArea);
                comp.Links.Add(link2);
                comp.Links.Add(link1);
                comp.Landscape = true;
                comp.PaperKind = System.Drawing.Printing.PaperKind.A2;
                comp.ExportToPdf(pdfName);
            }
            this.Cursor        = Cursors.Default;
            this.UseWaitCursor = false;
            acControl.Show(frmMain.ActiveForm, "Print Completed", "Click on folder to open");
            //RemovedCode2
        }
Esempio n. 23
0
 protected override bool Export(CompositeLink link, string path, ExportOptions options)
 {
     link.ShowPreview();
     return(true);
 }
        private void btnTruyVan_Click(object sender, EventArgs e)
        {
            tenCSKCB     = "";
            complinkMain = new CompositeLink(new PrintingSystem());
            int soluongGridControl = soluongLookupEdit;
            int i_sl = 0;

            GridControl[]            gridcontrolTemps = new GridControl[soluongGridControl + 1];
            PrintableComponentLink[] linkTemps        = new PrintableComponentLink[soluongGridControl + 1];
            DataTable[] dt_Temps = new DataTable[soluongGridControl + 1];

            int soLuongSheet = 0;

            maDieuKiens  = new string[soluongGridControl];
            tenDieuKiens = new string[soluongGridControl];
            DieuKiens    = new string[soluongGridControl];


            if (this.lookUpEditCSKCB.EditValue.ToString() != "Tên CSKCB")
            {
                if (this.lookUpEditCSKCB.Text == "Tất cả CSKCB")
                {
                    flag_excel = false;
                    string query = "select table_name from information_schema.tables where table_name like '%xml123_%' and table_name not like 'xml123_dtdi'";


                    SqlConnection conn = DBUtils.GetDBConnection();
                    conn.Open();
                    try
                    {
                        DataTable _dt_schema_table = DBUtils.GetDBTable(query, conn);

                        if (_dt_schema_table.Rows.Count > 0)
                        {
                            string temp            = "";
                            string temp_cautruyvan = "";
                            if (this.lookUpEditCauTruyVan.EditValue.ToString() != "Tất cả điều kiện")
                            {
                                //Code
                                string _ngayBatDau  = this.tbThoiGianBatDau.Text;
                                string _ngayKetThuc = this.tbThoiGianKetThuc.Text;
                                string _CauTruyVan  = this.lookUpEditCauTruyVan.EditValue.ToString();
                                _CauTruyVan     = _CauTruyVan.Replace("_ngaybatdau_", _ngayBatDau);
                                _CauTruyVan     = _CauTruyVan.Replace("_ngayketthuc_", _ngayKetThuc);
                                temp_cautruyvan = _CauTruyVan;
                                temp            = temp_cautruyvan.Replace("xml123", _dt_schema_table.Rows[0][0].ToString());

                                if (_dt_schema_table.Rows.Count > 1)
                                {
                                    for (int i = 1; i < _dt_schema_table.Rows.Count; i++)
                                    {
                                        temp_cautruyvan = _CauTruyVan;
                                        string _MaCSKCB = _dt_schema_table.Rows[i][0].ToString();
                                        temp = temp + " UNION ALL " + temp_cautruyvan.Replace("xml123", _MaCSKCB);
                                    }
                                }
                                //MessageBox.Show(temp);

                                DataTable dt_alllll = DBUtils.GetDBTable(temp, conn);
                                this.gridControlKetQua.DataSource = dt_alllll;
                            }
                            else
                            {
                                MessageBox.Show("Không được chọn tất cả các điều kiện!", "Thông báo!", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            }
                        }
                    }
                    catch (SqlException ex)
                    {
                        MessageBox.Show("Error: " + ex.ToString());
                    }
                    finally
                    {
                        conn.Close();
                        conn.Dispose();
                    }
                }
                else //Từng cơ sở khám chữa bệnh
                {
                    string _MaCSKCB = this.lookUpEditCSKCB.EditValue.ToString();

                    tenCSKCB = _MaCSKCB;
                    _MaCSKCB = "xml123_" + _MaCSKCB;
                    if (this.lookUpEditCauTruyVan.EditValue.ToString() != "Tất cả điều kiện")
                    {
                        flag_excel = false;
                        //Code
                        string _ngayBatDau  = this.tbThoiGianBatDau.Text;
                        string _ngayKetThuc = this.tbThoiGianKetThuc.Text;
                        string _CauTruyVan  = this.lookUpEditCauTruyVan.EditValue.ToString();
                        _CauTruyVan = _CauTruyVan.Replace("_ngaybatdau_", _ngayBatDau);
                        _CauTruyVan = _CauTruyVan.Replace("_ngayketthuc_", _ngayKetThuc);
                        _CauTruyVan = _CauTruyVan.Replace("xml123", _MaCSKCB);

                        SqlConnection conn = DBUtils.GetDBConnection();
                        conn.Open();
                        try
                        {
                            DataTable dt = DBUtils.GetDBTable(_CauTruyVan, conn);
                            this.gridControlKetQua.DataSource = dt;
                        }
                        catch (SqlException ex)
                        {
                            MessageBox.Show("Error: " + ex.ToString());
                        }
                        finally
                        {
                            conn.Close();
                            conn.Dispose();
                        }
                    }
                    else //Chọn tất cả các câu truy vấn.
                    {
                        flag_excel = true;

                        /*
                         * ****************************************************
                         * ****************************************************
                         * ****************************************************
                         * ****************************************************
                         * ****************************************************
                         * ****************************************************
                         * ****************************************************
                         */

                        //MessageBox.Show(dtBangDieuKien.Rows.Count.ToString());


                        string DieuKien = "";
                        string query    = "";
                        for (int j = 0; j < dtBangDieuKien.Rows.Count - 1; j++)
                        {
                            string _ngayBatDau  = this.tbThoiGianBatDau.Text;
                            string _ngayKetThuc = this.tbThoiGianKetThuc.Text;
                            string _CauTruyVan  = dtBangDieuKien.Rows[j][2].ToString();
                            _CauTruyVan = _CauTruyVan.Replace("_ngaybatdau_", _ngayBatDau);
                            _CauTruyVan = _CauTruyVan.Replace("_ngayketthuc_", _ngayKetThuc);
                            _CauTruyVan = _CauTruyVan.Replace("xml123", _MaCSKCB);

                            query    = _CauTruyVan;
                            DieuKien = _CauTruyVan;

                            maDieuKiens[i_sl]  = dtBangDieuKien.Rows[j][0].ToString();
                            tenDieuKiens[i_sl] = dtBangDieuKien.Rows[j][1].ToString();

                            //Gridv
                            SqlConnection conn = DBUtils.GetDBConnection();
                            conn.Open();
                            try
                            {
                                dt_Temps[i_sl] = DBUtils.GetDBTable(query, conn);
                                DataColumn Col = dt_Temps[i_sl].Columns.Add("STT");
                                Col.SetOrdinal(0);
                                for (int i = 0; i < dt_Temps[i_sl].Rows.Count; i++)
                                {
                                    dt_Temps[i_sl].Rows[i]["STT"] = i + 1;
                                }

                                //MessageBox.Show(dt_Temps[i_sl].Rows.Count.ToString());

                                if (dt_Temps[i_sl].Rows.Count > 0)
                                {
                                    gridcontrolTemps[i_sl] = new GridControl();
                                    gridcontrolTemps[i_sl].BindingContext = new System.Windows.Forms.BindingContext();
                                    gridcontrolTemps[i_sl].DataSource     = dt_Temps[i_sl];

                                    Form frm = new Form();
                                    frm.Controls.Add(gridcontrolTemps[i_sl]);
                                    gridcontrolTemps[i_sl].ForceInitialize();

                                    linkTemps[i_sl]           = new PrintableComponentLink(new PrintingSystem());
                                    linkTemps[i_sl].Component = gridcontrolTemps[i_sl];

                                    //Bảng đổi tên
                                    soLuongSheets[soLuongSheet]           = tenDieuKiens[i_sl];
                                    soLuongMaDieuKienSheets[soLuongSheet] = maDieuKiens[i_sl];
                                    soLuongSheet++;
                                    linkTemps[i_sl].CreateMarginalHeaderArea += new CreateAreaEventHandler(Link_CreateMarginalHeaderArea);

                                    complinkMain.Links.Add(linkTemps[i_sl]);
                                }
                            }
                            catch (SqlException ex)
                            {
                                MessageBox.Show("Error: " + ex.ToString());
                            }
                            finally
                            {
                                conn.Close();
                                conn.Dispose();
                            }
                            //KẾT THÚC ĐIỀU KIỆN
                            i_sl++;
                        }

                        MessageBox.Show("Đã khởi tạo xong dữ liệu!", "Thông báo!", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                }
            }
            else
            {
                MessageBox.Show("Chưa chọn Cơ sở khám chữa bệnh!", "Thông báo!", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
        public static void ExportToExcel(string title, params IPrintable[] panels)
        {
            SaveFileDialog saveFileDialog = new SaveFileDialog();

            saveFileDialog.FileName = title;
            saveFileDialog.Title    = string.Format("{0} Excel", UnitField.Export);
            saveFileDialog.Filter   = "Excel (*.xlsx)|*.xlsx|Excel(*.xls)|*.xls";
            if (saveFileDialog.ShowDialog() == DialogResult.Cancel)
            {
                return;
            }
            string         text          = saveFileDialog.FileName;
            PrintingSystem expr_43       = new PrintingSystem();
            CompositeLink  compositeLink = new CompositeLink(expr_43);

            expr_43.Links.Add(compositeLink);
            for (int i = 0; i < panels.Length; i++)
            {
                IPrintable printable = panels[i];
                compositeLink.Links.Add(ExportToExcelHelper.CreatePrintableLink(printable));
            }
            compositeLink.Landscape = true;
            try
            {
                int num = 1;
                while (File.Exists(text))
                {
                    if (text.Contains(")."))
                    {
                        int startIndex = text.LastIndexOf("(", StringComparison.Ordinal);
                        int length     = text.LastIndexOf(").", StringComparison.Ordinal) - text.LastIndexOf("(", StringComparison.Ordinal) + 2;
                        text = text.Replace(text.Substring(startIndex, length), string.Format("({0}).", num));
                    }
                    else
                    {
                        text = text.Replace(".", string.Format("({0}).", num));
                    }
                    num++;
                }
                if (text.LastIndexOf(".xlsx", StringComparison.Ordinal) >= text.Length - 5)
                {
                    XlsxExportOptions options = new XlsxExportOptions();
                    compositeLink.ExportToXlsx(text, options);
                }
                else
                {
                    XlsExportOptions options2 = new XlsExportOptions();
                    compositeLink.ExportToXls(text, options2);
                }
                //if (XtraMessageBox.Show(Face.resources.UnitField.ExportOK, UnitField.SystemMessage, MessageBoxButtons.YesNo, MessageBoxIcon.Asterisk) == DialogResult.Yes)
                if (XtraMessageBox.Show("µ¼³öOK", UnitField.SystemMessage, MessageBoxButtons.YesNo, MessageBoxIcon.Asterisk) == DialogResult.Yes)

                {
                    Process.Start(text);
                }
            }
            catch (Exception arg_16F_0)
            {
                XtraMessageBox.Show(arg_16F_0.Message);
            }
        }