public static string RefreshGlobalReport7(string startDateStr, string endDateStr, string selectedProjectsStr, string sortTypeStr) { DateTime startDate = Convert.ToDateTime(startDateStr); DateTime endDate = Convert.ToDateTime(endDateStr); Report7_Params param = new Report7_Params() { StartDate = Convert.ToDateTime(startDateStr), EndDate = Convert.ToDateTime(endDateStr), selectProjectStr = selectedProjectsStr, OrderBy = sortTypeStr }; return(ReportManager.GetReport7_HTML(param)); }
/// <summary> /// 获取报表7所需的数据 /// </summary> /// <param name="param">参数实体</param> /// <returns></returns> public static SqlDataReader GetReport7_Data(Report7_Params param) { string sortStr = ""; if (param.OrderBy == "0") { sortStr = "ORDER BY Bug.ProjectID,Bug.BugID ASC"; } else { sortStr = "ORDER BY Bug.ProjectID,Bug.BugID DESC"; } string sqlStr = string.Format(@" select Bug.ProjectID,Project.ProjectName,Bug.BugID,Bug.BugTitle,ProgressStatusTypes.ProgressStatusName from Bug join Project on(Bug.ProjectID=Project.ProjectID) join ProgressStatusTypes on(Bug.ProjectID=ProgressStatusTypes.ProjectID and Bug.ProgressStatusID=ProgressStatusTypes.ProgressStatusID) where DATEDIFF(DD,@startDate,Bug.DateCreated)>=0 AND DATEDIFF(DD,@endDate,Bug.DateCreated)<=0 AND Bug.ProjectID IN("); sqlStr += param.selectProjectStr; sqlStr += ") " + sortStr; SqlParameter[] pms = new SqlParameter[] { new SqlParameter("@startDate", param.StartDate), new SqlParameter("@endDate", param.EndDate) }; SqlDataReader reportData = null; try { reportData = SQLHelper.GetResultByReader(sqlStr, pms); return(reportData); } catch (SqlException ex) { throw new Exception("执行获取方法GetReport7_Data的时候出现sql异常:" + ex.Message); } catch (Exception ex) { throw ex; } }
/// <summary> /// 获取报表需要的数据,返回列表集合 /// </summary> /// <param name="param"></param> /// <returns></returns> protected static List <Report4> GetReport7_Data(Report7_Params param) { SqlDataReader reportDataReader = ReportService.GetReport7_Data(param); List <Report4> reportDataList = new List <Report4>(); while (reportDataReader.Read()) { reportDataList.Add(new Report4() { ProjectID = reportDataReader["ProjectID"].ToString(), ProjectName = reportDataReader["ProjectName"].ToString(), BugID = reportDataReader["BugID"].ToString(), BugTitle = reportDataReader["BugTitle"].ToString(), ProgressStatusName = reportDataReader["ProgressStatusName"].ToString() }); } reportDataReader.Close(); return(reportDataList); }
public static string GetReport7_HTML(Report7_Params param) { List <Report4> reportDataList = ReportManager.GetReport7_Data(param); if (reportDataList.Count == 0) { return(string.Empty); } //写报表头部 StringBuilder sbReportHTML = new StringBuilder(@"<table class='report_table' style='width:100%; text-align:left' >"); sbReportHTML.Append("<tr><th>项目名称</th><th>任务编号</th><th>任务名称</th><th>任务状态</th></tr>"); sbReportHTML.Append("<tbody>"); foreach (Report4 item in reportDataList) { sbReportHTML.AppendFormat("<tr><td>{0}</td><td>{1}</td><td>{2}</td><td>{3}</td>", item.ProjectName, item.BugID, item.BugTitle, item.ProgressStatusName); } sbReportHTML.AppendFormat("</tbody></table>"); return(sbReportHTML.ToString()); }