using DAL;
using DBUtility;
using Model;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using Newtonsoft.Json.Linq;
using SQLHelper;
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;
using WebAPI.Models;
using WebAPI.Service;
namespace WebAPI.Controllers
{
public class WEBSController : ApiController
{
public string sWhere = "";
public WebServer webserver = new WebServer();
public DataSet ds = new DataSet();
private json objJsonResult = new json();
SQLHelper.ClsCN oCn = new SQLHelper.ClsCN();
public ClsKf_ICStockBill_WMS oBar = new Model.ClsKf_ICStockBill_WMS();
public WebS.WebService1 oWebs = new WebS.WebService1();
public WebS.ClsKf_ICStockBill_WMS WebSoBar = new WebS.ClsKf_ICStockBill_WMS();
Pub_Class.ClsXt_SystemParameter oSystemParameter = new Pub_Class.ClsXt_SystemParameter();
WebS.ClsXt_SystemParameterMain oSystemParameterMain = new WebS.ClsXt_SystemParameterMain();
#region 公用方法
#region 获取最大单据ID、单据号
///
/// 获取最大单据ID、单据号
///
///
[Route("WEBSController/GetMaxBillNoAndID_Json")]
[HttpGet]
public object GetMaxBillNoAndID_Json(string HBillType)
{
try
{
string sErrMsg = "";
Int64 HInterID = 0;
string HBillNo = "";
HInterID = DBUtility.ClsPub.CreateBillID_Prod(HBillType, ref sErrMsg);
HBillNo = DBUtility.ClsPub.CreateBillCode_Prod(HBillType, ref sErrMsg, true);
//----------创建虚表------------------------
DataTable dt_Main = new DataTable("Json");
dt_Main.Columns.Add("HBillNo", typeof(string));
dt_Main.Columns.Add("HInterID", typeof(int));
//---------创建新行------------------------
DataRow dr_main = dt_Main.NewRow(); //创建新行
dt_Main.Rows.Add(dr_main); //将新行加入到表中
dr_main["HBillNo"] = DBUtility.ClsPub.isStrNull(HBillNo);
dr_main["HInterID"] = DBUtility.ClsPub.isLong(HInterID);
//返回数据
if (HBillNo == "" || HInterID == 0)
{
objJsonResult.code = "0";
objJsonResult.count = 0;
objJsonResult.Message = "最大单据ID、单据号获取失败";
objJsonResult.data = null;
return objJsonResult;
}
else
{
objJsonResult.code = "0";
objJsonResult.count = 1;
objJsonResult.Message = "获取成功";
objJsonResult.data = dt_Main;
return objJsonResult;
}
}
catch (Exception e)
{
objJsonResult.code = "0";
objJsonResult.count = 0;
objJsonResult.Message = "获取最大单据ID、单据号失败!" + e.ToString();
objJsonResult.data = null;
return objJsonResult;
}
}
#endregion
#endregion
#region 基础资料
#region 仓库资料
//根据仓库ID、组织ID,返回仓库信息
public Model.ClsGy_Warehouse_Model GetWhInfoByIDandOrg(long sHWhID, long HUSEORGID, ref string sErr)
{
DAL.ClsIF_Warehouse_View dal = new DAL.ClsIF_Warehouse_View();
if (dal.GetInfoByIDandOrgID(sHWhID, HUSEORGID))
{
return dal.omodel;
}
else
{
return null;
}
}
#endregion
#region 仓位资料
#endregion
#endregion
#region 界面控件功能调用方法
#region 根据单据类型获取单据子类型
///
/// 根据单据类型获取单据子类型
///
///
[Route("WEBSController/GetBillSubType_Json")]
[HttpGet]
public Object GetBillSubType_Json(string HBillType, Int64 HStockOrgID)
{
try
{
ds = oWebs.get_BillSubType(HBillType, HStockOrgID);
if (ds == null)
{
objJsonResult.code = "0";
objJsonResult.count = 0;
objJsonResult.Message = "查询不到单据子类型信息!";
objJsonResult.data = null;
return objJsonResult;
}
else
{
objJsonResult.code = "0";
objJsonResult.count = 1;
objJsonResult.Message = "成功";
objJsonResult.data = ds.Tables[0];
return objJsonResult;
}
}
catch (Exception e)
{
objJsonResult.code = "0";
objJsonResult.count = 0;
objJsonResult.Message = "根据单据类型获取单据子类型信息失败!" + e.ToString();
objJsonResult.data = null;
return objJsonResult;
}
}
#endregion
#endregion
#region 缓存列表 编辑功能调用
///
/// 缓存列表选择编辑时,判断所选单据是否已存在上传记录,启用先进先出功能的,回填先进先出临时表状态(更新 HlineStatus =0)
///
///
[Route("WEBSController/TempList_Modify_Json")]
[HttpGet]
public object TempList_Modify_Json(long HInterID, string HBillNo, string HBillType)
{
try
{
if (oWebs.TempList_Modify(HInterID, HBillNo, HBillType, ref DBUtility.ClsPub.sErrInfo))
{
objJsonResult.code = "0";
objJsonResult.count = 1;
objJsonResult.Message = "成功";
objJsonResult.data = null;
return objJsonResult;
}
else
{
objJsonResult.code = "0";
objJsonResult.count = 0;
objJsonResult.Message = DBUtility.ClsPub.sErrInfo; //失败!
objJsonResult.data = null;
return objJsonResult;
}
}
catch (Exception e)
{
objJsonResult.code = "0";
objJsonResult.count = 0;
objJsonResult.Message = "缓存列表编辑前判断失败!" + e.ToString();
objJsonResult.data = null;
return objJsonResult;
}
}
#endregion
#region 已上传查询界面,根据单据号、源单号查询已上传单据信息
///
/// 已上传查询界面,根据单据号、源单号查询已上传单据信息
///
///
[Route("WEBSController/GetKf_ICStockBillQueryList_Json")]
[HttpGet]
public object GetKf_ICStockBillQueryList_Json(string HBillType, string HBillNo, string HSourceBillNo)
{
try
{
ds = oWebs.GetKf_ICStockBillQueryList(HBillType, HBillNo, HSourceBillNo);
if (ds == null)
{
objJsonResult.code = "0";
objJsonResult.count = 0;
objJsonResult.Message = "查询不到该单据记录!";
objJsonResult.data = null;
return objJsonResult;
}
else
{
List