Beispiel #1
0
        public ActionResult ExportDataTableToExcelUserAnaly(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.LoadRepalceAnaly(strWhere);

            DataTable dt      = udtTask.DtData;
            string    strCols = "";

            if (name == "" || name == null)
            {
                strCols = "仪表发生问题同年对比,问题数量,所占比例";
            }
            else
            {
                if (name.Contains("贸易"))
                {
                    strCols = "贸易,问题数量,所占比例";
                }
                else
                {
                    strCols = "区域计量,问题数量,所占比例";
                }
            }


            System.IO.MemoryStream stream = ExcelHelper.ExportDataTableToExcelUserAnaly(dt, "问题数量", strCols.Split(','));
            stream.Seek(0, System.IO.SeekOrigin.Begin);
            return(File(stream, "application/vnd.ms-excel", "问题数量.xls"));
        }
Beispiel #2
0
        public ActionResult LoadRepalceAnaly()
        {
            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.LoadRepalceAnaly(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));
        }