protected void Page_Load(object sender, EventArgs e) { LoadScript(""); if (CurrentUser.DepartmentName != "系统管理员" && CurrentUser.ID != "sysuser") { Response.Redirect("../../login.aspx", true); return; } if (Request.QueryString["ResID"] != null) { ResID = Request.QueryString["ResID"]; } if (Request.QueryString["PResID"] != null) { PResID = Request.QueryString["PResID"]; } if (Request["Params"] != null) { Params = Request["Params"].ToString(); } if (Request.QueryString["IsmultiSelect"] != null) { IsmultiSelect = Convert.ToBoolean(Convert.ToInt32(Request.QueryString["IsmultiSelect"])); } string strSql = "select D.CD_RESID,D.CD_COLNAME,D.CD_DISPNAME,S.CS_SHOW_WIDTH from CMS_TABLE_DEFINE D join CMS_TABLE_SHOW S on D.CD_RESID = S.CS_RESID and D.CD_COLNAME = S.CS_COLNAME where CD_RESID = {0} and CS_SHOW_ENABLE = 1 order by CS_SHOW_ORDER "; SysSettings Psys = Common.GetSysSettingsByResID(PResID); PResName = Psys.ShowTitle; SysSettings Csys = Common.GetSysSettingsByResID(ResID); ResName = Csys.ShowTitle; string[] changePassWord = Common.getChangePassWord(); //获取主资源字段列表 dtParent = Service.Query(string.Format(strSql, PResID), changePassWord[0], changePassWord[1], changePassWord[2]).Tables[0]; //获取子资源字段列表 dtChild = Service.Query(string.Format(strSql, ResID), changePassWord[0], changePassWord[1], changePassWord[2]).Tables[0]; }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { ResId = Request.QueryString["resId"]; KeyWord = Request.QueryString["KeyWord"] == null ? "" : Request.QueryString["KeyWord"]; if (KeyWord != "") { //获取当前资源配置的查询字段 WebServices.Services Resource = new WebServices.Services(); string strSql = " select id,keyword,datetype,Searchcol,showCol from Sys_CXZJLB where keyword='" + KeyWord + "' order by xh asc "; string[] changePassWord = Common.getChangePassWord(); dt = Resource.Query(strSql, changePassWord[0], changePassWord[1], changePassWord[2]).Tables[0]; //获取当前资源配置的列表字段 string strColSql = " select rc.id,rc.columnName,rc.orderNum,rc.DateType,rc.keyword from ResourceColumn rc where rc.keyword='" + KeyWord + "' order by rc.orderNum asc "; dtCol = Resource.Query(strColSql, changePassWord[0], changePassWord[1], changePassWord[2]).Tables[0]; } } }
protected void Page_Load(object sender, EventArgs e) { ResId = Request.QueryString["resId"]; KeyWord = Request.QueryString["KeyWord"] == null ? "" : Request.QueryString["KeyWord"]; if (KeyWord != "") { //获取当前资源配置的查询字段 WebServices.Services Resource = new WebServices.Services(); string strSql = " select id,keyword,datetype,Searchcol,showCol from Sys_CXZJLB where keyword='" + KeyWord + "' order by xh asc "; string[] changePassWord = Common.getChangePassWord(); dt = Resource.Query(strSql, changePassWord[0], changePassWord[1], changePassWord[2]).Tables[0]; } }
protected string GetDataListBySql(string sql) { string resultStr; WebServices.Services Resource = new WebServices.Services(); string[] changePassWord = Common.getChangePassWord(); DataTable dt = Resource.Query(sql, changePassWord[0], changePassWord[1], changePassWord[2]).Tables[0]; Newtonsoft.Json.Converters.IsoDateTimeConverter timeConverter = new Newtonsoft.Json.Converters.IsoDateTimeConverter(); // //这里使用自定义日期格式,如果不使用的话,默认是ISO8601格式 //timeConverter.DateTimeFormat = "yyyy'-'MM'-'dd' 'HH':'mm':'ss" timeConverter.DateTimeFormat = "yyyy'-'MM'-'dd' 'HH':'mm"; resultStr = Newtonsoft.Json.JsonConvert.SerializeObject(dt, timeConverter); return(resultStr); }
private string GetfDataByYSKTJ() { WebServices.Services Resource = new WebServices.Services(); string str = ""; if (Request["SKRQ"] != null && Request["SKRQ"] != "") { DateTime skrq = Convert.ToDateTime(Request["SKRQ"]); string sql = "select SUM(C3_401795702260) 本月回款 from CT401290354058 "; sql += " where Year(C3_475688833284)='" + skrq.Year + "' and MONTH(C3_475688833284)='" + skrq.Month + "'; "; sql += " SELECT sum(C3_403033088714) 本月开票 FROM ct401290382901 "; sql += " where Year(C3_404405195524)='" + skrq.Year + "' and MONTH(C3_404405195524)='" + skrq.Month + "'; "; sql += " SELECT sum(C3_403007677105) 三个月内应收款 FROM ct401290382901 "; sql += " where C3_404405195524 between dateadd(day,-90,'" + skrq + "') and '" + skrq + "';"; sql += " SELECT sum(C3_403007677105) 三个月以上应收款 FROM ct401290382901 "; sql += " where C3_404405195524 < dateadd(day,-90,'" + skrq + "') ; "; sql += " SELECT sum(C3_403007677105) 应收款总额 FROM ct401290382901 where C3_404405195524 < '" + skrq + "';"; string[] changePassWord = Common.getChangePassWord(); DataSet ds = Resource.Query(sql, changePassWord[0], changePassWord[1], changePassWord[2]); DataTable dt = new DataTable(); dt.Columns.Add("本月回款"); dt.Columns.Add("本月开票"); dt.Columns.Add("三个月内合计"); dt.Columns.Add("三个月内应收款"); dt.Columns.Add("三个月以上应收款"); dt.Columns.Add("应收款总额"); dt.Rows.Add(); dt.Rows[0]["本月回款"] = ds.Tables[0].Rows[0]["本月回款"].ToString(); dt.Rows[0]["本月开票"] = ds.Tables[1].Rows[0]["本月开票"].ToString(); dt.Rows[0]["三个月内应收款"] = ds.Tables[2].Rows[0]["三个月内应收款"].ToString(); dt.Rows[0]["三个月以上应收款"] = ds.Tables[3].Rows[0]["三个月以上应收款"].ToString(); dt.Rows[0]["应收款总额"] = ds.Tables[4].Rows[0]["应收款总额"].ToString(); Newtonsoft.Json.Converters.IsoDateTimeConverter timeConverter = new Newtonsoft.Json.Converters.IsoDateTimeConverter(); timeConverter.DateTimeFormat = "yyyy'-'MM'-'dd"; str = Newtonsoft.Json.JsonConvert.SerializeObject(dt, timeConverter); } return("{\"total\":1 ,\"rows\":" + str + "}"); }
private string GetfDataByYSKTJKH() { WebServices.Services Resource = new WebServices.Services(); string str = ""; DataTable dt = new DataTable(); if (Request["SKRQ"] != null && Request["SKRQ"] != "") { DateTime skrq = Convert.ToDateTime(Request["SKRQ"]); string sql = "select A.客户名称,SUM(A.C3_401795702260) 本月回款 from (select C3_401795702260, "; sql += " (select max(C3_403007779574) from ct401290344433 where C3_403007758511=C3_401795684760) 客户名称 from CT401290354058 "; sql += " where Year(C3_475688833284)='" + skrq.Year + "' and MONTH(C3_475688833284)='" + skrq.Month + "') A group by A.客户名称; "; sql += " SELECT sum(C3_403033088714) 本月开票,C3_403033049855 客户名称 FROM ct401290382901 "; sql += " where Year(C3_404405195524)='" + skrq.Year + "' and MONTH(C3_404405195524)='" + skrq.Month + "' group by C3_403033049855; "; sql += " SELECT sum(C3_403007677105) 三个月内应收款,C3_403033049855 客户名称 FROM ct401290382901 "; sql += " where C3_404405195524 between dateadd(day,-90,'" + skrq + "') and '" + skrq + "' and isnull(C3_403007677105,0)!=0 group by C3_403033049855;"; sql += " SELECT sum(C3_403007677105) 三个月以上应收款,C3_403033049855 客户名称 FROM ct401290382901 "; sql += " where C3_404405195524 < dateadd(day,-90,'" + skrq + "') and isnull(C3_403007677105,0)!=0 group by C3_403033049855; "; sql += " SELECT sum(C3_403007677105) 应收款总额,C3_403033049855 客户名称 FROM ct401290382901 where C3_404405195524 < '" + skrq + "' and isnull(C3_403007677105,0)!=0 group by C3_403033049855;"; string[] changePassWord = Common.getChangePassWord(); DataSet ds = Resource.Query(sql, changePassWord[0], changePassWord[1], changePassWord[2]); dt.Columns.Add("客户名称"); dt.Columns.Add("本月回款"); dt.Columns.Add("本月开票"); dt.Columns.Add("三个月内合计"); dt.Columns.Add("三个月内应收款"); dt.Columns.Add("三个月以上应收款"); dt.Columns.Add("应收款总额"); for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { dt.Rows.Add(); dt.Rows[dt.Rows.Count - 1]["客户名称"] = ds.Tables[0].Rows[i]["客户名称"].ToString(); dt.Rows[dt.Rows.Count - 1]["本月回款"] = ds.Tables[0].Rows[i]["本月回款"].ToString(); } for (int i = 0; i < ds.Tables[1].Rows.Count; i++) { int isHave = 0; for (int j = 0; j < dt.Rows.Count; j++) { if (dt.Rows[j]["客户名称"].ToString() == ds.Tables[1].Rows[i]["客户名称"].ToString()) { if (ds.Tables[1].Rows[i]["本月开票"].ToString() != "") { dt.Rows[j]["本月开票"] = Math.Round(Convert.ToDouble(ds.Tables[1].Rows[i]["本月开票"].ToString()), 2); } isHave = 1; } } if (isHave == 0) { dt.Rows.Add(); dt.Rows[dt.Rows.Count - 1]["客户名称"] = ds.Tables[1].Rows[i]["客户名称"].ToString(); if (ds.Tables[1].Rows[i]["本月开票"].ToString() != "") { dt.Rows[dt.Rows.Count - 1]["本月开票"] = Math.Round(Convert.ToDouble(ds.Tables[1].Rows[i]["本月开票"].ToString()), 2); } } } for (int i = 0; i < ds.Tables[2].Rows.Count; i++) { int isHave = 0; for (int j = 0; j < dt.Rows.Count; j++) { if (dt.Rows[j]["客户名称"].ToString() == ds.Tables[2].Rows[i]["客户名称"].ToString()) { if (ds.Tables[2].Rows[i]["三个月内应收款"].ToString() != "") { dt.Rows[j]["三个月内应收款"] = Math.Round(Convert.ToDouble(ds.Tables[2].Rows[i]["三个月内应收款"].ToString()), 2); } isHave = 1; } } if (isHave == 0) { dt.Rows.Add(); dt.Rows[dt.Rows.Count - 1]["客户名称"] = ds.Tables[2].Rows[i]["客户名称"].ToString(); if (ds.Tables[2].Rows[i]["三个月内应收款"].ToString() != "") { dt.Rows[dt.Rows.Count - 1]["三个月内应收款"] = Math.Round(Convert.ToDouble(ds.Tables[2].Rows[i]["三个月内应收款"].ToString()), 2); } } } for (int i = 0; i < ds.Tables[3].Rows.Count; i++) { int isHave = 0; for (int j = 0; j < dt.Rows.Count; j++) { if (dt.Rows[j]["客户名称"].ToString() == ds.Tables[3].Rows[i]["客户名称"].ToString()) { if (ds.Tables[3].Rows[i]["三个月以上应收款"].ToString() != "") { dt.Rows[j]["三个月以上应收款"] = Math.Round(Convert.ToDouble(ds.Tables[3].Rows[i]["三个月以上应收款"].ToString()), 2);; } isHave = 1; } } if (isHave == 0) { dt.Rows.Add(); dt.Rows[dt.Rows.Count - 1]["客户名称"] = ds.Tables[3].Rows[i]["客户名称"].ToString(); if (ds.Tables[3].Rows[i]["三个月以上应收款"].ToString() != "") { dt.Rows[dt.Rows.Count - 1]["三个月以上应收款"] = Math.Round(Convert.ToDouble(ds.Tables[3].Rows[i]["三个月以上应收款"].ToString()), 2);; } } } for (int i = 0; i < ds.Tables[4].Rows.Count; i++) { int isHave = 0; for (int j = 0; j < dt.Rows.Count; j++) { if (dt.Rows[j]["客户名称"].ToString() == ds.Tables[4].Rows[i]["客户名称"].ToString()) { if (ds.Tables[4].Rows[i]["应收款总额"].ToString() != "") { dt.Rows[j]["应收款总额"] = Math.Round(Convert.ToDouble(ds.Tables[4].Rows[i]["应收款总额"].ToString()), 2); } isHave = 1; } } if (isHave == 0) { dt.Rows.Add(); dt.Rows[dt.Rows.Count - 1]["客户名称"] = ds.Tables[4].Rows[i]["客户名称"].ToString(); if (ds.Tables[4].Rows[i]["应收款总额"].ToString() != "") { dt.Rows[dt.Rows.Count - 1]["应收款总额"] = Math.Round(Convert.ToDouble(ds.Tables[4].Rows[i]["应收款总额"].ToString()), 2); } } } Newtonsoft.Json.Converters.IsoDateTimeConverter timeConverter = new Newtonsoft.Json.Converters.IsoDateTimeConverter(); timeConverter.DateTimeFormat = "yyyy'-'MM'-'dd"; str = Newtonsoft.Json.JsonConvert.SerializeObject(dt, timeConverter); } return("{\"total\":" + dt.Rows.Count + " ,\"rows\":" + str + "}"); }
protected void Page_Load(object sender, EventArgs e) { oEmployee = CurrentUser; UserID = oEmployee.ID; UserName = oEmployee.Name; string json = ""; string typeValue = Request["typeValue"]; if (typeValue == "GetField") { string keywordParameters = Request.QueryString["keyWordValue"]; string MenuResID = Request.QueryString["MenuResID"]; bool IsChildResource = Convert.ToBoolean(Convert.ToInt32(Request.QueryString["IsChildResource"])); json = CommonMethod.GetFieldJson(keywordParameters, MenuResID, oEmployee);//获取grid的Field里面的值 } if (typeValue == "GetfieldInfo") { string ColTitle = Request["ColName"]; string ColField = Request["ColField"]; string ColWidth = Request["ColWidth"]; string OperatePageUrl = Request["OperatePageUrl"]; string OperateText = Request["OperateText"]; string OperateFunction = Request["OperateFunction"]; Int32 OperatePageWidth = 1000; if (Request["OperatePageWidth"] != null) { OperatePageWidth = Convert.ToInt32(Request["OperatePageWidth"]); } Int32 OperatePageHeight = 800; if (Request["OperatePageHeight"] != null) { OperatePageHeight = Convert.ToInt32(Request["OperatePageHeight"]); } bool IsOperateButton = true; if (Request["IsOperateButton"] != null) { IsOperateButton = Convert.ToBoolean(Convert.ToInt32(Request["IsOperateButton"])); } json = CommonMethod.Getfield(ColTitle, ColField, ColWidth, OperatePageWidth, OperatePageHeight, IsOperateButton, OperatePageUrl, OperateFunction, OperateText); } if (typeValue == "GetChildField") { string keywordParameters = Request.QueryString["keyWordValue"]; string ParentKeyWord = Request.QueryString["ParentKeyWord"]; string MenuResID = Request.QueryString["MenuResID"]; json = CommonMethod.GetFieldJson_ChildResource(keywordParameters, ParentKeyWord, MenuResID, oEmployee);//获取grid的Field里面的值 } if (typeValue == "GetSysSettings") { string keyWordValue = Request.QueryString["keyWordValue"]; json = Newtonsoft.Json.JsonConvert.SerializeObject(Common.GetSysSettingsByENKey(keyWordValue)); json = "[" + json + "]"; } if (typeValue == "GetData") { string ResID = Request["ResID"].ToString(); string Condition = Request["Condition"].ToString(); json = CommonMethod.GetDataJson(ResID, "ID", Condition, UserID); } if (typeValue == "GetChildDataByParent") { string ParentResID = Request["ParentResID"].ToString(); string ParentRecID = Request["ParentRecID"].ToString(); string ResID = Request["ResID"].ToString(); json = CommonMethod.GetDataJson(ParentResID, ResID, ParentRecID, "ID", UserID); } if (typeValue == "GetDataOfPageByTableName") { string KeyWord = Request["keyWordValue"]; SysSettings sys = Common.GetSysSettingsByENKey(KeyWord); string ResID = Request["ResID"].ToString(); int PageSize = Request["rows"] == null ? 10 : Convert.ToInt32(Request["rows"]); int PageNumber = Request["page"] == null ? 1 : Convert.ToInt32(Request["page"]); string SortField = ""; string SortBy = ""; if (Request["sort"] != null) { SortField = Request["sort"].ToString(); } if (Request["order"] != null) { SortBy = Request["order"].ToString(); } string Condition = Request["Condition"]; string TableName = Request["TableName"]; json = CommonMethod.GetDataJsonOfPageByTableName(KeyWord, ResID, PageNumber, PageSize, Condition, UserID); } if (typeValue == "GetDataByTableName") { string KeyWord = Request["keyWordValue"]; SysSettings sys = Common.GetSysSettingsByENKey(KeyWord); string ResID = Request["ResID"].ToString(); string SortField = ""; string SortBy = ""; if (Request["sort"] != null) { SortField = Request["sort"].ToString(); } if (Request["order"] != null) { SortBy = Request["order"].ToString(); } string Condition = Request["Condition"]; string TableName = Request["TableName"]; json = CommonMethod.GetDataJsonByTableName(KeyWord, ResID, Condition, UserID); } if (typeValue == "GetDataOfPage") { string ResID = Request["ResID"].ToString(); if (ResID == "") { json = "{\"total\":0,\"rows\":[]}"; } else { string KeyWord = Request["keyWordValue"]; int PageSize = Request["rows"] == null?10: Convert.ToInt32(Request["rows"]); int PageNumber = Request["page"] == null ? 1 : Convert.ToInt32(Request["page"]); string SortField = ""; string SortBy = ""; string Condition = "";//条件 if (Request["sort"] != null) { SortField = Request["sort"]; } if (Request["order"] != null) { SortBy = Request["order"]; } //关键字查询条件 string where = Request["Condition"] == null ? "" : Request["Condition"]; if (where.Trim() != "") { Condition += CommonMethod.GetResouceCondtion(KeyWord, where.Trim()); } //列表初始化筛选条件 if (Request["Authority"] != null && Request["Authority"] != "") { Condition += CommonMethod.GetFilterCondition(Server.UrlDecode(Request["Authority"]), oEmployee); } if (ResID == "1300") { Condition += " and 登录帐号 not in ('admin','sysuser','security')"; } //高级组合筛选条件 if (Request["FilterRules"] != null && Request["FilterRules"] != "") { Condition += " and " + Request["FilterRules"]; } //主子表关联字段筛选,主子表关联字段只能有一个 if (Request["RelationCondtion"] != null && Request["RelationCondtion"] != "") { string str = Request["RelationCondtion"]; string str1 = Request["RelationCondtion"].Substring(0, Request["RelationCondtion"].IndexOf("=") + 1); string str2 = Request["RelationCondtion"].Substring(Request["RelationCondtion"].IndexOf("=") + 1); //截取出关联字段值,判断是否需要添加引号 if (str2.Trim().Length > 0) { //if (!CommonMethod.IsNum(str2.Trim()))//判断类型 // Condition += " and " + Request["RelationCondtion"]; //else Condition += " and " + str1 + "'" + str2 + "'"; } } string footName = Request["FootStr"]; if (footName != null && footName != "") { json = CommonMethod.GetDataOfPageForFooter(KeyWord, ResID, PageNumber, PageSize, SortField, SortBy, Condition, UserID, footName); } else { json = CommonMethod.GetDataJsonOfPage(KeyWord, ResID, PageNumber, PageSize, SortField, SortBy, Condition, UserID); } } } if (typeValue == "GetDataBySql") { string Condition = Request["Condition"].ToString(); int PageSize = 0; if (Request["rows"] != null) { PageSize = Convert.ToInt32(Request["rows"]); } int PageNumber = 0; if (Request["rows"] != null) { PageNumber = Convert.ToInt32(Request["page"]); } string sqlData = Request["sqlData"].ToString(); string SortField = ""; string SortBy = ""; if (Request["SortField"] != null) { SortField = Request["SortField"].ToString(); } if (Request["SortBy"] != null) { SortBy = Request["SortBy"].ToString(); } string sql = "select * from (" + sqlData + ") as c where 1=1 " + Condition; string OrderBy = "";//order by if (SortField != "" && SortBy != "") { OrderBy = " " + SortField + " " + SortBy; } WebServices.Services services = new WebServices.Services(); DataTable dt = null; string dtCount = "0"; string[] changePassWord = Common.getChangePassWord(); if (PageSize == 0 && PageNumber == 0) { dt = services.Query(sql, changePassWord[0], changePassWord[1], changePassWord[2]).Tables[0]; } else { dt = GetDataListPage(sql, PageNumber, PageSize, OrderBy).Tables[0]; dtCount = services.Query(sql, changePassWord[0], changePassWord[1], changePassWord[2]).Tables[0].Rows.Count.ToString(); } Newtonsoft.Json.Converters.IsoDateTimeConverter timeConverter = new Newtonsoft.Json.Converters.IsoDateTimeConverter(); // //这里使用自定义日期格式,如果不使用的话,默认是ISO8601格式 timeConverter.DateTimeFormat = "yyyy'-'MM'-'dd"; string str = Newtonsoft.Json.JsonConvert.SerializeObject(dt, timeConverter); json = "{\"total\":" + dtCount + ",\"rows\":" + str + "}"; } //单表单记录查询 if (typeValue == "GetOneRowByRecID") { string RecID = Request["RecID"]; string ResID = Request["ResID"]; json = CommonMethod.GetOneRowByRecID(ResID, RecID); } //单表单记录查询 if (typeValue == "GetOneRowBySql") { Services oServices = new Services(); string strSql = Request["sql"]; string RecID = Request["RecID"]; if (strSql.ToLower().Contains("where")) { strSql += " and ID=" + RecID; } else { strSql += " where ID=" + RecID; } string[] changePassWord = Common.getChangePassWord(); json = Newtonsoft.Json.JsonConvert.SerializeObject(oServices.SelectData(strSql, changePassWord[0], changePassWord[1], changePassWord[2]).Tables[0]); } //删除普通Grid数据 if (typeValue == "DeleteRow") { json = DeleteRow(); } //由于筛选条件和要导出的Excel列字段数据较大,无法通过url传递,因此先通过此方法将其存储在cookes中 if (typeValue.Equals("saveExcelData")) { string s1 = Request["conditionStr"] == null ? "" : Request["conditionStr"]; string where = Request["Condition"] == null ? "" : Request["Condition"]; string KeyWord = Request["KeyWord"] == null ? "" : Request["KeyWord"]; if (where.Trim() != "") { where = CommonMethod.GetResouceCondtion(KeyWord, where.Trim()); s1 += where.Substring(4, where.Length - 4); } //string s2 = Request["columnStr"]; //if (Request["columnStr"] == null || Request["columnStr"] == "") // json = "{\"success\": false,\"key\": \"0\"}"; //else //{ string CookieKey = Guid.NewGuid().ToString(); HttpCookie CookieCdn = new HttpCookie("cdn" + CookieKey); CookieCdn.Value = s1; CookieCdn.Expires = DateTime.Now.AddDays(1); Response.Cookies.Add(CookieCdn); HttpCookie CookiecdnCol = new HttpCookie("col" + CookieKey); CookiecdnCol.Value = ""; CookiecdnCol.Expires = DateTime.Now.AddDays(1); Response.Cookies.Add(CookiecdnCol); json = "{\"success\": true,\"key\": \"" + CookieKey + "\"}"; //} } if (typeValue.Equals("Excel")) { if (Request.QueryString["cookeId"] == null) { Response.Write("导出失败,请重新操作!"); Response.End(); } string cookeId = Request.QueryString["cookeId"]; //从Cookies中取出存储的参数 筛选条件、导出字段,然后在销毁Cookies string Condition = Request.Cookies["cdn" + cookeId].Value; string Column = Request.Cookies["col" + cookeId].Value; Request.Cookies["col" + cookeId].Expires = DateTime.Now.AddDays(-1); Request.Cookies["cdn" + cookeId].Expires = DateTime.Now.AddDays(-1); Condition = Condition.Equals("") ? "" : " and " + Condition; //导出筛选条件 Column = Column.Equals("") ? "*" : Column; //导出的列 string fileName = Request.QueryString["ExcelfileName"] == null ? "数据" : Request.QueryString["ExcelfileName"]; //获取资源ID及资源关键字参数 string resid = Request.QueryString["resId"]; string keyWord = Request.QueryString["KeyWord"]; //根据筛选条件及字段列,获取导出数据 WebServices.Services services = new WebServices.Services(); //列表初始化筛选条件 if (Request["Authority"] != null && Request["Authority"] != "") { Condition += CommonMethod.GetFilterCondition(Server.UrlDecode(Request["Authority"]), oEmployee); } DataTable dt = services.GetDataListByResID(resid, "", Condition, UserID).Tables[0]; DataTable newDt = new DataTable(); DataTable colDt = services.GetDataListByResID("502816446274", " 排序号 asc", " and 参数关键字='" + keyWord + "'", UserID).Tables[0]; for (int i = 0; i < colDt.Rows.Count; i++) { newDt.Columns.Add(colDt.Rows[i]["显示字段"].ToString()); } for (int i = 0; i < dt.Rows.Count; i++) { newDt.ImportRow(dt.Rows[i]); } // DataTable dt = services.GetDataColumnListByResID(resid, Column, "ID", Condition, UserID).Tables[0]; Byte[] fileByte = new DoExcel().ExportExcel(newDt, fileName); Response.Clear(); Response.ClearContent(); Response.ClearHeaders(); Response.ContentType = "application/octet-stream"; Response.AddHeader("Content-Length", fileByte.Length.ToString()); Response.AddHeader("Content-Disposition", "attachment; filename=" + HttpUtility.UrlEncode(fileName + DateTime.Now.ToString("yyyyMMdd") + ".xlsx", System.Text.Encoding.UTF8)); Response.BinaryWrite(fileByte); Response.Flush(); Response.End(); } Response.Write(json); }