//客户端查询
public void pgsearchclient(HttpContext context, string starttime, string endtime, int page, int rows, string phone,string province)
{
endtime = Convert.ToDateTime(endtime).AddDays(1).ToString("yyyy-MM-dd");
string sql = "SELECT ";
sql += " CASE WHEN ffoi.city_id in(SELECT id from fc_city where fccc.p_id=0) then fccc.short_name when ffoi.city_id=0 then '全国' ELSE fcc.short_name end as province, ";
sql += " CASE WHEN ffoi.city_id in(SELECT id from fc_city where fccc.p_id=0) then fccc.short_name when ffoi.city_id=0 then '全国' ELSE fc.short_name end as city, ";
sql += " CASE WHEN ffoi.operators=0 THEN '电信' WHEN ffoi.operators=1 THEN '移动' WHEN ffoi.operators=2 THEN '联通' END as operatorsname,";
sql += " ffo.mobile,";
sql += " to_char(ffo.updatetime,'yyyy-MM-dd hh24:mi:ss') as updatetime";
sql += " ,ffoi.display_name";
sql += " ,ffoi.product_name";
sql += " ,ffoi.product_code,";
sql += " ffoi.tag_type";
sql += " ,ffoi.fee";
sql += " ,ffoi.flow_size";
sql += " ,ffoi.product_id";
sql += " ,ffoi.flow_type";
sql += " ,ffo.cash_fee";
sql += " ,ffo.app_code";
sql += " ,ffo.status";
sql += " ,'客户端' as channel";
sql += " ,ffoi.operators";
sql += " ,ffo.id as zongkuid";
sql += " ,ffo.order_no";
sql += " ,to_char(ffo.createtime,'yyyy-MM-dd hh24:mi:ss') as createtime";
sql += " ,ffo.unique_id";
sql += " ,to_char(ffo.success_time,'yyyy-MM-dd hh24:mi:ss') as success_time";
sql += " ,ffo.send_sms_time";
sql += " ,ffoi.city_id";
sql += " FROM fc_flow_order as ffo ";
sql += " LEFT JOIN fc_flow_order_item as ffoi on ffoi.order_id=ffo.id ";
sql += " LEFT JOIN fc_city as fc on ffoi.city_id=fc.id and fc.is_city=1 ";
sql += " LEFT JOIN fc_city as fcc on fcc.id=fc.p_id and fcc.depth=2 ";
sql += "LEFT JOIN fc_city as fccc on ffoi.city_id=fccc.id and fccc.p_id=0 where 1=1 ";
if (starttime != "")
{
sql += " and ffo.updatetime>='" + starttime + "'";
}
if (endtime != "")
{
sql += " and ffo.updatetime<='" + endtime + "'";
}
if (phone != "")
{
sql += " and ffo.mobile='" + phone + "'";
} if (province != "")
{
sql += " and fcc.short_name='" + province + "'";
}
DataSet ds = ExecuteQuery2(sql);
DataTable dt = ds.Tables[0];
int count = dt.Rows.Count;
DataSet ds2 = comh.SplitDataSet(ds, page, rows);
context.Session["clientpgsearchTable"] = dt;
string strJson = "{\"total\":" + count + ",\"rows\":" + Newtonsoft.Json.JsonConvert.SerializeObject(ds2.Tables[0]) + "}";//DataSet数据转化为Json数据
context.Response.Write(strJson);//返回给前台页面
context.Response.End();
}

public DataSet ExecuteQuery2(string StrText)
{
string StrConnection = ConfigurationManager.ConnectionStrings["sqlConnection5"].ConnectionString;
using (NpgsqlConnection conn = new NpgsqlConnection(StrConnection))
{
conn.Open();
NpgsqlCommand cmd = new NpgsqlCommand(StrText, conn);
NpgsqlDataAdapter NpgDa = new NpgsqlDataAdapter(cmd);
DataSet ds = new DataSet();
NpgDa.Fill(ds, "ds");
cmd.Parameters.Clear();
return ds;

}
}

最新文章

  1. nyoj138 找球号(二)_离散化
  2. mysql 登录及常用命令
  3. FZU 2183 字符串处理
  4. ant风格是什么?
  5. VBS基础篇 - Dictionary对象
  6. android 输入法的打开和关闭
  7. IE10用video标签播放本地mp4文件失败的解决办法
  8. jquery第四期:对象转换的小实例
  9. nohup及/dev/null使用
  10. 转:Loadrunner——Simulate a new user on each iteration设置
  11. JavaEE中的MVC(四)AOP代理
  12. 123 A. Prime Permutation
  13. 同主机下Docker+nginx+tomcat负载均衡集群搭建
  14. eclipse安装cucumber插件
  15. javascript基础 之 json
  16. Python基础-if判断以及其他循环
  17. mysql配置修改项
  18. VC6到VC2010,项目迁移错误
  19. 课程一(Neural Networks and Deep Learning),第三周(Shallow neural networks)—— 3.Programming Assignment : Planar data classification with a hidden layer
  20. 反射调用 java bean的set和get方法

热门文章

  1. linux上安装gitolite和windows上安装tortoisegit及msysgit
  2. 蓝桥杯 算法训练 ALGO-115 和为T
  3. 几种排序方式的java实现(01:插入排序,冒泡排序,选择排序,快速排序)
  4. (转)C#特性详解
  5. maven jetty 配置
  6. spring学习七
  7. socket关闭
  8. hibernate Annotation 以及注解版的数据关联
  9. cURL使用教程及实例演示
  10. 问题:C#控制台 停留;结果:c#控制台如何延时显示