• 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; } } }
  • 相关阅读:
    jxl将list导入到Excel中供下载
    秒转为时分秒格式js
    秒转为时分秒格式
    加载样式js
    myeclipse:web项目不能显示Web App Libraries
    myeclipse出现src作为报名一部分src.com.*
    top命令
    Linux编写一个C程序HelloWorld
    前端jsp页面script引入url项目名使用${appName}
    流量监控iftop安装-CentOS7
  • 原文地址:https://www.cnblogs.com/yek9520/p/9408135.html
Copyright © 2020-2023  润新知