using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using DevExpress.XtraReports.UI;
using System.Collections.Generic;
namespace DL698AmmeterTest.form
{
public partial class XtraReport1 : DevExpress.XtraReports.UI.XtraReport
{
private string _changShang;//厂商
private string _sn;//型号
private string _type;//类型
private string _songJianRen;//送检人
private string _ceShiDanWei;//测试单位
private string _ceShiRen;//测试人
private TestPlan _testPlan;//测试计划(批次)
private List<TestItem> _listTI;//测试项
private List<Ammeter> _listAmmeter;//测试结果
private ReportOptions ro = new ReportOptions();
public XtraReport1()
{
InitializeComponent();
}
public XtraReport1(TestPlan testPlan, List<TestItem> listTI, List<Ammeter> listAmmeter)
{
InitializeComponent();
this._testPlan = testPlan;
if (listTI != null && listTI.Count > 0)
{
this._listTI = listTI;
}
else
{
this._listTI = new List<TestItem>();
}
if (listAmmeter != null && listAmmeter.Count > 0)
{
this._listAmmeter = listAmmeter;
}
else
{
this._listAmmeter = new List<Ammeter>();
}
}
//设置标题
public void setTitle()
{
this.xrLabelTitle.Text = this._testPlan.Test_name;
}
public void setFoot()
{
}
public void setBody()
{
Int64 planid = this._testPlan.Id;
foreach (Ammeter ammeter in this._listAmmeter)
{
//创建panel1,并将label及表头加入
XRPanel xrPanel1 = new XRPanel();
xrPanel1.Location = new Point(0, getY());
xrPanel1.Size = new Size(PageWidth - Margins.Left - Margins.Right, 42);
this.Detail.Controls.Add(xrPanel1);
XRLabel xrLabel1 = new XRLabel();
xrLabel1.Text = "电能表号:";
xrLabel1.Location = new Point(0,;
xrLabel1.Size = new Size(Convert.ToInt32(xrPanel1.Width * 0.13), 25);
xrLabel1.TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleLeft;
xrPanel1.Controls.Add(xrLabel1);
//填写表号的label
XRLabel xrLabel2 = new XRLabel();
xrLabel2.Location = new Point(xrLabel1.Location.X + xrLabel1.Width,;
xrLabel2.Size = new Size(Convert.ToInt32(xrPanel1.Width * 0.2), 25);
xrLabel2.Text = ammeter.Ammeter_adc_id;
xrLabel2.Font = new Font("宋体", 10, FontStyle.Underline);
xrLabel2.TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleLeft;
xrPanel1.Controls.Add(xrLabel2);
XRLabel xrLabel3 = new XRLabel();
xrLabel3.Text = "送检单位:";
xrLabel3.Location = new Point(xrLabel2.Location.X + xrLabel2.Width,;
xrLabel3.Size = new Size(Convert.ToInt32(xrPanel1.Width * 0.13), 25);
xrLabel3.TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleLeft;
xrPanel1.Controls.Add(xrLabel3);
//填写送检单位的label
XRLabel xrLabel4 = new XRLabel();
xrLabel4.Location = new Point(xrLabel3.Location.X + xrLabel3.Width,;
xrLabel4.Size = new Size(Convert.ToInt32(xrPanel1.Width * 0.23), 25);
xrLabel4.Text = this._testPlan.Comsumer_name;
xrLabel4.Font = new Font("宋体", 10, FontStyle.Underline);
xrLabel4.TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleLeft;
xrPanel1.Controls.Add(xrLabel4);
XRLabel xrLabel5 = new XRLabel();
xrLabel5.Text = "测试日期:";
xrLabel5.Location = new Point(xrLabel4.Location.X + xrLabel4.Width,;
xrLabel5.Size = new Size(Convert.ToInt32(xrPanel1.Width * 0.13), 25);
xrLabel5.TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleLeft;
xrPanel1.Controls.Add(xrLabel5);
//
XRLabel xrLabel6 = new XRLabel();
xrLabel6.Location = new Point(xrLabel5.Location.X + xrLabel5.Width,;
xrLabel6.Size = new Size(Convert.ToInt32(xrPanel1.Width * 0.18), 25);
xrLabel6.Text = this._testPlan.Test_time.Year + "年" + this._testPlan.Test_time.Month + "月" + this._testPlan.Test_time.Day + "日";
xrLabel6.Font = new Font("宋体", 10, FontStyle.Underline);
xrLabel6.TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleLeft;
xrPanel1.Controls.Add(xrLabel6);
//panel2,装表格
XRPanel xrPanel2 = new XRPanel();
xrPanel2.Location = new Point(0, xrPanel1.Location.Y + 25);
xrPanel2.Size = new Size(xrPanel1.Width, 42);
this.Detail.Controls.Add(xrPanel2);
List<TestResult> listTr = ro.findByPlanIDAndAmmeterAdc_TestResult(planid, ammeter.Ammeter_adc_id);
List<TestData> listTd = new List<TestData>();
XRTable xrTable1 = new XRTable();
xrTable1.BorderWidth = 1;
xrTable1.Borders = DevExpress.XtraPrinting.BorderSide.All;
xrTable1.Location = new Point(0,;
// xrTable1.Size = new Size(xrPanel2.Width, 25*(listTr.Count+2)/3);
xrTable1.Size = new Size(xrPanel2.Width, 25);
//第一行,表头
XRTableRow xrTableRow1 = new XRTableRow();
XRTableCell xrTableCell1 = new XRTableCell();
XRTableCell xrTableCell2 = new XRTableCell();
XRTableCell xrTableCell3 = new XRTableCell();
xrTableRow1.Size = new Size(xrTable1.Width, 25);
xrTableRow1.TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleCenter;
xrTable1.Rows.Add(xrTableRow1);
//第一行,第一列
xrTableCell1.Size = new Size(Convert.ToInt32(xrTableRow1.Width * 0.4), 25);
xrTableCell1.TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleCenter;
xrTableCell1.Font = new Font("宋体", 10, FontStyle.Bold);
xrTableCell1.Width = Convert.ToInt32(xrTableRow1.Width * 0.4);
xrTableCell1.Text = "抄收数据项";
//第一行,第二列
//XRTableCell xrTableCell2 = new XRTableCell();
xrTableCell2.Size = new Size(Convert.ToInt32(xrTableRow1.Width * 0.3), 25);
xrTableCell2.TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleCenter;
xrTableCell2.Font = new Font("宋体", 10, FontStyle.Bold);
xrTableCell2.Width = Convert.ToInt32(xrTableRow1.Width * 0.3);
xrTableCell2.Text = "抄收实时数据";
//第一行,第三列
//XRTableCell xrTableCell3 = new XRTableCell();
xrTableCell3.Size = new Size(Convert.ToInt32(xrTableRow1.Width * 0.3), 25);
xrTableCell3.TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleCenter;
xrTableCell3.Font = new Font("宋体", 10, FontStyle.Bold);
xrTableCell3.Width = Convert.ToInt32(xrTableRow1.Width * 0.3);
xrTableCell3.Text = "抄收冻结数据";
xrTableRow1.Cells.Add(xrTableCell1);
xrTableRow1.Cells.Add(xrTableCell2);
xrTableRow1.Cells.Add(xrTableCell3);
foreach (TestItem testItem in this._listTI)
{
TestData td = new TestData();
td.Test_item = testItem.Name;
td.Result1 = "电能表没有该功能";
td.Result2 = "电能表没有该功能";
listTd.Add(td);
foreach (TestResult testResult in listTr)
{
if (testItem.Id == testResult.Test_item_id)
{
foreach (TestData td1 in listTd)
{
if (td1.Test_item == testItem.Name)
{
if (testResult.Type.Substring(0,2)=="01")
{
td1.Result1 = "通过";
}
else if (testResult.Type.Substring(0,2) == "02")
{
td1.Result2 = "通过";
}
}
}
}
}
}
foreach (TestData testData in listTd)
{
xrTable1.Height = xrTable1.Height + 25;
XRTableRow xrTableRow2 = new XRTableRow();
xrTableRow2.Size = xrTableRow1.Size;
XRTableCell xrTableCell4 = new XRTableCell();
xrTableCell4.Size = xrTableCell1.Size;
xrTableCell4.TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleLeft;
xrTableCell4.Width = xrTableCell1.Width;
xrTableCell4.Text = testData.Test_item;
xrTableRow2.Cells.Add(xrTableCell4);
XRTableCell xrTableCell5 = new XRTableCell();
xrTableCell5.Size = xrTableCell2.Size;
xrTableCell5.TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleLeft;
xrTableCell5.Width = xrTableCell2.Width;
xrTableCell5.Text = testData.Result1;
xrTableRow2.Cells.Add(xrTableCell5);
XRTableCell xrTableCell6 = new XRTableCell();
xrTableCell6.Size = xrTableCell3.Size;
xrTableCell6.TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleLeft;
xrTableCell6.Width = xrTableCell3.Width;
xrTableCell6.Text = testData.Result2;
xrTableRow2.Cells.Add(xrTableCell6);
//xrTable1.Rows.AddRange(new XRTableRow[] { xrTableRow2 });
xrTable1.Rows.Add(xrTableRow2);
}
xrPanel2.Controls.Add(xrTable1);
//panel3,装表底
XRPanel xrPanel3 = new XRPanel();
xrPanel3.Location = new Point(0, xrPanel2.Location.Y + xrPanel2.Height + 10);
xrPanel3.Size = new Size(xrPanel2.Width, 150);
XRLabel xrLabel8 = new XRLabel();
xrLabel8.Text = "(具体的抄收数据报文、解析数据作为附录)";
xrLabel8.TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleLeft;
xrLabel8.Location = new Point(0, 0);
xrLabel8.Size = new Size(Convert.ToInt32(xrPanel3.Width * 0.6), 25);
xrPanel3.Controls.Add(xrLabel8);
XRLabel xrLabel9 = new XRLabel();
xrLabel9.Text = "测试人员:";
xrLabel9.Location = new Point(308, 33);
xrLabel9.Size = new Size(Convert.ToInt32(xrPanel3.Width * 0.2), 25);
xrLabel9.TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleLeft;
xrPanel3.Controls.Add(xrLabel9);
XRLabel xrLabel10 = new XRLabel();
xrLabel10.Text = "测试单位: (盖章有效)";
xrLabel10.Location = new Point(308, 75);
xrLabel10.Size = new Size(Convert.ToInt32(xrPanel3.Width * 0.3), 25);
xrLabel10.TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleLeft;
xrPanel3.Controls.Add(xrLabel10);
XRLabel xrLabel11 = new XRLabel();
xrLabel11.Text = "日 期:";
xrLabel11.Location = new Point(308, 117);
xrLabel11.TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleLeft;
xrLabel11.Size = new Size(Convert.ToInt32(xrPanel3.Width * 0.3), 25);
xrPanel3.Controls.Add(xrLabel11);
this.Detail.Controls.Add(xrPanel3);
XRPageBreak xrPageBreak0 = new XRPageBreak();
Detail.Controls.Add(xrPageBreak0);
xrPageBreak0.Location = new Point(0, xrPanel3.Location.Y + xrPanel3.Height + 10);
//附抄收数据结果
//sql:select t1.id , t1.ammeter_id,t1.result,t1.plant_id, t2.name as test_item,t1.happen_time from test_result as t1 join test_item as t2 on t1.test_item=t2.id
//SELECT t1.ID, t1.AMMETER_ID, t1.RESULT, t1.PLANT_ID, t2.NAME AS Test_Item, t1.HAPPEN_TIME FROM TEST_RESULT AS t1 INNER JOINTEST_ITEM AS t2 ON t1.TEST_ITEM = t2.ID WHERE (t1.PLANT_ID = 1) AND (t1.AMMETER_ID = '000000000011')
//panel4,装附加信息
XRPanel xrPanel4 = new XRPanel();
xrPanel4.Location = new Point(0, xrPageBreak0.Location.Y);
xrPanel4.Size = new Size(xrPanel3.Width, 42);
this.Detail.Controls.Add(xrPanel4);
List<TestResult> listResultData = ro.findTestResult1(planid, ammeter.Ammeter_adc_id);
XRLabel xrLabelf = new XRLabel();
xrLabelf.Text = "附表:";
xrLabelf.Location = new Point(0, 0);
xrLabelf.Size = new Size(83, 25);
xrLabelf.TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleLeft;
xrPanel4.Controls.Add(xrLabelf);
int pages = 0;
if (listResultData.Count % 34 == 0)
{
pages = listResultData.Count / 34;
}
else
{
pages = listResultData.Count / 34 + 1;
}
int num = 0;
int tablex = 0;
int tabley = 30;
int n = 0;
for (int p = 1; p <= pages; p++)
{
XRTable xrTable3 = new XRTable();
xrTable3.Location = new Point(tablex, tabley);
//xrTable3.Size = new Size(xrPanel4.Width, 25 * (listResultData.Count + 6) / 7);
xrTable3.Size = new Size(xrPanel4.Width, 25);
xrTable3.Borders = DevExpress.XtraPrinting.BorderSide.All;
xrTable3.BorderWidth = 1;
xrTable3.Font = new Font("宋体",;
xrPanel4.Controls.Add(xrTable3);
XRTableRow xrTableRow3 = new XRTableRow();
xrTableRow3.Size = new Size(xrTable3.Width, 25);
//xrTable3.Rows.Add(xrTableRow3);
XRTableCell xrTableCell_3 = new XRTableCell();
xrTableCell_3.Size = new Size(Convert.ToInt32(xrTableRow3.Width * 0.05), 25);
//xrTableCell_3.Size = new Size(83, 25);
// xrTableCell_3.Width = Convert.ToInt32(xrTableRow3.Width * 0.1);
xrTableCell_3.TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleCenter;
xrTableCell_3.Font = new Font("宋体", 8, FontStyle.Bold);
xrTableCell_3.Text = "编号";
xrTableRow3.Cells.Add(xrTableCell_3);
XRTableCell xrTableCell_4 = new XRTableCell();
xrTableCell_4.Size = new Size(Convert.ToInt32(xrTableRow3.Width * 0.15), 25);
//xrTableCell_4.Size = new Size(165, 25);
//xrTableCell_4.Width = Convert.ToInt32(xrTableRow3.Width * 0.2);
xrTableCell_4.TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleCenter;
xrTableCell_4.Font = new Font("宋体", 8, FontStyle.Bold);
xrTableCell_4.Text = "电能表编号";
xrTableRow3.Cells.Add(xrTableCell_4);
XRTableCell xrTableCell_5 = new XRTableCell();
xrTableCell_5.Size = new Size(Convert.ToInt32(xrTableRow3.Width * 0.2), 25);
//xrTableCell_5.Size = new Size(83, 25);
//xrTableCell_5.Width = Convert.ToInt32(xrTableRow3.Width * 0.1);
xrTableCell_5.TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleCenter;
xrTableCell_5.Font = new Font("宋体", 8, FontStyle.Bold);
xrTableCell_5.Text = "抄收结果";
xrTableRow3.Cells.Add(xrTableCell_5);
//XRTableCell xrTableCell_6 = new XRTableCell();
//xrTableCell_6.Size = new Size(Convert.ToInt32(xrTableRow3.Width * 0.1), 25);
////xrTableCell_6.Size = new Size(83, 25);
//// xrTableCell_6.Width = Convert.ToInt32(xrTableRow3.Width * 0.1);
//xrTableCell_6.TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleCenter;
//xrTableCell_6.Font = new Font("宋体", 10, FontStyle.Bold);
//xrTableCell_6.Text = "计划批次";
//xrTableRow3.Cells.Add(xrTableCell_6);
XRTableCell xrTableCell_7 = new XRTableCell();
xrTableCell_7.Size = new Size(Convert.ToInt32(xrTableRow3.Width * 0.2), 25);
//xrTableCell_7.Size = new Size(165, 25);
//xrTableCell_7.Width = Convert.ToInt32(xrTableRow3.Width * 0.2);
xrTableCell_7.TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleCenter;
xrTableCell_7.Font = new Font("宋体", 8, FontStyle.Bold);
xrTableCell_7.Text = "测试项目";
xrTableRow3.Cells.Add(xrTableCell_7);
XRTableCell xrTableCell_8 = new XRTableCell();
xrTableCell_8.Size = new Size(Convert.ToInt32(xrTableRow3.Width * 0.2), 25);
//xrTableCell_8.Size = new Size(165, 25);
//xrTableCell_8.Width = Convert.ToInt32(xrTableRow3.Width * 0.2);
xrTableCell_8.TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleCenter;
xrTableCell_8.Font = new Font("宋体", 8, FontStyle.Bold);
xrTableCell_8.Text = "测试时间";
xrTableRow3.Cells.Add(xrTableCell_8);
XRTableCell xrTableCell_9 = new XRTableCell();
//xrTableCell_9.Size = new Size(Convert.ToInt32(xrTableRow3.Width * 0.1), 25);
//xrTableCell_9.Size = new Size(83, 25);
xrTableCell_9.Size = new Size(Convert.ToInt32(xrTableRow3.Width * 0.2), 25);
xrTableCell_9.Width = Convert.ToInt32(xrTableRow3.Width * 0.1);
xrTableCell_9.TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleCenter;
xrTableCell_9.Font = new Font("宋体", 8, FontStyle.Bold);
xrTableCell_9.Text = "类型";
xrTableRow3.Cells.Add(xrTableCell_9);
xrTable3.Height = xrTable3.Height + 25;
xrTable3.Rows.Add(xrTableRow3);
int pagestemp = 0;
if (p * 34 > listResultData.Count)
{
pagestemp = listResultData.Count;
}
else
{
pagestemp = p * 34;
}
for (int j = n; j < pagestemp; j++)
{
num++;
n++;
TestResult tr2 = listResultData[j];
xrTable3.Height = xrTable3.Height + 25;
XRTableRow xrTableRow_3 = new XRTableRow();
xrTableRow_3.Size = xrTableRow3.Size;
// xrTable3.Rows.Add(xrTableRow_3);
xrTableRow_3.Borders = DevExpress.XtraPrinting.BorderSide.All;
xrTableRow_3.BorderWidth = 1;
XRTableCell xrTableCell_31 = new XRTableCell();
xrTableCell_31.Size = xrTableCell_3.Size;
xrTableCell_31.Width = xrTableCell_3.Width;
xrTableCell_31.TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleCenter;
xrTableCell_31.Text = num.ToString();
xrTableCell_31.Borders = DevExpress.XtraPrinting.BorderSide.All;
xrTableCell_31.BorderWidth = 1;
xrTableRow_3.Cells.Add(xrTableCell_31);
XRTableCell xrTableCell_41 = new XRTableCell();
xrTableCell_41.Size = xrTableCell_4.Size;
xrTableCell_41.Width = xrTableCell_4.Width;
xrTableCell_41.TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleCenter;
xrTableCell_41.Text = tr2.Ammeter_id;
xrTableCell_41.Borders = DevExpress.XtraPrinting.BorderSide.All;
xrTableCell_41.BorderWidth = 1;
xrTableRow_3.Cells.Add(xrTableCell_41);
XRTableCell xrTableCell_51 = new XRTableCell();
xrTableCell_51.Size = xrTableCell_5.Size;
xrTableCell_51.Width = xrTableCell_5.Width;
xrTableCell_51.TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleCenter;
xrTableCell_51.Text = tr2.Result;
xrTableCell_51.Borders = DevExpress.XtraPrinting.BorderSide.All;
xrTableCell_51.BorderWidth = 1;
xrTableRow_3.Cells.Add(xrTableCell_51);
//XRTableCell xrTableCell_61 = new XRTableCell();
//xrTableCell_61.Size = xrTableCell_6.Size;
//xrTableCell_61.Width = xrTableCell_6.Width;
//xrTableCell_61.TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleCenter;
//xrTableCell_61.Text = tr2.Plan_id.ToString();
//xrTableCell_61.Borders = DevExpress.XtraPrinting.BorderSide.All;
//xrTableCell_61.BorderWidth = 1;
//xrTableRow_3.Cells.Add(xrTableCell_61);
XRTableCell xrTableCell_71 = new XRTableCell();
xrTableCell_71.Size = xrTableCell_7.Size;
xrTableCell_71.Width = xrTableCell_7.Width;
xrTableCell_71.TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleCenter;
xrTableCell_71.Text = tr2.Test_item_string;
xrTableCell_71.Borders = DevExpress.XtraPrinting.BorderSide.All;
xrTableCell_71.BorderWidth = 1;
xrTableRow_3.Cells.Add(xrTableCell_71);
XRTableCell xrTableCell_81 = new XRTableCell();
xrTableCell_81.Size = xrTableCell_8.Size;
xrTableCell_81.Width = xrTableCell_8.Width;
xrTableCell_81.TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleCenter;
xrTableCell_81.Text = tr2.Happen_time.ToString();
xrTableCell_81.Borders = DevExpress.XtraPrinting.BorderSide.All;
xrTableCell_81.BorderWidth = 1;
xrTableRow_3.Cells.Add(xrTableCell_81);
XRTableCell xrTableCell_91 = new XRTableCell();
xrTableCell_91.Size = xrTableCell_9.Size;
xrTableCell_91.Width = xrTableCell_9.Width;
xrTableCell_91.TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleCenter;
xrTableCell_91.Borders = DevExpress.XtraPrinting.BorderSide.All;
xrTableCell_91.BorderWidth = 1;
if (tr2.Type.Equals("0100"))
{
xrTableCell_91.Text = "实时";
}
else if (tr2.Type.Equals("0200"))
{
xrTableCell_91.Text = "冻结(5min)";
}
else if (tr2.Type.Equals("0201"))
{
xrTableCell_91.Text = "冻结(15min)";
}
else if (tr2.Type.Equals("0202"))
{
xrTableCell_91.Text = "冻结(30min)";
}
else if (tr2.Type.Equals("0203"))
{
xrTableCell_91.Text = "冻结(60min)";
}
else if (tr2.Type.Equals("0204"))
{
xrTableCell_91.Text = "冻结(24h)";
}
else if (tr2.Type.Equals("0205"))
{
xrTableCell_91.Text = "冻结(1mon)";
}
xrTableRow_3.Cells.Add(xrTableCell_91);
xrTable3.Rows.Add(xrTableRow_3);
}
if (p == pages)
{
}
else
{
XRPageBreak xrPageBreak3 = new XRPageBreak();
Detail.Controls.Add(xrPageBreak3);
xrPageBreak3.Location = new Point(0, xrTable3.Location.Y + xrTable3.Height + 10);
tablex = 0;
tabley = xrTable3.Location.Y + xrTable3.Height + 60;
}
}
XRPageBreak xrPageBreak1 = new XRPageBreak();
Detail.Controls.Add(xrPageBreak1);
xrPageBreak1.Location = new Point(0, xrPanel4.Location.Y + xrPanel4.Height + 10);
}
}
private void Detail_BeforePrint(object sender, System.Drawing.Printing.PrintEventArgs e)
{
setBody();
}
private void ReportHeader_BeforePrint(object sender, System.Drawing.Printing.PrintEventArgs e)
{
setTitle();
}
//得到最后一个控件的位置X
public int getX()
{
XRControlCollection ce = this.Detail.Controls;
XRControl obj = ce[ce.Count - 1];
return obj.Location.X;
}
//得到最后一个控件的位置Y
public int getY()
{
XRControlCollection ce = this.Detail.Controls;
int y = 8;
//for (int i = ce.Count - 1; i >= 0; i--)
//{
// XRControl obj = ce[i];
// if (obj.ToString() == "DevExpress.XtraReports.UI.XRPanel")
// {
// y = obj.Location.Y + obj.Size.Height+10;
// break;
// }
// //if (obj.ToString() == "DevExpress.XtraReports.UI.XRPageBreak")
// //{
// // y = obj.Location.Y;
// // break;
// //}
//}
if (ce != null && ce.Count > 0)
{
XRControl obj = ce[ce.Count - 1];
y = obj.Location.Y + obj.Size.Height + 10;
}
return y;
}
public int getHeadY()
{
XRControlCollection ce = this.Detail.Controls;
int y = 8;
for (int i = ce.Count - 1; i >= 0; i--)
{
XRControl obj = ce[i];
if (obj.ToString() == "DevExpress.XtraReports.UI.XRPanel")
{
y = obj.Location.Y + 25;
break;
}
//if (obj.ToString() == "DevExpress.XtraReports.UI.XRPageBreak")
//{
// y = obj.Location.Y;
// break;
//}
}
return y;
}
public int getXrPanel4Height(XRControl xrc)
{
XRControlCollection ce = xrc.Controls;
int y = 0;
for (int i = 0; i < ce.Count; i++)
{
y = y + ce[i].Location.Y + ce[i].Height;
}
return y + xrc.Location.Y;
}
}
}
在这数据就不上传了,请大家根据需要自己更改数据源