zoukankan      html  css  js  c++  java
  • C# 报表接口样例,简单实用

    //连接视图名称,视图在数据库写好
    <%@ WebHandler Language="C#" Class="GetwmsReport" %> using System; using System.Drawing; using System.Data; using System.Data.SqlClient; using System.Collections.Generic; using System.Web; using System.Text; using CloudSaaS.DAL; using CloudSaaS.Model; using Newtonsoft.Json; using CloudSaaS.Common; using CloudSaaS.DB.Handler; using Newtonsoft.Json.Linq; public class GetwmsReport : IHttpHandler { public void ProcessRequest(HttpContext context) { var json = string.Empty; var req = context.Request["req"].Trim(); string tenantId = HttpContext.Current.Request.Cookies["tenantID"].Value; switch(req){ case "GetDeliverSum": json = GetDeliverSum(tenantId, context);//当日发货汇总 break; case "GetDeliverDetail": json = GetDeliverDetail(tenantId, context);//当日发货明细 break; case "GetReceiptSum": json = GetReceiptSum(tenantId, context);//当日收获汇总 break; case "GetReceiptDetail": json = GetReceiptDetail(tenantId, context);//当日收货明细 break; } context.Response.ContentType = "text/json"; context.Response.Write(json); context.Response.End(); context.Response.Close(); } /*--当日收货明细:UV_SYSWMSREPORT_1 --当日发货明细:UV_SYSWMSREPORT_2 --当日收货汇总:UV_SYSWMSREPORT_3 --当日发货汇总:UV_SYSWMSREPORT_4*/ /// <summary> ///当日发货汇总 /// </summary> /// <param name="BillNo "></param> /// <returns>当日发货汇总</returns> public string GetDeliverSum(string tenantId, HttpContext context) { DataTable dt = new DataTable(); StringBuilder strSql = new StringBuilder(); string hetong = context.Request["hetong"]; //摘要 string product = context.Request["product"]; //文件名称 string project = context.Request["project"]; strSql.Append("select * from UV_SYSWMSREPORT_4 where 1=1 "); DataSet ds = CloudSaaS.DB.Handler.CloudDB.GetHandler(tenantId).Query(strSql.ToString()); if (ds.Tables.Count > 0) { dt = ds.Tables[0]; // obj.code = "200"; // obj.msg = "操作成功!"; } return Newtonsoft.Json.JsonConvert.SerializeObject(dt); } /// <summary> ///当日发货明细 /// </summary> /// <param name="BillNo "></param> /// <returns>当日发货明细</returns> public string GetDeliverDetail(string tenantId, HttpContext context) { DataTable dt = new DataTable(); StringBuilder strSql = new StringBuilder(); string hetong = context.Request["hetong"]; //摘要 string product = context.Request["product"]; //文件名称 string project = context.Request["project"]; strSql.Append("select * from UV_SYSWMSREPORT_2 where 1=1 "); DataSet ds = CloudSaaS.DB.Handler.CloudDB.GetHandler(tenantId).Query(strSql.ToString()); if (ds.Tables.Count > 0) { dt = ds.Tables[0]; // obj.code = "200"; //obj.msg = "操作成功!"; } return Newtonsoft.Json.JsonConvert.SerializeObject(dt); } /// <summary> ///当日收货汇总 /// </summary> /// <param name="BillNo "></param> /// <returns>当日收货汇总</returns> public string GetReceiptSum(string tenantId, HttpContext context) { DataTable dt = new DataTable(); StringBuilder strSql = new StringBuilder(); string hetong = context.Request["hetong"]; //摘要 string product = context.Request["product"]; //文件名称 string project = context.Request["project"]; strSql.Append("select * from UV_SYSWMSREPORT_3 where 1=1 "); DataSet ds = CloudSaaS.DB.Handler.CloudDB.GetHandler(tenantId).Query(strSql.ToString()); if (ds.Tables.Count > 0) { dt = ds.Tables[0]; // obj.code = "200"; // obj.msg = "操作成功!"; } return Newtonsoft.Json.JsonConvert.SerializeObject(dt); } /// <summary> ///当日收货明细 /// </summary> /// <param name="BillNo "></param> /// <returns>当日收货明细</returns> public string GetReceiptDetail(string tenantId, HttpContext context) { dynamic obj = new System.Dynamic.ExpandoObject(); obj.code = "1000"; obj.msg="提交时出现错误!"; try { // DataTable dt = new DataTable(); // dalSYSWMSInputBillHead dal = new dalSYSWMSInputBillHead(tenantId); StringBuilder strSql = new StringBuilder(); string hetong = context.Request["hetong"]; //摘要 string product = context.Request["product"]; //文件名称 string project = context.Request["project"]; strSql.Append("select * from UV_SYSWMSREPORT_1 where 1=1 "); /* if (!string.IsNullOrEmpty(hetong)) { strSql.AppendFormat(" and 合同编号 like '%{0}%'",hetong); } // strSql.AppendFormat(" order by 序号 desc"); */ DataSet ds = CloudSaaS.DB.Handler.CloudDB.GetHandler(tenantId).Query(strSql.ToString()); if (ds.Tables.Count > 0) { obj.data = ds.Tables[0]; obj.code = "200"; obj.msg = "操作成功!"; } } catch (Exception ex) { string strMsg = string.Format("提交时出现错误{0}", ex.Message); obj.code = "1000"; obj.msg = strMsg; } // return Newtonsoft.Json.JsonConvert.SerializeObject(obj); return JsonConvert.SerializeObject(obj); } public bool IsReusable { get { return false; } } }
  • 相关阅读:
    cf 786B. Legacy(线段树区间建图)
    cf 1416D. Graph and Queries (生成树重构+线段树维护dfs序)
    cf 1437E. Make It Increasing
    cf 1434D. Roads and Ramen (树上最长偶权链)
    cf 1413C (贪心排序+双指针)
    cf 1421E. Swedish Heroes (dp)
    CF1428 F.Fruit Sequences
    11.Redis详解(十一)------ 过期删除策略和内存淘汰策略
    10.Redis详解(十)------ 集群模式详解
    9.Redis详解(九)------ 哨兵(Sentinel)模式详解
  • 原文地址:https://www.cnblogs.com/yek9520/p/9408135.html
Copyright © 2011-2022 走看看