public static Com.DataPack.DataRsp <string> page(List <string> arr) { //变量声明区域 Com.DataPack.DataRsp <string> rsp = new Com.DataPack.DataRsp <string>(); if (Com.Session.userid == null) { rsp.code = "expire"; rsp.msg = "你现在登录已过期,请重新登录!"; } else { string PageIndex = ""; string PageSize = ""; string txtAccount = "", txtUserTname = "", txtProvince = "", txtCity = "", txtUserType = "", txtAdditional = "", txtPackage = "", txtStat = ""; string txtSource = "", txtStartTime01 = "", txtStartTime02 = "", txtEndTime01 = "", txtEndTime02 = ""; //分解前台传递过来的参数并给变量赋值 foreach (string str in arr) { string[] strarr = str.Split('#'); if (strarr[0] == "PageIndex") { PageIndex = strarr[1]; } else if (strarr[0] == "PageSize") { PageSize = strarr[1]; } else if (strarr[0] == "txtAccount") { txtAccount = strarr[1]; } else if (strarr[0] == "txtUserTname") { txtUserTname = strarr[1]; } else if (strarr[0] == "txtProvince") { txtProvince = strarr[1]; } else if (strarr[0] == "txtCity") { txtCity = strarr[1]; } else if (strarr[0] == "txtUserType") { txtUserType = strarr[1]; } else if (strarr[0] == "txtAdditional") { txtAdditional = strarr[1]; } else if (strarr[0] == "txtPackage") { txtPackage = strarr[1]; } else if (strarr[0] == "txtStat") { txtStat = strarr[1]; } else if (strarr[0] == "txtStartTime01") { txtStartTime01 = strarr[1]; } else if (strarr[0] == "txtStartTime02") { txtStartTime02 = strarr[1]; } else if (strarr[0] == "txtEndTime01") { txtEndTime01 = strarr[1]; } else if (strarr[0] == "txtEndTime02") { txtEndTime02 = strarr[1]; } else if (strarr[0] == "txtSource") { txtSource = strarr[1]; } } //实例化对象 SchSystem.BLL.ServUserFor sufBll = new SchSystem.BLL.ServUserFor(); //声明SQL拼接变量 StringBuilder strwhere = new StringBuilder(); //条件SQL拼接 strwhere.Append("1=1"); if (!string.IsNullOrEmpty(txtAccount)) { strwhere.Append(" and UserName='******'"); } if (!string.IsNullOrEmpty(txtUserTname)) { strwhere.Append(" and UTname='" + txtUserTname + "'"); } if (!string.IsNullOrEmpty(txtProvince)) { strwhere.Append(" and left(Uareano,2)='" + Com.Public.SqlEncStr(txtProvince.Substring(0, 2)) + "'"); } if (!string.IsNullOrEmpty(txtCity)) { strwhere.Append(" and left(Uareano,4)='" + Com.Public.SqlEncStr(txtCity.Substring(0, 4)) + "'"); } if (!string.IsNullOrEmpty(txtStat)) { strwhere.Append(" and ServStat='" + txtStat + "'"); } if (!string.IsNullOrEmpty(txtStartTime01) && !string.IsNullOrEmpty(txtStartTime02)) { strwhere.Append(" and RecTime between '" + DateTime.Parse(txtStartTime01) + "' and '" + DateTime.Parse(txtStartTime02) + "'"); } if (!string.IsNullOrEmpty(txtSource)) { strwhere.Append(" and FromType='" + txtSource + "'"); } if (!string.IsNullOrEmpty(txtEndTime01) && !string.IsNullOrEmpty(txtEndTime02)) { strwhere.Append(" and EndTime between '" + DateTime.Parse(txtEndTime01) + "' and '" + DateTime.Parse(txtEndTime02) + "'"); } if (!string.IsNullOrEmpty(txtPackage)) { strwhere.Append(" and ServiceId='" + txtPackage + "'"); } Com.Public.PageModelResp pages = new Com.Public.PageModelResp(); pages.PageIndex = int.Parse(PageIndex); pages.PageSize = int.Parse(PageSize); int rowc = 0; int pc = 0; try { string dbcols = "AutoId,UserName,UTname,Uareano,FromType,RecUser,CnName,FeeM,ServMonth,RecTime,EndTime,EditTime,ServStat,DoNote"; DataTable dt = sufBll.GetListColsV(dbcols, strwhere.ToString(), "AutoId", "DESC", pages.PageIndex, pages.PageSize, ref rowc, ref pc).Tables[0]; if (dt.Rows.Count > 0) { dt.Columns.Add("Province"); dt.Columns.Add("City"); for (int i = 0; i < dt.Rows.Count; i++) { if (dt.Rows[i]["Uareano"].ToString() != "") { dt.Rows[i]["Province"] = Com.Public.GetSSQ("0", dt.Rows[i]["Uareano"].ToString()); dt.Rows[i]["City"] = Com.Public.GetSSQ("1", dt.Rows[i]["Uareano"].ToString()); } else { dt.Rows[i]["Province"] = ""; dt.Rows[i]["City"] = ""; } } } pages.PageCount = pc; pages.RowCount = rowc; if (dt.Rows.Count > 0) { pages.list = dt; } rsp.RspData = Newtonsoft.Json.JsonConvert.SerializeObject(pages); } catch (Exception ex) { rsp.code = "excepError"; rsp.msg = ex.Message; } } return(rsp); }
public static string page(List <string> arr) { //变量声明区域 string ret = ""; if (Com.Session.userid == null) { ret = "expire"; } else { string PageIndex = ""; string PageSize = ""; string txtAccount = "", txtUserTname = "", txtProvince = "", txtCity = "", txtUserType = "", txtAdditional = "", txtPackage = "", txtStat = ""; string txtSource = "", txtStartTime01 = "", txtStartTime02 = "", txtEndTime01 = "", txtEndTime02 = "", ordercols = "AutoId", orderby = "ASC"; //分解前台传递过来的参数并给变量赋值 foreach (string str in arr) { string[] strarr = str.Split('#'); if (strarr[0] == "PageIndex") { PageIndex = strarr[1]; } else if (strarr[0] == "PageSize") { PageSize = strarr[1]; } else if (strarr[0] == "txtAccount") { txtAccount = strarr[1]; } else if (strarr[0] == "txtUserTname") { txtUserTname = strarr[1]; } else if (strarr[0] == "txtProvince") { txtProvince = strarr[1]; } else if (strarr[0] == "txtCity") { txtCity = strarr[1]; } else if (strarr[0] == "txtUserType") { txtUserType = strarr[1]; } else if (strarr[0] == "txtAdditional") { txtAdditional = strarr[1]; } else if (strarr[0] == "txtPackage") { txtPackage = strarr[1]; } else if (strarr[0] == "txtStat") { txtStat = strarr[1]; } else if (strarr[0] == "txtStartTime01") { txtStartTime01 = strarr[1]; } else if (strarr[0] == "txtStartTime02") { txtStartTime02 = strarr[1]; } else if (strarr[0] == "txtEndTime01") { txtEndTime01 = strarr[1]; } else if (strarr[0] == "txtEndTime02") { txtEndTime02 = strarr[1]; } else if (strarr[0] == "txtSource") { txtSource = strarr[1]; } else if (strarr[0] == "ordercols") { ordercols = strarr[1]; } else if (strarr[0] == "orderby") { orderby = strarr[1]; } } if (ordercols == "") { ordercols = "AutoId"; } if (orderby == "") { orderby = "asc"; } //实例化对象 SchSystem.BLL.ServUserFor sufBll = new SchSystem.BLL.ServUserFor(); //声明SQL拼接变量 StringBuilder strwhere = new StringBuilder(); //条件SQL拼接 strwhere.Append("1=1"); if (!string.IsNullOrEmpty(txtAccount)) { strwhere.Append(" and UserName='******'"); } if (!string.IsNullOrEmpty(txtUserTname)) { strwhere.Append(" and UTname='" + txtUserTname + "'"); } if (!string.IsNullOrEmpty(txtProvince)) { strwhere.Append(" and left(Uareano,2)='" + Com.Public.SqlEncStr(txtProvince.Substring(0, 2)) + "'"); } if (!string.IsNullOrEmpty(txtCity)) { strwhere.Append(" and left(Uareano,4)='" + Com.Public.SqlEncStr(txtCity.Substring(0, 4)) + "'"); } if (!string.IsNullOrEmpty(txtStat)) { strwhere.Append(" and ServStat='" + txtStat + "'"); } if (!string.IsNullOrEmpty(txtStartTime01) && !string.IsNullOrEmpty(txtStartTime02)) { strwhere.Append(" and RecTime between '" + DateTime.Parse(txtStartTime01) + "' and '" + DateTime.Parse(txtStartTime02) + "'"); } if (!string.IsNullOrEmpty(txtSource)) { strwhere.Append(" and FromType='" + txtSource + "'"); } if (!string.IsNullOrEmpty(txtEndTime01) && !string.IsNullOrEmpty(txtEndTime02)) { strwhere.Append(" and EndTime between '" + DateTime.Parse(txtEndTime01) + "' and '" + DateTime.Parse(txtEndTime02) + "'"); } if (!string.IsNullOrEmpty(txtPackage)) { strwhere.Append(" and ServiceId='" + txtPackage + "'"); } int rowc = 0; int pc = 0; string errcode = ""; DataTable dt = new DataTable(); try { string dbcols = "AutoId,UserName,UTname,Uareano,FromType,RecUser,CnName,FeeM,ServMonth,RecTime,EndTime,EditTime,ServStat,DoNote"; dt = sufBll.GetListColsV(dbcols, strwhere.ToString(), ordercols, orderby, int.Parse(PageIndex), int.Parse(PageSize), ref rowc, ref pc).Tables[0]; if (dt.Rows.Count > 0) { dt.Columns.Add("Province"); dt.Columns.Add("City"); for (int i = 0; i < dt.Rows.Count; i++) { if (dt.Rows[i]["Uareano"].ToString() != "") { dt.Rows[i]["Province"] = Com.Public.GetSSQ("0", dt.Rows[i]["Uareano"].ToString()); dt.Rows[i]["City"] = Com.Public.GetSSQ("1", dt.Rows[i]["Uareano"].ToString()); } else { dt.Rows[i]["Province"] = ""; dt.Rows[i]["City"] = ""; } } } } catch (Exception ex) { errcode = ex.Message; } data dtobj = new data(); dtobj.total = rowc; dtobj.rows = dt; dtobj.errcode = errcode; ret = Newtonsoft.Json.JsonConvert.SerializeObject(dtobj); } return(ret); }