#region 入库扫描
///
///入库扫描///
/// 产品序列号
///
[HttpPost]public JsonResult GetInstock(string productSN, string lotSN, int planQty,stringradomTime)
{//1.先判断SN是否重复
if (!string.IsNullOrEmpty(productSN))
{bool resultSN =bll.IsExistsSN(productSN);int scanQty = 0;if(resultSN)
{//验证计划入库数量和已扫描的数量
DataTable dt =bll.OverInStockQty(lotSN);if (dt != null && dt.Rows.Count > 0)
{int planCount = Convert.ToInt32(dt.Rows[0]["F_Qty"]); /*计划入库数量*/scanQty= Convert.ToInt32(dt.Rows[0]["F_SNIndex"]);/*已扫描数量*/
if (scanQty >=planCount)
{//已扫描的数量,大于计划入库数量
return Json("OverStockQty", JsonRequestBehavior.AllowGet);
}else{
Dictionary lstStrSN = new Dictionary();
InStockModel insertModel= newInStockModel()
{
F_UserID= CookieHelper.GetCookieValue("hcUserName"), //Session["UserName"].ToString(),
F_LotSN =lotSN,
F_SN=productSN,
F_PCName=Environment.MachineName,
F_Qty=planQty
};int result =bll.InsertInstock(insertModel);if (result > 0)
{//更新已入库数据
bll.UpdateScanQty(result);
scanQty+= 1;
lstStrSN.Add(productSN, scanQty);return Json(newJavaScriptSerializer().Serialize(lstStrSN), JsonRequestBehavior.AllowGet);
}
}
}if (dt!=null&& dt.Rows.Count == 0)
{
Dictionary lstStrSN = new Dictionary();
InStockModel insertModel= newInStockModel()
{
F_UserID= CookieHelper.GetCookieValue("hcUserName"), //Session["UserName"].ToString(),
F_LotSN =lotSN,
F_SN=productSN,
F_PCName=Environment.MachineName,
F_Qty=planQty
};int result =bll.InsertInstock(insertModel);if (result > 0)
{//更新已入库数据
bll.UpdateScanQty(result);
scanQty= 1;
lstStrSN.Add(productSN, scanQty);return Json(newJavaScriptSerializer().Serialize(lstStrSN), JsonRequestBehavior.AllowGet);
}
}
}else{//重复序列号
return Json("RepeatSN", JsonRequestBehavior.AllowGet);
}
}else{//请输入序列号
return Json("EmptySN", JsonRequestBehavior.AllowGet);
}//出现错误
return Json("Error", JsonRequestBehavior.AllowGet);
}#endregion