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 System.Windows.Forms;
using WebAPI;
using WebAPI.Models;
using WebAPI.Service;
namespace WebAPI.Controllers
{
public class WEBSController : ApiController
{
public DBUtility.ClsPub.Enum_BillStatus BillStatus;
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();
string ComputerName = SystemInformation.ComputerName; //设备名称
WebS.ClsXt_SystemParameterMain oSystemParameterMain = new WebS.ClsXt_SystemParameterMain();
#region 公用方法
#region 账号登入
///
/// 账号登入时验证账号、密码信息
///
///
[Route("WEBSController/GetUser_Json")]
[HttpGet]
public object GetUser_Json(string HUserNumber, string HPassWord, Int64 HStockOrgID, string HStockOrgName)
{
try
{
HPassWord = DBUtility.ClsPub.StrToPsd(HPassWord.Trim());
ds = oCn.RunProcReturn("exec h_p_Gy_User '" + HUserNumber + "','" + HPassWord + "'," + HStockOrgID.ToString(), "h_p_Gy_User");
if (ds == null || ds.Tables[0].Rows.Count == 0)
{
objJsonResult.code = "0";
objJsonResult.count = 0;
objJsonResult.Message = "输入的用户名或密码错误!";
objJsonResult.data = null;
return objJsonResult;
}
else
{
//判断用户对应组织权限,得到登入组织信息(ID、代码、名称)
DataSet ds2 = oWebs.get_ORGANIZATIONS_UserByOrgRelation(HUserNumber, HStockOrgName);
if (ds2 == null || ds2.Tables[0].Rows.Count == 0)
{
objJsonResult.code = "0";
objJsonResult.count = 0;
objJsonResult.Message = "判断用户对应组织权限错误!";
objJsonResult.data = null;
return objJsonResult;
}
else if (DBUtility.ClsPub.isLong(ds2.Tables[0].Rows[0]["HBack"])==1)
{
objJsonResult.code = "0";
objJsonResult.count = 0;
objJsonResult.Message = DBUtility.ClsPub.isStrNull(ds2.Tables[0].Rows[0]["HRemark"]);
objJsonResult.data = null;
return objJsonResult;
}
//判断用户账号密码(WISE、CLOUD)是否正确
if (!oWebs.CheckUser(DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["Czymc"]), ref DBUtility.ClsPub.sErrInfo))
{
objJsonResult.code = "0";
objJsonResult.count = 0;
objJsonResult.Message = DBUtility.ClsPub.sErrInfo; //失败!
objJsonResult.data = null;
return objJsonResult;
}
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
#region 用户模块权限判断
///
/// 进入模块时进行用户权限判断
///
///
[Route("WEBSController/CheckModRight_Json")]
[HttpGet]
public object CheckModRight_Json(string ModRightName, string HUserName)
{
try
{
//获取系统参数
string sErrMsg = "";
if (oSystemParameter.ShowBill(ref sErrMsg) == true)
{
//判断权限
if (!DBUtility.ClsPub.Security_Log(ModRightName, 3, false, HUserName))
{
objJsonResult.code = "0";
objJsonResult.count = 0;
objJsonResult.Message = "您没有对应模块权限,请与管理员联系!";
objJsonResult.data = null;
return objJsonResult;
}
if (oSystemParameter.omodel.WMS_WMSStockCtl_ERPMode.ToUpper() == "WISE")
{
ds = oCn.RunProcReturn("exec h_p_K3_User '" + HUserName + "'", "h_p_K3_User");
if (ds == null || ds.Tables[0].Rows.Count == 0)
{
objJsonResult.code = "0";
objJsonResult.count = 0;
objJsonResult.Message = "您的用户没有绑定金蝶账号,请与管理员联系!";
objJsonResult.data = null;
return objJsonResult;
}
}
else if (oSystemParameter.omodel.WMS_WMSStockCtl_ERPMode.ToUpper() == "CLOUD")
{
//判断用户账号密码(WISE、CLOUD)是否正确
if (!oWebs.CheckUser(HUserName, ref DBUtility.ClsPub.sErrInfo))
{
objJsonResult.code = "0";
objJsonResult.count = 0;
objJsonResult.Message = DBUtility.ClsPub.sErrInfo; //失败!
objJsonResult.data = null;
return objJsonResult;
}
}
objJsonResult.code = "0";
objJsonResult.count = 1;
objJsonResult.Message = "成功!";
objJsonResult.data = null;
return objJsonResult;
}
else
{
objJsonResult.code = "0";
objJsonResult.count = 0;
objJsonResult.Message = "获取系统参数失败! " + sErrMsg;
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 获取最大单据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
#region 获取最大单据号
///
/// 获取最大单据号
///
///
[Route("WEBSController/GetMaxBillNo_Json")]
[HttpGet]
public object GetMaxBillNo_Json(string HBillType)
{
try
{
string sErrMsg = "";
string HBillNo = "";
HBillNo = DBUtility.ClsPub.CreateBillCode_Prod(HBillType, ref sErrMsg, true);
//----------创建虚表------------------------
DataTable dt_Main = new DataTable("Json");
dt_Main.Columns.Add("HBillNo", typeof(string));
//---------创建新行------------------------
DataRow dr_main = dt_Main.NewRow(); //创建新行
dt_Main.Rows.Add(dr_main); //将新行加入到表中
dr_main["HBillNo"] = DBUtility.ClsPub.isStrNull(HBillNo);
//返回数据
if (HBillNo == "")
{
objJsonResult.code = "0";
objJsonResult.count = 0;
objJsonResult.Message = "最大单据号获取失败";
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 = "获取最大单据号失败!" + e.ToString();
objJsonResult.data = null;
return objJsonResult;
}
}
#endregion
#region 根据条码,返回条码档案中条码信息
///
/// 根据条码,返回条码档案中条码信息
///
///
[Route("WEBSController/GetBarCode_Json")]
[HttpGet]
public object GetBarCode_Json(string HBarCode)
{
try
{
ds = oCn.RunProcReturn("select * from h_v_Gy_BarCodeBill where HBarCode='" + HBarCode + "' order by HStopflag", "h_v_Gy_BarCodeBill");
if (ds == null || ds.Tables[0].Rows.Count == 0)
{
objJsonResult.code = "0";
objJsonResult.count = 0;
objJsonResult.Message = "条码档案中不存在该条码,请确认条码是否正确或是否已被删除!";
objJsonResult.data = null;
return objJsonResult;
}
else if (DBUtility.ClsPub.isBool(ds.Tables[0].Rows[0]["HStopflag"]))
{
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 基础资料
#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;
}
}
///
/// 扫码返回仓库信息
///
///
[Route("WEBSController/GetWarehouse_Json")]
[HttpGet]
public object GetWarehouse_Json(string HBarCode, Int64 HStockOrgID)
{
try
{
Int64 HWhID = 0;
HWhID = DBUtility.ClsPub.isLong(HBarCode.Replace("HWH", ""));
ds = oCn.RunProcReturn("select HItemID,HNumber,HName,HSPFlag from Gy_Warehouse with(nolock) where HStopflag=0 and HItemID=" + HWhID.ToString() + " and HUSEORGID = " + HStockOrgID.ToString(), "Gy_Warehouse");
if (ds == null || ds.Tables[0].Rows.Count == 0)
{
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
#region 仓位资料
///
/// 扫码返回仓位信息
///
///
[Route("WEBSController/GetStockPlace_Json")]
[HttpGet]
public object GetStockPlace_Json(string HBarCode, Int64 HWhID, Int64 HStockOrgID)
{
try
{
Int64 sHSPID = 0;
Int64 sHWhID = 0;
if (HBarCode.Contains(";"))
{
string[] sArray = HBarCode.Replace("HSP", "").Split(';');
sHSPID = DBUtility.ClsPub.isLong(sArray[1]);
sHWhID = DBUtility.ClsPub.isLong(sArray[0]);
}
if(HWhID==0)
{
ds = oCn.RunProcReturn("select HItemID,HNumber,HName,HWHID,HWhNumber,HWhName from h_v_IF_StockPlace where HStopflag=0 and HItemID=" + sHSPID.ToString() + " and HWHID=" + sHWhID.ToString() + " and HUSEORGID = " + HStockOrgID.ToString(), "h_v_IF_StockPlace");
if (ds == null || ds.Tables[0].Rows.Count == 0)
{
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;
}
}
else
{
ds = oCn.RunProcReturn("select HItemID,HNumber,HName,HWHID,HWhNumber,HWhName from h_v_IF_StockPlace where HStopflag=0 and HItemID=" + sHSPID.ToString() + " and HWHID=" + HWhID.ToString() + " and HUSEORGID = " + HStockOrgID.ToString(), "h_v_IF_StockPlace");
if (ds == null || ds.Tables[0].Rows.Count == 0)
{
DataSet ds2 = oCn.RunProcReturn("select HItemID,HNumber,HName,HWHID,HWhNumber,HWhName from h_v_IF_StockPlace where HStopflag=0 and HItemID=" + sHSPID.ToString() + " and HWHID=" + sHWhID.ToString() + " and HUSEORGID = " + HStockOrgID.ToString(), "h_v_IF_StockPlace");
if (ds2 == null || ds2.Tables[0].Rows.Count == 0)
{
objJsonResult.code = "0";
objJsonResult.count = 0;
objJsonResult.Message = "没有返回任何记录,请确认所扫仓位条码是否属于该组织,且为非禁用状态!";
objJsonResult.data = null;
return objJsonResult;
}
else
{
objJsonResult.code = "0";
objJsonResult.count = 1;
objJsonResult.Message = "成功!";
objJsonResult.data = ds2.Tables[0];
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;
}
}
///
/// 获取仓位列表信息
///
///
[Route("WEBSController/GetStockPlaceList_Json")]
[HttpGet]
public object GetStockPlaceList_Json(string StockPlace, Int64 HWhID, Int64 HStockOrgID)
{
try
{
//界面上未选择仓库 或 仓位选择列表界面输入过滤条件
if (HWhID == 0)
{
ds = oCn.RunProcReturn("select HItemID,HNumber,HName,HWHID,HWhNumber,HWhName from h_v_IF_StockPlace where HStopflag=0 and HUSEORGID=" + HStockOrgID.ToString() + " and (HNumber like '%" + StockPlace + "%' or HName like '%" + StockPlace + "%')", "h_v_IF_StockPlace");
if (ds == null || ds.Tables[0].Rows.Count == 0)
{
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;
}
}
//界面上已选仓库
else
{
ds = oCn.RunProcReturn("select HItemID,HNumber,HName,HWHID,HWhNumber,HWhName from h_v_IF_StockPlace where HStopflag=0 and HUSEORGID=" + HStockOrgID.ToString() + " and HWHID=" + HWhID.ToString() + " and (HNumber like '%" + StockPlace + "%' or HName like '%" + StockPlace + "%')", "h_v_IF_StockPlace");
if (ds == null || ds.Tables[0].Rows.Count == 0)
{
DataSet ds2 = oCn.RunProcReturn("select HItemID,HNumber,HName,HWHID,HWhNumber,HWhName from h_v_IF_StockPlace where HStopflag=0 and HUSEORGID = " + HStockOrgID.ToString() + " and (HNumber like '%" + StockPlace + "%' or HName like '%" + StockPlace + "%')", "h_v_IF_StockPlace");
if (ds2 == null || ds2.Tables[0].Rows.Count == 0)
{
objJsonResult.code = "0";
objJsonResult.count = 0;
objJsonResult.Message = "没有返回任何仓位记录!";
objJsonResult.data = null;
return objJsonResult;
}
else
{
objJsonResult.code = "0";
objJsonResult.count = 1;
objJsonResult.Message = "成功!";
objJsonResult.data = ds2.Tables[0];
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
#region 职员资料
///
/// 扫码返回职员信息
///
///
[Route("WEBSController/GetEmployee_Json")]
[HttpGet]
public object GetEmployee_Json(string HBarCode)
{
try
{
Int64 HEmpID = 0;
HEmpID = DBUtility.ClsPub.isLong(HBarCode);
ds = oCn.RunProcReturn("select HItemID,HNumber,HName from Gy_Employee with(nolock) where HStopflag=0 and HItemID=" + HEmpID.ToString(), "Gy_Employee");
if (ds == null || ds.Tables[0].Rows.Count == 0)
{
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
#region 部门资料
///
/// 扫码返回部门信息
///
///
[Route("WEBSController/GetDepartment_Json")]
[HttpGet]
public object GetDepartment_Json(string HBarCode)
{
try
{
Int64 HDepID = 0;
HDepID = DBUtility.ClsPub.isLong(HBarCode.Replace("HDE", ""));
ds = oCn.RunProcReturn("select HItemID,HNumber,HName from Gy_Department with(nolock) where HStopflag=0 and HItemID=" + HDepID.ToString(), "Gy_Department");
if (ds == null || ds.Tables[0].Rows.Count == 0)
{
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
#region 供应商资料
///
/// 扫码返回供应商信息
///
///
[Route("WEBSController/GetSupplier_Json")]
[HttpGet]
public object GetSupplier_Json(string HBarCode, Int64 HStockOrgID)
{
try
{
Int64 HSupID = 0;
HSupID = DBUtility.ClsPub.isLong(HBarCode);
ds = oCn.RunProcReturn("select HItemID,HNumber,HName from Gy_Supplier with(nolock) where HStopflag=0 and HItemID=" + HSupID.ToString() + " and HUSEORGID = " + HStockOrgID.ToString(), "Gy_Supplier");
if (ds == null || ds.Tables[0].Rows.Count == 0)
{
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;
}
}
///
/// 获取供应商列表信息
///
///
[Route("WEBSController/GetSupplierList_Json")]
[HttpGet]
public object GetSupplierList_Json(string Supplier, Int64 HStockOrgID)
{
try
{
ds = oCn.RunProcReturn("select HItemID,HNumber,HName from Gy_Supplier with(nolock) where HStopflag=0 and HUSEORGID=" + HStockOrgID.ToString() + " and (HNumber like '%" + Supplier + "%' or HName like '%" + Supplier + "%')", "Gy_Supplier");
if (ds == null || ds.Tables[0].Rows.Count == 0)
{
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
#region 客户资料
///
/// 扫码返回客户信息
///
///
[Route("WEBSController/GetCustomer_Json")]
[HttpGet]
public object GetCustomer_Json(string HBarCode, Int64 HStockOrgID)
{
try
{
Int64 HCusID = 0;
HCusID = DBUtility.ClsPub.isLong(HBarCode);
ds = oCn.RunProcReturn("select HItemID,HNumber,HName from Gy_Customer with(nolock) where HStopflag=0 and HItemID=" + HCusID.ToString() + " and HUSEORGID = " + HStockOrgID.ToString(), "Gy_Customer");
if (ds == null || ds.Tables[0].Rows.Count == 0)
{
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;
}
}
///
/// 获取客户列表信息
///
///
[Route("WEBSController/GetCustomerList_Json")]
[HttpGet]
public object GetCustomerList_Json(string Customer, Int64 HStockOrgID)
{
try
{
ds = oCn.RunProcReturn("select HItemID,HNumber,HName from Gy_Customer with(nolock) where HStopflag=0 and HUSEORGID=" + HStockOrgID.ToString() + " and (HNumber like '%" + Customer + "%' or HName like '%" + Customer + "%')", "Gy_Customer");
if (ds == null || ds.Tables[0].Rows.Count == 0)
{
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
#region 班组资料
///
/// 扫码返回班组信息
///
///
[Route("WEBSController/GetGroup_Json")]
[HttpGet]
public object GetGroup_Json(string HBarCode, Int64 HStockOrgID)
{
try
{
Int64 HGroupID = 0;
HGroupID = DBUtility.ClsPub.isLong(HBarCode);
ds = oCn.RunProcReturn("select HItemID,HNumber,HName from Gy_Group with(nolock) where HStopflag=0 and HItemID=" + HGroupID.ToString() + " and HUSEORGID = " + HStockOrgID.ToString(), "Gy_Group");
if (ds == null || ds.Tables[0].Rows.Count == 0)
{
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;
}
}
///
/// 获取班组列表信息
///
///
[Route("WEBSController/GetGroupList_Json")]
[HttpGet]
public object GetGroupList_Json(string Group, Int64 HStockOrgID)
{
try
{
ds = oCn.RunProcReturn("select HItemID,HNumber,HName from Gy_Group with(nolock) where HStopflag=0 and HUSEORGID=" + HStockOrgID.ToString() + " and (HNumber like '%" + Group + "%' or HName like '%" + Group + "%')", "Gy_Group");
if (ds == null || ds.Tables[0].Rows.Count == 0)
{
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
#region 生产设备资料
///
/// 扫码返回生产设备信息
///
///
[Route("WEBSController/GetEquip_Json")]
[HttpGet]
public object GetEquip_Json(string HBarCode)
{
try
{
ds = oCn.RunProcReturn("select HInterID,HEquipFileNumber,HName,HSourceID from h_v_Gy_EquipFileBill where HBarCode='" + HBarCode + "'", "h_v_Gy_EquipFileBill");
if (ds == null || ds.Tables[0].Rows.Count == 0)
{
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;
}
}
///
/// 获取生产设备列表信息
///
///
[Route("WEBSController/GetEquipList_Json")]
[HttpGet]
public object GetEquipList_Json(string Equip)
{
try
{
ds = oCn.RunProcReturn("select HInterID,HEquipFileNumber,HName,HSourceID,HSourceName from h_v_Gy_EquipFileBill where HEquipFileNumber like '%" + Equip + "%' or HName like '%" + Equip + "%'", "h_v_Gy_EquipFileBill");
if (ds == null || ds.Tables[0].Rows.Count == 0)
{
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 扫码模块调用方法
#region 直接调拨 获取调拨出货类型
///
/// 获取调拨出货类型
///
///
[Route("WEBSController/GetStockMoveStyle_Json")]
[HttpGet]
public Object GetStockMoveStyle_Json()
{
try
{
ds = oWebs.get_StockMoveStyle();
if (ds == null || ds.Tables[0].Rows.Count == 0)
{
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
#region 直接调拨 获取调拨方向
///
/// 获取调拨方向
///
///
[Route("WEBSController/GetMoveDirect_Json")]
[HttpGet]
public Object GetMoveDirect_Json()
{
try
{
ds = oWebs.get_MoveDirect();
if (ds == null || ds.Tables[0].Rows.Count == 0)
{
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
#region 根据单据类型获取单据子类型
///
/// 根据单据类型获取单据子类型
///
///
[Route("WEBSController/GetBillSubType_Json")]
[HttpGet]
public Object GetBillSubType_Json(string HBillType, Int64 HStockOrgID)
{
try
{
ds = oWebs.get_BillSubType(HBillType, HStockOrgID);
if (ds == null || ds.Tables[0].Rows.Count == 0)
{
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
#region 扫码模块 根据条码删除缓存列表中对应条码记录
///
/// 根据条码删除条码出入库缓存表中记录
///
///
[Route("WEBSController/set_DelPonderationBillMain_Temp_BarCode_Json")]
[HttpGet]
public object set_DelPonderationBillMain_Temp_BarCode_Json(long HInterID, string HBillType, string HBarCode)
{
try
{
oCn.RunProc("Delete from KF_PonderationBillMain_Temp where HBarCode<>'' and HInterID=" + HInterID.ToString() + " and HBillType='" + HBillType + "' and HBarCode='" + HBarCode + "'", ref DBUtility.ClsPub.sExeReturnInfo);
objJsonResult.code = "0";
objJsonResult.count = 1;
objJsonResult.Message = "删除成功";
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 扫码模块 根据HItemID删除缓存列表中对应条码记录
///
/// 根据HItemID删除条码出入库缓存表中记录
///
///
[Route("WEBSController/set_DelPonderationBillMain_Temp_HItemID_Json")]
[HttpGet]
public object set_DelPonderationBillMain_Temp_HItemID_Json(long HInterID, string HBillType, long HItemID)
{
try
{
oCn.RunProc("Delete from KF_PonderationBillMain_Temp where HInterID=" + HInterID.ToString() + " and HBillType='" + HBillType + "' and HItemID=" + HItemID.ToString(), ref DBUtility.ClsPub.sExeReturnInfo);
objJsonResult.code = "0";
objJsonResult.count = 1;
objJsonResult.Message = "删除成功";
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/set_DelPonderationBillMain_Temp_InterIDAndSource_Json")]
[HttpGet]
public object set_DelPonderationBillMain_Temp_InterIDAndSource_Json(long HInterID, long HMaterID, long HAuxPropID, string HMTONo, long HSourceInterID, long HSourceEntryID, string HBillType)
{
try
{
if (oWebs.set_DelPonderationBillMain_Temp_InterIDAndSource(HInterID, HMaterID, HAuxPropID, HMTONo, HSourceInterID, HSourceEntryID, HBillType, ref DBUtility.ClsPub.sErrInfo))
{
objJsonResult.code = "0";
objJsonResult.count = 1;
objJsonResult.Message = DBUtility.ClsPub.sErrInfo; //成功!
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 扫描模块 退出功能按钮调用 删除先进先出临时表(更新 HlineStatus =1)
///
/// 删除先进先出临时表(更新 HlineStatus =1)
///
///
[Route("WEBSController/set_DelPonderationBillMain_Temp_FIFO_Json")]
[HttpGet]
public object set_DelPonderationBillMain_Temp_FIFO_Json(long HInterID, string HBillType)
{
try
{
if (oWebs.set_DelPonderationBillMain_Temp_FIFO(HInterID, HBillType, ref DBUtility.ClsPub.sErrInfo))
{
objJsonResult.code = "0";
objJsonResult.count = 1;
objJsonResult.Message = DBUtility.ClsPub.sErrInfo; //成功!
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 = "更新先进先出临时表HlineStatus值失败!" + e.ToString();
objJsonResult.data = null;
return objJsonResult;
}
}
#endregion
#endregion
#region 缓存列表模块调用
#region 缓存列表界面,返回缓存列表信息
///
/// 缓存列表界面,返回缓存列表信息
///
///
[Route("WEBSController/GetKf_PonderationBillMain_TempList_New_Json")]
[HttpGet]
public object GetKf_PonderationBillMain_TempList_New_Json(string HBillType, string HMaker, Int64 HStockOrgID)
{
try
{
ds = oWebs.GetKf_PonderationBillMain_TempList_New(HBillType, HMaker, HStockOrgID);
if (ds == null || ds.Tables[0].Rows.Count == 0)
{
objJsonResult.code = "0";
objJsonResult.count = 0;
objJsonResult.Message = "没有返回任何记录!";
objJsonResult.data = null;
return objJsonResult;
}
else
{
List