using Newtonsoft.Json;
|
using Newtonsoft.Json.Converters;
|
using Pub_Class;
|
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;
|
namespace WebAPI.Controllers
|
{
|
public class ZWDBController : ApiController
|
{
|
public DBUtility.ClsPub.Enum_BillStatus BillStatus;//单据状态(新增,修改,浏览,更新单价,变更)
|
public SQLHelper.ClsCN oCn = new SQLHelper.ClsCN();
|
private json objJsonResult = new json();
|
public DataSet ds = new DataSet();
|
public WebServer webserver = new WebServer();
|
// GET: ZWDB
|
[Route("ZWDBController/GetLIST")]
|
public object GetLIST(string user,int OrgIDs)
|
{
|
List<object> columnNameList = new List<object>();
|
try
|
{
|
DataSet ds = oCn.RunProcReturn("select * from h_v_ZWDB where 1=1 order by HItemID desc", "h_v_ZWDB");
|
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 = "1";
|
objJsonResult.count = 1;
|
objJsonResult.Message = "Sucess!";
|
objJsonResult.data = ds.Tables[0];
|
objJsonResult.list = columnNameList;
|
return objJsonResult;
|
}
|
catch (Exception ex)
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "查询数据异常,请与管理员联系!" + ex.ToString();
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
}
|
|
|
[Route("ZWDBController/insertTODOS")]
|
[HttpGet]
|
public object insertTODOS(string contents, string user)
|
{
|
List<object> columnNameList = new List<object>();
|
try
|
{
|
oCn.BeginTran();
|
if (contents == "" || contents == null)
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "查询数据异常,请与管理员联系!" ;
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
oCn.RunProc($"INSERT INTO [Gy_ZWDB] ( [HDate], [HMaker], [HMakeDate], [contents], [IsBan], [IsUsed], [IsEdit], [HUSEORGID]) VALUES ( '{DateTime.Now}', '{user}', '{DateTime.Now}', '{contents}', 0, 1, 1, 100038);");
|
|
oCn.Commit();
|
DataSet ds = oCn.RunProcReturn("select MAX(HItemID) HItemID from Gy_ZWDB ", "Gy_ZWDB");
|
objJsonResult.code = "1";
|
objJsonResult.count = 1;
|
objJsonResult.Message = "Sucess!";
|
objJsonResult.data = ds.Tables[0];
|
objJsonResult.list = columnNameList;
|
return objJsonResult;
|
}
|
catch (Exception ex)
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "查询数据异常,请与管理员联系!" + ex.ToString();
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
}
|
|
|
[Route("ZWDBController/deleteTODOS")]
|
[HttpGet]
|
public object deleteTODOS( string user,int HID)
|
{
|
List<object> columnNameList = new List<object>();
|
try
|
{
|
oCn.BeginTran();
|
if ( HID == null)
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "查询数据异常,请与管理员联系!";
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
oCn.RunProc($"UPDATE Gy_ZWDB set IsUsed=0 where HItemID='{HID}'");
|
oCn.Commit();
|
DataSet ds = oCn.RunProcReturn("select MAX(HItemID) HItemID from Gy_ZWDB ", "Gy_ZWDB");
|
objJsonResult.code = "1";
|
objJsonResult.count = 1;
|
objJsonResult.Message = "Sucess!";
|
objJsonResult.data = ds.Tables[0];
|
objJsonResult.list = columnNameList;
|
return objJsonResult;
|
}
|
catch (Exception ex)
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "查询数据异常,请与管理员联系!" + ex.ToString();
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
}
|
}
|
}
|