using DBUtility;
|
using Model;
|
using Newtonsoft.Json;
|
using Newtonsoft.Json.Converters;
|
using Newtonsoft.Json.Linq;
|
using System;
|
using System.Collections.Generic;
|
using System.Data;
|
using System.Linq;
|
using System.Net;
|
using System.Net.Http;
|
using System.Web.Http;
|
using WebAPI.Models;
|
using SyntacticSugar.constant;
|
|
namespace WebAPI.Controllers.基础资料.基础资料
|
{
|
public class Gy_ShelfLifeNearExpiryController : ApiController
|
{
|
private json objJsonResult = new json();
|
SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
|
DataSet ds;
|
|
#region [保质期临期报表列表]
|
[Route("Gy_ShelfLifeNearExpiry/list")]
|
[HttpGet]
|
public object list(string sWhere, string user)
|
{
|
try
|
{
|
List<object> columnNameList = new List<object>();
|
if (sWhere == null || sWhere.Equals(""))
|
{
|
ds = oCN.RunProcReturn("select * from h_v_Gy_ShelfLifeNearExpiryList order by HMainID asc", "h_v_Gy_BarCodeBill_OutList");
|
}
|
else
|
{
|
string sql1 = "select * from h_v_Gy_ShelfLifeNearExpiryList where 1 = 1 ";
|
string sql = sql1 + sWhere + " order by HMainID asc";
|
ds = oCN.RunProcReturn(sql, "h_v_Gy_ShelfLifeNearExpiryList");
|
}
|
foreach (DataColumn col in ds.Tables[0].Columns)//遍历ds中第一个表(Tables[0])的所有列(Columns)每次循环中,col变量会持有当前列的引用
|
{
|
Type dataType = col.DataType; //获取当前数据类型传入 自定义变量datadataType
|
string ColmString = "{\"ColmCols\":\"" + col.ColumnName + "\",\"ColmType\":\"" + dataType.Name + "\"}"; //字符串拼接 // 将列名和数据类型信息拼接成一个JSON格式的字符串
|
columnNameList.Add(JsonConvert.DeserializeObject(ColmString));//获取到DataColumn列对象的列名
|
}
|
objJsonResult.code = "1";
|
objJsonResult.count = 1;
|
objJsonResult.Message = "Sucess!";
|
objJsonResult.data = ds.Tables[0];
|
objJsonResult.list = columnNameList;
|
return objJsonResult;
|
}
|
catch (Exception e)
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "Exception!" + e.ToString();
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
}
|
#endregion
|
|
#region [保质期临期报表列表 分页]
|
[Route("Gy_ShelfLifeNearExpiry/listPage")]
|
[HttpGet]
|
public object listPage(string sWhere, string user,int page, int size)
|
{
|
try
|
{
|
List<object> columnNameList = new List<object>();
|
|
if (string.IsNullOrWhiteSpace(sWhere) == true)
|
{
|
ds = oCN.RunProcReturn("exec h_p_Gy_ShelfLifeNearExpiryList " + page + "," + size + ",N''" , "h_p_Gy_ShelfLifeNearExpiryList");
|
}
|
else
|
{
|
string swhere = sWhere.Replace("'", "''");
|
ds = oCN.RunProcReturn("exec h_p_Gy_ShelfLifeNearExpiryList " + page + "," + size + ",N'" + swhere + "'", "h_p_Gy_ShelfLifeNearExpiryList");
|
}
|
|
//添加列名
|
foreach (DataColumn col in ds.Tables[0].Columns)
|
{
|
Type dataType = col.DataType;
|
string ColmString = "{\"ColmCols\":\"" + col.ColumnName + "\",\"ColmType\":\"" + dataType.Name + "\"}";
|
columnNameList.Add(JsonConvert.DeserializeObject(ColmString));//获取到DataColumn列对象的列名
|
}
|
|
objJsonResult.code = CodeConstant.SUCCEED;
|
objJsonResult.count = int.Parse(ds.Tables[1].Rows[0]["count"].ToString());
|
objJsonResult.Message = "Sucess!";
|
objJsonResult.data = ds.Tables[0];
|
objJsonResult.list = columnNameList;
|
return objJsonResult;
|
}
|
catch (Exception e)
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "Exception!" + e.ToString();
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
}
|
#endregion
|
|
|
|
}
|
}
|