private void toolStripButton1_Click(object sender, EventArgs e) { axGRDisplayViewer1.Stop(); BaseReportTitle reportTitle = (BaseReportTitle)treeView1.SelectedNode.Tag; tPrintTable = (DataTable)InvokeController("ExecReportResult", reportTitle.TitleId, GetReportParamsValue()); string Reportname = reportTitle.RptFileName.Trim() + ".grf"; if (!System.IO.File.Exists(EFWCoreLib.CoreFrame.Init.AppGlobal.AppRootPath + @"Report\" + Reportname)) { Report = new GridppReport(); Report.InsertReportHeader(); Report.InsertDetailGrid(); Report.InsertReportFooter(); Report.DetailGrid.IsCrossTab = true; IGRRecordset RecordSet = Report.DetailGrid.Recordset; foreach (DataColumn col in tPrintTable.Columns) { if (col.DataType == typeof(Int32)) { RecordSet.AddField(col.ColumnName, GRFieldType.grftInteger); } else if (col.DataType == typeof(Decimal) || col.DataType == typeof(Double)) { RecordSet.AddField(col.ColumnName, GRFieldType.grftFloat); } else { RecordSet.AddField(col.ColumnName, GRFieldType.grftString); } } Report.AddParameter("报表名称", GRParameterDataType.grptString); Report.AddParameter("打印时间", GRParameterDataType.grptString); Report.AddParameter("当前科室", GRParameterDataType.grptString); Report.AddParameter("当前人员", GRParameterDataType.grptString); Report.DetailGrid.IsCrossTab = false; Report.SaveToFile(EFWCoreLib.CoreFrame.Init.AppGlobal.AppRootPath + @"Report\" + Reportname); } Report = new GridppReport(); Report.LoadFromFile(EFWCoreLib.CoreFrame.Init.AppGlobal.AppRootPath + @"Report\" + Reportname); Report.ParameterByName("报表名称").AsString = reportTitle.Name; Report.ParameterByName("打印时间").AsString = System.DateTime.Now.ToString(); Report.ParameterByName("当前科室").AsString = ""; Report.ParameterByName("当前人员").AsString = ""; Report.FetchRecord += new _IGridppReportEvents_FetchRecordEventHandler(reportPrinter_FetchRecord); axGRDisplayViewer1.Report = Report; axGRDisplayViewer1.Start(); }
protected override void ReportInit() { base.ReportInit(); if (report.ParameterByName("htdwmc") != null) { report.ParameterByName("htdwmc").AsString = this.txthtdw.Text.Trim(); } //定义数据集的各个字段 IGRRecordset RecordSet = report.DetailGrid.Recordset; report.DetailGrid.Columns.RemoveAll(); report.DetailGrid.Recordset.Fields.RemoveAll(); RecordSet.AddField("姓名", GRFieldType.grftString).Format = ""; IGRColumn ColumnBrxm = report.DetailGrid.AddColumn("姓名", "姓名", "姓名", 1.5); ColumnBrxm.TitleCell.TextAlign = GRTextAlign.grtaMiddleCenter; ColumnBrxm.ContentCell.TextAlign = GRTextAlign.grtaMiddleCenter; ColumnBrxm.ContentCell.Font.Point = 9; RecordSet.AddField("安全员", GRFieldType.grftString).Format = ""; IGRColumn ColumnAqy = report.DetailGrid.AddColumn("安全员", "安全员", "安全员", 1.5); ColumnAqy.TitleCell.TextAlign = GRTextAlign.grtaMiddleCenter; ColumnAqy.ContentCell.TextAlign = GRTextAlign.grtaMiddleCenter; ColumnAqy.ContentCell.Font.Point = 9; RecordSet.AddField("记账收费员", GRFieldType.grftString).Format = ""; IGRColumn ColumnSfy = report.DetailGrid.AddColumn("记账收费员", "记账收费员", "记账收费员", 2); ColumnSfy.TitleCell.TextAlign = GRTextAlign.grtaMiddleCenter; ColumnSfy.ContentCell.TextAlign = GRTextAlign.grtaMiddleCenter; ColumnSfy.ContentCell.Font.Point = 9; RecordSet.AddField("记账日期", GRFieldType.grftString).Format = ""; IGRColumn ColumnRq = report.DetailGrid.AddColumn("记账日期", "记账日期", "记账日期", 2); ColumnRq.TitleCell.TextAlign = GRTextAlign.grtaMiddleCenter; ColumnRq.ContentCell.TextAlign = GRTextAlign.grtaMiddleCenter; ColumnRq.ContentCell.Font.Point = 9; if (_menuTag.Function_Name == "Fun_MZSF_HTDWMX") { RecordSet.AddField("回款员", GRFieldType.grftString).Format = ""; IGRColumn ColumnHky = report.DetailGrid.AddColumn("回款员", "回款员", "回款员", 2); ColumnHky.TitleCell.TextAlign = GRTextAlign.grtaMiddleCenter; ColumnHky.ContentCell.TextAlign = GRTextAlign.grtaMiddleCenter; ColumnHky.ContentCell.Font.Point = 9; RecordSet.AddField("回款日期", GRFieldType.grftString).Format = ""; IGRColumn ColumnHkrq = report.DetailGrid.AddColumn("回款日期", "回款日期", "回款日期", 2); ColumnHkrq.TitleCell.TextAlign = GRTextAlign.grtaMiddleCenter; ColumnHkrq.ContentCell.TextAlign = GRTextAlign.grtaMiddleCenter; ColumnHkrq.ContentCell.Font.Point = 9; RecordSet.AddField("发票号", GRFieldType.grftString).Format = ""; IGRColumn ColumnFph = report.DetailGrid.AddColumn("发票号", "发票号", "发票号", 2); ColumnFph.TitleCell.TextAlign = GRTextAlign.grtaMiddleCenter; ColumnFph.ContentCell.TextAlign = GRTextAlign.grtaMiddleCenter; ColumnFph.ContentCell.Font.Point = 9; } RecordSet.AddField("门诊号", GRFieldType.grftString).Format = ""; IGRColumn ColumnBlh = report.DetailGrid.AddColumn("门诊号", "门诊号", "门诊号", 3); ColumnBlh.TitleCell.TextAlign = GRTextAlign.grtaMiddleCenter; ColumnBlh.ContentCell.TextAlign = GRTextAlign.grtaMiddleCenter; ColumnBlh.ContentCell.Font.Point = 9; foreach (DataColumn Col in dt.Columns) { string baseField = Col.ColumnName; if (baseField == "门诊号" || baseField == "安全员" || baseField == "姓名" || baseField == "记账日期" || baseField == "发票号" || baseField == "回款日期" || baseField == "记账收费员" || baseField == "回款员" || baseField == "记账收费员") { continue; } IGRColumn ColumnBase; switch (Col.DataType.Name.ToString()) { case "int": RecordSet.AddField(baseField, GRFieldType.grftInteger).Format = "0;;#"; break; case "float": RecordSet.AddField(baseField, GRFieldType.grftFloat).Format = "0.00;;#"; break; case "Decimal": RecordSet.AddField(baseField, GRFieldType.grftFloat).Format = "0.00;;#"; break; default: RecordSet.AddField(baseField, GRFieldType.grftString).Format = ""; break; } ColumnBase = report.DetailGrid.AddColumn(baseField, baseField, baseField, 1.5); ColumnBase.TitleCell.TextAlign = GRTextAlign.grtaMiddleCenter; ColumnBase.ContentCell.FreeCell = true; ColumnBase.ContentCell.Controls.RemoveAll(); IGRMemoBox memoBox = ColumnBase.ContentCell.Controls.Add(GRControlType.grctMemoBox) as IGRMemoBox; memoBox.Text = "[#" + baseField + ":0.00;;##]"; memoBox.Dock = GRDockStyle.grdsFill; memoBox.TextAlign = GRTextAlign.grtaMiddleRight; } }
private void DefineDetailGrid() { Report.InsertDetailGrid(); Report.DetailGrid.ColumnTitle.Height = 0.98;//标题行高度 // Report.DetailGrid.ColumnTitle.TitleCells[3].WordWrap = true; Report.DetailGrid.ColumnContent.Height = 0.58;//内容行高度 Report.DetailGrid.ColumnContent.AlternatingBackColor = 230 * 256 * 256 + 217 * 256 + 217; //内容行交替背景色 Report.DetailGrid.ColumnTitle.BackColor = 217 * 256 * 256 + 217 * 256 + 217; //标题行背景色 //定义数据集的各个字段 IGRRecordset RecordSet = Report.DetailGrid.Recordset; RecordSet.AddField("单据日期", GRFieldType.grftString).Format = "#,##0.00"; RecordSet.AddField("仓库编号", GRFieldType.grftString).Format = "#,##0.00"; RecordSet.AddField("物料类型", GRFieldType.grftString).Format = "#,##0.00"; RecordSet.AddField("单据名称", GRFieldType.grftString).Format = "#,##0.00"; RecordSet.AddField("单据编号", GRFieldType.grftString).Format = "#,##0.00"; RecordSet.AddField("发票号", GRFieldType.grftString).Format = "#,##0.00"; RecordSet.AddField("客户名称", GRFieldType.grftString).Format = "#,##0.00"; RecordSet.AddField("数量in", GRFieldType.grftString).Format = "#,##0.00"; RecordSet.AddField("成本in", GRFieldType.grftString).Format = "#,##0.00"; RecordSet.AddField("数量out", GRFieldType.grftString).Format = "#,##0.00"; RecordSet.AddField("成本out", GRFieldType.grftString).Format = "#,##0.00"; RecordSet.AddField("数量sum", GRFieldType.grftString).Format = "#,##0"; RecordSet.AddField("成本sum", GRFieldType.grftString).Format = "#,##0.00"; Report.DetailGrid.AddColumn("序号", "序号", "序号", 1.2).ContentCell.TextAlign = GRTextAlign.grtaMiddleCenter; Report.DetailGrid.AddColumn("单据日期", "单据日期", "单据日期", 2.1).ContentCell.TextAlign = GRTextAlign.grtaMiddleLeft; Report.DetailGrid.AddColumn("仓库编号", "仓库编号", "仓库编号", 0.9).ContentCell.TextAlign = GRTextAlign.grtaMiddleLeft; Report.DetailGrid.AddColumn("物料类型", "物料类型", "物料类型", 0.9).ContentCell.TextAlign = GRTextAlign.grtaMiddleLeft; Report.DetailGrid.AddColumn("单据名称", "单据名称", "单据名称", 2.7).ContentCell.TextAlign = GRTextAlign.grtaMiddleLeft; Report.DetailGrid.AddColumn("单据编号", "单据编号", "单据编号", 3.2).ContentCell.TextAlign = GRTextAlign.grtaMiddleLeft; Report.DetailGrid.AddColumn("发票号", "发票号", "发票号", 2.1).ContentCell.TextAlign = GRTextAlign.grtaMiddleLeft; Report.DetailGrid.AddColumn("客户名称", "客户名称", "客户名称", 7.0).ContentCell.TextAlign = GRTextAlign.grtaMiddleLeft; Report.DetailGrid.AddColumn("数量in", "数量", "数量in", 1.9).ContentCell.TextAlign = GRTextAlign.grtaBottomRight; Report.DetailGrid.AddColumn("成本in", "成本", "成本in", 2.3).ContentCell.TextAlign = GRTextAlign.grtaBottomRight; Report.DetailGrid.AddColumn("数量out", "数量", "数量out", 1.9).ContentCell.TextAlign = GRTextAlign.grtaBottomRight; Report.DetailGrid.AddColumn("成本out", "成本", "成本out", 2.3).ContentCell.TextAlign = GRTextAlign.grtaBottomRight; Report.DetailGrid.AddColumn("数量sum", "数量", "数量sum", 2.28).ContentCell.TextAlign = GRTextAlign.grtaBottomRight; Report.DetailGrid.AddColumn("成本sum", "成本", "成本sum", 2.58).ContentCell.TextAlign = GRTextAlign.grtaBottomRight; //标题行绕行 Report.DetailGrid.ColumnTitle.TitleCells[3].WordWrap = true; Report.DetailGrid.ColumnTitle.TitleCells[4].WordWrap = true; Report.DetailGrid.ColumnContent.ContentCells[6].WordWrap = true; //定义行号系统变量 IGRColumn Column = Report.DetailGrid.Columns[1]; Column.ContentCell.FreeCell = true; Column.ContentCell.Controls.RemoveAll(); IGRSystemVarBox SystemVarBox = Column.ContentCell.Controls.Add(GRControlType.grctSystemVarBox).AsSystemVarBox; SystemVarBox.Dock = GRDockStyle.grdsFill; SystemVarBox.SystemVar = GRSystemVarType.grsvRowNo; //定义双层表头 //定义标题组 IGRColumnTitleCell ColumnTitleCell1 = Report.DetailGrid.AddGroupTitle("收入", "收入"); ColumnTitleCell1.TextAlign = GRTextAlign.grtaMiddleCenter; ColumnTitleCell1.EncloseColumn("数量in"); ColumnTitleCell1.EncloseColumn("成本in"); IGRColumnTitleCell ColumnTitleCell2 = Report.DetailGrid.AddGroupTitle("发出", "发出"); ColumnTitleCell2.TextAlign = GRTextAlign.grtaMiddleCenter; ColumnTitleCell2.EncloseColumn("数量out"); ColumnTitleCell2.EncloseColumn("成本out"); IGRColumnTitleCell ColumnTitleCell3 = Report.DetailGrid.AddGroupTitle("库存", "库存"); ColumnTitleCell3.TextAlign = GRTextAlign.grtaMiddleCenter; ColumnTitleCell3.EncloseColumn("数量sum"); ColumnTitleCell3.EncloseColumn("成本sum"); //定义分组 IGRGroup Group = Report.DetailGrid.Groups.Add(); // Group.ByFields = "OrderID"; //<<定义分组头 Group.Header.Height = 0.0; //<<定义分组尾 Group.Footer.Height = 0.6; //定义分组尾的缺省字体为粗体,其拥有的部件框如没有显示定义字体,则将应用缺省字体 //Group.Footer.Font.Bold = true; IGRStaticBox StaticBox = Group.Header.Controls.Add(GRControlType.grctStaticBox).AsStaticBox; StaticBox = Group.Footer.Controls.Add(GRControlType.grctStaticBox).AsStaticBox; StaticBox.Text = "合计"; StaticBox.Left = 0.1; StaticBox.Top = 0.1; StaticBox.Width = 2.59; StaticBox.Height = 0.5; IGRSummaryBox SummaryBox = Group.Footer.Controls.Add(GRControlType.grctSummaryBox).AsSummaryBox; SummaryBox.SummaryFun = GRSummaryFun.grsfSum; SummaryBox.Format = "#,##0"; SummaryBox.DataField = "数量in"; SummaryBox.AlignColumn = "数量in"; //通过对齐到列确定部件框的左边位置与宽度 SummaryBox.TextAlign = GRTextAlign.grtaMiddleRight; SummaryBox.Top = 0.19; SummaryBox.Height = 0.40; SummaryBox = Group.Footer.Controls.Add(GRControlType.grctSummaryBox).AsSummaryBox; SummaryBox.SummaryFun = GRSummaryFun.grsfSum; SummaryBox.Format = "#,##0.00"; SummaryBox.DataField = "成本in"; SummaryBox.AlignColumn = "成本in"; //通过对齐到列确定部件框的左边位置与宽度 SummaryBox.TextAlign = GRTextAlign.grtaMiddleRight; SummaryBox.Top = 0.19; SummaryBox.Height = 0.40; SummaryBox = Group.Footer.Controls.Add(GRControlType.grctSummaryBox).AsSummaryBox; SummaryBox.SummaryFun = GRSummaryFun.grsfSum; SummaryBox.Format = "#,##0"; SummaryBox.DataField = "数量out"; SummaryBox.AlignColumn = "数量out"; //通过对齐到列确定部件框的左边位置与宽度 SummaryBox.TextAlign = GRTextAlign.grtaMiddleRight; SummaryBox.Top = 0.19; SummaryBox.Height = 0.40; SummaryBox = Group.Footer.Controls.Add(GRControlType.grctSummaryBox).AsSummaryBox; SummaryBox.SummaryFun = GRSummaryFun.grsfSum; SummaryBox.Format = "#,##0.00"; SummaryBox.DataField = "成本out"; SummaryBox.AlignColumn = "成本out"; //通过对齐到列确定部件框的左边位置与宽度 SummaryBox.TextAlign = GRTextAlign.grtaMiddleRight; SummaryBox.Top = 0.19; SummaryBox.Height = 0.40; SummaryBox = Group.Footer.Controls.Add(GRControlType.grctSummaryBox).AsSummaryBox; SummaryBox.SummaryFun = GRSummaryFun.grsfSum; SummaryBox.Format = "#,##0"; SummaryBox.DataField = "数量sum"; SummaryBox.AlignColumn = "数量sum"; //通过对齐到列确定部件框的左边位置与宽度 SummaryBox.TextAlign = GRTextAlign.grtaMiddleRight; SummaryBox.Top = 0.19; SummaryBox.Height = 0.40; SummaryBox = Group.Footer.Controls.Add(GRControlType.grctSummaryBox).AsSummaryBox; SummaryBox.SummaryFun = GRSummaryFun.grsfSum; SummaryBox.Format = "#,##0.00"; SummaryBox.DataField = "成本sum"; SummaryBox.AlignColumn = "成本sum"; //通过对齐到列确定部件框的左边位置与宽度 SummaryBox.TextAlign = GRTextAlign.grtaMiddleRight; SummaryBox.Top = 0.19; SummaryBox.Height = 0.40; }
/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnQuery_Click(object sender, EventArgs e) { if (_currentReport.REPORT_ID <= 0) { MessageBox.Show("请选择报表", "提示"); return; } string Reportname = _currentReport.NAME.Trim() + ".grf"; if (!System.IO.File.Exists(System.Windows.Forms.Application.StartupPath + "\\report\\newreport\\" + Reportname)) { Report = new GridppReport(); Paramlist = _Paramprocess.getParaX(_currentReport.REPORT_ID); if (Paramlist == null) { return; } Report.InsertReportHeader(); Report.InsertDetailGrid(); Report.InsertReportFooter(); Report.DetailGrid.IsCrossTab = true; IGRRecordset RecordSet = Report.DetailGrid.Recordset; foreach (Paramater pp in Paramlist) { if (pp.PARAMETER_TYPE == "表头表尾" || pp.PARAMETER_TYPE == "IN") { Report.AddParameter(pp.PARAMETER_CN, GRParameterDataType.grptString); } else if (pp.PARAMETER_TYPE == "明细") { if (pp.PARAMDATATYPE == 1) { RecordSet.AddField(pp.PARAMETER, GRFieldType.grftFloat); } else { RecordSet.AddField(pp.PARAMETER, GRFieldType.grftString); } } else { continue; } } Report.AddParameter("报表名称", GRParameterDataType.grptString); Report.AddParameter("打印时间", GRParameterDataType.grptString); Report.AddParameter("当前科室", GRParameterDataType.grptString); Report.AddParameter("当前人员", GRParameterDataType.grptString); Report.DetailGrid.IsCrossTab = false; Report.SaveToFile(System.Windows.Forms.Application.StartupPath + "\\report\\newreport\\" + Reportname); } FrmQueryControl query = new FrmQueryControl(_Paramprocess.getPara(_currentReport.REPORT_ID), _user.EmployeeID, _dept.DeptID); if (paramlistCopy != null && paramlistCopy.Count > 0) { query.setParamValue(paramlistCopy); } query.ShowDialog(); if (!query.isok) { return; } Report = new GridppReport(); Paramlist = query.GetParaValue(); paramlistCopy = Paramlist; string filePath = System.Windows.Forms.Application.StartupPath + "\\report\\newreport\\" + Reportname; Report.LoadFromFile(filePath); foreach (Paramater pp in Paramlist) { if (pp.PARAMETER_TYPE == "OUT") { continue; } if (pp.PARAMETER_TYPE != "明细") { if (pp.objvalueCN != null) { try { Report.ParameterByName(pp.PARAMETER_CN).AsString = pp.objvalueCN.ToString(); } catch { Report.AddParameter(pp.PARAMETER_CN, GRParameterDataType.grptString); Report.SaveToFile(System.Windows.Forms.Application.StartupPath + "\\report\\newreport\\" + Reportname); } finally { Report.ParameterByName(pp.PARAMETER_CN).AsString = pp.objvalueCN.ToString(); } } else { try { Report.ParameterByName(pp.PARAMETER_CN).AsString = pp.objvalue.ToString(); } catch { Report.AddParameter(pp.PARAMETER_CN, GRParameterDataType.grptString); Report.SaveToFile(System.Windows.Forms.Application.StartupPath + "\\report\\newreport\\" + Reportname); } finally { Report.ParameterByName(pp.PARAMETER_CN).AsString = pp.objvalue.ToString(); } } } } Report.ParameterByName("报表名称").AsString = HIS.SYSTEM.BussinessLogicLayer.Classes.BaseData.WorkName + _currentReport.NAME; Report.ParameterByName("打印时间").AsString = System.DateTime.Now.ToString(); Report.ParameterByName("当前科室").AsString = _currentDeptidname; Report.ParameterByName("当前人员").AsString = _user.Name; DataTable dataoutPara = _reportProcess.getOutParamter(_currentReport, Paramlist); //获取报表数据 if (_currentReport.REMARK != null && _currentReport.REMARK.ToString() == "1") //add by heyan 按统计大类统计报表 { for (int i = 0; i < dataoutPara.Rows.Count; i++) { int columndex = 0; try { Report.ParameterByName(dataoutPara.Rows[i][0].ToString()).AsString = dataoutPara.Rows[i][0].ToString(); for (columndex = 1; columndex < dataoutPara.Columns.Count; columndex++) { Report.ParameterByName(dataoutPara.Rows[i][0].ToString().Trim() + "_" + columndex).AsString = dataoutPara.Rows[i][columndex].ToString(); } } catch { Report.AddParameter(dataoutPara.Rows[i][0].ToString(), GRParameterDataType.grptString); for (columndex = 1; columndex < dataoutPara.Columns.Count; columndex++) { Report.AddParameter(dataoutPara.Rows[i][0].ToString().Trim() + "_" + columndex, GRParameterDataType.grptString); } Report.SaveToFile(System.Windows.Forms.Application.StartupPath + "\\report\\newreport\\" + Reportname); } Report.ParameterByName(dataoutPara.Rows[i][0].ToString()).AsString = dataoutPara.Rows[i][0].ToString(); for (columndex = 1; columndex < dataoutPara.Columns.Count; columndex++) { Report.ParameterByName(dataoutPara.Rows[i][0].ToString().Trim() + "_" + columndex).AsString = dataoutPara.Rows[i][columndex].ToString(); } } decimal sum = 0; for (int i = 0; i < dataoutPara.Rows.Count; i++) { sum += Convert.ToDecimal(HIS.SYSTEM.PubicBaseClasses.XcConvert.IsNull(dataoutPara.Rows[i][1], "0")); } try { Report.ParameterByName("合计金额").AsString = sum.ToString(); } catch { Report.AddParameter("合计金额", GRParameterDataType.grptString); Report.SaveToFile(System.Windows.Forms.Application.StartupPath + "\\report\\newreport\\" + Reportname); Report.ParameterByName("合计金额").AsString = sum.ToString(); } } else { try { if (Report.DetailGrid.Recordset.Fields.Count == 0) { for (int i = 0; i < dataoutPara.Columns.Count; i++) { Report.DetailGrid.AddColumn(dataoutPara.Columns[i].ColumnName, dataoutPara.Columns[i].ColumnName, dataoutPara.Columns[i].ColumnName, 2); Report.DetailGrid.Recordset.AddField(dataoutPara.Columns[i].ColumnName, GRFieldType.grftString); } Report.SaveToFile(System.Windows.Forms.Application.StartupPath + "\\report\\newreport\\" + Reportname); } } catch { } } tPrintTable = dataoutPara; Report.FetchRecord += new _IGridppReportEvents_FetchRecordEventHandler(reportPrinter_FetchRecord); Frmtest foo = new Frmtest(); foo.AttachReport(Report); foo.TopLevel = false; foo.WindowState = FormWindowState.Maximized; foo.FormBorderStyle = FormBorderStyle.None; panel12.Controls.Add(foo); foo.Dock = DockStyle.Fill; foo.Show(); }
private void DefineDetailGrid() { Report.InsertDetailGrid(); Report.DetailGrid.ColumnTitle.Height = 0.98;//标题行高度 // Report.DetailGrid.ColumnTitle.TitleCells[3].WordWrap = true; Report.DetailGrid.ColumnContent.Height = 0.58; //内容行高度 Report.DetailGrid.ColumnContent.AlternatingBackColor = 230 * 256 * 256 + 217 * 256 + 217; //内容行交替背景色 Report.DetailGrid.ColumnTitle.BackColor = 217 * 256 * 256 + 217 * 256 + 217; //标题行背景色 //定义数据集的各个字段 IGRRecordset RecordSet = Report.DetailGrid.Recordset; switch (this.selectedIndex) { case 0: RecordSet.AddField("单据类别", GRFieldType.grftString).Format = "#,##0.00"; RecordSet.AddField("单据日期", GRFieldType.grftString).Format = "#,##0.00"; RecordSet.AddField("仓库", GRFieldType.grftString).Format = "#,##0.00"; RecordSet.AddField("发票编号", GRFieldType.grftString).Format = "#,##0.00"; RecordSet.AddField("客户名称", GRFieldType.grftString).Format = "#,##0.00"; RecordSet.AddField("商品编号", GRFieldType.grftString).Format = "#,##0.00"; RecordSet.AddField("商品名称", GRFieldType.grftString).Format = "#,##0.00"; RecordSet.AddField("数量", GRFieldType.grftString).Format = "#,##0.00"; RecordSet.AddField("含税金额", GRFieldType.grftString).Format = "#,##0.00"; RecordSet.AddField("核销金额", GRFieldType.grftString).Format = "#,##0.00"; RecordSet.AddField("核销记录", GRFieldType.grftString).Format = "#,##0.00"; RecordSet.AddField("操作员", GRFieldType.grftString).Format = "#,##0"; RecordSet.AddField("成本金额", GRFieldType.grftString).Format = "#,##0.00"; RecordSet.AddField("凭证号", GRFieldType.grftString).Format = "#,##0.00"; RecordSet.AddField("备注", GRFieldType.grftString).Format = "#,##0"; RecordSet.AddField("备注1", GRFieldType.grftString).Format = "#,##0.00"; Report.DetailGrid.AddColumn("序号", "序号", "序号", 1.2).ContentCell.TextAlign = GRTextAlign.grtaMiddleCenter; Report.DetailGrid.AddColumn("单据类别", "单据类别", "单据类别", 1.2).ContentCell.TextAlign = GRTextAlign.grtaMiddleCenter; Report.DetailGrid.AddColumn("单据日期", "单据日期", "单据日期", 2.1).ContentCell.TextAlign = GRTextAlign.grtaMiddleLeft; Report.DetailGrid.AddColumn("仓库", "仓库", "仓库", 0.9).ContentCell.TextAlign = GRTextAlign.grtaMiddleLeft; Report.DetailGrid.AddColumn("发票编号", "发票编号", "发票编号", 0.9).ContentCell.TextAlign = GRTextAlign.grtaMiddleLeft; Report.DetailGrid.AddColumn("客户名称", "客户名称", "客户名称", 2.7).ContentCell.TextAlign = GRTextAlign.grtaMiddleLeft; Report.DetailGrid.AddColumn("商品编号", "商品编号", "商品编号", 3.2).ContentCell.TextAlign = GRTextAlign.grtaMiddleLeft; Report.DetailGrid.AddColumn("商品名称", "商品名称", "商品名称", 2.1).ContentCell.TextAlign = GRTextAlign.grtaMiddleLeft; Report.DetailGrid.AddColumn("数量", "数量", "数量", 1.9).ContentCell.TextAlign = GRTextAlign.grtaBottomRight; Report.DetailGrid.AddColumn("含税金额", "含税金额", "含税金额", 2.3).ContentCell.TextAlign = GRTextAlign.grtaBottomRight; Report.DetailGrid.AddColumn("核销金额", "核销金额", "核销金额", 1.9).ContentCell.TextAlign = GRTextAlign.grtaBottomRight; Report.DetailGrid.AddColumn("核销记录", "核销记录", "核销记录", 2.3).ContentCell.TextAlign = GRTextAlign.grtaBottomRight; Report.DetailGrid.AddColumn("操作员", "操作员", "操作员", 2.28).ContentCell.TextAlign = GRTextAlign.grtaBottomRight; Report.DetailGrid.AddColumn("成本金额", "成本金额", "成本金额", 2.58).ContentCell.TextAlign = GRTextAlign.grtaBottomRight; Report.DetailGrid.AddColumn("凭证号", "凭证号", "凭证号", 2.3).ContentCell.TextAlign = GRTextAlign.grtaBottomRight; Report.DetailGrid.AddColumn("备注", "备注", "备注", 2.28).ContentCell.TextAlign = GRTextAlign.grtaBottomRight; Report.DetailGrid.AddColumn("备注1", "备注1", "备注1", 2.58).ContentCell.TextAlign = GRTextAlign.grtaBottomRight; break; case 1: RecordSet.AddField("发票编号", GRFieldType.grftString).Format = "#,##0.00"; RecordSet.AddField("单据日期", GRFieldType.grftString).Format = "#,##0.00"; RecordSet.AddField("客户名称", GRFieldType.grftString).Format = "#,##0.00"; RecordSet.AddField("商品编号", GRFieldType.grftString).Format = "#,##0.00"; RecordSet.AddField("商品名称", GRFieldType.grftString).Format = "#,##0.00"; RecordSet.AddField("数量", GRFieldType.grftString).Format = "#,##0.00"; RecordSet.AddField("含税金额", GRFieldType.grftString).Format = "#,##0.00"; RecordSet.AddField("核销金额", GRFieldType.grftString).Format = "#,##0.00"; RecordSet.AddField("余额", GRFieldType.grftString).Format = "#,##0"; RecordSet.AddField("核销日期", GRFieldType.grftString).Format = "#,##0.00"; RecordSet.AddField("核销记录", GRFieldType.grftString).Format = "#,##0.00"; RecordSet.AddField("凭证号", GRFieldType.grftString).Format = "#,##0.00"; RecordSet.AddField("备注", GRFieldType.grftString).Format = "#,##0"; RecordSet.AddField("备注1", GRFieldType.grftString).Format = "#,##0.00"; Report.DetailGrid.AddColumn("序号", "序号", "序号", 1.2).ContentCell.TextAlign = GRTextAlign.grtaMiddleCenter; Report.DetailGrid.AddColumn("单据日期", "单据日期", "单据日期", 2.1).ContentCell.TextAlign = GRTextAlign.grtaMiddleLeft; Report.DetailGrid.AddColumn("发票编号", "发票编号", "发票编号", 0.9).ContentCell.TextAlign = GRTextAlign.grtaMiddleLeft; Report.DetailGrid.AddColumn("客户名称", "客户名称", "客户名称", 2.7).ContentCell.TextAlign = GRTextAlign.grtaMiddleLeft; Report.DetailGrid.AddColumn("商品编号", "商品编号", "商品编号", 3.2).ContentCell.TextAlign = GRTextAlign.grtaMiddleLeft; Report.DetailGrid.AddColumn("商品名称", "商品名称", "商品名称", 2.1).ContentCell.TextAlign = GRTextAlign.grtaMiddleLeft; Report.DetailGrid.AddColumn("数量", "数量", "数量", 1.9).ContentCell.TextAlign = GRTextAlign.grtaBottomRight; Report.DetailGrid.AddColumn("含税金额", "含税金额", "含税金额", 2.3).ContentCell.TextAlign = GRTextAlign.grtaBottomRight; Report.DetailGrid.AddColumn("核销金额", "核销金额", "核销金额", 1.9).ContentCell.TextAlign = GRTextAlign.grtaBottomRight; Report.DetailGrid.AddColumn("余额", "余额", "余额", 1.9).ContentCell.TextAlign = GRTextAlign.grtaBottomRight; Report.DetailGrid.AddColumn("核销日期", "核销日期", "核销日期", 1.9).ContentCell.TextAlign = GRTextAlign.grtaBottomRight; Report.DetailGrid.AddColumn("核销记录", "核销记录", "核销记录", 2.3).ContentCell.TextAlign = GRTextAlign.grtaBottomRight; Report.DetailGrid.AddColumn("凭证号", "凭证号", "凭证号", 2.3).ContentCell.TextAlign = GRTextAlign.grtaBottomRight; Report.DetailGrid.AddColumn("备注", "备注", "备注", 2.28).ContentCell.TextAlign = GRTextAlign.grtaBottomRight; Report.DetailGrid.AddColumn("备注1", "备注1", "备注1", 2.58).ContentCell.TextAlign = GRTextAlign.grtaBottomRight; break; case 2: RecordSet.AddField("工作年月", GRFieldType.grftString).Format = "#,##0.00"; RecordSet.AddField("客户代码", GRFieldType.grftString).Format = "#,##0.00"; RecordSet.AddField("客户名称", GRFieldType.grftString).Format = "#,##0.00"; RecordSet.AddField("商品名称", GRFieldType.grftString).Format = "#,##0.00"; RecordSet.AddField("核销金额", GRFieldType.grftString).Format = "#,##0.00"; RecordSet.AddField("现金支票", GRFieldType.grftString).Format = "#,##0"; RecordSet.AddField("核销记录", GRFieldType.grftString).Format = "#,##0.00"; RecordSet.AddField("凭证号", GRFieldType.grftString).Format = "#,##0.00"; RecordSet.AddField("备注", GRFieldType.grftString).Format = "#,##0"; RecordSet.AddField("备注1", GRFieldType.grftString).Format = "#,##0.00"; Report.DetailGrid.AddColumn("序号", "序号", "序号", 1.2).ContentCell.TextAlign = GRTextAlign.grtaMiddleCenter; Report.DetailGrid.AddColumn("工作年月", "工作年月", "工作年月", 2.1).ContentCell.TextAlign = GRTextAlign.grtaMiddleLeft; Report.DetailGrid.AddColumn("客户代码", "客户代码", "客户代码", 0.9).ContentCell.TextAlign = GRTextAlign.grtaMiddleLeft; Report.DetailGrid.AddColumn("客户名称", "客户名称", "客户名称", 2.7).ContentCell.TextAlign = GRTextAlign.grtaMiddleLeft; Report.DetailGrid.AddColumn("商品名称", "商品名称", "商品名称", 2.1).ContentCell.TextAlign = GRTextAlign.grtaMiddleLeft; Report.DetailGrid.AddColumn("核销金额", "核销金额", "核销金额", 1.9).ContentCell.TextAlign = GRTextAlign.grtaBottomRight; Report.DetailGrid.AddColumn("现金支票", "现金支票", "现金支票", 1.9).ContentCell.TextAlign = GRTextAlign.grtaBottomRight; Report.DetailGrid.AddColumn("核销记录", "核销记录", "核销记录", 2.3).ContentCell.TextAlign = GRTextAlign.grtaBottomRight; Report.DetailGrid.AddColumn("凭证号", "凭证号", "凭证号", 2.3).ContentCell.TextAlign = GRTextAlign.grtaBottomRight; Report.DetailGrid.AddColumn("备注", "备注", "备注", 2.28).ContentCell.TextAlign = GRTextAlign.grtaBottomRight; Report.DetailGrid.AddColumn("备注1", "备注1", "备注1", 2.58).ContentCell.TextAlign = GRTextAlign.grtaBottomRight; break; case 3: RecordSet.AddField("工作年月", GRFieldType.grftString).Format = "#,##0.00"; RecordSet.AddField("核销记录", GRFieldType.grftString).Format = "#,##0.00"; RecordSet.AddField("客户名称", GRFieldType.grftString).Format = "#,##0.00"; RecordSet.AddField("核销金额", GRFieldType.grftString).Format = "#,##0.00"; RecordSet.AddField("凭证号", GRFieldType.grftString).Format = "#,##0.00"; RecordSet.AddField("备注", GRFieldType.grftString).Format = "#,##0"; RecordSet.AddField("备注1", GRFieldType.grftString).Format = "#,##0.00"; Report.DetailGrid.AddColumn("序号", "序号", "序号", 1.2).ContentCell.TextAlign = GRTextAlign.grtaMiddleCenter; Report.DetailGrid.AddColumn("工作年月", "工作年月", "工作年月", 2.1).ContentCell.TextAlign = GRTextAlign.grtaMiddleLeft; Report.DetailGrid.AddColumn("核销记录", "核销记录", "核销记录", 2.3).ContentCell.TextAlign = GRTextAlign.grtaBottomRight; Report.DetailGrid.AddColumn("客户名称", "客户名称", "客户名称", 2.7).ContentCell.TextAlign = GRTextAlign.grtaMiddleLeft; Report.DetailGrid.AddColumn("核销金额", "核销金额", "核销金额", 1.9).ContentCell.TextAlign = GRTextAlign.grtaBottomRight; Report.DetailGrid.AddColumn("凭证号", "凭证号", "凭证号", 2.3).ContentCell.TextAlign = GRTextAlign.grtaBottomRight; Report.DetailGrid.AddColumn("备注", "备注", "备注", 2.28).ContentCell.TextAlign = GRTextAlign.grtaBottomRight; Report.DetailGrid.AddColumn("备注1", "备注1", "备注1", 2.58).ContentCell.TextAlign = GRTextAlign.grtaBottomRight; break; case 4: RecordSet.AddField("单据类别", GRFieldType.grftString).Format = "#,##0.00"; RecordSet.AddField("单据日期", GRFieldType.grftString).Format = "#,##0.00"; RecordSet.AddField("仓库", GRFieldType.grftString).Format = "#,##0.00"; RecordSet.AddField("发票编号", GRFieldType.grftString).Format = "#,##0.00"; RecordSet.AddField("客户名称", GRFieldType.grftString).Format = "#,##0.00"; RecordSet.AddField("商品编号", GRFieldType.grftString).Format = "#,##0.00"; RecordSet.AddField("商品名称", GRFieldType.grftString).Format = "#,##0.00"; RecordSet.AddField("数量", GRFieldType.grftString).Format = "#,##0.00"; RecordSet.AddField("含税金额", GRFieldType.grftString).Format = "#,##0.00"; RecordSet.AddField("核销金额", GRFieldType.grftString).Format = "#,##0.00"; RecordSet.AddField("核销记录", GRFieldType.grftString).Format = "#,##0.00"; RecordSet.AddField("操作员", GRFieldType.grftString).Format = "#,##0"; RecordSet.AddField("成本金额", GRFieldType.grftString).Format = "#,##0.00"; RecordSet.AddField("凭证号", GRFieldType.grftString).Format = "#,##0.00"; RecordSet.AddField("备注", GRFieldType.grftString).Format = "#,##0"; RecordSet.AddField("备注1", GRFieldType.grftString).Format = "#,##0.00"; Report.DetailGrid.AddColumn("序号", "序号", "序号", 1.2).ContentCell.TextAlign = GRTextAlign.grtaMiddleCenter; Report.DetailGrid.AddColumn("单据类别", "单据类别", "单据类别", 1.2).ContentCell.TextAlign = GRTextAlign.grtaMiddleCenter; Report.DetailGrid.AddColumn("单据日期", "单据日期", "单据日期", 2.1).ContentCell.TextAlign = GRTextAlign.grtaMiddleLeft; Report.DetailGrid.AddColumn("仓库", "仓库", "仓库", 0.9).ContentCell.TextAlign = GRTextAlign.grtaMiddleLeft; Report.DetailGrid.AddColumn("发票编号", "发票编号", "发票编号", 0.9).ContentCell.TextAlign = GRTextAlign.grtaMiddleLeft; Report.DetailGrid.AddColumn("客户名称", "客户名称", "客户名称", 2.7).ContentCell.TextAlign = GRTextAlign.grtaMiddleLeft; Report.DetailGrid.AddColumn("商品编号", "商品编号", "商品编号", 3.2).ContentCell.TextAlign = GRTextAlign.grtaMiddleLeft; Report.DetailGrid.AddColumn("商品名称", "商品名称", "商品名称", 2.1).ContentCell.TextAlign = GRTextAlign.grtaMiddleLeft; Report.DetailGrid.AddColumn("数量", "数量", "数量", 1.9).ContentCell.TextAlign = GRTextAlign.grtaBottomRight; Report.DetailGrid.AddColumn("含税金额", "含税金额", "含税金额", 2.3).ContentCell.TextAlign = GRTextAlign.grtaBottomRight; Report.DetailGrid.AddColumn("核销金额", "核销金额", "核销金额", 1.9).ContentCell.TextAlign = GRTextAlign.grtaBottomRight; Report.DetailGrid.AddColumn("核销记录", "核销记录", "核销记录", 2.3).ContentCell.TextAlign = GRTextAlign.grtaBottomRight; Report.DetailGrid.AddColumn("操作员", "操作员", "操作员", 2.28).ContentCell.TextAlign = GRTextAlign.grtaBottomRight; Report.DetailGrid.AddColumn("成本金额", "成本金额", "成本金额", 2.58).ContentCell.TextAlign = GRTextAlign.grtaBottomRight; Report.DetailGrid.AddColumn("凭证号", "凭证号", "凭证号", 2.3).ContentCell.TextAlign = GRTextAlign.grtaBottomRight; Report.DetailGrid.AddColumn("备注", "备注", "备注", 2.28).ContentCell.TextAlign = GRTextAlign.grtaBottomRight; Report.DetailGrid.AddColumn("备注1", "备注1", "备注1", 2.58).ContentCell.TextAlign = GRTextAlign.grtaBottomRight; break; case 5: RecordSet.AddField("发票编号", GRFieldType.grftString).Format = "#,##0.00"; RecordSet.AddField("单据日期", GRFieldType.grftString).Format = "#,##0.00"; RecordSet.AddField("客户名称", GRFieldType.grftString).Format = "#,##0.00"; RecordSet.AddField("商品编号", GRFieldType.grftString).Format = "#,##0.00"; RecordSet.AddField("商品名称", GRFieldType.grftString).Format = "#,##0.00"; RecordSet.AddField("数量", GRFieldType.grftString).Format = "#,##0.00"; RecordSet.AddField("含税金额", GRFieldType.grftString).Format = "#,##0.00"; RecordSet.AddField("核销金额", GRFieldType.grftString).Format = "#,##0.00"; RecordSet.AddField("余额", GRFieldType.grftString).Format = "#,##0"; RecordSet.AddField("核销日期", GRFieldType.grftString).Format = "#,##0.00"; RecordSet.AddField("核销记录", GRFieldType.grftString).Format = "#,##0.00"; RecordSet.AddField("凭证号", GRFieldType.grftString).Format = "#,##0.00"; RecordSet.AddField("备注", GRFieldType.grftString).Format = "#,##0"; RecordSet.AddField("备注1", GRFieldType.grftString).Format = "#,##0.00"; Report.DetailGrid.AddColumn("序号", "序号", "序号", 1.2).ContentCell.TextAlign = GRTextAlign.grtaMiddleCenter; Report.DetailGrid.AddColumn("单据日期", "单据日期", "单据日期", 2.1).ContentCell.TextAlign = GRTextAlign.grtaMiddleLeft; Report.DetailGrid.AddColumn("发票编号", "发票编号", "发票编号", 0.9).ContentCell.TextAlign = GRTextAlign.grtaMiddleLeft; Report.DetailGrid.AddColumn("客户名称", "客户名称", "客户名称", 2.7).ContentCell.TextAlign = GRTextAlign.grtaMiddleLeft; Report.DetailGrid.AddColumn("商品编号", "商品编号", "商品编号", 3.2).ContentCell.TextAlign = GRTextAlign.grtaMiddleLeft; Report.DetailGrid.AddColumn("商品名称", "商品名称", "商品名称", 2.1).ContentCell.TextAlign = GRTextAlign.grtaMiddleLeft; Report.DetailGrid.AddColumn("数量", "数量", "数量", 1.9).ContentCell.TextAlign = GRTextAlign.grtaBottomRight; Report.DetailGrid.AddColumn("含税金额", "含税金额", "含税金额", 2.3).ContentCell.TextAlign = GRTextAlign.grtaBottomRight; Report.DetailGrid.AddColumn("核销金额", "核销金额", "核销金额", 1.9).ContentCell.TextAlign = GRTextAlign.grtaBottomRight; Report.DetailGrid.AddColumn("余额", "余额", "余额", 1.9).ContentCell.TextAlign = GRTextAlign.grtaBottomRight; Report.DetailGrid.AddColumn("核销日期", "核销日期", "核销日期", 1.9).ContentCell.TextAlign = GRTextAlign.grtaBottomRight; Report.DetailGrid.AddColumn("核销记录", "核销记录", "核销记录", 2.3).ContentCell.TextAlign = GRTextAlign.grtaBottomRight; Report.DetailGrid.AddColumn("凭证号", "凭证号", "凭证号", 2.3).ContentCell.TextAlign = GRTextAlign.grtaBottomRight; Report.DetailGrid.AddColumn("备注", "备注", "备注", 2.28).ContentCell.TextAlign = GRTextAlign.grtaBottomRight; Report.DetailGrid.AddColumn("备注1", "备注1", "备注1", 2.58).ContentCell.TextAlign = GRTextAlign.grtaBottomRight; break; default: return; } //标题行绕行 Report.DetailGrid.ColumnTitle.TitleCells[3].WordWrap = true; Report.DetailGrid.ColumnTitle.TitleCells[4].WordWrap = true; Report.DetailGrid.ColumnContent.ContentCells[6].WordWrap = true; //定义行号系统变量 IGRColumn Column = Report.DetailGrid.Columns[1]; Column.ContentCell.FreeCell = true; Column.ContentCell.Controls.RemoveAll(); IGRSystemVarBox SystemVarBox = Column.ContentCell.Controls.Add(GRControlType.grctSystemVarBox).AsSystemVarBox; SystemVarBox.Dock = GRDockStyle.grdsFill; SystemVarBox.SystemVar = GRSystemVarType.grsvRowNo; //定义分组 IGRGroup Group = Report.DetailGrid.Groups.Add(); // Group.ByFields = "OrderID"; //<<定义分组头 Group.Header.Height = 0.0; //<<定义分组尾 Group.Footer.Height = 0.6; //定义分组尾的缺省字体为粗体,其拥有的部件框如没有显示定义字体,则将应用缺省字体 //Group.Footer.Font.Bold = true; IGRStaticBox StaticBox = Group.Header.Controls.Add(GRControlType.grctStaticBox).AsStaticBox; StaticBox = Group.Footer.Controls.Add(GRControlType.grctStaticBox).AsStaticBox; StaticBox.Text = "合计"; StaticBox.Left = 0.1; StaticBox.Top = 0.1; StaticBox.Width = 2.59; StaticBox.Height = 0.5; IGRSummaryBox SummaryBox = Group.Footer.Controls.Add(GRControlType.grctSummaryBox).AsSummaryBox; SummaryBox.SummaryFun = GRSummaryFun.grsfSum; SummaryBox.Format = "#,##0"; SummaryBox.DataField = "数量in"; SummaryBox.AlignColumn = "数量in"; //通过对齐到列确定部件框的左边位置与宽度 SummaryBox.TextAlign = GRTextAlign.grtaMiddleRight; SummaryBox.Top = 0.19; SummaryBox.Height = 0.40; SummaryBox = Group.Footer.Controls.Add(GRControlType.grctSummaryBox).AsSummaryBox; SummaryBox.SummaryFun = GRSummaryFun.grsfSum; SummaryBox.Format = "#,##0.00"; SummaryBox.DataField = "成本in"; SummaryBox.AlignColumn = "成本in"; //通过对齐到列确定部件框的左边位置与宽度 SummaryBox.TextAlign = GRTextAlign.grtaMiddleRight; SummaryBox.Top = 0.19; SummaryBox.Height = 0.40; SummaryBox = Group.Footer.Controls.Add(GRControlType.grctSummaryBox).AsSummaryBox; SummaryBox.SummaryFun = GRSummaryFun.grsfSum; SummaryBox.Format = "#,##0"; SummaryBox.DataField = "数量out"; SummaryBox.AlignColumn = "数量out"; //通过对齐到列确定部件框的左边位置与宽度 SummaryBox.TextAlign = GRTextAlign.grtaMiddleRight; SummaryBox.Top = 0.19; SummaryBox.Height = 0.40; SummaryBox = Group.Footer.Controls.Add(GRControlType.grctSummaryBox).AsSummaryBox; SummaryBox.SummaryFun = GRSummaryFun.grsfSum; SummaryBox.Format = "#,##0.00"; SummaryBox.DataField = "成本out"; SummaryBox.AlignColumn = "成本out"; //通过对齐到列确定部件框的左边位置与宽度 SummaryBox.TextAlign = GRTextAlign.grtaMiddleRight; SummaryBox.Top = 0.19; SummaryBox.Height = 0.40; SummaryBox = Group.Footer.Controls.Add(GRControlType.grctSummaryBox).AsSummaryBox; SummaryBox.SummaryFun = GRSummaryFun.grsfSum; SummaryBox.Format = "#,##0"; SummaryBox.DataField = "数量sum"; SummaryBox.AlignColumn = "数量sum"; //通过对齐到列确定部件框的左边位置与宽度 SummaryBox.TextAlign = GRTextAlign.grtaMiddleRight; SummaryBox.Top = 0.19; SummaryBox.Height = 0.40; SummaryBox = Group.Footer.Controls.Add(GRControlType.grctSummaryBox).AsSummaryBox; SummaryBox.SummaryFun = GRSummaryFun.grsfSum; SummaryBox.Format = "#,##0.00"; SummaryBox.DataField = "成本sum"; SummaryBox.AlignColumn = "成本sum"; //通过对齐到列确定部件框的左边位置与宽度 SummaryBox.TextAlign = GRTextAlign.grtaMiddleRight; SummaryBox.Top = 0.19; SummaryBox.Height = 0.40; }
private void DefineDetailGrid() { Report.InsertDetailGrid(); Report.DetailGrid.ColumnTitle.Height = 0.68; Report.DetailGrid.ColumnContent.Height = 0.58; Report.DetailGrid.ColumnContent.AlternatingBackColor = 151 * 256 * 256 + 255 * 256 + 255; //内容行交替色 Report.DetailGrid.ColumnTitle.BackColor = 217 * 256 * 256 + 217 * 256 + 217; //标题行颜色 //定义数据集的各个字段 IGRRecordset RecordSet = Report.DetailGrid.Recordset; //RecordSet.AddField("序号", GRFieldType.grftString); RecordSet.AddField("卡片编号", GRFieldType.grftString).Format = "#,##0.00"; RecordSet.AddField("卡片名称", GRFieldType.grftString).Format = "#,##0.00"; RecordSet.AddField("仓库", GRFieldType.grftString).Format = "#,##0.00"; RecordSet.AddField("类型", GRFieldType.grftString).Format = "#,##0.00"; RecordSet.AddField("期初数量", GRFieldType.grftString).Format = "#,##0.00"; RecordSet.AddField("收入数量", GRFieldType.grftString).Format = "#,##0.00"; RecordSet.AddField("发出数量", GRFieldType.grftString).Format = "#,##0.00"; RecordSet.AddField("结存数量", GRFieldType.grftString).Format = "#,##0.00"; RecordSet.AddField("结存成本", GRFieldType.grftString).Format = "#,##0.00"; Report.DetailGrid.AddColumn("序号", "序号", "序号", 1.0).ContentCell.TextAlign = GRTextAlign.grtaMiddleCenter; Report.DetailGrid.AddColumn("卡片编号", "卡片编号", "卡片编号", 2.3).ContentCell.TextAlign = GRTextAlign.grtaMiddleLeft; Report.DetailGrid.AddColumn("卡片名称", "卡片名称", "卡片名称", 5.4).ContentCell.TextAlign = GRTextAlign.grtaMiddleLeft; Report.DetailGrid.AddColumn("仓库", "仓库", "仓库", 0.9).ContentCell.TextAlign = GRTextAlign.grtaMiddleLeft; Report.DetailGrid.AddColumn("类型", "类型", "类型", 0.9).ContentCell.TextAlign = GRTextAlign.grtaMiddleLeft; Report.DetailGrid.AddColumn("期初数量", "期初数量", "期初数量", 2.2).ContentCell.TextAlign = GRTextAlign.grtaMiddleRight; Report.DetailGrid.AddColumn("收入数量", "收入数量", "收入数量", 2.0).ContentCell.TextAlign = GRTextAlign.grtaMiddleRight; Report.DetailGrid.AddColumn("发出数量", "发出数量", "发出数量", 1.8).ContentCell.TextAlign = GRTextAlign.grtaMiddleRight; Report.DetailGrid.AddColumn("结存数量", "结存数量", "结存数量", 2.38).ContentCell.TextAlign = GRTextAlign.grtaMiddleRight; Report.DetailGrid.AddColumn("结存成本", "结存成本", "结存成本", 2.38).ContentCell.TextAlign = GRTextAlign.grtaMiddleRight; //定义列(定义明细网格) 后部分为明细显示的位置方法 IGRColumn Column = Report.DetailGrid.Columns[1]; Column.ContentCell.FreeCell = true; Column.ContentCell.Controls.RemoveAll(); IGRSystemVarBox SystemVarBox = Column.ContentCell.Controls.Add(GRControlType.grctSystemVarBox).AsSystemVarBox; SystemVarBox.Dock = GRDockStyle.grdsFill; SystemVarBox.SystemVar = GRSystemVarType.grsvRowNo; //定义分组 IGRGroup Group = Report.DetailGrid.Groups.Add(); // Group.ByFields = "OrderID"; //<<定义分组头 Group.Header.Height = 0.0; //<<定义分组尾 Group.Footer.Height = 0.6; //定义分组尾的缺省字体为粗体,其拥有的部件框如没有显示定义字体,则将应用缺省字体 Group.Footer.Font.Bold = true; IGRStaticBox StaticBox = Group.Header.Controls.Add(GRControlType.grctStaticBox).AsStaticBox; StaticBox = Group.Footer.Controls.Add(GRControlType.grctStaticBox).AsStaticBox; StaticBox.Text = "合计"; StaticBox.Left = 0.1; StaticBox.Top = 0.1; StaticBox.Width = 2.59; StaticBox.Height = 0.5; IGRSummaryBox SummaryBox = Group.Footer.Controls.Add(GRControlType.grctSummaryBox).AsSummaryBox; SummaryBox.SummaryFun = GRSummaryFun.grsfSum; SummaryBox.Format = "#,##0"; SummaryBox.DataField = "期初数量"; SummaryBox.AlignColumn = "期初数量"; //通过对齐到列确定部件框的左边位置与宽度 SummaryBox.TextAlign = GRTextAlign.grtaMiddleRight; SummaryBox.Top = 0.19; SummaryBox.Height = 0.40; SummaryBox = Group.Footer.Controls.Add(GRControlType.grctSummaryBox).AsSummaryBox; SummaryBox.SummaryFun = GRSummaryFun.grsfSum; SummaryBox.Format = "#,##0"; SummaryBox.DataField = "收入数量"; SummaryBox.AlignColumn = "收入数量"; //通过对齐到列确定部件框的左边位置与宽度 SummaryBox.TextAlign = GRTextAlign.grtaMiddleRight; SummaryBox.Top = 0.19; SummaryBox.Height = 0.40; SummaryBox = Group.Footer.Controls.Add(GRControlType.grctSummaryBox).AsSummaryBox; SummaryBox.SummaryFun = GRSummaryFun.grsfSum; SummaryBox.Format = "#,##0"; SummaryBox.DataField = "发出数量"; SummaryBox.AlignColumn = "发出数量"; //通过对齐到列确定部件框的左边位置与宽度 SummaryBox.TextAlign = GRTextAlign.grtaMiddleRight; SummaryBox.Top = 0.19; SummaryBox.Height = 0.40; SummaryBox = Group.Footer.Controls.Add(GRControlType.grctSummaryBox).AsSummaryBox; SummaryBox.SummaryFun = GRSummaryFun.grsfSum; SummaryBox.Format = "#,##0"; SummaryBox.DataField = "结存数量"; SummaryBox.AlignColumn = "结存数量"; //通过对齐到列确定部件框的左边位置与宽度 SummaryBox.TextAlign = GRTextAlign.grtaMiddleRight; SummaryBox.Top = 0.19; SummaryBox.Height = 0.40; SummaryBox = Group.Footer.Controls.Add(GRControlType.grctSummaryBox).AsSummaryBox; SummaryBox.SummaryFun = GRSummaryFun.grsfSum; SummaryBox.Format = "#,##0.00"; SummaryBox.DataField = "结存成本"; SummaryBox.AlignColumn = "结存成本"; //通过对齐到列确定部件框的左边位置与宽度 SummaryBox.TextAlign = GRTextAlign.grtaMiddleRight; SummaryBox.Top = 0.19; SummaryBox.Height = 0.40; }