コード例 #1
0
        /// <summary>
        /// 时间统计-导出
        /// </summary>
        public FileResult ExportReport(E_ExpeStatisticsSearchParameter eSearchParameter)
        {
            //拼接查询条件
            string strWhere = this.GetListByReportStrWhere(eSearchParameter);

            DataTable dt = new DataTable();

            dt = tDetectProject.GetExportListByReport(strWhere, "").Tables[0];

            MemoryStream stream = new MemoryStream();

            stream = PublicClass.ExportReportToExcel(dt);
            string filename = "实验统计列表" + DateTime.Now.ToFileTime() + ".xls";

            return(File(stream, "application/vnd.ms-excel", filename));
        }
コード例 #2
0
        public FileResult ExportReport(string ddl_selecttype, string txt_dept, string ddl_type, string txt_search, string txt_StartTime, string txt_EndTime)
        {
            DataTable dt = new DataTable();

            System.IO.MemoryStream stream = new MemoryStream();
            #region 获取数据
            int total = 0;

            string strWhere = " 1=1 ";
            try
            {
                if (!string.IsNullOrEmpty(txt_dept))
                {
                    switch (ddl_selecttype)
                    {
                    case "mhcx":
                    {
                        strWhere += " and Department like '%%" + txt_dept + "%%'";
                        break;
                    }

                    case "qzpp":
                    {
                        strWhere += " and Department = '" + txt_dept + "'";
                        break;
                    }
                    }
                }
                if (!string.IsNullOrEmpty(txt_search))
                {
                    switch (ddl_type)
                    {
                    case "ypmc":
                    {
                        strWhere += " and name like '%%" + txt_search + "%%'";
                        break;
                    }

                    case "jyxm":
                    {
                        strWhere += " and ProjectName like '%%" + txt_search + "%%'";
                        break;
                    }

                    case "jyr":
                    {
                        strWhere += " and TestPersonnelName like '%%" + txt_search + "%%'";
                        break;
                    }
                    }
                }
                if (!string.IsNullOrEmpty(txt_StartTime))
                {
                    strWhere += " and DetectTime >= '" + txt_StartTime + "'";
                }
                if (!string.IsNullOrEmpty(txt_EndTime))
                {
                    strWhere += " and DetectTime <= '" + txt_EndTime + "'";
                }

                dt = tDetectProject.GetExportListByReport(strWhere, "").Tables[0];
                dt.Columns.Add("QualifiedLevelA", typeof(int)); dt.Columns.Add("QualifiedLevelB", typeof(int));
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    try
                    {
                        dt.Rows[i]["QualifiedLevelA"] = tDetectProject.GetListCountForReport(dt.Rows[i], "合格");
                        dt.Rows[i]["QualifiedLevelB"] = tDetectProject.GetListCountForReport(dt.Rows[i], "");
                    }
                    catch
                    {
                        continue;
                    }
                }

                DataRow dr2 = dt.NewRow();

                dr2["name"]            = "总合计";
                dr2["QualifiedLevel"]  = tDetectProject.GetAllListCountForReport(strWhere, "");
                dr2["QualifiedLevelA"] = tDetectProject.GetAllListCountForReport(strWhere, "1");
                dr2["QualifiedLevelB"] = tDetectProject.GetAllListCountForReport(strWhere, "2");
                dt.Rows.InsertAt(dr2, dt.Rows.Count);

                stream = PublicClass.ExportReportToExcel(dt);
            }
            catch { }
            #endregion

            string filename = "实验统计列表" + DateTime.Now.ToFileTime() + ".xls";
            return(File(stream, "application/vnd.ms-excel", filename));
        }