private void loadReport() { List <Paramater> paralist; paralist = _paramProcess.getPara(_Reportid); //DataTable Paradat = _paramProcess.getParamlist(_Reportid); tvwField.Nodes.Clear(); TreeNode node = new TreeNode("报表参数集合", 15, 14); Paramater mould; mould = new Paramater(); mould.PARAMETERID = -1; mould.PARAMETER = "公共报表"; node.Tag = mould; tvwField.Nodes.Add(node); TreeNode childnode; foreach (Paramater para in paralist) { childnode = new TreeNode(para.PARAMETER, 15, 14); childnode.Tag = para; node.Nodes.Add(childnode); } }
private void btnGetReportParam_Click(object sender, EventArgs e) { DataTable dataoutPara; Paramater outpara; if (_currentReport != null && _currentReport.PROCEDURES != "") { FrmGetInParater frmGetpara = new FrmGetInParater(_Paramprocess.getPara(_currentReport.REPORT_ID), _user, _dept); if (frmGetpara.ShowDialog() == DialogResult.OK) { Paramlist = frmGetpara.paralist; } else { return; } dataoutPara = _reportProcess.getOutParamter(_currentReport, Paramlist); if (dataoutPara != null) { for (int index = 0; index < dataoutPara.Columns.Count; index++) { outpara = new Paramater(); outpara.PARAMETER = dataoutPara.Columns[index].ColumnName; outpara.PARAMETER_TYPE = ""; if (dataoutPara.Columns[index].DataType.Name == "String") { outpara.PARAMDATATYPE = 0; } else { outpara.PARAMDATATYPE = 1; } outpara.REPORT_ID = _currentReport.REPORT_ID; outpara.addParamter(); } } } }
private void button1_Click(object sender, EventArgs e) { #region //if (controller == null) //{ // return; //} //Report = new GridppReport(); //Paramlist = controller.GetParaValue(); //if (Paramlist.Count == 0) // return; //string Reportname = _currentReport.NAME.Trim() + ".grf"; //string filePath = System.Windows.Forms.Application.StartupPath + "\\report\\" + Reportname; // Report.LoadFromFile(filePath); //foreach (Paramater pp in Paramlist) //{ // if (pp.PARAMETER_TYPE == "OUT") // continue; // if (pp.PARAMETER_TYPE != "明细") // { // if (pp.objvalueCN != null) // Report.ParameterByName(pp.PARAMETER_CN).AsString = pp.objvalueCN.ToString(); // else // Report.ParameterByName(pp.PARAMETER_CN).AsString = pp.objvalue.ToString(); // } //} //Report.ParameterByName("报表名称").AsString = _currentReport.NAME; //Report.ParameterByName("打印时间").AsString = System.DateTime.Now.ToString(); //Report.ParameterByName("当前科室").AsString = _currentDeptidname; //Report.ParameterByName("当前人员").AsString = _currentUser; //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\\" + 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\\" + Reportname); // Report.ParameterByName("合计金额").AsString = sum.ToString(); // } //} //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; //panel6.Controls.Add(foo); //foo.Dock = DockStyle.Fill; //foo.Show(); #endregion if (_currentReport.REPORT_ID <= 0) { MessageBox.Show("请选择报表", "提示"); return; } string Reportname = _currentReport.NAME.Trim() + ".grf"; 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\\" + 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\\" + 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\\" + 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\\" + 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; panel6.Controls.Add(foo); foo.Dock = DockStyle.Fill; foo.Show(); }