using Newtonsoft.Json; using Newtonsoft.Json.Linq; using Pub_Class; using System; using System.Collections; using System.Collections.Generic; using System.Data; using System.Data.SqlClient; using System.Web.Http; using WebAPI.Models; namespace WebAPI.Controllers.CJGL { public class Cj_CheckBarcodeController : ApiController { private json objJsonResult = new json(); SQLHelper.ClsCN oCn = new SQLHelper.ClsCN(); Pub_Class.ClsXt_SystemParameter oSystemParameter = new Pub_Class.ClsXt_SystemParameter(); DataSet ds; #region 三码合一,判断扫描物料条码绑定信息是否一致 [Route("CheckBarcodeController/Get_BarCode_BarcodeCheck")] [HttpGet] public object CheckBarcode(string HBarCode_Pallet, string HBarCode_Destination, string HBarCode_MiddleBox, string HBarCode_SN, int HBarCodeType,int HInterID, string HBillNo,string HMaker) { try { ds = oCn.RunProcReturn("exec h_p_Cj_CheckBarcodeBing '" + HBarCode_Pallet + "','" + HBarCode_Destination + "','" + HBarCode_MiddleBox + "','" + HBarCode_SN + "','" + HBarCodeType + "'," + HInterID + ",'" + HBillNo + "','" + HMaker + "'", "h_p_Cj_CheckBarcodeBing"); 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.isLong(ds.Tables[0].Rows[0]["HBack"]) == 1) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HBackRemark"]); objJsonResult.data = null; return objJsonResult; } else { objJsonResult.code = "1"; 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("CheckBarcodeController/Save_BarCode_BarcodeCheck")] [HttpGet] public object Save_BarCode_BarcodeCheck(Int64 HInterID, string HBillNo) { try { oCn.BeginTran(); DataSet ds = oCn.RunProcReturn("exec h_p_WMS_BarCodeBingCheckBill_Insert " + HInterID.ToString() + ",'" + HBillNo + "'", "h_p_WMS_BarCodeBingCheckBill_Insert"); if (ds == null || ds.Tables[0].Rows.Count == 0) { oCn.RollBack(); objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = DBUtility.ClsPub.sErrInfo; //失败! objJsonResult.data = null; return objJsonResult; } else { if (DBUtility.ClsPub.isLong(ds.Tables[0].Rows[0][0]) == 1) { oCn.RollBack(); objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = DBUtility.ClsPub.sErrInfo; //失败! objJsonResult.data = null; return objJsonResult; } else { oCn.Commit(); objJsonResult.code = "0"; objJsonResult.count = 1; objJsonResult.Message = "单据号:" + HBillNo + " 保存成功!"; objJsonResult.data = null; return objJsonResult; } } } catch (Exception e) { oCn.RollBack(); objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "生成单据失败!" + e.ToString(); objJsonResult.data = null; return objJsonResult; } } #endregion } }