public List <BASE_IntegrationReport> GetBusinessSelect(CE_BillTypeEnum billType) { string error = ""; List <BASE_IntegrationReport> listReport = new List <BASE_IntegrationReport>(); Hashtable hsTable = new Hashtable(); hsTable.Add("@BusineesName", billType.ToString()); DataTable dtTemp = GlobalObject.DatabaseServer.QueryInfoPro("BASE_IntegrationReport_GetBusinessSelect", hsTable, out error); if (dtTemp != null || dtTemp.Rows.Count > 0 || dtTemp.Rows[0][0].ToString().Trim().Length > 0) { foreach (DataRow dr in dtTemp.Rows) { BASE_IntegrationReport report = new BASE_IntegrationReport(); report.FindType = dr["FindType"].ToString(); report.PrintName = dr["PrintName"].ToString(); report.ProcedureName = dr["ProcedureName"].ToString(); report.ReportCode = dr["ReportCode"].ToString(); report.ReportName = dr["ReportName"].ToString(); listReport.Add(report); } } return(listReport); }
private void treeView1_AfterSelect(object sender, TreeViewEventArgs e) { m_lnqIntegration = m_serverReport.GetReportInfo(treeView1.SelectedNode.Tag.ToString()); SpecialHandling(); dataGridView1.DataSource = m_serverReport.GetFindInfo(m_lnqIntegration.ReportCode); dataGridView1.Columns["查询内容"].Width = 200; dataGridView1.Columns["查询字段"].Width = 150; dataGridView1.Columns["查询字段格式"].Width = 200; dataGridView1.Columns["参数名"].Visible = false; dataGridView1.Columns["参数类型"].Visible = false; for (int i = 0; i < this.dataGridView1.Columns.Count; i++) { this.dataGridView1.Columns[i].SortMode = DataGridViewColumnSortMode.NotSortable; } dataGridView2.DataSource = null; }
/// <summary> /// 界面初始化 /// </summary> /// <param name="reportCode">报表编号</param> /// <param name="flag">状态 0 :添加 1:编辑</param> public 集成报表数据编辑(string reportCode, int flag) { InitializeComponent(); if (flag == 0) { m_lnqReport.ID = 0; m_lnqReport.ReportCode = m_serverReport.GetNewReportCode(reportCode); } else if (flag == 1) { m_lnqReport = m_serverReport.GetReportInfo(reportCode); } cmbFindType.DataSource = GlobalObject.GeneralFunction.GetEumnList(typeof(Report_FindType)); ShowInfo(); }
/// <summary> /// 保存报表设置信息 /// </summary> /// <param name="integrationReport">报表数据集</param> /// <param name="reportInfoList">字段数据表</param> /// <param name="error">错误信息</param> /// <returns>成功返回True,失败返回False</returns> public bool SaveReportInfo(BASE_IntegrationReport integrationReport, DataTable reportInfoList, out string error) { DepotManagementDataContext dataContext = CommentParameter.DepotDataContext; error = null; try { dataContext.Connection.Open(); dataContext.Transaction = dataContext.Connection.BeginTransaction(); if (integrationReport.ID == 0) { if (CheckInfoIsRepeat(integrationReport.ReportCode)) { error = "报表编码重复,请重新录入"; return(false); } dataContext.BASE_IntegrationReport.InsertOnSubmit(integrationReport); } else { var varData = from a in dataContext.BASE_IntegrationReport where a.ID == integrationReport.ID select a; if (varData.Count() == 1) { BASE_IntegrationReport lnqIntegration = varData.Single(); lnqIntegration.PrintName = integrationReport.PrintName; lnqIntegration.ProcedureName = integrationReport.ProcedureName; lnqIntegration.ReportCode = integrationReport.ReportCode; lnqIntegration.ReportName = integrationReport.ReportName; lnqIntegration.FindType = integrationReport.FindType; } else { error = "数据为空或者不唯一"; return(false); } } if (!SaveReportInfoList(dataContext, integrationReport.ReportCode, reportInfoList, out error)) { return(false); } dataContext.SubmitChanges(); dataContext.Transaction.Commit(); return(true); } catch (Exception ex) { dataContext.Transaction.Rollback(); error = ex.Message; return(false); } }
/// <summary> /// 执行存储过程查询 /// </summary> /// <param name="reportCode">报表编号</param> /// <param name="infoList">查询内容</param> /// <param name="error">错误信息</param> /// <returns>返回Table</returns> public DataTable QueryInfo(string reportCode, DataTable infoList, out string error) { error = null; DataTable result = new DataTable(); try { DepotManagementDataContext dataContext = CommentParameter.DepotDataContext; var varData = from a in dataContext.BASE_IntegrationReport where a.ReportCode == reportCode select a; BASE_IntegrationReport lnqintegration = new BASE_IntegrationReport(); if (varData.Count() == 1) { lnqintegration = varData.Single(); } else { error = "数据不唯一或者为空"; return(null); } Report_FindType findType = GlobalObject.GeneralFunction.StringConvertToEnum <Report_FindType>(lnqintegration.FindType); switch (findType) { case Report_FindType.存储过程: Hashtable parameters = new Hashtable(); if (infoList != null) { for (int i = 0; i < infoList.Rows.Count; i++) { if (infoList.Rows[i]["参数类型"].ToString() == "DateTime" && (infoList.Rows[i]["查询内容"] == null || infoList.Rows[i]["查询内容"].ToString().Trim().Length == 0)) { infoList.Rows[i]["查询内容"] = ServerTime.Time.ToString().Trim(); } parameters.Add(infoList.Rows[i]["参数名"].ToString(), GlobalObject.GeneralFunction.ChangeType(infoList.Rows[i]["查询内容"].ToString().Trim(), infoList.Rows[i]["参数类型"].ToString())); } } else { var varList = (from a in dataContext.BASE_IntegrationReportList where a.ReportCode == reportCode select a).ToList(); if (varList.Count() == 2 && varList[0].ParameterType == "DateTime" && varList[0].ParameterType == "DateTime") { DateTime time = ServerTime.Time.Date; parameters.Add(varList[0].ParameterName, Convert.ToDateTime(time.AddYears(-1).ToShortDateString() + " 00:00:00")); parameters.Add(varList[1].ParameterName, Convert.ToDateTime(time.ToShortDateString() + " 23:59:59")); } } result = GlobalObject.DatabaseServer.QueryInfoPro(lnqintegration.ProcedureName, parameters, out error); break; case Report_FindType.业务授权: IAuthorization authorization = PlatformFactory.GetObject <IAuthorization>(); IQueryResult qr = null; string strWhere = null; if (infoList != null && infoList.Rows.Count > 0) { strWhere = "日期 >= '" + infoList.Rows[0]["查询内容"].ToString().Trim() + "' and 日期 <= '" + infoList.Rows[1]["查询内容"].ToString().Trim() + "'"; } qr = authorization.Query(lnqintegration.ProcedureName, null, strWhere); if (qr.Succeeded) { result = qr.DataCollection.Tables[0]; } break; case Report_FindType.视图: string strSql = "select * from " + lnqintegration.ProcedureName + " where 1 = 1"; if (infoList != null && infoList.Rows.Count > 0) { for (int i = 0; i < infoList.Rows.Count; i++) { if (infoList.Rows[i]["查询内容"].ToString().Trim().Length > 0) { strSql = strSql + " and " + infoList.Rows[i]["参数名"].ToString() + " = '" + infoList.Rows[i]["查询内容"].ToString() + "'"; } } } result = GlobalObject.DatabaseServer.QueryInfo(strSql); break; default: break; } return(result); } catch (Exception ex) { error = ex.Message; return(null); } }