private void btnPrint_Click(object sender, EventArgs e) { try { XtraReport report = new XtraReport(); report.LoadLayout(Application.StartupPath + "/Print/TongJiCount.repx"); report.DataSource = (DataTable)grd.DataSource; report.Parameters.Clear(); DevExpress.XtraReports.Parameters.Parameter p2 = new DevExpress.XtraReports.Parameters.Parameter(); p2.Name = "标题"; p2.Description = "标题"; p2.Value = "鉴定机构中标率统计报表 " + DateTime.Now.ToString("yyyy-MM-dd"); report.Parameters.Add(p2); if (Program.sOperID != "admin") { report.Print(); } else { report.ShowDesignerDialog(); } } catch { } }
private void btnPrint_Click(object sender, EventArgs e) { try { XtraReport report = new XtraReport(); report.LoadLayout(Application.StartupPath + "/Print/AnQingCount.repx"); report.DataSource = (DataTable)grd.DataSource; //添加参数 report.Parameters.Clear(); DevExpress.XtraReports.Parameters.Parameter p2 = new DevExpress.XtraReports.Parameters.Parameter(); p2.Name = "标题"; p2.Description = "标题"; p2.Value = "交通事故案情报统计 " + CommonInfo.CDate(this.dateEdit1.EditValue).ToString("yyyy-MM-dd") + "至" + CommonInfo.CDate(this.dateEdit2.EditValue).ToString("yyyy-MM-dd"); report.Parameters.Add(p2); DevExpress.XtraReports.Parameters.Parameter p3_1 = new DevExpress.XtraReports.Parameters.Parameter(); p3_1.Name = "统计"; p3_1.Description = "统计"; p3_1.Value = gridColumn2.SummaryText;;;; report.Parameters.Add(p3_1); DevExpress.XtraReports.Parameters.Parameter p3_2 = new DevExpress.XtraReports.Parameters.Parameter(); p3_2.Name = "A统计"; p3_2.Description = "A统计"; p3_2.Value = " " + gridColumn5.SummaryText; report.Parameters.Add(p3_2); DevExpress.XtraReports.Parameters.Parameter p3_3 = new DevExpress.XtraReports.Parameters.Parameter(); p3_3.Name = "B统计"; p3_3.Description = "B统计"; p3_3.Value = " " + gridColumn7.SummaryText; report.Parameters.Add(p3_3); DevExpress.XtraReports.Parameters.Parameter p3_4 = new DevExpress.XtraReports.Parameters.Parameter(); p3_4.Name = "D统计"; p3_4.Description = "D统计"; p3_4.Value = " " + gridColumn8.SummaryText; report.Parameters.Add(p3_4); DevExpress.XtraReports.Parameters.Parameter p3_5 = new DevExpress.XtraReports.Parameters.Parameter(); p3_5.Name = "S统计"; p3_5.Description = "S统计"; p3_5.Value = " " + gridColumn9.SummaryText; report.Parameters.Add(p3_5); if (Program.sOperID != "admin") { report.Print(); } else { report.ShowDesignerDialog(); } } catch { } }
private void createReportWhithDataSourceButton_Click(object sender, EventArgs e) { using (UnitOfWork session = CreateSessionByName("person.mdb")) { XtraReport report = new XtraReport(); ReportDesignExtension.AssociateReportWithExtension(report, ExtensionName); report.DataSource = CreateDataSource(session); report.ShowDesignerDialog(); } }
private void Form1_Load(object sender, EventArgs e) { XtraReport report = new XtraReport(); MyBand band = new MyBand(); report.Bands.Add(band); report.ShowDesignerDialog(); this.Close(); }
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); } }
private void loadReportfromFileButton_Click(object sender, EventArgs e) { OpenFileDialog openfd = new OpenFileDialog(); if (openfd.ShowDialog() != DialogResult.OK) { return; } XtraReport report = new XtraReport(); report.LoadLayoutFromXml(openfd.FileName); report.ShowDesignerDialog(); }
private void btnIn_Click(object sender, EventArgs e) { if (trangthai.Equals("toanbo")) { if (gridViewTKTienTuThien.RowCount > 0) { XtraReport rp = new XtraReport(); rp.DataSource = gridTKTienTuThien.DataSource; rp.LoadLayout(Application.StartupPath + @"\ReportTKTienTuThienToanBoThang.repx"); //rp.ShowDesignerDialog(); rp.ShowPreviewDialog(); } else { XtraMessageBox.Show("Không có dữ liệu để in!"); } } if (trangthai.Equals("toanbomotthang")) { if (gridViewTKTienTuThien.RowCount > 0) { XtraReport rp = new XtraReport(); rp.DataSource = gridTKTienTuThien.DataSource; rp.LoadLayout(Application.StartupPath + @"\ReportTKTienTuThienToanBoMotThang.repx"); //rp.ShowDesignerDialog(); rp.ShowPreviewDialog(); } else { XtraMessageBox.Show("Không có dữ liệu để in!"); } } if (trangthai.Equals("tungngaymotthang")) { if (gridViewTKTienTuThien.RowCount > 0) { XtraReport rp = new XtraReport(); rp.DataSource = gridTKTienTuThien.DataSource; rp.LoadLayout(Application.StartupPath + @"\ReportTKTienTuThienTungNgayMotThang.repx"); rp.ShowDesignerDialog(); rp.ShowPreviewDialog(); } else { XtraMessageBox.Show("Không có dữ liệu để in!"); } } ConTKTienTuThienThang_Load(sender, e); }
//---------------------------------------------------// //------------------ Xử lý in ấn --------------------// private void btnIn_Click(object sender, EventArgs e) { if (gridVPhongO.RowCount > 0) { //XtraReport rp = new XtraReport(); //rp.DataSource = gridVPhongO.DataSource; //rp.LoadLayout(Application.StartupPath + @"\ReportTimTheoPhong.repx"); //rp.ShowDesignerDialog(); //rp.ShowPreviewDialog(); XtraReport rp = new XtraReport(); rp.DataSource = gridVPhongO.DataSource; rp.LoadLayout(Application.StartupPath + @"\ReportGroupTimTheoPhong.repx"); rp.ShowDesignerDialog(); //rp.ShowPreviewDialog(); } else { XtraMessageBox.Show("Không có dữ liệu để in", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }
/// <summary> /// 打印 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnPrint_Click(object sender, EventArgs e) { try { XtraReport report = new XtraReport(); report.LoadLayout(Application.StartupPath + "/Print/DieCount.repx"); report.DataSource = (DataTable)grd.DataSource; //添加参数 report.Parameters.Clear(); DevExpress.XtraReports.Parameters.Parameter p2 = new DevExpress.XtraReports.Parameters.Parameter(); p2.Name = "标题"; p2.Description = "标题"; //死亡人数统计2018 - 03 - 01至2018 - 03 - 31 p2.Value = CommonInfo.CObjectToStr(this.dateEdit1.EditValue).Trim() + "至" + CommonInfo.CObjectToStr(this.dateEdit2.EditValue).Trim() + "死亡人数统计"; report.Parameters.Add(p2); DevExpress.XtraReports.Parameters.Parameter p3_5 = new DevExpress.XtraReports.Parameters.Parameter(); p3_5.Name = "死亡人数"; p3_5.Description = "死亡人数"; p3_5.Value = gridColumn3.SummaryText; report.Parameters.Add(p3_5); if (Program.sOperID != "admin") { report.Print(); } else { report.ShowDesignerDialog(); } } catch { } }
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); } }
private void btnPrint_Click(object sender, EventArgs e) { getSum(); try { string sError = ""; DataSet ds = new DataSet();//创建数据集 string sql = $"select * from T_AnQing where AnQingNo={sID}"; DataTable tb = SqlHelper.RunQuery(CommandType.Text, sql, null, out sError); DataTable tb2 = (DataTable)grd.DataSource; tb.TableName = "dt1n"; ds.Tables.Add(tb2.Copy()); tb2.TableName = "dt2n"; ds.Tables.Add(tb.Copy()); XtraReport report = new XtraReport(); report.LoadLayout(Application.StartupPath + "/Print/AnQingXX.repx"); report.DataSource = ds; // report.PageHeight = 320 + 18 * dt.Rows.Count; //添加参数 report.Parameters.Clear(); DevExpress.XtraReports.Parameters.Parameter p2 = new DevExpress.XtraReports.Parameters.Parameter(); p2.Name = "标题"; p2.Description = "标题"; if (CommonInfo.CLng(this.cmbDeptID.EditValue) == -1) { p2.Value = "案情编号:" + sID + " 交通事故详情"; } if (CommonInfo.CLng(this.cmbDeptID.EditValue) == 1) { p2.Value = "案情编号:" + sID + " 交通事故痕迹检验详情"; } if (CommonInfo.CLng(this.cmbDeptID.EditValue) == 2) { p2.Value = "案情编号:" + sID + " 交通事故酒精检验详情"; } if (CommonInfo.CLng(this.cmbDeptID.EditValue) == 3) { p2.Value = "案情编号:" + sID + " 交通事故尸体检验详情"; } report.Parameters.Add(p2); DevExpress.XtraReports.Parameters.Parameter p3_1 = new DevExpress.XtraReports.Parameters.Parameter(); p3_1.Name = "统计"; p3_1.Description = "统计"; p3_1.Value = gridColumn4.SummaryText;;;; report.Parameters.Add(p3_1); DevExpress.XtraReports.Parameters.Parameter p3_2 = new DevExpress.XtraReports.Parameters.Parameter(); p3_2.Name = "打包价"; p3_2.Description = "打包价"; if (sum == 0) { p3_2.Value = " " + gridColumn4.SummaryText; } else { p3_2.Value = " " + sum; } report.Parameters.Add(p3_2); DevExpress.XtraReports.Parameters.Parameter p3_3 = new DevExpress.XtraReports.Parameters.Parameter(); p3_3.Name = "状态"; p3_3.Description = "状态"; p3_3.Value = ja; report.Parameters.Add(p3_3); if (Program.sOperID != "admin") { report.Print(); } else { report.ShowDesignerDialog(); } } catch { } }
public static void CreateReportTemplate(this ColumnView view, string reportName, bool showSTT, bool showFooter , PaperKind paperKind, bool landscape) { XtraReport r = new XtraReport(); r.PaperKind = paperKind; r.Landscape = landscape; r.Margins.Top = 50; r.Margins.Bottom = 50; r.Margins.Left = 70; //thamso r.Margins.Right = 70; //thamso r.DataSource = view.DataSource; float width = r.PageSize.Width - r.Margins.Left - r.Margins.Right; // ADD HEDER var headerBand = new ReportHeaderBand(); XRLabel lbReporName = new XRLabel(); lbReporName.Text = reportName.ToUpper(); lbReporName.WidthF = width; lbReporName.Font = new System.Drawing.Font("Times New Roman", 14F, System.Drawing.FontStyle.Bold); lbReporName.TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleCenter; headerBand.Controls.Add(lbReporName); XRTable rtableHeader = new XRTable(); var rRowHeader = new XRTableRow(); XRTableCell cellHeader = null; if (showSTT) { cellHeader = new XRTableCell(); cellHeader.TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleCenter; cellHeader.Font = new System.Drawing.Font("Times New Roman", 9.75F, System.Drawing.FontStyle.Bold); cellHeader.Borders = ((DevExpress.XtraPrinting.BorderSide)((DevExpress.XtraPrinting.BorderSide.Left | DevExpress.XtraPrinting.BorderSide.Bottom | DevExpress.XtraPrinting.BorderSide.Top ))); cellHeader.Text = "STT"; rRowHeader.Cells.Add(cellHeader); } foreach (GridColumn c in view.VisibleColumns) { cellHeader = new XRTableCell(); cellHeader.TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleCenter; cellHeader.Font = new System.Drawing.Font("Times New Roman", 9.75F, System.Drawing.FontStyle.Bold); cellHeader.Borders = ((DevExpress.XtraPrinting.BorderSide)((DevExpress.XtraPrinting.BorderSide.Left | DevExpress.XtraPrinting.BorderSide.Bottom | DevExpress.XtraPrinting.BorderSide.Top ))); cellHeader.Text = c.Caption == string.Empty ? c.FieldName : c.Caption; rRowHeader.Cells.Add(cellHeader); } cellHeader.Borders = ((DevExpress.XtraPrinting.BorderSide)((DevExpress.XtraPrinting.BorderSide.Left | DevExpress.XtraPrinting.BorderSide.Bottom | DevExpress.XtraPrinting.BorderSide.Right | DevExpress.XtraPrinting.BorderSide.Top ))); rtableHeader.Rows.Add(rRowHeader); rRowHeader.BackColor = System.Drawing.Color.WhiteSmoke; rtableHeader.WidthF = width; rtableHeader.LocationF = new PointF(0, lbReporName.HeightF + 20); headerBand.HeightF = 0; headerBand.Controls.Add(rtableHeader); r.Bands.Add(headerBand); // ve band if (view is BandedGridView) { headerBand.HeightF = 250; // xac dinh sau rtableHeader.LocationF = new PointF(0, headerBand.HeightF - rtableHeader.HeightF); var l = new XRLabel(); var bandView = (BandedGridView)view; List <GridBand> listLevel0 = new List <GridBand>(); List <GridBand> listLevel1 = new List <GridBand>(); List <GridBand> listLevel2 = new List <GridBand>(); List <GridBand> listLevel3 = new List <GridBand>(); List <GridBand> listLast = null; foreach (GridBand b in bandView.Bands) { if (b.BandLevel == 0) { listLevel0.Add(b); } foreach (GridBand b1 in b.Children) { if (b1.BandLevel == 1) { listLevel1.Add(b1); } foreach (GridBand b2 in b1.Children) { if (b2.BandLevel == 2) { listLevel2.Add(b2); } foreach (GridBand b3 in b2.Children) { if (b3.BandLevel == 3) { listLevel3.Add(b3); } } } } } if (listLevel3.Count > 0) { listLast = listLevel3; } else if (listLevel2.Count > 0) { listLast = listLevel2; } else if (listLevel1.Count > 0) { listLast = listLevel1; } XRTableCell xrCell = null; if (showSTT) { xrCell = rRowHeader.Cells[0]; l.Name = "lbSTT"; l.Text = "STT"; l.WidthF = xrCell.WidthF; l.HeightF = 50; // xac dinh sau l.LocationF = new PointF(xrCell.LocationF.X, headerBand.HeightF - xrCell.HeightF - l.HeightF); l.Borders = ((DevExpress.XtraPrinting.BorderSide)((DevExpress.XtraPrinting.BorderSide.Left | DevExpress.XtraPrinting.BorderSide.Top))); l.Font = new System.Drawing.Font("Times New Roman", 9.75F, System.Drawing.FontStyle.Bold); l.TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleCenter; l.BackColor = Color.WhiteSmoke; headerBand.Controls.Add(l); } List <GridBand> listBand1 = new List <GridBand>(); // luu nhung thang có cha string labelName = string.Empty; for (int i = 0; i < bandView.VisibleColumns.Count; i++) { BandedGridColumn c = (BandedGridColumn)bandView.VisibleColumns[i]; if (c.OwnerBand != null) { xrCell = showSTT ? rRowHeader.Cells[i + 1] : rRowHeader.Cells[i]; labelName = string.Format("lb{0}", c.OwnerBand.Caption); l = headerBand.FindControl(labelName, true) as XRLabel; if (l == null) { l = new XRLabel(); l.Name = labelName; l.Text = c.OwnerBand.Caption; l.WidthF = xrCell.WidthF; l.HeightF = 50; // xac dinh sau l.LocationF = new PointF(xrCell.LocationF.X, headerBand.HeightF - xrCell.HeightF - l.HeightF); l.Borders = ((DevExpress.XtraPrinting.BorderSide)((DevExpress.XtraPrinting.BorderSide.Left | DevExpress.XtraPrinting.BorderSide.Top))); l.Font = new System.Drawing.Font("Times New Roman", 9.75F, System.Drawing.FontStyle.Bold); l.TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleCenter; l.BackColor = Color.WhiteSmoke; headerBand.Controls.Add(l); } else { l.WidthF += xrCell.WidthF; } } } l.Borders |= ((DevExpress.XtraPrinting.BorderSide)((DevExpress.XtraPrinting.BorderSide.Right))); foreach (GridBand b in listLevel2) { if (b.Columns.Count > 0) { continue; } labelName = string.Format("lb{0}", b.Caption); l = headerBand.FindControl(labelName, true) as XRLabel; if (l == null) { l = new XRLabel(); l.Name = labelName; l.Text = b.Caption; l.WidthF = 0; l.HeightF = 50; // xac dinh sau bool t = false; foreach (GridBand bChild in b.Children) { labelName = string.Format("lb{0}", bChild.Caption); var lchild = headerBand.FindControl(labelName, true) as XRLabel; if (lchild != null) { l.WidthF += lchild.WidthF; if (t == false) { l.LocationF = new PointF(lchild.LocationF.X, lchild.LocationF.Y - l.HeightF); t = true; } } } l.Borders = ((DevExpress.XtraPrinting.BorderSide)((DevExpress.XtraPrinting.BorderSide.Left | DevExpress.XtraPrinting.BorderSide.Top))); l.Font = new System.Drawing.Font("Times New Roman", 9.75F, System.Drawing.FontStyle.Bold); l.TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleCenter; l.BackColor = Color.WhiteSmoke; headerBand.Controls.Add(l); } } foreach (GridBand b in listLevel1) { if (b.Columns.Count > 0) { continue; } labelName = string.Format("lb{0}", b.Caption); l = headerBand.FindControl(labelName, true) as XRLabel; if (l == null) { l = new XRLabel(); l.Name = labelName; l.Text = b.Caption; l.WidthF = 0; l.HeightF = 50; // xac dinh sau bool t = false; foreach (GridBand bChild in b.Children) { labelName = string.Format("lb{0}", bChild.Caption); var lchild = headerBand.FindControl(labelName, true) as XRLabel; if (lchild != null) { l.WidthF += lchild.WidthF; if (t == false) { l.LocationF = new PointF(lchild.LocationF.X, lchild.LocationF.Y - l.HeightF); t = true; } } } l.Borders = ((DevExpress.XtraPrinting.BorderSide)((DevExpress.XtraPrinting.BorderSide.Left | DevExpress.XtraPrinting.BorderSide.Top))); l.Font = new System.Drawing.Font("Times New Roman", 9.75F, System.Drawing.FontStyle.Bold); l.TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleCenter; l.BackColor = Color.WhiteSmoke; headerBand.Controls.Add(l); } } foreach (GridBand b in listLevel0) { labelName = string.Format("lb{0}", b.Caption); l = headerBand.FindControl(labelName, true) as XRLabel; if (l == null) { l = new XRLabel(); l.Name = labelName; l.Text = b.Caption; l.WidthF = 0; l.HeightF = 50; // xac dinh sau bool t = false; foreach (GridBand bChild in b.Children) { labelName = string.Format("lb{0}", bChild.Caption); var lchild = headerBand.FindControl(labelName, true) as XRLabel; if (lchild != null) { l.WidthF += lchild.WidthF; if (t == false) { l.LocationF = new PointF(lchild.LocationF.X, lchild.LocationF.Y - l.HeightF); t = true; } if (l.LocationF.Y < lchild.LocationF.Y) { l.LocationF = new PointF(l.LocationF.X, lchild.LocationF.Y - l.HeightF); } } } l.WidthF -= 2; l.Borders = ((DevExpress.XtraPrinting.BorderSide)((DevExpress.XtraPrinting.BorderSide.Left | DevExpress.XtraPrinting.BorderSide.Top))); l.Font = new System.Drawing.Font("Times New Roman", 9.75F, System.Drawing.FontStyle.Bold); l.TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleCenter; l.BackColor = Color.WhiteSmoke; headerBand.Controls.Add(l); } if (b.Columns.Count > 0) { int max = listLast.Max(z => z.BandLevel); l.HeightF += max * 50; l.LocationF = new PointF(l.LocationF.X, l.LocationF.Y - max * 50); } } l.Borders |= ((DevExpress.XtraPrinting.BorderSide)((DevExpress.XtraPrinting.BorderSide.Right))); for (int i = 0; i < rRowHeader.Cells.Count; i++) { rRowHeader.Cells[i].Text = (i + 1).ToString(); } rtableHeader.ConvertToControls(); var stt = headerBand.FindControl("lbSTT", true); if (stt != null) { stt.HeightF += 50; stt.LocationF = new PointF(stt.LocationF.X, stt.LocationF.Y - 50); } headerBand.HeightF = 0; } // ADD GROUP for (int i = view.GroupedColumns.Count - 1; i >= 0; i--) { GridColumn c = view.GroupedColumns[i]; GroupHeaderBand groupBand = new GroupHeaderBand(); groupBand.GroupFields.Add(new GroupField(c.FieldName)); XRLabel lbGroup = new XRLabel(); lbGroup.DataBindings.Add("Text", r.DataSource, c.FieldName); lbGroup.WidthF = width; lbGroup.Font = new System.Drawing.Font("Times New Roman", 12F, System.Drawing.FontStyle.Bold); lbGroup.Borders = ((DevExpress.XtraPrinting.BorderSide)((DevExpress.XtraPrinting.BorderSide.Left | DevExpress.XtraPrinting.BorderSide.Bottom | DevExpress.XtraPrinting.BorderSide.Right ))); lbGroup.BackColor = Color.Honeydew; lbGroup.Padding = new DevExpress.XtraPrinting.PaddingInfo(20, 0, 0, 0); lbGroup.TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleLeft; groupBand.Controls.Add(lbGroup); groupBand.HeightF = 0; r.Bands.Add(groupBand); // TODO: ADD SUM GROUP CHO NAY TIEP // LAM SAU } // ADD DETAIL TABLE XRTable rtable = new XRTable(); var rRow = new XRTableRow(); XRTableCell cell = null; if (showSTT) { cell = new XRTableCell(); cell.TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleCenter; cell.Borders = ((DevExpress.XtraPrinting.BorderSide)((DevExpress.XtraPrinting.BorderSide.Left | DevExpress.XtraPrinting.BorderSide.Bottom))); cell.Summary.Func = SummaryFunc.RecordNumber; if (view.GroupedColumns.Count > 0 && showSTT) { cell.Summary.Running = SummaryRunning.Group; } else { cell.Summary.Running = SummaryRunning.Report; } rRow.Cells.Add(cell); } foreach (GridColumn c in view.VisibleColumns) { cell = new XRTableCell(); if (c.ColumnType == typeof(decimal) || c.ColumnType == typeof(int)) { cell.TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleRight; } else { cell.TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleLeft; } cell.Borders = ((DevExpress.XtraPrinting.BorderSide)((DevExpress.XtraPrinting.BorderSide.Left | DevExpress.XtraPrinting.BorderSide.Bottom))); cell.DataBindings.Add("Text", r.DataSource, c.FieldName); cell.Padding = new DevExpress.XtraPrinting.PaddingInfo(5, 5, 0, 0); rRow.Cells.Add(cell); } cell.Borders = ((DevExpress.XtraPrinting.BorderSide)((DevExpress.XtraPrinting.BorderSide.Left | DevExpress.XtraPrinting.BorderSide.Bottom | DevExpress.XtraPrinting.BorderSide.Right ))); rtable.Rows.Add(rRow); rtable.WidthF = width; var detailBand = new DetailBand(); detailBand.HeightF = rtable.HeightF; detailBand.Controls.Add(rtable); r.Bands.Add(detailBand); // ADD SUM FOOTER if (showFooter) { var reportFooter = new ReportFooterBand(); XRTable rtableFooter = new XRTable(); var rRowFooter = new XRTableRow(); XRTableCell cellFooter = null; if (showSTT) { cellFooter = new XRTableCell(); cellFooter.TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleCenter; cellFooter.Font = new System.Drawing.Font("Times New Roman", 9.75F, System.Drawing.FontStyle.Bold); cellFooter.Borders = ((DevExpress.XtraPrinting.BorderSide)((DevExpress.XtraPrinting.BorderSide.Left | DevExpress.XtraPrinting.BorderSide.Bottom ))); rRowFooter.Cells.Add(cellFooter); } for (int i = 0; i < view.VisibleColumns.Count; i++) { var c = view.VisibleColumns[i]; cellFooter = new XRTableCell(); cellFooter.TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleRight; cellFooter.Padding = new DevExpress.XtraPrinting.PaddingInfo(0, 5, 0, 0); cellFooter.Font = new System.Drawing.Font("Times New Roman", 9.75F, System.Drawing.FontStyle.Bold); cellFooter.Borders = ((DevExpress.XtraPrinting.BorderSide)((DevExpress.XtraPrinting.BorderSide.Left | DevExpress.XtraPrinting.BorderSide.Bottom ))); if (c.SummaryItem.SummaryType != DevExpress.Data.SummaryItemType.None) { cellFooter.Summary.Func = ConvertToSummaryFunc(c.SummaryItem.SummaryType); cellFooter.Summary.FormatString = c.SummaryItem.DisplayFormat; cellFooter.DataBindings.Add("Text", r.DataSource, c.FieldName); cellFooter.Summary.Running = SummaryRunning.Report; } rRowFooter.Cells.Add(cellFooter); } cellFooter.Borders = ((DevExpress.XtraPrinting.BorderSide)((DevExpress.XtraPrinting.BorderSide.Left | DevExpress.XtraPrinting.BorderSide.Bottom | DevExpress.XtraPrinting.BorderSide.Right ))); rtableFooter.WidthF = width; rRowFooter.BackColor = Color.LightYellow; rtableFooter.Rows.Add(rRowFooter); reportFooter.Controls.Add(rtableFooter); r.Bands.Add(reportFooter); } r.CreateDocument(); r.ShowDesignerDialog(); }
public static void CreateReportTemplate_old(this ColumnView view, string reportName, bool showSTT, bool showFooter , PaperKind paperKind, bool landscape) { XtraReport r = new XtraReport(); r.PaperKind = paperKind; r.Landscape = landscape; r.Margins.Left = 70; //thamso r.Margins.Right = 50; //thamso r.DataSource = view.DataSource; float width = r.PageSize.Width - r.Margins.Left - r.Margins.Right; // ADD HEDER var headerBand = new ReportHeaderBand(); XRLabel lbReporName = new XRLabel(); lbReporName.Text = reportName.ToUpper(); lbReporName.WidthF = width; lbReporName.Font = new System.Drawing.Font("Times New Roman", 14F, System.Drawing.FontStyle.Bold); lbReporName.TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleCenter; headerBand.Controls.Add(lbReporName); XRTable rtableHeader = new XRTable(); var rRowHeader = new XRTableRow(); XRTableCell cellHeader = null; if (showSTT) { cellHeader = new XRTableCell(); cellHeader.TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleCenter; cellHeader.Font = new System.Drawing.Font("Times New Roman", 9.75F, System.Drawing.FontStyle.Bold); cellHeader.Borders = ((DevExpress.XtraPrinting.BorderSide)((DevExpress.XtraPrinting.BorderSide.Left | DevExpress.XtraPrinting.BorderSide.Bottom | DevExpress.XtraPrinting.BorderSide.Top ))); cellHeader.Text = "STT"; rRowHeader.Cells.Add(cellHeader); } foreach (GridColumn c in view.VisibleColumns) { cellHeader = new XRTableCell(); cellHeader.TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleCenter; cellHeader.Font = new System.Drawing.Font("Times New Roman", 9.75F, System.Drawing.FontStyle.Bold); cellHeader.Borders = ((DevExpress.XtraPrinting.BorderSide)((DevExpress.XtraPrinting.BorderSide.Left | DevExpress.XtraPrinting.BorderSide.Bottom | DevExpress.XtraPrinting.BorderSide.Top ))); cellHeader.Text = c.Caption == string.Empty ? c.FieldName : c.Caption; rRowHeader.Cells.Add(cellHeader); } cellHeader.Borders = ((DevExpress.XtraPrinting.BorderSide)((DevExpress.XtraPrinting.BorderSide.Left | DevExpress.XtraPrinting.BorderSide.Bottom | DevExpress.XtraPrinting.BorderSide.Right | DevExpress.XtraPrinting.BorderSide.Top ))); rtableHeader.Rows.Add(rRowHeader); rRowHeader.BackColor = System.Drawing.Color.WhiteSmoke; rtableHeader.WidthF = width; rtableHeader.LocationF = new PointF(0, lbReporName.HeightF + 20); headerBand.HeightF = 0; headerBand.Controls.Add(rtableHeader); r.Bands.Add(headerBand); // ADD GROUP for (int i = view.GroupedColumns.Count - 1; i >= 0; i--) { GridColumn c = view.GroupedColumns[i]; GroupHeaderBand groupBand = new GroupHeaderBand(); groupBand.GroupFields.Add(new GroupField(c.FieldName)); XRLabel lbGroup = new XRLabel(); lbGroup.DataBindings.Add("Text", r.DataSource, c.FieldName); lbGroup.WidthF = width; lbGroup.Font = new System.Drawing.Font("Times New Roman", 12F, System.Drawing.FontStyle.Bold); lbGroup.Borders = ((DevExpress.XtraPrinting.BorderSide)((DevExpress.XtraPrinting.BorderSide.Left | DevExpress.XtraPrinting.BorderSide.Bottom | DevExpress.XtraPrinting.BorderSide.Right ))); lbGroup.BackColor = Color.Honeydew; lbGroup.Padding = new DevExpress.XtraPrinting.PaddingInfo(20, 0, 0, 0); lbGroup.TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleLeft; groupBand.Controls.Add(lbGroup); groupBand.HeightF = 0; r.Bands.Add(groupBand); // TODO: ADD SUM GROUP CHO NAY TIEP // LAM SAU } // ADD DETAIL TABLE XRTable rtable = new XRTable(); var rRow = new XRTableRow(); XRTableCell cell = null; if (showSTT) { cell = new XRTableCell(); cell.TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleCenter; cell.Borders = ((DevExpress.XtraPrinting.BorderSide)((DevExpress.XtraPrinting.BorderSide.Left | DevExpress.XtraPrinting.BorderSide.Bottom))); cell.Summary.Func = SummaryFunc.RecordNumber; if (view.GroupedColumns.Count > 0 && showSTT) { cell.Summary.Running = SummaryRunning.Group; } else { cell.Summary.Running = SummaryRunning.Report; } rRow.Cells.Add(cell); } foreach (GridColumn c in view.VisibleColumns) { cell = new XRTableCell(); if (c.ColumnType == typeof(decimal) || c.ColumnType == typeof(int)) { cell.TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleRight; } else { cell.TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleLeft; } cell.Borders = ((DevExpress.XtraPrinting.BorderSide)((DevExpress.XtraPrinting.BorderSide.Left | DevExpress.XtraPrinting.BorderSide.Bottom))); cell.DataBindings.Add("Text", r.DataSource, c.FieldName); cell.Padding = new DevExpress.XtraPrinting.PaddingInfo(5, 5, 0, 0); rRow.Cells.Add(cell); } cell.Borders = ((DevExpress.XtraPrinting.BorderSide)((DevExpress.XtraPrinting.BorderSide.Left | DevExpress.XtraPrinting.BorderSide.Bottom | DevExpress.XtraPrinting.BorderSide.Right ))); rtable.Rows.Add(rRow); rtable.WidthF = width; var detailBand = new DetailBand(); detailBand.HeightF = rtable.HeightF; detailBand.Controls.Add(rtable); r.Bands.Add(detailBand); // ADD SUM FOOTER if (showFooter) { var reportFooter = new ReportFooterBand(); XRTable rtableFooter = new XRTable(); var rRowFooter = new XRTableRow(); XRTableCell cellFooter = null; if (showSTT) { cellFooter = new XRTableCell(); cellFooter.TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleCenter; cellFooter.Font = new System.Drawing.Font("Times New Roman", 9.75F, System.Drawing.FontStyle.Bold); cellFooter.Borders = ((DevExpress.XtraPrinting.BorderSide)((DevExpress.XtraPrinting.BorderSide.Left | DevExpress.XtraPrinting.BorderSide.Bottom ))); rRowFooter.Cells.Add(cellFooter); } for (int i = 0; i < view.VisibleColumns.Count; i++) { var c = view.VisibleColumns[i]; cellFooter = new XRTableCell(); cellFooter.TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleRight; cellFooter.Padding = new DevExpress.XtraPrinting.PaddingInfo(0, 5, 0, 0); cellFooter.Font = new System.Drawing.Font("Times New Roman", 9.75F, System.Drawing.FontStyle.Bold); cellFooter.Borders = ((DevExpress.XtraPrinting.BorderSide)((DevExpress.XtraPrinting.BorderSide.Left | DevExpress.XtraPrinting.BorderSide.Bottom ))); if (c.SummaryItem.SummaryType != DevExpress.Data.SummaryItemType.None) { cellFooter.Summary.Func = ConvertToSummaryFunc(c.SummaryItem.SummaryType); cellFooter.Summary.FormatString = c.SummaryItem.DisplayFormat; cellFooter.DataBindings.Add("Text", r.DataSource, c.FieldName); cellFooter.Summary.Running = SummaryRunning.Report; } rRowFooter.Cells.Add(cellFooter); } cellFooter.Borders = ((DevExpress.XtraPrinting.BorderSide)((DevExpress.XtraPrinting.BorderSide.Left | DevExpress.XtraPrinting.BorderSide.Bottom | DevExpress.XtraPrinting.BorderSide.Right ))); rtableFooter.WidthF = width; rRowFooter.BackColor = Color.LightYellow; rtableFooter.Rows.Add(rRowFooter); reportFooter.Controls.Add(rtableFooter); r.Bands.Add(reportFooter); } r.CreateDocument(); r.ShowDesignerDialog(); }
public void Print(int id) { DataSet ds = new DataSet();//创建数据集 string sqlError = ""; string sql = $"select * from T_AnQing where AnQingNo={ID}"; DataTable tb = SqlHelper.RunQuery(CommandType.Text, sql, null, out sqlError); sql = $"SELECT GongSiName,Bao_Name FROM T_AnQingXiang x join T_GongSi g on x.GongSiID=g.GongSiId join T_BaoType t on x.BaoType_Id=t.Bao_TypeId where AnQingId={ID} and BaoType_Id ={id}"; DataTable tb2 = SqlHelper.RunQuery(CommandType.Text, sql, null, out sqlError); sql = $"select stuff((SELECT ',' + XiangMuName FROM T_AnQingXiang x JOIN T_XiangMu m ON x.XiangMuId = m.XiangMuNo where x.AnQingId = {ID} and x.BaoType_Id = {id} GROUP BY XiangMuName FOR XML path('')), 1, 1, '')"; DataTable tb3 = SqlHelper.RunQuery(CommandType.Text, sql, null, out sqlError); tb.TableName = "dt1n"; ds.Tables.Add(tb.Copy()); tb2.TableName = "dt2n"; ds.Tables.Add(tb2.Copy()); tb3.TableName = "dt3n"; ds.Tables.Add(tb3.Copy()); XtraReport report = new XtraReport(); if (TYPEID == 1) { if (id == 1) { report.LoadLayout(Application.StartupPath + "/Print/RE_AnQingJD.repx"); } if (id == 2) { report.LoadLayout(Application.StartupPath + "/Print/RE_AnQingJDB.repx"); } if (id == 3) { report.LoadLayout(Application.StartupPath + "/Print/RE_AnQingJDD.repx"); } } else { if (id == 1) { report.LoadLayout(Application.StartupPath + "/Print/AnQingJD.repx"); } if (id == 2) { report.LoadLayout(Application.StartupPath + "/Print/AnQingJDB.repx"); } if (id == 3) { report.LoadLayout(Application.StartupPath + "/Print/AnQingJDD.repx"); } } report.DataSource = ds; if (Program.sOperID != "admin") { report.Print(); } else { report.ShowDesignerDialog(); } }
private void btnInKetQua_Click(object sender, EventArgs e) { if (trangthai.Equals("toanbotatcanam")) { if (gridViewTKTienTuThien.RowCount > 0) { XtraReport rp = new XtraReport(); rp.DataSource = gridTKTienTuThien.DataSource; rp.LoadLayout(Application.StartupPath + @"\ReportTienTuThienToanBoNam.repx"); //rp.ShowDesignerDialog(); rp.ShowPreviewDialog(); } else { XtraMessageBox.Show("Không có dữ liệu để thống kê!"); } } if (trangthai.Equals("chianhomtatcanam")) { if (gridViewTKTienTuThien.RowCount > 0) { XtraReport rp = new XtraReport(); rp.DataSource = gridTKTienTuThien.DataSource; rp.LoadLayout(Application.StartupPath + @"\ReportTienTuThienToanBoNamTheoNhom.repx"); rp.ShowDesignerDialog(); rp.ShowPreviewDialog(); } else { XtraMessageBox.Show("Không có dữ liệu để thống kê!"); } } if (trangthai.Equals("toanbotungnam")) { if (gridViewTKTienTuThien.RowCount > 0) { XtraReport rp = new XtraReport(); rp.DataSource = gridTKTienTuThien.DataSource; rp.LoadLayout(Application.StartupPath + @"\ReportTienTuThienToanBoNamTheoNhom.repx"); //rp.ShowDesignerDialog(); rp.ShowPreviewDialog(); } else { XtraMessageBox.Show("Không có dữ liệu để thống kê!"); } } if (trangthai.Equals("chianhomtungnam")) { if (gridViewTKTienTuThien.RowCount > 0) { if (txtTuNam.Text.Equals(txtDenNam.Text)) { XtraReport rp = new XtraReport(); rp.DataSource = tuthien.TKTienTuThienTungNamTheoThang(txtTuNam.Text.Trim()); rp.LoadLayout(Application.StartupPath + @"\ReportTienTuThienMotNamTheoNhom.repx"); //rp.ShowDesignerDialog(); rp.ShowPreviewDialog(); } else { XtraReport rp = new XtraReport(); rp.DataSource = gridTKTienTuThien.DataSource; rp.LoadLayout(Application.StartupPath + @"\ReportTienTuThienNhieuNamTheoNhom.repx"); //rp.ShowDesignerDialog(); rp.ShowPreviewDialog(); } } else { XtraMessageBox.Show("Không có dữ liệu để thống kê!"); } } ConTKTienTuThienNam_Load(sender, e); }
private void barButtonItem2_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { _report.ShowDesignerDialog(); }
private void editReportButton_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { xtraReport.ShowDesignerDialog(); xtraReport.CreateDocument(); }