public ActionResult ExportDataTableToExcelCalibreAnaly(tk_CardSearch c) { string name = c.CustomerName; string sdate = c.SS_Date; string edate = c.ES_Date; string strWhere = ""; if (name != null && name != "") { strWhere += " and CustomerName like '%" + name + "%'"; } if (sdate != null && sdate != "" && edate != "" && edate != null) { strWhere += " and DATEPART(year,S_Date)>=" + sdate + " and DATEPART(year,S_Date)<=" + edate; } else { if (sdate != null && sdate != "") { strWhere += "and DATEPART(year,S_Date)=" + sdate; } if (edate != null && edate != "") { strWhere += "and DATEPART(year,S_Date)=" + edate; } } UIDataTable udtTask = new UIDataTable(); udtTask = FlowDAMan.LoadCalibreAnaly(strWhere); DataTable dt = udtTask.DtData; string strCols = ""; if (name == "" || name == null) { strCols = "仪表发生问题同年对比,总表数,总问题表数,总故障率,大问题表数,大问题故障率,影响计量问题表数,影响计量故障率"; } else { if (name.Contains("贸易")) { strCols = "贸易,总表数,总问题表数,总故障率,大问题表数,大问题故障率,影响计量问题表数,影响计量故障率"; } else { strCols = "区域计量,总表数,总问题表数,总故障率,大问题表数,大问题故障率,影响计量问题表数,影响计量故障率"; } } System.IO.MemoryStream stream = ExcelHelper.ExportDataTableToExcelCalibreAnaly(dt, "按口径", strCols.Split(',')); stream.Seek(0, System.IO.SeekOrigin.Begin); return(File(stream, "application/vnd.ms-excel", "按口径.xls")); }
public ActionResult LoadCalibreAnaly() { string name = Request["name"]; string sdate = Request["sdate"]; string edate = Request["edate"]; string strWhere = ""; if (name != "") { strWhere += " and CustomerName like '%" + name + "%'"; } if (sdate != "" && edate != "") { strWhere += " and DATEPART(year,S_Date)>=" + sdate + " and DATEPART(year,S_Date)<=" + edate; } else { if (sdate != "") { strWhere += "and DATEPART(year,S_Date)=" + sdate; } if (edate != "") { strWhere += "and DATEPART(year,S_Date)=" + edate; } } UIDataTable udtTask = new UIDataTable(); udtTask = FlowDAMan.LoadCalibreAnaly(strWhere); string strjson = GFun.Dt2Json("", udtTask.DtData); strjson = strjson.Substring(1); strjson = strjson.Substring(0, strjson.Length - 1); string jsonData = "{ \"page\":" + GFun.SafeToInt32(Request["curpage"]) + ", \"total\": " + udtTask.IntTotalPages + ", \"records\": " + udtTask.IntRecords + ", \"rows\": "; jsonData += strjson + "}"; return(Json(jsonData, JsonRequestBehavior.AllowGet)); }