using System;
|
using System.Collections.Generic;
|
using System.Text;
|
using System.Data;
|
|
namespace DAL
|
{
|
public class ClsKF_PonderationBillMain_Temp_Ctl : DBUtility.ClsGy_Base_Ctl
|
{
|
|
//原代码 用于 替换子项目
|
public string HOldNumber;
|
public Model.ClsKF_PonderationBillMain_Temp oModel = new Model.ClsKF_PonderationBillMain_Temp();
|
|
|
|
//判断条码 入库数量是否超过条码本身额定数量
|
public bool IsBarCode(string sBarCode, string sBillType, bool sRedBlueFlag, ref double sQty, ref string sReturn)
|
{
|
SQLHelper.ClsCN oCn = new SQLHelper.ClsCN();
|
DataSet DS;
|
try
|
{
|
DS = oCn.RunProcReturn("exec h_p_IF_IsBarCode '" + sBarCode + "'," + sQty.ToString(), "h_p_IF_IsBarCode", ref DBUtility.ClsPub.sExeReturnInfo);
|
if (DS.Tables[0].Rows.Count == 0)
|
{
|
sQty = sQty;
|
oCn.CnClose();
|
oCn.CnDispose();
|
sReturn = "正常!";
|
return true; //不存在 入库数量超过条码本身额定数量 条码
|
}
|
else
|
{
|
if (DBUtility.ClsPub.isDoule(DS.Tables[0].Rows[0]["HQty"]) <= 0)
|
{
|
sQty = 0;
|
oCn.CnClose();
|
oCn.CnDispose();
|
sReturn = "此条码已被其他单据扫描!";
|
return false;
|
}
|
else
|
{
|
sQty = DBUtility.ClsPub.isDoule(DS.Tables[0].Rows[0]["HQty"]);
|
oCn.CnClose();
|
oCn.CnDispose();
|
sReturn = "已获取未扫描数量!";
|
return true;
|
}
|
}
|
}
|
catch (Exception e)
|
{
|
sReturn = e.Message;
|
throw (e);
|
}
|
}
|
|
//判断条码临时表中是否存在
|
public bool IsBarCode(string sBarCode, long HInterID, long HErpClsID, string sBillType)
|
{
|
SQLHelper.ClsCN oCn = new SQLHelper.ClsCN();
|
DataSet DS;
|
try
|
{
|
//if (HErpClsID == 2)
|
//{
|
// return true;
|
//}
|
//DS = oCn.RunProcReturn("Select 1 from KF_PonderationBillMain_Temp Where HInterID=" + HInterID.ToString() + " and HBarCode='" + sBarCode + "' and HBillType='" + sBillType + "'", "KF_PonderationBillMain_Temp", ref DBUtility.ClsPub.sExeReturnInfo);
|
DS = oCn.RunProcReturn("exec h_p_WMS_CheckBarCodeInTemp " + HInterID.ToString() + ",'" + sBarCode + "','" + sBillType + "'", "h_p_WMS_CheckBarCodeInTemp", ref DBUtility.ClsPub.sExeReturnInfo);
|
if (DS.Tables[0].Rows.Count == 0)
|
{
|
|
oCn.CnClose();
|
oCn.CnDispose();
|
return true; //不存在相同条码
|
}
|
else
|
{
|
oCn.CnClose();
|
oCn.CnDispose();
|
return false;
|
}
|
}
|
catch (Exception e)
|
{
|
throw (e);
|
}
|
}
|
|
//判断条码临时表中是否存在(调拨单同一条码相同调入调出仓库仓位只允许扫描一次,销售出库同一条码同一仓库仓位只允许扫描一次) 丸井
|
public bool IsBarCode(string sBarCode, long HInterID, long HErpClsID, string sBillType, Int64 HWhID, Int64 HSPID, Int64 HSCWHID, Int64 HSCSPID, bool HRedBlueflag)
|
{
|
SQLHelper.ClsCN oCn = new SQLHelper.ClsCN();
|
DataSet DS;
|
try
|
{
|
DS = oCn.RunProcReturn("exec h_p_WMS_CheckBarCodeInTemp2 " + HInterID.ToString() + ",'" + sBarCode + "','" + sBillType + "'," + HWhID.ToString() + "," + HSPID.ToString() + "," + HSCWHID.ToString() + "," + HSCSPID.ToString() + "," + HRedBlueflag, "h_p_WMS_CheckBarCodeInTemp2", ref DBUtility.ClsPub.sExeReturnInfo);
|
if (DS.Tables[0].Rows.Count == 0)
|
{
|
|
oCn.CnClose();
|
oCn.CnDispose();
|
return true; //不存在相同条码
|
}
|
else
|
{
|
oCn.CnClose();
|
oCn.CnDispose();
|
return false;
|
}
|
}
|
catch (Exception e)
|
{
|
throw (e);
|
}
|
}
|
|
//判断托盘条码临时表中是否存在
|
public bool IsBarCode_Pack(string sBarCode_Pack, long HInterID, string sBillType)
|
{
|
SQLHelper.ClsCN oCn = new SQLHelper.ClsCN();
|
DataSet DS;
|
try
|
{
|
DS = oCn.RunProcReturn("Select * from KF_PonderationBillMain_Temp Where HInterID=" + HInterID.ToString() + " and HBarCode_Pack='" + sBarCode_Pack + "' and HBillType='" + sBillType + "'", "KF_PonderationBillMain_Temp", ref DBUtility.ClsPub.sExeReturnInfo);
|
if (DS.Tables[0].Rows.Count == 0)
|
{
|
oCn.CnClose();
|
oCn.CnDispose();
|
return true; //不存在相同托盘条码
|
}
|
else
|
{
|
oCn.CnClose();
|
oCn.CnDispose();
|
return false;
|
}
|
}
|
catch (Exception e)
|
{
|
throw (e);
|
}
|
}
|
|
//新增(一张单据,存在相同物料 托盘条码)
|
public bool AddNew_More_Select(ref string sReturn)
|
{
|
SQLHelper.ClsCN oCn = new SQLHelper.ClsCN();
|
try
|
{
|
oCn.BeginTran();
|
//箱号条码,批量新增
|
oCn.RunProc("exec h_p_KF_PonderationBillMain_Temp_Add_Select " + oModel.HInterID.ToString() + ",'" + oModel.HBillNo + "','" + oModel.HBillType + "','" + oModel.HBarCode + "','" + oModel.HMaker + "'," + oModel.HSourceInterID + "," + oModel.HSourceEntryID, ref DBUtility.ClsPub.sExeReturnInfo);
|
oCn.Commit();
|
oCn.CnClose();
|
oCn.CnDispose();
|
sReturn = "保存成功!";
|
return true;
|
}
|
catch (Exception e)
|
{
|
sReturn = e.Message;
|
oCn.RollBack();
|
throw (e);
|
}
|
}
|
|
//新增(一张单据,存在相同物料 非托盘条码 唯一条码) 箱发
|
public bool AddNew_Source(ref string sReturn)
|
{
|
SQLHelper.ClsCN oCn = new SQLHelper.ClsCN();
|
try
|
{
|
DataSet oDs = new DataSet();
|
oCn.BeginTran();
|
oCn.RunProc("Insert into " + MvarItemKey + " " +
|
" (HInterID,HBillNo,HBillType,HMaterID,HProcID,HWhID,HSCWHID" +
|
",HStockPlaceID,HOutStockPlaceID,HGroupID,HQty,HQtyMust,HPieceQty " +
|
",HAuxPropID,HBatchNo,HBarCode,HAddr,HMaker,HMakeDate " +
|
",HSourceInterID,HSourceEntryID,HSourceBillType,HSourceBillNo,HMTONo" +
|
",HSTOCKORGID,HOWNERID " +
|
",HRelationInterID,HRelationEntryID,HRelationBillNo,HRedBlueFlag) " +
|
" Values(" + oModel.HInterID.ToString() + ",'" + oModel.HBillNo + "','" + oModel.HBillType + "'," + oModel.HMaterID.ToString() + "," + oModel.HProcID.ToString() + "," + oModel.HWhID.ToString() + "," + oModel.HSCWHID.ToString() +
|
"," + oModel.HStockPlaceID.ToString() + "," + oModel.HOutStockPlaceID.ToString() + "," + oModel.HGroupID.ToString() + "," + oModel.HQty.ToString() + "," + oModel.HQtyMust.ToString() + "," + oModel.HPieceQty.ToString() +
|
"," + oModel.HAuxPropID.ToString() + ",'" + oModel.HBatchNo + "','" + oModel.HBarCode + "','" + oModel.HAddr + "','" + oModel.HMaker + "',getdate()" +
|
"," + oModel.HSourceInterID.ToString() + "," + oModel.HSourceEntryID.ToString() + ",'" + oModel.HSourceBillType + "','" + oModel.HSourceBillNo + "','" + oModel.HMTONo + "'" +
|
"," + oModel.HSTOCKORGID.ToString() + "," + oModel.HOWNERID.ToString() +
|
"," + oModel.HRelationInterID.ToString() + "," + oModel.HRelationEntryID.ToString() + ",'" + oModel.HRelationBillNo + "'," + Convert.ToString(oModel.HRedBlueFlag ? 1 : 0) + ")", ref DBUtility.ClsPub.sExeReturnInfo);
|
//修改上级为非末级代码
|
//oCn.RunProc("Update " + MvarItemKey + " set HEndflag=0 where HItemID=" + oModel.HParentID, ref DBUtility.ClsPub.sExeReturnInfo);
|
oCn.Commit();
|
oCn.CnClose();
|
oCn.CnDispose();
|
sReturn = "保存成功!";
|
return true;
|
}
|
catch (Exception e)
|
{
|
sReturn = e.Message;
|
oCn.RollBack();
|
throw (e);
|
}
|
}
|
|
//新增(一张单据,存在相同物料 非托盘条码 扫码前可快捷输入数量)
|
public bool AddNew_Source(double sQty, ref string sReturn)
|
{
|
SQLHelper.ClsCN oCn = new SQLHelper.ClsCN();
|
try
|
{
|
DataSet oDs = new DataSet();
|
DataSet oDs3 = new DataSet();
|
//
|
long sSourceInterID = oModel.HSourceInterID;
|
long sSourceEntryID = oModel.HSourceEntryID;
|
long sTMSourceInterID = 0;
|
long sTMSourceEntryID = 0;
|
double sHQty = 0;
|
string sHBarCodeType = "";
|
oCn.BeginTran();
|
//判断所扫描条码的类型
|
oDs3 = oCn.RunProcReturn("select HBarCodeType,HSourceInterID,HSourceEntryID from Gy_BarCodeBill where HBarCode='" + oModel.HBarCode + "'", "Gy_BarCodeBill");
|
sHBarCodeType = DBUtility.ClsPub.isStrNull(oDs3.Tables[0].Rows[0]["HBarCodeType"]);
|
sTMSourceInterID = DBUtility.ClsPub.isLong(oDs3.Tables[0].Rows[0]["HSourceInterID"]);
|
sTMSourceEntryID = DBUtility.ClsPub.isLong(oDs3.Tables[0].Rows[0]["HSourceEntryID"]);
|
//
|
if (sHBarCodeType == "唯一条码")
|
{
|
//产品入库,外购入库,其他入库,委外入库 有源单单据只能扫描对应源单条码(不包括红字单据)
|
if (oModel.HBillType == "1202" || oModel.HBillType == "1201" || oModel.HBillType == "1203" || oModel.HBillType == "1210")
|
{
|
if (oModel.HRedBlueFlag == false)
|
{
|
if (sSourceInterID > 0)
|
{
|
//有源单 (扫描条码 无源单信息)
|
if (sSourceInterID + sSourceEntryID != 0 && sTMSourceInterID + sTMSourceEntryID == 0)
|
{
|
sReturn = "有源单单据,不允许扫描无源单条码!";
|
return false;
|
}
|
//有源单(但是扫描条码 源单信息, 与所选源单信息 不匹配)
|
else if (sSourceInterID + sSourceEntryID != 0 && sTMSourceInterID.ToString() != sSourceInterID.ToString())
|
{
|
sReturn = "扫描条码源单,与所选源单不匹配!";
|
return false;
|
}
|
}
|
}
|
}
|
}
|
//
|
oDs = oCn.RunProcReturn("select sum(HQty) HQty from " + MvarItemKey + " where HInterID=" + oModel.HInterID.ToString() + " and HBillType='" + oModel.HBillType + "' and HSourceInterID=" + oModel.HSourceInterID.ToString() + " and HSourceEntryID=" + oModel.HSourceEntryID.ToString() + " and HQty <> 0 ", "KF_PonderationBillMain_Temp");
|
|
if (oModel.HQtyMust != 0)
|
{
|
if (sQty == 0)
|
{
|
if (sHBarCodeType != "唯一条码")
|
{
|
oModel.HQty = oModel.HQtyMust - DBUtility.ClsPub.isDoule(oDs.Tables[0].Rows[0]["HQty"]);
|
if (oModel.HQty <= 0)
|
{
|
sReturn = "扫描数量总和不能大于实际数量!";
|
return false;
|
}
|
}
|
}
|
else
|
{
|
sHQty = DBUtility.ClsPub.isDoule(sQty);
|
if (sHQty < 0)
|
{
|
sReturn = "输入的数量不能小于0!";
|
return false;
|
}
|
if (oModel.HQtyMust <= DBUtility.ClsPub.isDoule(oDs.Tables[0].Rows[0]["HQty"]))
|
{
|
sReturn = "扫描数量总和不能大于实际数量!";
|
return false;
|
}
|
if (sHBarCodeType == "唯一条码" && oModel.HQty < sHQty)
|
{
|
sReturn = "数量不足,已获取实际数量!";
|
}
|
else
|
{
|
oModel.HQty = sHQty;
|
}
|
}
|
}
|
else
|
{
|
if (sQty == 0)
|
{
|
|
}
|
else
|
{
|
sHQty = DBUtility.ClsPub.isDoule(sQty);
|
if (sHQty < 0)
|
{
|
sReturn = "输入的数量不能小于0!";
|
return false;
|
}
|
if (sHBarCodeType == "唯一条码" && oModel.HQty < sHQty)
|
{
|
sReturn = "数量不足,已获取实际数量!";
|
}
|
else
|
{
|
oModel.HQty = sHQty;
|
}
|
}
|
}
|
|
oModel.HQtyMust = 0;
|
|
oCn.RunProc("Insert into " + MvarItemKey + " " +
|
" (HInterID,HBillNo,HBillType,HMaterID,HProcID,HWhID,HSCWHID" +
|
",HStockPlaceID,HOutStockPlaceID,HGroupID,HQty,HQtyMust,HPieceQty " +
|
",HAuxPropID,HBatchNo,HBarCode,HAddr,HMaker,HMakeDate " +
|
",HSourceInterID,HSourceEntryID,HSourceBillType,HSourceBillNo,HMTONo" +
|
",HSTOCKORGID,HOWNERID " +
|
",HRelationInterID,HRelationEntryID,HRelationBillNo,HRedBlueFlag) " +
|
" Values(" + oModel.HInterID.ToString() + ",'" + oModel.HBillNo + "','" + oModel.HBillType + "'," + oModel.HMaterID.ToString() + "," + oModel.HProcID.ToString() + "," + oModel.HWhID.ToString() + "," + oModel.HSCWHID.ToString() +
|
"," + oModel.HStockPlaceID.ToString() + "," + oModel.HOutStockPlaceID.ToString() + "," + oModel.HGroupID.ToString() + "," + oModel.HQty.ToString() + "," + oModel.HQtyMust.ToString() + "," + oModel.HPieceQty.ToString() +
|
"," + oModel.HAuxPropID.ToString() + ",'" + oModel.HBatchNo + "','" + oModel.HBarCode + "','" + oModel.HAddr + "','" + oModel.HMaker + "',getdate()" +
|
"," + oModel.HSourceInterID.ToString() + "," + oModel.HSourceEntryID.ToString() + ",'" + oModel.HSourceBillType + "','" + oModel.HSourceBillNo + "','" + oModel.HMTONo + "'" +
|
"," + oModel.HSTOCKORGID.ToString() + "," + oModel.HOWNERID.ToString() +
|
"," + oModel.HRelationInterID.ToString() + "," + oModel.HRelationEntryID.ToString() + ",'" + oModel.HRelationBillNo + "'," + Convert.ToString(oModel.HRedBlueFlag ? 1 : 0) + ")", ref DBUtility.ClsPub.sExeReturnInfo);
|
//修改上级为非末级代码
|
//oCn.RunProc("Update " + MvarItemKey + " set HEndflag=0 where HItemID=" + oModel.HParentID, ref DBUtility.ClsPub.sExeReturnInfo);
|
oCn.Commit();
|
oCn.CnClose();
|
oCn.CnDispose();
|
sReturn = "保存成功!";
|
return true;
|
}
|
catch (Exception e)
|
{
|
sReturn = e.Message;
|
oCn.RollBack();
|
throw (e);
|
}
|
}
|
|
//新增(不存在相同物料 托盘条码)
|
public bool AddNew_More(ref string sReturn)
|
{
|
SQLHelper.ClsCN oCn = new SQLHelper.ClsCN();
|
try
|
{
|
oCn.BeginTran();
|
//箱号条码,批量新增
|
oCn.RunProc("exec h_p_KF_PonderationBillMain_Temp_Add_Sell " + oModel.HInterID.ToString() + ",'" + oModel.HBillNo + "','" + oModel.HBillType + "','" + oModel.HBarCode + "'," + oModel.HWhID.ToString() + "," + oModel.HStockPlaceID.ToString() + "," + oModel.HSCWHID.ToString() + "," + oModel.HOutStockPlaceID.ToString() + ",'" + oModel.HMaker + "'," + Convert.ToString(oModel.HRedBlueFlag ? 1 : 0), ref DBUtility.ClsPub.sExeReturnInfo);
|
oCn.Commit();
|
oCn.CnClose();
|
oCn.CnDispose();
|
sReturn = "保存成功!";
|
return true;
|
}
|
catch (Exception e)
|
{
|
sReturn = e.Message;
|
oCn.RollBack();
|
throw (e);
|
}
|
}
|
|
//新增(不存在相同物料 非托盘条码)
|
public bool AddNew(ref string sReturn)
|
{
|
SQLHelper.ClsCN oCn = new SQLHelper.ClsCN();
|
try
|
{
|
DataSet oDs = new DataSet();
|
DataSet oDs1 = new DataSet();
|
DataSet oDs2 = new DataSet();
|
//
|
long sSourceInterID = 0;
|
long sSourceEntryID = 0;
|
long sTMSourceInterID = oModel.HSourceInterID;
|
long sTMSourceEntryID = oModel.HSourceEntryID;
|
bool iBool = false;
|
oCn.BeginTran();
|
//产品入库,外购入库,其他入库,委外入库 有源单单据只能扫描对应源单条码,无源单单据只能扫描无源单条码(不包括红字单据)
|
if (oModel.HBillType == "1202" || oModel.HBillType == "1201" || oModel.HBillType == "1203" || oModel.HBillType == "1210")
|
{
|
if (oModel.HRedBlueFlag == false)
|
{
|
oDs1 = oCn.RunProcReturn("select distinct HSourceInterID,HSourceEntryID from " + MvarItemKey + " where HInterID=" + oModel.HInterID.ToString() + " and HQty=0 ", "KF_PonderationBillMain_Temp");
|
if (oDs1 != null && oDs1.Tables[0].Rows.Count > 0)
|
{
|
for (int i = 0; i <= oDs1.Tables[0].Rows.Count - 1; i++)
|
{
|
sSourceInterID = DBUtility.ClsPub.isLong(oDs1.Tables[0].Rows[i]["HSourceInterID"]);
|
sSourceEntryID = DBUtility.ClsPub.isLong(oDs1.Tables[0].Rows[i]["HSourceEntryID"]);
|
|
//有源单 (扫描条码 无源单信息)
|
if (sSourceInterID + sSourceEntryID != 0 && sTMSourceInterID + sTMSourceEntryID == 0)
|
{
|
oCn.Commit();
|
oCn.CnClose();
|
oCn.CnDispose();
|
sReturn = "有源单单据,不允许扫描无源单条码!";
|
return false;
|
}
|
//有源单(但是扫描条码 源单信息, 与所选源单信息 不匹配)
|
else if (sSourceInterID + sSourceEntryID != 0 && sTMSourceInterID.ToString() + sTMSourceEntryID.ToString() != sSourceInterID.ToString() + sSourceEntryID.ToString())
|
{
|
iBool = false;
|
continue;
|
}
|
//有源单(但是扫描条码 源单信息, 与所选源单信息 匹配) ***
|
else if (sSourceInterID + sSourceEntryID != 0 && sTMSourceInterID.ToString() + sTMSourceEntryID.ToString() == sSourceInterID.ToString() + sSourceEntryID.ToString())
|
{
|
iBool = true;
|
break;
|
}
|
////无源单 (扫描条码 有源单信息 )
|
//else if (sSourceInterID + sSourceEntryID == 0 && sTMSourceInterID + sTMSourceEntryID != 0)
|
//{
|
// oCn.Commit();
|
// oCn.CnClose();
|
// oCn.CnDispose();
|
// sReturn = "无源单单据,不允许扫描有源单条码!";
|
// return false;
|
//}
|
////无源单 (扫描条码 无源单信息 )
|
//else if (sSourceInterID + sSourceEntryID == 0 && sTMSourceInterID + sTMSourceEntryID == 0)
|
//{
|
// iBool = true;
|
// break;
|
//}
|
}
|
if (iBool == false)
|
{
|
oCn.Commit();
|
oCn.CnClose();
|
oCn.CnDispose();
|
sReturn = "扫描条码源单,与所选源单不匹配!";
|
return false;
|
}
|
}
|
//else if (oDs1.Tables[0].Rows.Count == 0)
|
//{
|
// //无源单 (扫描条码 有源单信息 )
|
// if (sSourceInterID + sSourceEntryID == 0 && sTMSourceInterID + sTMSourceEntryID != 0)
|
// {
|
// oCn.Commit();
|
// oCn.CnClose();
|
// oCn.CnDispose();
|
// sReturn = "无源单单据,不允许扫描有源单条码!";
|
// return false;
|
// }
|
//}
|
}
|
}
|
//
|
oDs = oCn.RunProcReturn("select HQtyMust,HSourceInterID,HSourceEntryID,HSourceBillType,HSourceBillNo from " + MvarItemKey + " where HInterID=" + oModel.HInterID.ToString() + " and HBillType='" + oModel.HBillType + "' and HMaterID=" + oModel.HMaterID.ToString() + " and HAuxPropID=" + oModel.HAuxPropID.ToString() + " and HQty=0 ", "KF_PonderationBillMain_Temp");
|
//
|
if (oDs != null && oDs.Tables[0].Rows.Count > 0)
|
{
|
oDs2 = oCn.RunProcReturn("select HBarCodeType from Gy_BarCodeBill where HBarCode='" + oModel.HBarCode + "'", "Gy_BarCodeBill");
|
if (DBUtility.ClsPub.isStrNull(oDs2.Tables[0].Rows[0]["HBarCodeType"]) != "唯一条码")
|
{
|
oModel.HQty = DBUtility.ClsPub.isLong(oDs.Tables[0].Rows[0]["HQtyMust"]);
|
}
|
oModel.HQtyMust = 0;
|
oModel.HSourceInterID = DBUtility.ClsPub.isLong(oDs.Tables[0].Rows[0]["HSourceInterID"]);
|
oModel.HSourceEntryID = DBUtility.ClsPub.isLong(oDs.Tables[0].Rows[0]["HSourceEntryID"]);
|
oModel.HSourceBillType = DBUtility.ClsPub.isStrNull(oDs.Tables[0].Rows[0]["HSourceBillType"]);
|
oModel.HSourceBillNo = DBUtility.ClsPub.isStrNull(oDs.Tables[0].Rows[0]["HSourceBillNo"]);
|
}
|
else
|
{
|
oModel.HQtyMust = 0;
|
}
|
|
oCn.RunProc("Insert into " + MvarItemKey + " " +
|
" (HInterID,HBillNo,HBillType,HMaterID,HProcID,HWhID,HSCWHID" +
|
",HStockPlaceID,HOutStockPlaceID,HGroupID,HQty,HQtyMust,HPieceQty " +
|
",HAuxPropID,HBatchNo,HBarCode,HAddr,HMaker,HMakeDate " +
|
//",HVDAPack,HVDAMaterNum,HVDAQty " +
|
",HSourceInterID,HSourceEntryID,HSourceBillType,HSourceBillNo" +
|
",HRelationInterID,HRelationEntryID,HRelationBillNo,HRedBlueFlag) " +
|
" Values(" + oModel.HInterID.ToString() + ",'" + oModel.HBillNo + "','" + oModel.HBillType + "'," + oModel.HMaterID.ToString() + "," + oModel.HProcID.ToString() + "," + oModel.HWhID.ToString() + "," + oModel.HSCWHID.ToString() +
|
"," + oModel.HStockPlaceID.ToString() + "," + oModel.HOutStockPlaceID.ToString() + "," + oModel.HGroupID.ToString() + "," + oModel.HQty.ToString() + "," + oModel.HQtyMust.ToString() + "," + oModel.HPieceQty.ToString() +
|
"," + oModel.HAuxPropID.ToString() + ",'" + oModel.HBatchNo + "','" + oModel.HBarCode + "','" + oModel.HAddr + "','" + oModel.HMaker + "',getdate()" +
|
//",'','',0 "+
|
"," + oModel.HSourceInterID.ToString() + "," + oModel.HSourceEntryID.ToString() + ",'" + oModel.HSourceBillType + "','" + oModel.HSourceBillNo + "'" +
|
"," + oModel.HRelationInterID.ToString() + "," + oModel.HRelationEntryID.ToString() + ",'" + oModel.HRelationBillNo + "'," + Convert.ToString(oModel.HRedBlueFlag ? 1 : 0) + ")", ref DBUtility.ClsPub.sExeReturnInfo);
|
//修改上级为非末级代码
|
//oCn.RunProc("Update " + MvarItemKey + " set HEndflag=0 where HItemID=" + oModel.HParentID, ref DBUtility.ClsPub.sExeReturnInfo);
|
oCn.Commit();
|
oCn.CnClose();
|
oCn.CnDispose();
|
sReturn = "保存成功!";
|
return true;
|
}
|
catch (Exception e)
|
{
|
sReturn = e.Message;
|
oCn.RollBack();
|
throw (e);
|
}
|
}
|
|
//新增(不存在相同物料 非托盘条码 扫码前可快捷输入数量)
|
public bool AddNew_sQty(double sQty, ref string sReturn)
|
{
|
SQLHelper.ClsCN oCn = new SQLHelper.ClsCN();
|
try
|
{
|
DataSet oDs = new DataSet();
|
DataSet oDs1 = new DataSet();
|
DataSet oDs2 = new DataSet();
|
DataSet oDs3 = new DataSet();
|
//
|
long sSourceInterID = 0;
|
long sSourceEntryID = 0;
|
long sTMSourceInterID = oModel.HSourceInterID;
|
long sTMSourceEntryID = oModel.HSourceEntryID;
|
string sHBarCodeType = "";
|
double sHQty = 0;
|
bool iBool = false;
|
oCn.BeginTran();
|
//判断所扫描条码的类型
|
oDs3 = oCn.RunProcReturn("select HBarCodeType from Gy_BarCodeBill where HBarCode='" + oModel.HBarCode + "'", "Gy_BarCodeBill");
|
sHBarCodeType = DBUtility.ClsPub.isStrNull(oDs3.Tables[0].Rows[0]["HBarCodeType"]);
|
//
|
if (sHBarCodeType == "唯一条码")
|
{
|
//产品入库,外购入库,其他入库,委外入库 有源单单据只能扫描对应源单条码,无源单单据只能扫描无源单条码(不包括红字单据)
|
if (oModel.HBillType == "1202" || oModel.HBillType == "1201" || oModel.HBillType == "1203" || oModel.HBillType == "1210")
|
{
|
if (oModel.HRedBlueFlag == false)
|
{
|
oDs1 = oCn.RunProcReturn("select distinct HSourceInterID,HSourceEntryID from " + MvarItemKey + " where HInterID=" + oModel.HInterID.ToString() + " and HQty=0 ", "KF_PonderationBillMain_Temp");
|
if (oDs1 != null && oDs1.Tables[0].Rows.Count > 0)
|
{
|
for (int i = 0; i <= oDs1.Tables[0].Rows.Count - 1; i++)
|
{
|
sSourceInterID = DBUtility.ClsPub.isLong(oDs1.Tables[0].Rows[i]["HSourceInterID"]);
|
sSourceEntryID = DBUtility.ClsPub.isLong(oDs1.Tables[0].Rows[i]["HSourceEntryID"]);
|
|
//有源单 (扫描条码 无源单信息)
|
if (sSourceInterID + sSourceEntryID != 0 && sTMSourceInterID + sTMSourceEntryID == 0)
|
{
|
oCn.Commit();
|
oCn.CnClose();
|
oCn.CnDispose();
|
sReturn = "有源单单据,不允许扫描无源单条码!";
|
return false;
|
}
|
//有源单(但是扫描条码 源单信息, 与所选源单信息 不匹配)
|
else if (sSourceInterID + sSourceEntryID != 0 && sTMSourceInterID.ToString() + sTMSourceEntryID.ToString() != sSourceInterID.ToString() + sSourceEntryID.ToString())
|
{
|
iBool = false;
|
continue;
|
}
|
//有源单(但是扫描条码 源单信息, 与所选源单信息 匹配) ***
|
else if (sSourceInterID + sSourceEntryID != 0 && sTMSourceInterID.ToString() + sTMSourceEntryID.ToString() == sSourceInterID.ToString() + sSourceEntryID.ToString())
|
{
|
iBool = true;
|
break;
|
}
|
////无源单 (扫描条码 有源单信息 )
|
//else if (sSourceInterID + sSourceEntryID == 0 && sTMSourceInterID + sTMSourceEntryID != 0)
|
//{
|
// oCn.Commit();
|
// oCn.CnClose();
|
// oCn.CnDispose();
|
// sReturn = "无源单单据,不允许扫描有源单条码!";
|
// return false;
|
//}
|
////无源单 (扫描条码 无源单信息 )
|
//else if (sSourceInterID + sSourceEntryID == 0 && sTMSourceInterID + sTMSourceEntryID == 0)
|
//{
|
// iBool = true;
|
// break;
|
//}
|
}
|
if (iBool == false)
|
{
|
oCn.Commit();
|
oCn.CnClose();
|
oCn.CnDispose();
|
sReturn = "扫描条码源单,与所选源单不匹配!";
|
return false;
|
}
|
}
|
//else if (oDs1.Tables[0].Rows.Count == 0)
|
//{
|
// //无源单 (扫描条码 有源单信息 )
|
// if (sSourceInterID + sSourceEntryID == 0 && sTMSourceInterID + sTMSourceEntryID != 0)
|
// {
|
// oCn.Commit();
|
// oCn.CnClose();
|
// oCn.CnDispose();
|
// sReturn = "无源单单据,不允许扫描有源单条码!";
|
// return false;
|
// }
|
//}
|
}
|
}
|
}
|
//得到源单主ID、源单子ID、源单类型、源单单号、条码数量
|
oDs = oCn.RunProcReturn("select HQtyMust,HSourceInterID,HSourceEntryID,HSourceBillType,HSourceBillNo from " + MvarItemKey + " where HInterID=" + oModel.HInterID.ToString() + " and HBillType='" + oModel.HBillType + "' and HMaterID=" + oModel.HMaterID.ToString() + " and HAuxPropID=" + oModel.HAuxPropID.ToString() + " and HQty=0 ", "KF_PonderationBillMain_Temp");
|
//
|
if (oDs != null && oDs.Tables[0].Rows.Count > 0)
|
{
|
oModel.HQtyMust = 0;
|
oModel.HSourceInterID = DBUtility.ClsPub.isLong(oDs.Tables[0].Rows[0]["HSourceInterID"]);
|
oModel.HSourceEntryID = DBUtility.ClsPub.isLong(oDs.Tables[0].Rows[0]["HSourceEntryID"]);
|
oModel.HSourceBillType = DBUtility.ClsPub.isStrNull(oDs.Tables[0].Rows[0]["HSourceBillType"]);
|
oModel.HSourceBillNo = DBUtility.ClsPub.isStrNull(oDs.Tables[0].Rows[0]["HSourceBillNo"]);
|
double sHSumQty = DBUtility.ClsPub.isDoule(oDs.Tables[0].Rows[0]["HQtyMust"]);
|
oDs2 = oCn.RunProcReturn("select sum(HQty) HQty from " + MvarItemKey + " where HInterID=" + oModel.HInterID.ToString() + " and HBillType='" + oModel.HBillType + "' and HSourceInterID=" + oModel.HSourceInterID.ToString() + " and HSourceEntryID=" + oModel.HSourceEntryID.ToString() + " and HQty <> 0 ", "KF_PonderationBillMain_Temp");
|
|
//没有输入数量,非唯一条码 数量直接取剩余应收数量或实收数量,有输入数量,条码数量取所输入数量
|
if (sQty == 0)
|
{
|
if (sHBarCodeType != "唯一条码")
|
{
|
oModel.HQty = sHSumQty - DBUtility.ClsPub.isDoule(oDs2.Tables[0].Rows[0]["HQty"]);
|
if (oModel.HQty <= 0)
|
{
|
sReturn = "检查数量是否小于等于应收数量!";
|
return false;
|
}
|
}
|
}
|
else
|
{
|
sHQty = DBUtility.ClsPub.isDoule(sQty);
|
if (sHQty < 0)
|
{
|
sReturn = "输入的数量不能小于0!";
|
return false;
|
}
|
if (sHSumQty <= DBUtility.ClsPub.isDoule(oDs2.Tables[0].Rows[0]["HQty"]))
|
{
|
sReturn = "扫描数量总和不能大于实际数量!";
|
return false;
|
}
|
if (sHBarCodeType == "唯一条码" && oModel.HQty < sHQty)
|
{
|
sReturn = "数量不足,已获取实际数量!";
|
}
|
else
|
{
|
oModel.HQty = sHQty;
|
}
|
}
|
}
|
else
|
{
|
oModel.HQtyMust = 0;
|
oModel.HSourceInterID = 0;
|
oModel.HSourceEntryID = 0;
|
oModel.HSourceBillType = "";
|
oModel.HSourceBillNo = "";
|
if (sQty == 0)
|
{
|
|
}
|
else
|
{
|
sHQty = DBUtility.ClsPub.isDoule(sQty);
|
if (sHQty < 0)
|
{
|
sReturn = "输入的数量不能小于0!";
|
return false;
|
}
|
if (sHBarCodeType == "唯一条码" && oModel.HQty < sHQty)
|
{
|
sReturn = "数量不足,已获取实际数量!";
|
}
|
else
|
{
|
oModel.HQty = sHQty;
|
}
|
}
|
}
|
|
oCn.RunProc("Insert into " + MvarItemKey + " " +
|
" (HInterID,HBillNo,HBillType,HMaterID,HProcID,HWhID,HSCWHID" +
|
",HStockPlaceID,HOutStockPlaceID,HGroupID,HQty,HQtyMust,HPieceQty " +
|
",HAuxPropID,HBatchNo,HBarCode,HAddr,HMaker,HMakeDate " +
|
//",HVDAPack,HVDAMaterNum,HVDAQty " +
|
",HSourceInterID,HSourceEntryID,HSourceBillType,HSourceBillNo,HMTONo" +
|
",HSTOCKORGID,HOWNERID " +
|
",HRelationInterID,HRelationEntryID,HRelationBillNo,HRedBlueFlag) " +
|
" Values(" + oModel.HInterID.ToString() + ",'" + oModel.HBillNo + "','" + oModel.HBillType + "'," + oModel.HMaterID.ToString() + "," + oModel.HProcID.ToString() + "," + oModel.HWhID.ToString() + "," + oModel.HSCWHID.ToString() +
|
"," + oModel.HStockPlaceID.ToString() + "," + oModel.HOutStockPlaceID.ToString() + "," + oModel.HGroupID.ToString() + "," + oModel.HQty.ToString() + "," + oModel.HQtyMust.ToString() + "," + oModel.HPieceQty.ToString() +
|
"," + oModel.HAuxPropID.ToString() + ",'" + oModel.HBatchNo + "','" + oModel.HBarCode + "','" + oModel.HAddr + "','" + oModel.HMaker + "',getdate()" +
|
//",'','',0 "+
|
"," + oModel.HSourceInterID.ToString() + "," + oModel.HSourceEntryID.ToString() + ",'" + oModel.HSourceBillType + "','" + oModel.HSourceBillNo + "','" + oModel.HMTONo + "'" +
|
"," + oModel.HSTOCKORGID.ToString() + "," + oModel.HOWNERID.ToString() +
|
"," + oModel.HRelationInterID.ToString() + "," + oModel.HRelationEntryID.ToString() + ",'" + oModel.HRelationBillNo + "'," + Convert.ToString(oModel.HRedBlueFlag ? 1 : 0) + ")", ref DBUtility.ClsPub.sExeReturnInfo);
|
//修改上级为非末级代码
|
//oCn.RunProc("Update " + MvarItemKey + " set HEndflag=0 where HItemID=" + oModel.HParentID, ref DBUtility.ClsPub.sExeReturnInfo);
|
oCn.Commit();
|
oCn.CnClose();
|
oCn.CnDispose();
|
sReturn = "保存成功!";
|
return true;
|
}
|
catch (Exception e)
|
{
|
sReturn = e.Message;
|
oCn.RollBack();
|
throw (e);
|
}
|
}
|
|
//新增(源单) 根据源单单号 批量新增源单信息
|
public bool AddNew_Source(long sNewInterID, string sNewBillNo, string sNewBillType, string sSourceBillNo, string sSourceBillType, string sRedBlueflag, ref string sReturn)
|
{
|
SQLHelper.ClsCN oCn = new SQLHelper.ClsCN();
|
try
|
{
|
DataSet oDs = new DataSet();
|
oCn.BeginTran();
|
oCn.RunProc("exec h_p_WMS_ERPSourceBillToLocal '" + sSourceBillNo + "','" + sSourceBillType + "'");
|
oDs = oCn.RunProcReturn("exec h_p_IF_SourceBill_Check_Add " + sNewInterID.ToString() + ",'" + sNewBillNo + "','" + sNewBillType + "','" + sSourceBillNo + "','" + sSourceBillType + "','" + sRedBlueflag + "'", "h_p_IF_SourceBill_Check_Add");
|
if (oDs.Tables[0].Rows.Count == 0 || oDs == null)
|
{
|
oCn.Commit();
|
oCn.CnClose();
|
oCn.CnDispose();
|
sReturn = "null未知错误!";
|
return false;
|
}
|
if (DBUtility.ClsPub.isLong(oDs.Tables[0].Rows[0][0]) == 1)
|
{
|
oCn.Commit();
|
oCn.CnClose();
|
oCn.CnDispose();
|
sReturn = "您扫描的源单已经被关联!不能再次操作!";
|
return false;
|
}
|
else if (DBUtility.ClsPub.isLong(oDs.Tables[0].Rows[0][0]) == 2)
|
{
|
//输入源单信息不准确,请输入较完整的单据号
|
oCn.Commit();
|
oCn.CnClose();
|
oCn.CnDispose();
|
sReturn = "输入源单信息不准确,请输入较完整的单据号!";
|
return false;
|
}
|
else if (DBUtility.ClsPub.isLong(oDs.Tables[0].Rows[0][0]) == 9)
|
{
|
//保存成功
|
oCn.Commit();
|
oCn.CnClose();
|
oCn.CnDispose();
|
sReturn = "保存成功!";
|
return true;
|
}
|
else
|
{
|
oCn.Commit();
|
oCn.CnClose();
|
oCn.CnDispose();
|
sReturn = "else未知错误!";
|
return false;
|
}
|
//
|
}
|
catch (Exception e)
|
{
|
sReturn = e.Message;
|
oCn.RollBack();
|
throw (e);
|
}
|
}
|
|
//新增(源单) 领料出库根据计划模式、配套数量 批量新增源单信息
|
public bool AddNew_Source_MateOut(long sNewInterID, string sNewBillNo, string sNewBillType, string sSourceBillNo, string sSourceBillType, string sRedBlueflag, string sMaker, Double sPPQty, Int64 sPlanMode, ref string sReturn)
|
{
|
SQLHelper.ClsCN oCn = new SQLHelper.ClsCN();
|
try
|
{
|
DataSet oDs = new DataSet();
|
oCn.BeginTran();
|
oCn.RunProc("exec h_p_WMS_ERPSourceBillToLocal '" + sSourceBillNo + "','" + sSourceBillType + "'");
|
oDs = oCn.RunProcReturn("exec h_p_WMS_PPBOMComplementQTY " + sNewInterID.ToString() + ",'" + sNewBillNo + "','" + sNewBillType + "','" + sSourceBillNo + "','" + sSourceBillType + "','" + sRedBlueflag + "','" + sMaker + "'," + sPPQty + "," + sPlanMode, "h_p_WMS_PPBOMComplementQTY");
|
if (oDs.Tables[0].Rows.Count == 0 || oDs == null)
|
{
|
oCn.Commit();
|
oCn.CnClose();
|
oCn.CnDispose();
|
sReturn = "null未知错误!";
|
return false;
|
}
|
if (DBUtility.ClsPub.isLong(oDs.Tables[0].Rows[0][0]) == 1)
|
{
|
oCn.Commit();
|
oCn.CnClose();
|
oCn.CnDispose();
|
sReturn = "您所选计划模式不对,或扫描的源单已经被关联!不能再次操作!";
|
return false;
|
}
|
else if (DBUtility.ClsPub.isLong(oDs.Tables[0].Rows[0][0]) == 2)
|
{
|
//输入源单信息不准确,请输入较完整的单据号
|
oCn.Commit();
|
oCn.CnClose();
|
oCn.CnDispose();
|
sReturn = "输入源单信息不准确,请输入较完整的单据号!";
|
return false;
|
}
|
else if (DBUtility.ClsPub.isLong(oDs.Tables[0].Rows[0][0]) == 9)
|
{
|
//保存成功
|
oCn.Commit();
|
oCn.CnClose();
|
oCn.CnDispose();
|
sReturn = "保存成功!";
|
return true;
|
}
|
else
|
{
|
oCn.Commit();
|
oCn.CnClose();
|
oCn.CnDispose();
|
sReturn = "else未知错误!";
|
return false;
|
}
|
//
|
}
|
catch (Exception e)
|
{
|
sReturn = e.Message;
|
oCn.RollBack();
|
throw (e);
|
}
|
}
|
|
//新增 (写入出入库条码临时表(编辑增加数量))
|
public bool AddNew_More_ChangGui(long HInterID, long HMaterID, Int64 HAuxPropID, string HMTONo, Int64 HWhID, Int64 HSPID, Int64 HSCWhID, Int64 HSCSPID, string HBatchNo, Int64 HSourceInterID, Int64 HSourceEntryID, string sBarCode, string sBillType, double sQty, ref string sReturn)
|
{
|
SQLHelper.ClsCN oCn = new SQLHelper.ClsCN();
|
try
|
{
|
oCn.BeginTran();
|
//批量新增
|
oCn.RunProc("exec h_p_KF_PonderationBillMain_Temp_Add_BatchNo " + HInterID + ",'" + sBillType + "'" +
|
"," + HMaterID +
|
"," + HAuxPropID +
|
",'" + HMTONo + "'" +
|
"," + HWhID +
|
"," + HSPID +
|
"," + HSCWhID +
|
"," + HSCSPID +
|
",'" + HBatchNo + "'" +
|
"," + HSourceInterID +
|
"," + HSourceEntryID +
|
",'" + sBarCode + "'" +
|
"," + sQty, ref DBUtility.ClsPub.sExeReturnInfo);
|
oCn.Commit();
|
oCn.CnClose();
|
oCn.CnDispose();
|
sReturn = "保存成功!";
|
return true;
|
}
|
catch (Exception e)
|
{
|
sReturn = e.Message;
|
oCn.RollBack();
|
throw (e);
|
}
|
}
|
|
//新增 (写入出入库条码临时表(编辑减少数量))
|
public bool AddNew_Clear_ChangGui(long HInterID, long HMaterID, Int64 HAuxPropID, string HMTONo, Int64 HWhID, Int64 HSPID, Int64 HSCWhID, Int64 HSCSPID, string HBatchNo, Int64 HSourceInterID, Int64 HSourceEntryID, string sBarCode, string sBillType, double sQty, ref string sReturn)
|
{
|
SQLHelper.ClsCN oCn = new SQLHelper.ClsCN();
|
try
|
{
|
oCn.BeginTran();
|
//批量新增
|
oCn.RunProc("exec h_p_KF_PonderationBillMain_Temp_Clear_BatchNo " + HInterID + ",'" + sBillType + "'" +
|
"," + HMaterID +
|
"," + HAuxPropID +
|
",'" + HMTONo + "'" +
|
"," + HWhID +
|
"," + HSPID +
|
"," + HSCWhID +
|
"," + HSCSPID +
|
",'" + HBatchNo + "'" +
|
"," + HSourceInterID +
|
"," + HSourceEntryID +
|
",'" + sBarCode + "'" +
|
"," + sQty, ref DBUtility.ClsPub.sExeReturnInfo);
|
oCn.Commit();
|
oCn.CnClose();
|
oCn.CnDispose();
|
sReturn = "减少成功!";
|
return true;
|
}
|
catch (Exception e)
|
{
|
sReturn = e.Message;
|
oCn.RollBack();
|
throw (e);
|
}
|
}
|
|
//删除(选中删除明细列表中的一条记录)
|
public bool DeleteByInterIDAndSource(Int64 sHInterID, Int64 sMaterID, Int64 sHAuxPropID, string sHMTONo, Int64 sSInterID, Int64 sSEntryID, string sHBillType)
|
{
|
try
|
{
|
oCn.RunProc("Delete from " + MvarItemKey + " where HInterID=" + sHInterID.ToString() + " and HMaterID= " + sMaterID.ToString() + " and HAuxPropID= " + sHAuxPropID.ToString() + " and HMTONo='" + sHMTONo + "' and HBillType='" + sHBillType + "' and HSourceInterID=" + sSInterID.ToString() + " and HSourceEntryID=" + sSEntryID.ToString() + " and HQty<>0 ", ref DBUtility.ClsPub.sExeReturnInfo);
|
return true;
|
}
|
catch (Exception e)
|
{
|
throw (e);
|
}
|
}
|
|
//删除(选中删除编辑明细列表中的一条条码记录)
|
public bool DeleteByBarCode(Int64 sHInterID, string sBarCode, string sHBillType)
|
{
|
try
|
{
|
oCn.RunProc("Delete from " + MvarItemKey + " where HInterID=" + sHInterID.ToString() + " and HBillType='" + sHBillType + "' and HBarCode='" + sBarCode + "'", ref DBUtility.ClsPub.sExeReturnInfo);
|
return true;
|
}
|
catch (Exception e)
|
{
|
throw (e);
|
}
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//删除
|
public bool DeleteByInterID(Int64 sHInterID, string sHBillType)
|
{
|
try
|
{
|
oCn.RunProc("Delete from " + MvarItemKey + " where HInterID=" + sHInterID.ToString() + " and HBillType='" + sHBillType + "'", ref DBUtility.ClsPub.sExeReturnInfo);
|
return true;
|
}
|
catch (Exception e)
|
{
|
throw (e);
|
}
|
}
|
|
//删除(源单主ID,源单子ID)
|
public bool DeleteByInterID(Int64 sHInterID, Int64 sHEntryID, string sHBillType)
|
{
|
try
|
{
|
oCn.RunProc("Delete from " + MvarItemKey + " where HSourceInterID=" + sHInterID.ToString() + " and HSourceEntryID=" + sHEntryID.ToString() + " and HBillType='" + sHBillType + "'", ref DBUtility.ClsPub.sExeReturnInfo);
|
return true;
|
}
|
catch (Exception e)
|
{
|
throw (e);
|
}
|
}
|
|
//删除(先进先出数据)更新 HlineStatus =1
|
public bool DeleteFIFOByInterID(Int64 sHInterID, string sHBillType)
|
{
|
try
|
{
|
oCn.RunProc("update Kf_ICInventory_FIFO_Tmp set HlineStatus =1 where HInterID=" + sHInterID.ToString() + " and HBillType='" + sHBillType + "'", ref DBUtility.ClsPub.sExeReturnInfo);
|
return true;
|
}
|
catch (Exception e)
|
{
|
throw (e);
|
}
|
}
|
//删除缓存列表单据
|
public bool DeleteBillList(Int64 sHInterID)
|
{
|
try
|
{
|
oCn.RunProc("Delete from " + MvarItemKey + " where HInterID=" + sHInterID.ToString() , ref DBUtility.ClsPub.sExeReturnInfo);
|
return true;
|
}
|
catch (Exception e)
|
{
|
throw (e);
|
}
|
}
|
|
//新增
|
public bool AddNew_sQty_FIFO(string sQty, ref string sReturn)
|
{
|
SQLHelper.ClsCN oCn = new SQLHelper.ClsCN();
|
try
|
{
|
DataSet oDs = new DataSet();
|
DataSet oDs1 = new DataSet();
|
//
|
long sSourceInterID = 0;
|
long sSourceEntryID = 0;
|
long sTMSourceInterID = oModel.HSourceInterID;
|
long sTMSourceEntryID = oModel.HSourceEntryID;
|
bool iBool = false;
|
oCn.BeginTran();
|
//产品入库,外购入库,其他入库,委外入库 有源单单据只能扫描对应源单条码,无源单单据只能扫描无源单条码(不包括红字单据)
|
if (oModel.HBillType == "2" || oModel.HBillType == "10" || oModel.HBillType == "5" || oModel.HBillType == "1")
|
{
|
if (oModel.HRedBlueFlag == false)
|
{
|
oDs1 = oCn.RunProcReturn("select distinct HSourceInterID,HSourceEntryID from " + MvarItemKey + " where HInterID=" + oModel.HInterID.ToString() + " and HQty=0 ", "KF_PonderationBillMain_Temp");
|
if (oDs1 != null && oDs1.Tables[0].Rows.Count > 0)
|
{
|
for (int i = 0; i <= oDs1.Tables[0].Rows.Count - 1; i++)
|
{
|
sSourceInterID = DBUtility.ClsPub.isLong(oDs1.Tables[0].Rows[i]["HSourceInterID"]);
|
sSourceEntryID = DBUtility.ClsPub.isLong(oDs1.Tables[0].Rows[i]["HSourceEntryID"]);
|
|
//有源单 (扫描条码 无源单信息)
|
if (sSourceInterID + sSourceEntryID != 0 && sTMSourceInterID + sTMSourceEntryID == 0)
|
{
|
oCn.Commit();
|
oCn.CnClose();
|
oCn.CnDispose();
|
sReturn = "有源单单据,不允许扫描无源单条码!";
|
return false;
|
}
|
//有源单(但是扫描条码 源单信息, 与所选源单信息 不匹配)
|
else if (sSourceInterID + sSourceEntryID != 0 && sTMSourceInterID.ToString() + sTMSourceEntryID.ToString() != sSourceInterID.ToString() + sSourceEntryID.ToString())
|
{
|
iBool = false;
|
continue;
|
}
|
//有源单(但是扫描条码 源单信息, 与所选源单信息 匹配) ***
|
else if (sSourceInterID + sSourceEntryID != 0 && sTMSourceInterID.ToString() + sTMSourceEntryID.ToString() == sSourceInterID.ToString() + sSourceEntryID.ToString())
|
{
|
iBool = true;
|
break;
|
}
|
////无源单 (扫描条码 有源单信息 )
|
//else if (sSourceInterID + sSourceEntryID == 0 && sTMSourceInterID + sTMSourceEntryID != 0)
|
//{
|
// oCn.Commit();
|
// oCn.CnClose();
|
// oCn.CnDispose();
|
// sReturn = "无源单单据,不允许扫描有源单条码!";
|
// return false;
|
//}
|
////无源单 (扫描条码 无源单信息 )
|
//else if (sSourceInterID + sSourceEntryID == 0 && sTMSourceInterID + sTMSourceEntryID == 0)
|
//{
|
// iBool = true;
|
// break;
|
//}
|
}
|
if (iBool == false)
|
{
|
oCn.Commit();
|
oCn.CnClose();
|
oCn.CnDispose();
|
sReturn = "扫描条码源单,与所选源单不匹配!";
|
return false;
|
}
|
}
|
//else if (oDs1.Tables[0].Rows.Count == 0)
|
//{
|
// //无源单 (扫描条码 有源单信息 )
|
// if (sSourceInterID + sSourceEntryID == 0 && sTMSourceInterID + sTMSourceEntryID != 0)
|
// {
|
// oCn.Commit();
|
// oCn.CnClose();
|
// oCn.CnDispose();
|
// sReturn = "无源单单据,不允许扫描有源单条码!";
|
// return false;
|
// }
|
//}
|
}
|
}
|
//
|
oDs = oCn.RunProcReturn("select 1 from Kf_ICInventory_FIFO_Tmp where HBillType='" + oModel.HBillType + "' and HMaterID=" + oModel.HMaterID.ToString() + " and HQty=0 and HWhID= " + oModel.HWhID.ToString() + " and HSPID= " + oModel.HStockPlaceID.ToString() + " and HBillNo= '" + oModel.HBillNo + "'", "Kf_ICInventory_FIFO_Tmp");
|
if (oDs != null && oDs.Tables[0].Rows.Count > 0)
|
{
|
oDs = oCn.RunProcReturn("select HSumQtyMust,HSourceInterID,HSourceEntryID,HSourceBillType,HSourceBillNo from Kf_ICInventory_FIFO_Tmp where HBillType='" + oModel.HBillType + "' and HMaterID=" + oModel.HMaterID.ToString() + " and HQty=0 and HWhID= " + oModel.HWhID.ToString() + " and HSPID= " + oModel.HStockPlaceID.ToString() + " and HBillNo= '" + oModel.HBillNo + "'", "Kf_ICInventory_FIFO_Tmp");
|
//
|
if (oDs != null && oDs.Tables[0].Rows.Count > 0)
|
{
|
if (sQty == "")
|
{
|
oModel.HQty = DBUtility.ClsPub.isDoule(oDs.Tables[0].Rows[0]["HSumQtyMust"]);
|
if (oModel.HQty < 0)
|
{
|
sReturn = "检查数量是否小于等于实!";
|
return false;
|
}
|
}
|
else
|
{
|
oModel.HQty = DBUtility.ClsPub.isDoule(sQty);
|
if (oModel.HQty < 0)
|
{
|
sReturn = "输入的数量不能小于0!";
|
return false;
|
}
|
}
|
|
oModel.HQtyMust = 0;
|
oModel.HSourceInterID = DBUtility.ClsPub.isLong(oDs.Tables[0].Rows[0]["HSourceInterID"]);
|
oModel.HSourceEntryID = DBUtility.ClsPub.isLong(oDs.Tables[0].Rows[0]["HSourceEntryID"]);
|
oModel.HSourceBillType = DBUtility.ClsPub.isStrNull(oDs.Tables[0].Rows[0]["HSourceBillType"]);
|
oModel.HSourceBillNo = DBUtility.ClsPub.isStrNull(oDs.Tables[0].Rows[0]["HSourceBillNo"]);
|
}
|
else
|
{
|
oModel.HQtyMust = 0;
|
}
|
|
oCn.RunProc("Insert into " + MvarItemKey + " " +
|
" (HInterID,HBillNo,HBillType,HMaterID,HProcID,HWhID,HSCWHID" +
|
",HStockPlaceID,HOutStockPlaceID,HGroupID,HQty,HQtyMust,HPieceQty " +
|
",HBatchNo,HBarCode,HAddr,HMaker,HMakeDate " +
|
//",HVDAPack,HVDAMaterNum,HVDAQty " +
|
",HSourceInterID,HSourceEntryID,HSourceBillType,HSourceBillNo" +
|
",HRelationInterID,HRelationEntryID,HRelationBillNo,HRedBlueFlag) " +
|
" Values(" + oModel.HInterID.ToString() + ",'" + oModel.HBillNo + "','" + oModel.HBillType + "'," + oModel.HMaterID.ToString() + "," + oModel.HProcID.ToString() + "," + oModel.HWhID.ToString() + "," + oModel.HSCWHID.ToString() +
|
"," + oModel.HStockPlaceID.ToString() + "," + oModel.HOutStockPlaceID.ToString() + "," + oModel.HGroupID.ToString() + "," + oModel.HQty.ToString() + "," + oModel.HQtyMust.ToString() + "," + oModel.HPieceQty.ToString() +
|
",'" + oModel.HBatchNo + "','" + oModel.HBarCode + "','" + oModel.HAddr + "','" + oModel.HMaker + "',getdate()" +
|
//",'','',0 "+
|
"," + oModel.HSourceInterID.ToString() + "," + oModel.HSourceEntryID.ToString() + ",'" + oModel.HSourceBillType + "','" + oModel.HSourceBillNo + "'" +
|
"," + oModel.HRelationInterID.ToString() + "," + oModel.HRelationEntryID.ToString() + ",'" + oModel.HRelationBillNo + "'," + Convert.ToString(oModel.HRedBlueFlag ? 1 : 0) + ")", ref DBUtility.ClsPub.sExeReturnInfo);
|
//修改上级为非末级代码
|
//oCn.RunProc("Update " + MvarItemKey + " set HEndflag=0 where HItemID=" + oModel.HParentID, ref DBUtility.ClsPub.sExeReturnInfo);
|
oCn.Commit();
|
oCn.CnClose();
|
oCn.CnDispose();
|
sReturn = "保存成功!";
|
return true;
|
}
|
else
|
{
|
sReturn = "物料、批次、仓位没有对应上,重新扫描!";
|
return false;
|
}
|
}
|
catch (Exception e)
|
{
|
sReturn = e.Message;
|
oCn.RollBack();
|
throw (e);
|
}
|
}
|
|
//新增(出入库单据已经生成,核对生单时)
|
public bool AddNew_CheckAdd(ref string sReturn)
|
{
|
SQLHelper.ClsCN oCn = new SQLHelper.ClsCN();
|
try
|
{
|
DataSet oDs = new DataSet();
|
oCn.BeginTran();
|
oDs = oCn.RunProcReturn("select HQtyMust,HSourceInterID,HSourceEntryID,HSourceBillType,HSourceBillNo from " + MvarItemKey + " where HInterID=" + oModel.HInterID.ToString() + " and HBillType='" + oModel.HBillType + "' and HMaterID=" + oModel.HMaterID.ToString() + " and HQty=0 ", "KF_PonderationBillMain_Temp");
|
//
|
if (oDs != null && oDs.Tables[0].Rows.Count > 0)
|
{
|
oModel.HQtyMust = 0;
|
oModel.HSourceInterID = DBUtility.ClsPub.isLong(oDs.Tables[0].Rows[0]["HSourceInterID"]);
|
oModel.HSourceEntryID = DBUtility.ClsPub.isLong(oDs.Tables[0].Rows[0]["HSourceEntryID"]);
|
oModel.HSourceBillType = DBUtility.ClsPub.isStrNull(oDs.Tables[0].Rows[0]["HSourceBillType"]);
|
oModel.HSourceBillNo = DBUtility.ClsPub.isStrNull(oDs.Tables[0].Rows[0]["HSourceBillNo"]);
|
}
|
else
|
{
|
oModel.HQtyMust = 0;
|
}
|
|
oCn.RunProc("Insert into " + MvarItemKey + " " +
|
" (HInterID,HBillNo,HBillType,HMaterID,HProcID,HWhID,HSCWHID" +
|
",HStockPlaceID,HOutStockPlaceID,HGroupID,HQty,HQtyMust,HPieceQty " +
|
",HAuxPropID,HBatchNo,HBarCode,HAddr,HMaker,HMakeDate " +
|
//",HVDAPack,HVDAMaterNum,HVDAQty " +
|
",HSourceInterID,HSourceEntryID,HSourceBillType,HSourceBillNo" +
|
",HRelationInterID,HRelationEntryID,HRelationBillNo,HRedBlueFlag) " +
|
" Values(" + oModel.HInterID.ToString() + ",'" + oModel.HBillNo + "','" + oModel.HBillType + "'," + oModel.HMaterID.ToString() + "," + oModel.HProcID.ToString() + "," + oModel.HWhID.ToString() + "," + oModel.HSCWHID.ToString() +
|
"," + oModel.HStockPlaceID.ToString() + "," + oModel.HOutStockPlaceID.ToString() + "," + oModel.HGroupID.ToString() + "," + oModel.HQty.ToString() + "," + oModel.HQtyMust.ToString() + "," + oModel.HPieceQty.ToString() +
|
"," + oModel.HAuxPropID.ToString() + ",'" + oModel.HBatchNo + "','" + oModel.HBarCode + "','" + oModel.HAddr + "','" + oModel.HMaker + "',getdate()" +
|
//",'','',0 "+
|
"," + oModel.HSourceInterID.ToString() + "," + oModel.HSourceEntryID.ToString() + ",'" + oModel.HSourceBillType + "','" + oModel.HSourceBillNo + "'" +
|
"," + oModel.HRelationInterID.ToString() + "," + oModel.HRelationEntryID.ToString() + ",'" + oModel.HRelationBillNo + "'," + Convert.ToString(oModel.HRedBlueFlag ? 1 : 0) + ")", ref DBUtility.ClsPub.sExeReturnInfo);
|
//修改上级为非末级代码
|
//oCn.RunProc("Update " + MvarItemKey + " set HEndflag=0 where HItemID=" + oModel.HParentID, ref DBUtility.ClsPub.sExeReturnInfo);
|
oCn.Commit();
|
oCn.CnClose();
|
oCn.CnDispose();
|
sReturn = "保存成功!";
|
return true;
|
}
|
catch (Exception e)
|
{
|
sReturn = e.Message;
|
oCn.RollBack();
|
throw (e);
|
}
|
}
|
|
//新增(出入库单据已经生成,核对生单时)
|
public bool AddNew_CheckAdd(double sQty, ref string sReturn)
|
{
|
SQLHelper.ClsCN oCn = new SQLHelper.ClsCN();
|
try
|
{
|
DataSet oDs = new DataSet();
|
DataSet oDs2 = new DataSet();
|
oCn.BeginTran();
|
oDs = oCn.RunProcReturn("select HQtyMust,HSourceInterID,HSourceEntryID,HSourceBillType,HSourceBillNo from " + MvarItemKey + " where HInterID=" + oModel.HInterID.ToString() + " and HBillType='" + oModel.HBillType + "' and HMaterID=" + oModel.HMaterID.ToString() + " and HQty=0 ", "KF_PonderationBillMain_Temp");
|
//
|
if (oDs != null && oDs.Tables[0].Rows.Count > 0)
|
{
|
oModel.HQtyMust = 0;
|
oModel.HSourceInterID = DBUtility.ClsPub.isLong(oDs.Tables[0].Rows[0]["HSourceInterID"]);
|
oModel.HSourceEntryID = DBUtility.ClsPub.isLong(oDs.Tables[0].Rows[0]["HSourceEntryID"]);
|
oModel.HSourceBillType = DBUtility.ClsPub.isStrNull(oDs.Tables[0].Rows[0]["HSourceBillType"]);
|
oModel.HSourceBillNo = DBUtility.ClsPub.isStrNull(oDs.Tables[0].Rows[0]["HSourceBillNo"]);
|
long sHSumQty = DBUtility.ClsPub.isLong(oDs.Tables[0].Rows[0]["HQtyMust"]);
|
|
oDs2 = oCn.RunProcReturn("select sum(HQty) HQty from " + MvarItemKey + " where HSourceInterID=" + oModel.HSourceInterID.ToString() + " and HSourceEntryID=" + oModel.HSourceEntryID.ToString() + " and HQty > 0 ", "KF_PonderationBillMain_Temp");
|
|
if (sQty == 0)
|
{
|
oModel.HQty = sHSumQty - DBUtility.ClsPub.isDoule(oDs2.Tables[0].Rows[0]["HQty"]);
|
if (oModel.HQty <= 0)
|
{
|
sReturn = "扫描数量总和不能大于实际数量!";
|
return false;
|
}
|
}
|
else
|
{
|
oModel.HQty = DBUtility.ClsPub.isDoule(sQty);
|
if (oModel.HQty < 0)
|
{
|
sReturn = "输入的数量不能小于0!";
|
return false;
|
}
|
if (oModel.HQtyMust <= DBUtility.ClsPub.isDoule(oDs2.Tables[0].Rows[0]["HQty"]))
|
{
|
sReturn = "扫描数量总和不能大于实际数量!";
|
return false;
|
}
|
}
|
}
|
else
|
{
|
oModel.HQtyMust = 0;
|
}
|
|
oCn.RunProc("Insert into " + MvarItemKey + " " +
|
" (HInterID,HBillNo,HBillType,HMaterID,HProcID,HWhID,HSCWHID" +
|
",HStockPlaceID,HOutStockPlaceID,HGroupID,HQty,HQtyMust,HPieceQty " +
|
",HBatchNo,HBarCode,HAddr,HMaker,HMakeDate " +
|
//",HVDAPack,HVDAMaterNum,HVDAQty " +
|
",HSourceInterID,HSourceEntryID,HSourceBillType,HSourceBillNo" +
|
",HRelationInterID,HRelationEntryID,HRelationBillNo,HRedBlueFlag) " +
|
" Values(" + oModel.HInterID.ToString() + ",'" + oModel.HBillNo + "','" + oModel.HBillType + "'," + oModel.HMaterID.ToString() + "," + oModel.HProcID.ToString() + "," + oModel.HWhID.ToString() + "," + oModel.HSCWHID.ToString() +
|
"," + oModel.HStockPlaceID.ToString() + "," + oModel.HOutStockPlaceID.ToString() + "," + oModel.HGroupID.ToString() + "," + oModel.HQty.ToString() + "," + oModel.HQtyMust.ToString() + "," + oModel.HPieceQty.ToString() +
|
",'" + oModel.HBatchNo + "','" + oModel.HBarCode + "','" + oModel.HAddr + "','" + oModel.HMaker + "',getdate()" +
|
//",'','',0 "+
|
"," + oModel.HSourceInterID.ToString() + "," + oModel.HSourceEntryID.ToString() + ",'" + oModel.HSourceBillType + "','" + oModel.HSourceBillNo + "'" +
|
"," + oModel.HRelationInterID.ToString() + "," + oModel.HRelationEntryID.ToString() + ",'" + oModel.HRelationBillNo + "'," + Convert.ToString(oModel.HRedBlueFlag ? 1 : 0) + ")", ref DBUtility.ClsPub.sExeReturnInfo);
|
//修改上级为非末级代码
|
//oCn.RunProc("Update " + MvarItemKey + " set HEndflag=0 where HItemID=" + oModel.HParentID, ref DBUtility.ClsPub.sExeReturnInfo);
|
oCn.Commit();
|
oCn.CnClose();
|
oCn.CnDispose();
|
sReturn = "保存成功!";
|
return true;
|
}
|
catch (Exception e)
|
{
|
sReturn = e.Message;
|
oCn.RollBack();
|
throw (e);
|
}
|
}
|
|
//新增
|
public bool AddNew_FIFO(ref string sReturn)
|
{
|
SQLHelper.ClsCN oCn = new SQLHelper.ClsCN();
|
try
|
{
|
DataSet oDs = new DataSet();
|
//
|
oCn.BeginTran();
|
//领料出库
|
if (oModel.HBillType == "24")
|
{
|
oDs = oCn.RunProcReturn("select HWHID,HSPID,HQty,HSumQtyMust,HSourceInterID,HSourceEntryID,HSourceBillType,HSourceBillNo from Kf_ICInventory_FIFO_Tmp where HInterID=" + oModel.HInterID.ToString() + " and HBillType='" + oModel.HBillType + "' and HBatchNo='" + oModel.HBatchNo + "' and HBarCode='" + oModel.HBarCode + "'", "Kf_ICInventory_FIFO_Tmp");
|
//
|
if (oDs != null && oDs.Tables[0].Rows.Count > 0)
|
{
|
double sKFQty = DBUtility.ClsPub.isDoule(oDs.Tables[0].Rows[0]["HQty"]);
|
if (oModel.HQty > sKFQty)
|
{
|
oModel.HQty = sKFQty;
|
}
|
oModel.HWhID = DBUtility.ClsPub.isLong(oDs.Tables[0].Rows[0]["HWHID"]);
|
oModel.HStockPlaceID = DBUtility.ClsPub.isLong(oDs.Tables[0].Rows[0]["HSPID"]);
|
oModel.HQtyMust = DBUtility.ClsPub.isDoule(oDs.Tables[0].Rows[0]["HSumQtyMust"]);
|
oModel.HSourceInterID = DBUtility.ClsPub.isLong(oDs.Tables[0].Rows[0]["HSourceInterID"]);
|
oModel.HSourceEntryID = DBUtility.ClsPub.isLong(oDs.Tables[0].Rows[0]["HSourceEntryID"]);
|
oModel.HSourceBillType = DBUtility.ClsPub.isStrNull(oDs.Tables[0].Rows[0]["HSourceBillType"]);
|
oModel.HSourceBillNo = DBUtility.ClsPub.isStrNull(oDs.Tables[0].Rows[0]["HSourceBillNo"]);
|
}
|
else
|
{
|
oCn.Commit();
|
oCn.CnClose();
|
oCn.CnDispose();
|
sReturn = "请根据先进先出清单扫码!";
|
return false;
|
}
|
}
|
//调拨
|
else if (oModel.HBillType == "41")
|
{
|
oDs = oCn.RunProcReturn("select HWHID,HSPID,HQty,HSumQtyMust,HSourceInterID,HSourceEntryID,HSourceBillType,HSourceBillNo from Kf_ICInventory_FIFO_Tmp where HInterID=" + oModel.HInterID.ToString() + " and HBillType='" + oModel.HBillType + "' and HBatchNo='" + oModel.HBatchNo + "' and HBarCode='" + oModel.HBarCode + "'", "Kf_ICInventory_FIFO_Tmp");
|
//
|
if (oDs != null && oDs.Tables[0].Rows.Count > 0)
|
{
|
double sKFQty = DBUtility.ClsPub.isDoule(oDs.Tables[0].Rows[0]["HQty"]);
|
if (oModel.HQty > sKFQty)
|
{
|
oModel.HQty = sKFQty;
|
}
|
oModel.HSCWHID = DBUtility.ClsPub.isLong(oDs.Tables[0].Rows[0]["HWHID"]);
|
oModel.HOutStockPlaceID = DBUtility.ClsPub.isLong(oDs.Tables[0].Rows[0]["HSPID"]);
|
oModel.HQtyMust = DBUtility.ClsPub.isDoule(oDs.Tables[0].Rows[0]["HSumQtyMust"]);
|
oModel.HSourceInterID = DBUtility.ClsPub.isLong(oDs.Tables[0].Rows[0]["HSourceInterID"]);
|
oModel.HSourceEntryID = DBUtility.ClsPub.isLong(oDs.Tables[0].Rows[0]["HSourceEntryID"]);
|
oModel.HSourceBillType = DBUtility.ClsPub.isStrNull(oDs.Tables[0].Rows[0]["HSourceBillType"]);
|
oModel.HSourceBillNo = DBUtility.ClsPub.isStrNull(oDs.Tables[0].Rows[0]["HSourceBillNo"]);
|
}
|
else
|
{
|
oCn.Commit();
|
oCn.CnClose();
|
oCn.CnDispose();
|
sReturn = "请根据先进先出清单扫码!";
|
return false;
|
}
|
}
|
oCn.RunProc("Insert into " + MvarItemKey + " " +
|
" (HInterID,HBillNo,HBillType,HMaterID,HProcID,HWhID,HSCWHID" +
|
",HStockPlaceID,HOutStockPlaceID,HGroupID,HQty,HQtyMust,HPieceQty " +
|
",HBatchNo,HBarCode,HAddr,HMaker,HMakeDate " +
|
//",HVDAPack,HVDAMaterNum,HVDAQty " +
|
",HSourceInterID,HSourceEntryID,HSourceBillType,HSourceBillNo" +
|
",HRelationInterID,HRelationEntryID,HRelationBillNo,HRedBlueFlag) " +
|
" Values(" + oModel.HInterID.ToString() + ",'" + oModel.HBillNo + "','" + oModel.HBillType + "'," + oModel.HMaterID.ToString() + "," + oModel.HProcID.ToString() + "," + oModel.HWhID.ToString() + "," + oModel.HSCWHID.ToString() +
|
"," + oModel.HStockPlaceID.ToString() + "," + oModel.HOutStockPlaceID.ToString() + "," + oModel.HGroupID.ToString() + "," + oModel.HQty.ToString() + "," + oModel.HQtyMust.ToString() + "," + oModel.HPieceQty.ToString() +
|
",'" + oModel.HBatchNo + "','" + oModel.HBarCode + "','" + oModel.HAddr + "','" + oModel.HMaker + "',getdate()" +
|
//",'','',0" +
|
"," + oModel.HSourceInterID.ToString() + "," + oModel.HSourceEntryID.ToString() + ",'" + oModel.HSourceBillType + "','" + oModel.HSourceBillNo + "'" +
|
"," + oModel.HRelationInterID.ToString() + "," + oModel.HRelationEntryID.ToString() + ",'" + oModel.HRelationBillNo + "'," + Convert.ToString(oModel.HRedBlueFlag ? 1 : 0) + ")", ref DBUtility.ClsPub.sExeReturnInfo);
|
//修改上级为非末级代码
|
//oCn.RunProc("Update " + MvarItemKey + " set HEndflag=0 where HItemID=" + oModel.HParentID, ref DBUtility.ClsPub.sExeReturnInfo);
|
oCn.Commit();
|
oCn.CnClose();
|
oCn.CnDispose();
|
sReturn = "保存成功!";
|
return true;
|
}
|
catch (Exception e)
|
{
|
sReturn = e.Message;
|
oCn.RollBack();
|
throw (e);
|
}
|
}
|
|
|
|
//新增(源单) 根据源单单号 批量新增源单信息
|
public bool AddNew_Source_CLD(long sNewInterID, string sNewBillNo, string sNewBillType, string sSourceBillNo, string sSourceBillType, string sRedBlueflag, ref string sReturn)
|
{
|
SQLHelper.ClsCN oCn = new SQLHelper.ClsCN();
|
try
|
{
|
DataSet oDs = new DataSet();
|
oCn.BeginTran();
|
oDs = oCn.RunProcReturn("exec h_p_CLD_SourceBill_Check_Add " + sNewInterID.ToString() + ",'" + sNewBillNo + "','" + sNewBillType + "','" + sSourceBillNo + "','" + sSourceBillType + "','" + sRedBlueflag + "'", "h_p_K3_SourceBill_Check_Add");
|
if (oDs.Tables[0].Rows.Count == 0 || oDs == null)
|
{
|
oCn.Commit();
|
oCn.CnClose();
|
oCn.CnDispose();
|
sReturn = "null未知错误!";
|
return false;
|
}
|
if (DBUtility.ClsPub.isLong(oDs.Tables[0].Rows[0][0]) == 1)
|
{
|
//输入源单信息不准确,请输入较完整的单据号
|
oCn.Commit();
|
oCn.CnClose();
|
oCn.CnDispose();
|
sReturn = "输入源单信息不准确,请输入较完整的单据号!";
|
return false;
|
}
|
else if (DBUtility.ClsPub.isLong(oDs.Tables[0].Rows[0][0]) == 9)
|
{
|
//保存成功
|
oCn.Commit();
|
oCn.CnClose();
|
oCn.CnDispose();
|
sReturn = "保存成功!";
|
return true;
|
}
|
else
|
{
|
oCn.Commit();
|
oCn.CnClose();
|
oCn.CnDispose();
|
sReturn = "else未知错误!";
|
return false;
|
}
|
//
|
}
|
catch (Exception e)
|
{
|
sReturn = e.Message;
|
oCn.RollBack();
|
throw (e);
|
}
|
}
|
|
//新增(源单) 根据源单单号 批量新增源单信息
|
public bool AddNew_Source_CLD_CG(long sNewInterID, string sNewBillNo, string sNewBillType, string sSourceBillNo, string sSourceBillType, string sRedBlueflag, ref string sReturn)
|
{
|
SQLHelper.ClsCN oCn = new SQLHelper.ClsCN();
|
try
|
{
|
DataSet oDs = new DataSet();
|
oCn.BeginTran();
|
oDs = oCn.RunProcReturn("exec h_p_CLD_SourceBill_Check_Add_CG " + sNewInterID.ToString() + ",'" + sNewBillNo + "','" + sNewBillType + "','" + sSourceBillNo + "','" + sSourceBillType + "','" + sRedBlueflag + "'", "h_p_K3_SourceBill_Check_Add");
|
if (oDs.Tables[0].Rows.Count == 0 || oDs == null)
|
{
|
oCn.Commit();
|
oCn.CnClose();
|
oCn.CnDispose();
|
sReturn = "null未知错误!";
|
return false;
|
}
|
if (DBUtility.ClsPub.isLong(oDs.Tables[0].Rows[0][0]) == 1)
|
{
|
//输入源单信息不准确,请输入较完整的单据号
|
oCn.Commit();
|
oCn.CnClose();
|
oCn.CnDispose();
|
sReturn = "输入源单信息不准确,请输入较完整的单据号!";
|
return false;
|
}
|
else if (DBUtility.ClsPub.isLong(oDs.Tables[0].Rows[0][0]) == 9)
|
{
|
//保存成功
|
oCn.Commit();
|
oCn.CnClose();
|
oCn.CnDispose();
|
sReturn = "保存成功!";
|
return true;
|
}
|
else
|
{
|
oCn.Commit();
|
oCn.CnClose();
|
oCn.CnDispose();
|
sReturn = "else未知错误!";
|
return false;
|
}
|
//
|
}
|
catch (Exception e)
|
{
|
sReturn = e.Message;
|
oCn.RollBack();
|
throw (e);
|
}
|
}
|
|
//新增(源单) 根据源单单号 批量新增源单信息(倒箱单)
|
public bool AddNew_Source_ChangeBox(long sNewInterID, string sNewBillNo, string sNewBillType, string sSourceBillNo, string sSourceBillType, string sRedBlueflag, long sInterID, string sBillNo, string sMaker, ref string sReturn)
|
{
|
SQLHelper.ClsCN oCn = new SQLHelper.ClsCN();
|
try
|
{
|
DataSet oDs = new DataSet();
|
oCn.BeginTran();
|
oDs = oCn.RunProcReturn("exec h_p_K3_SourceBill_Check_ChangeBox_Add " + sNewInterID.ToString() + ",'" + sNewBillNo + "','" + sNewBillType + "','" + sSourceBillNo + "','" + sSourceBillType + "','" + sRedBlueflag + "'," + sInterID.ToString() + ",'" + sBillNo + "','" + sMaker + "'", "h_p_K3_SourceBill_Check_ChangeBox_Add");
|
if (oDs.Tables[0].Rows.Count == 0 || oDs == null)
|
{
|
oCn.Commit();
|
oCn.CnClose();
|
oCn.CnDispose();
|
sReturn = "null未知错误!";
|
return false;
|
}
|
if (DBUtility.ClsPub.isLong(oDs.Tables[0].Rows[0][0]) == 1)
|
{
|
//输入源单信息不准确,请输入较完整的单据号
|
oCn.Commit();
|
oCn.CnClose();
|
oCn.CnDispose();
|
sReturn = "输入源单信息不准确,请输入较完整的单据号!";
|
return false;
|
}
|
else if (DBUtility.ClsPub.isLong(oDs.Tables[0].Rows[0][0]) == 9)
|
{
|
//保存成功
|
oCn.Commit();
|
oCn.CnClose();
|
oCn.CnDispose();
|
sReturn = "保存成功!";
|
return true;
|
}
|
else
|
{
|
oCn.Commit();
|
oCn.CnClose();
|
oCn.CnDispose();
|
sReturn = "else未知错误!";
|
return false;
|
}
|
//
|
}
|
catch (Exception e)
|
{
|
sReturn = e.Message;
|
oCn.RollBack();
|
throw (e);
|
}
|
}
|
|
//新增(源单) 根据源单单号 批量新增源单信息 (先进先出)
|
public bool AddNew_Source_FIFO(long sNewInterID, string sNewBillNo, string sNewBillType, string sSourceBillNo, string sSourceBillType, long sHWHID, string sRedBlueflag, ref string sReturn)
|
{
|
SQLHelper.ClsCN oCn = new SQLHelper.ClsCN();
|
try
|
{
|
DataSet oDs = new DataSet();
|
oCn.BeginTran();
|
oDs = oCn.RunProcReturn("exec h_p_K3_SourceBill_Check_FIFO_Add " + sNewInterID.ToString() + ",'" + sNewBillNo + "','" + sNewBillType + "','" + sSourceBillNo + "','" + sSourceBillType + "'," + sHWHID.ToString(), "h_p_K3_SourceBill_Check_FIFO_Add");
|
if (oDs.Tables[0].Rows.Count == 0 || oDs == null)
|
{
|
oCn.Commit();
|
oCn.CnClose();
|
oCn.CnDispose();
|
sReturn = "null未知错误!";
|
return false;
|
}
|
if (DBUtility.ClsPub.isLong(oDs.Tables[0].Rows[0][0]) == 1)
|
{
|
//输入源单信息不准确,请输入较完整的单据号
|
oCn.Commit();
|
oCn.CnClose();
|
oCn.CnDispose();
|
sReturn = "输入源单信息不准确,请输入较完整的单据号!";
|
return false;
|
}
|
else if (DBUtility.ClsPub.isLong(oDs.Tables[0].Rows[0][0]) == 9)
|
{
|
//保存成功
|
oCn.Commit();
|
oCn.CnClose();
|
oCn.CnDispose();
|
sReturn = "保存成功!";
|
return true;
|
}
|
else
|
{
|
oCn.Commit();
|
oCn.CnClose();
|
oCn.CnDispose();
|
sReturn = "else未知错误!";
|
return false;
|
}
|
//
|
}
|
catch (Exception e)
|
{
|
sReturn = e.Message;
|
oCn.RollBack();
|
throw (e);
|
}
|
}
|
|
//新增(源单) 根据源单单号 批量新增源单信息 (先进先出)
|
public bool AddNew_Source_FIFO_CLD(long sNewInterID, string sNewBillNo, string sNewBillType, string sSourceBillNo, string sSourceBillType, long sHWHID, string sRedBlueflag, ref string sReturn)
|
{
|
SQLHelper.ClsCN oCn = new SQLHelper.ClsCN();
|
try
|
{
|
DataSet oDs = new DataSet();
|
oCn.BeginTran();
|
oDs = oCn.RunProcReturn("exec h_p_CLD_SourceBill_Check_FIFO_Add '" + sNewBillNo + "','" + sNewBillType + "','" + sSourceBillNo + "','" + sSourceBillType + "'," + sHWHID.ToString(), "h_p_K3_SourceBill_Check_FIFO_Add");
|
if (oDs.Tables[0].Rows.Count == 0 || oDs == null)
|
{
|
oCn.Commit();
|
oCn.CnClose();
|
oCn.CnDispose();
|
sReturn = "null未知错误!";
|
return false;
|
}
|
if (DBUtility.ClsPub.isLong(oDs.Tables[0].Rows[0][0]) == 1)
|
{
|
//输入源单信息不准确,请输入较完整的单据号
|
oCn.Commit();
|
oCn.CnClose();
|
oCn.CnDispose();
|
sReturn = "输入源单信息不准确,请输入较完整的单据号!";
|
return false;
|
}
|
else if (DBUtility.ClsPub.isLong(oDs.Tables[0].Rows[0][0]) == 9)
|
{
|
//保存成功
|
oCn.Commit();
|
oCn.CnClose();
|
oCn.CnDispose();
|
sReturn = "保存成功!";
|
return true;
|
}
|
else
|
{
|
oCn.Commit();
|
oCn.CnClose();
|
oCn.CnDispose();
|
sReturn = "else未知错误!";
|
return false;
|
}
|
//
|
}
|
catch (Exception e)
|
{
|
sReturn = e.Message;
|
oCn.RollBack();
|
throw (e);
|
}
|
}
|
|
//新增(一张单据,存在相同物料)
|
public bool AddNew_Select_Check(ref string sReturn)
|
{
|
SQLHelper.ClsCN oCn = new SQLHelper.ClsCN();
|
try
|
{
|
DataSet oDs = new DataSet();
|
oCn.BeginTran();
|
oDs = oCn.RunProcReturn("select HQtyMust,HWhID,HStockPlaceID,HSCWHID,HOutStockPlaceID from " + MvarItemKey + " where HInterID=" + oModel.HInterID.ToString() + " and HMaterID=" + oModel.HMaterID.ToString() + " and HSourceInterID=" + oModel.HSourceInterID + " and HSourceEntryID=" + oModel.HSourceEntryID, "KF_PonderationBillMain_Temp");
|
if (oDs != null && oDs.Tables[0].Rows.Count > 0)
|
{
|
oModel.HQtyMust =0;
|
oModel.HWhID = DBUtility.ClsPub.isLong(oDs.Tables[0].Rows[0]["HWhID"]);
|
oModel.HStockPlaceID = DBUtility.ClsPub.isLong(oDs.Tables[0].Rows[0]["HStockPlaceID"]);
|
oModel.HSCWHID = DBUtility.ClsPub.isLong(oDs.Tables[0].Rows[0]["HSCWHID"]);
|
oModel.HOutStockPlaceID = DBUtility.ClsPub.isLong(oDs.Tables[0].Rows[0]["HOutStockPlaceID"]);
|
oModel.HBatchNo = DBUtility.ClsPub.isStrNull(oDs.Tables[0].Rows[0]["HBatchNo"]);
|
}
|
oCn.RunProc("Insert into " + MvarItemKey + " " +
|
" (HInterID,HBillNo,HBillType,HMaterID,HProcID,HWhID,HSCWHID" +
|
",HStockPlaceID,HOutStockPlaceID,HGroupID,HQty,HQtyMust,HPieceQty " +
|
",HBatchNo,HBarCode,HAddr,HMaker,HMakeDate " +
|
//",HVDAPack,HVDAMaterNum,HVDAQty " +
|
",HSourceInterID,HSourceEntryID,HSourceBillType,HSourceBillNo" +
|
",HRelationInterID,HRelationEntryID,HRelationBillNo,HRedBlueFlag) " +
|
" Values(" + oModel.HInterID.ToString() + ",'" + oModel.HBillNo + "','" + oModel.HBillType + "'," + oModel.HMaterID.ToString() + "," + oModel.HProcID.ToString() + "," + oModel.HWhID.ToString() + "," + oModel.HSCWHID.ToString() +
|
"," + oModel.HStockPlaceID.ToString() + "," + oModel.HOutStockPlaceID.ToString() + "," + oModel.HGroupID.ToString() + "," + oModel.HQty.ToString() + "," + oModel.HQtyMust.ToString() + "," + oModel.HPieceQty.ToString() +
|
",'" + oModel.HBatchNo + "','" + oModel.HBarCode + "','" + oModel.HAddr + "','" + oModel.HMaker + "',getdate()" +
|
//",'','',0 " +
|
"," + oModel.HSourceInterID.ToString() + "," + oModel.HSourceEntryID.ToString() + ",'" + oModel.HSourceBillType + "','" + oModel.HSourceBillNo + "'" +
|
"," + oModel.HRelationInterID.ToString() + "," + oModel.HRelationEntryID.ToString() + ",'" + oModel.HRelationBillNo + "'," + Convert.ToString(oModel.HRedBlueFlag ? 1 : 0) + ")", ref DBUtility.ClsPub.sExeReturnInfo);
|
//修改上级为非末级代码
|
//oCn.RunProc("Update " + MvarItemKey + " set HEndflag=0 where HItemID=" + oModel.HParentID, ref DBUtility.ClsPub.sExeReturnInfo);
|
oCn.Commit();
|
oCn.CnClose();
|
oCn.CnDispose();
|
sReturn = "保存成功!";
|
return true;
|
}
|
catch (Exception e)
|
{
|
sReturn = e.Message;
|
oCn.RollBack();
|
throw (e);
|
}
|
}
|
|
//新增(一张单据,存在相同物料)
|
public bool AddNew_Select(ref string sReturn)
|
{
|
SQLHelper.ClsCN oCn = new SQLHelper.ClsCN();
|
try
|
{
|
DataSet oDs = new DataSet();
|
oCn.BeginTran();
|
oDs = oCn.RunProcReturn("select HQtyMust from " + MvarItemKey + " where HInterID=" + oModel.HInterID.ToString() + " and HMaterID=" + oModel.HMaterID.ToString() + " and HSourceInterID=" + oModel.HSourceInterID + " and HSourceEntryID=" + oModel.HSourceEntryID, "KF_PonderationBillMain_Temp");
|
if (oDs != null && oDs.Tables[0].Rows.Count > 0)
|
{
|
oModel.HQtyMust = DBUtility.ClsPub.isDoule(oDs.Tables[0].Rows[0]["HQtyMust"]);
|
}
|
oCn.RunProc("Insert into " + MvarItemKey + " " +
|
" (HInterID,HBillNo,HBillType,HMaterID,HProcID,HWhID,HSCWHID" +
|
",HStockPlaceID,HOutStockPlaceID,HGroupID,HQty,HQtyMust,HPieceQty " +
|
",HBatchNo,HBarCode,HAddr,HMaker,HMakeDate " +
|
//",HVDAPack,HVDAMaterNum,HVDAQty " +
|
",HSourceInterID,HSourceEntryID,HSourceBillType,HSourceBillNo" +
|
",HRelationInterID,HRelationEntryID,HRelationBillNo,HRedBlueFlag) " +
|
" Values(" + oModel.HInterID.ToString() + ",'" + oModel.HBillNo + "','" + oModel.HBillType + "'," + oModel.HMaterID.ToString() + "," + oModel.HProcID.ToString() + "," + oModel.HWhID.ToString() + "," + oModel.HSCWHID.ToString() +
|
"," + oModel.HStockPlaceID.ToString() + "," + oModel.HOutStockPlaceID.ToString() + "," + oModel.HGroupID.ToString() + "," + oModel.HQty.ToString() + "," + oModel.HQtyMust.ToString() + "," + oModel.HPieceQty.ToString() +
|
",'" + oModel.HBatchNo + "','" + oModel.HBarCode + "','" + oModel.HAddr + "','" + oModel.HMaker + "',getdate()" +
|
//",'','', 0 " +
|
"," + oModel.HSourceInterID.ToString() + "," + oModel.HSourceEntryID.ToString() + ",'" + oModel.HSourceBillType + "','" + oModel.HSourceBillNo + "'" +
|
"," + oModel.HRelationInterID.ToString() + "," + oModel.HRelationEntryID.ToString() + ",'" + oModel.HRelationBillNo + "'," + Convert.ToString(oModel.HRedBlueFlag ? 1 : 0) + ")", ref DBUtility.ClsPub.sExeReturnInfo);
|
//修改上级为非末级代码
|
//oCn.RunProc("Update " + MvarItemKey + " set HEndflag=0 where HItemID=" + oModel.HParentID, ref DBUtility.ClsPub.sExeReturnInfo);
|
oCn.Commit();
|
oCn.CnClose();
|
oCn.CnDispose();
|
sReturn = "保存成功!";
|
return true;
|
}
|
catch (Exception e)
|
{
|
sReturn = e.Message;
|
oCn.RollBack();
|
throw (e);
|
}
|
}
|
|
|
|
//新增(盘点 扫仓库带出该仓库所有库存信息)
|
public bool AddNew_CheckStock(long HInterID, string HBillNo, string sBillType, long HWHID, long HSPID, ref string sReturn)
|
{
|
SQLHelper.ClsCN oCn = new SQLHelper.ClsCN();
|
try
|
{
|
oCn.BeginTran();
|
//批量新增
|
oCn.RunProc("exec h_p_Kf_CheckStock_Add " + HInterID.ToString() + ",'" + HBillNo + "','" + sBillType + "'," + HWHID.ToString() + "," + HSPID.ToString(), ref DBUtility.ClsPub.sExeReturnInfo);
|
oCn.Commit();
|
oCn.CnClose();
|
oCn.CnDispose();
|
sReturn = "保存成功!";
|
return true;
|
}
|
catch (Exception e)
|
{
|
sReturn = e.Message;
|
oCn.RollBack();
|
throw (e);
|
}
|
}
|
|
//新增(常规物料条码记录)
|
public bool AddNew_More_ChangGui(long HInterID, long HMaterID, string sBillType, double sQty, ref string sReturn)
|
{
|
SQLHelper.ClsCN oCn = new SQLHelper.ClsCN();
|
try
|
{
|
oCn.BeginTran();
|
//批量新增
|
oCn.RunProc("exec h_p_KF_PonderationBillMain_Temp_Add_ChangGui " + HInterID + ",'" + sBillType + "'," + HMaterID + "," + sQty, ref DBUtility.ClsPub.sExeReturnInfo);
|
oCn.Commit();
|
oCn.CnClose();
|
oCn.CnDispose();
|
sReturn = "保存成功!";
|
return true;
|
}
|
catch (Exception e)
|
{
|
sReturn = e.Message;
|
oCn.RollBack();
|
throw (e);
|
}
|
}
|
|
|
//新增
|
public override bool AddNew()
|
{
|
SQLHelper.ClsCN oCn = new SQLHelper.ClsCN();
|
try
|
{
|
oCn.BeginTran();
|
oCn.RunProc("Insert into " + MvarItemKey + " " +
|
" (HInterID,HBillNo,HBillType,HMaterID,HProcID,HWhID,HSCWHID" +
|
",HStockPlaceID,HOutStockPlaceID,HGroupID,HQty,HQtyMust,HPieceQty " +
|
",HBarCode,HAddr,HMaker,HMakeDate " +
|
",HSourceInterID,HSourceEntryID,HSourceBillType,HSourceBillNo" +
|
",HRelationInterID,HRelationEntryID,HRelationBillNo) " +
|
" Values(" + oModel.HInterID.ToString() + ",'" + oModel.HBillNo + "','" + oModel.HBillType + "'," + oModel.HMaterID.ToString() + "," + oModel.HProcID.ToString() + "," + oModel.HWhID.ToString() + "," + oModel.HSCWHID.ToString() +
|
"," + oModel.HStockPlaceID.ToString() + "," + oModel.HOutStockPlaceID.ToString() + "," + oModel.HGroupID.ToString() + "," + oModel.HQty.ToString() + "," + oModel.HQtyMust.ToString() + "," + oModel.HPieceQty.ToString() +
|
",'" + oModel.HBarCode + "','" + oModel.HAddr + "','" + oModel.HMaker + "',getdate()" +
|
"," + oModel.HSourceInterID.ToString() + "," + oModel.HSourceEntryID.ToString() + ",'" + oModel.HSourceBillType + "','" +oModel.HSourceBillNo+"'"+
|
"," + oModel.HRelationInterID.ToString() + "," + oModel.HRelationEntryID.ToString() + ",'" + oModel.HRelationBillNo + "')", ref DBUtility.ClsPub.sExeReturnInfo);
|
//修改上级为非末级代码
|
//oCn.RunProc("Update " + MvarItemKey + " set HEndflag=0 where HItemID=" + oModel.HParentID, ref DBUtility.ClsPub.sExeReturnInfo);
|
oCn.Commit();
|
oCn.CnClose();
|
oCn.CnDispose();
|
return true;
|
}
|
catch (Exception e)
|
{
|
oCn.RollBack();
|
throw (e);
|
}
|
}
|
|
//新增
|
public bool AddNew_More()
|
{
|
SQLHelper.ClsCN oCn = new SQLHelper.ClsCN();
|
try
|
{
|
oCn.BeginTran();
|
//箱号条码,批量新增
|
oCn.RunProc("exec h_p_KF_PonderationBillMain_Temp_Add " + oModel.HInterID.ToString() + "," + oModel.HWhID.ToString() + ",'" + oModel.HBillType + "','" + oModel.HBarCode + "'," + oModel.HSourceInterID.ToString() + "," + oModel.HSourceEntryID.ToString() + ",'" + oModel.HSourceBillType + "','" + oModel.HMaker + "'", ref DBUtility.ClsPub.sExeReturnInfo);
|
oCn.Commit();
|
oCn.CnClose();
|
oCn.CnDispose();
|
return true;
|
}
|
catch (Exception e)
|
{
|
oCn.RollBack();
|
throw (e);
|
}
|
}
|
|
public bool AddNew_Sell()
|
{
|
SQLHelper.ClsCN oCn = new SQLHelper.ClsCN();
|
try
|
{
|
DataSet oDs = new DataSet();
|
oCn.BeginTran();
|
oDs = oCn.RunProcReturn("select * from " + MvarItemKey + " where HInterID=" + oModel.HInterID.ToString() + " and HMaterID=" + oModel.HMaterID.ToString(), "KF_PonderationBillMain_Temp");
|
if (oDs == null || oDs.Tables[0].Rows.Count == 0)
|
{
|
return false;
|
}
|
else
|
{
|
//if (oModel.HBillType == "21")
|
//{
|
// oModel.HWhID = DBUtility.ClsPub.isLong(oDs.Tables[0].Rows[0]["HWhID"]);
|
//}
|
//else if (oModel.HBillType == "41")
|
//{
|
// oModel.HSCWHID = DBUtility.ClsPub.isLong(oDs.Tables[0].Rows[0]["HSCWhID"]);
|
//}
|
oModel.HQtyMust = DBUtility.ClsPub.isLong(oDs.Tables[0].Rows[0]["HQtyMust"]);
|
oModel.HSourceInterID = DBUtility.ClsPub.isLong(oDs.Tables[0].Rows[0]["HSourceInterID"]);
|
oModel.HSourceEntryID = DBUtility.ClsPub.isLong(oDs.Tables[0].Rows[0]["HSourceEntryID"]);
|
oModel.HSourceBillType = DBUtility.ClsPub.isStrNull(oDs.Tables[0].Rows[0]["HSourceBillType"]);
|
oModel.HSourceBillNo = DBUtility.ClsPub.isStrNull(oDs.Tables[0].Rows[0]["HSourceBillNo"]);
|
}
|
oCn.RunProc("Insert into " + MvarItemKey + " " +
|
" (HInterID,HBillNo,HBillType,HMaterID,HProcID,HWhID,HSCWHID" +
|
",HStockPlaceID,HOutStockPlaceID,HGroupID,HQty,HQtyMust,HPieceQty " +
|
",HBarCode,HAddr,HMaker,HMakeDate " +
|
",HSourceInterID,HSourceEntryID,HSourceBillType,HSourceBillNo" +
|
",HRelationInterID,HRelationEntryID,HRelationBillNo) " +
|
" Values(" + oModel.HInterID.ToString() + ",'" + oModel.HBillNo + "','" + oModel.HBillType + "'," + oModel.HMaterID.ToString() + "," + oModel.HProcID.ToString() + "," + oModel.HWhID.ToString() + "," + oModel.HSCWHID.ToString() +
|
"," + oModel.HStockPlaceID.ToString() + "," + oModel.HOutStockPlaceID.ToString() + "," + oModel.HGroupID.ToString() + "," + oModel.HQty.ToString() + "," + oModel.HQtyMust.ToString() + "," + oModel.HPieceQty.ToString() +
|
",'" + oModel.HBarCode + "','" + oModel.HAddr + "','" + oModel.HMaker + "',getdate()" +
|
"," + oModel.HSourceInterID.ToString() + "," + oModel.HSourceEntryID.ToString() + ",'" + oModel.HSourceBillType + "','" + oModel.HSourceBillNo + "'" +
|
"," + oModel.HRelationInterID.ToString() + "," + oModel.HRelationEntryID.ToString() + ",'" + oModel.HRelationBillNo + "')", ref DBUtility.ClsPub.sExeReturnInfo);
|
//修改上级为非末级代码
|
//oCn.RunProc("Update " + MvarItemKey + " set HEndflag=0 where HItemID=" + oModel.HParentID, ref DBUtility.ClsPub.sExeReturnInfo);
|
oCn.Commit();
|
oCn.CnClose();
|
oCn.CnDispose();
|
return true;
|
}
|
catch (Exception e)
|
{
|
oCn.RollBack();
|
throw (e);
|
}
|
}
|
|
//新增
|
public bool AddNew_More_Sell()
|
{
|
SQLHelper.ClsCN oCn = new SQLHelper.ClsCN();
|
try
|
{
|
oCn.BeginTran();
|
//箱号条码,批量新增
|
oCn.RunProc("exec h_p_KF_PonderationBillMain_Temp_Add_Sell " + oModel.HInterID.ToString() + ",'" + oModel.HBillNo + "','" + oModel.HBillType + "','" + oModel.HBarCode + "'," + oModel.HWhID.ToString() + "," + oModel.HSCWHID.ToString() + ",'" + oModel.HMaker + "'", ref DBUtility.ClsPub.sExeReturnInfo);
|
oCn.Commit();
|
oCn.CnClose();
|
oCn.CnDispose();
|
return true;
|
}
|
catch (Exception e)
|
{
|
oCn.RollBack();
|
throw (e);
|
}
|
}
|
|
//新增(一张单据,存在相同物料)
|
public bool AddNew_Select()
|
{
|
SQLHelper.ClsCN oCn = new SQLHelper.ClsCN();
|
try
|
{
|
DataSet oDs = new DataSet();
|
oCn.BeginTran();
|
oDs = oCn.RunProcReturn("select * from " + MvarItemKey + " where HInterID=" + oModel.HInterID.ToString() + " and HMaterID=" + oModel.HMaterID.ToString() + " and HSourceInterID=" + oModel.HSourceInterID + " and HSourceEntryID=" + oModel.HSourceEntryID, "KF_PonderationBillMain_Temp");
|
if (oDs == null || oDs.Tables[0].Rows.Count == 0)
|
{
|
return false;
|
}
|
else
|
{
|
//if (oModel.HBillType == "21")
|
//{
|
// oModel.HWhID = DBUtility.ClsPub.isLong(oDs.Tables[0].Rows[0]["HWhID"]);
|
//}
|
//else if (oModel.HBillType == "41")
|
//{
|
// oModel.HSCWHID = DBUtility.ClsPub.isLong(oDs.Tables[0].Rows[0]["HSCWhID"]);
|
//}
|
oModel.HQtyMust = DBUtility.ClsPub.isLong(oDs.Tables[0].Rows[0]["HQtyMust"]);
|
oModel.HSourceInterID = DBUtility.ClsPub.isLong(oDs.Tables[0].Rows[0]["HSourceInterID"]);
|
oModel.HSourceEntryID = DBUtility.ClsPub.isLong(oDs.Tables[0].Rows[0]["HSourceEntryID"]);
|
oModel.HSourceBillType = DBUtility.ClsPub.isStrNull(oDs.Tables[0].Rows[0]["HSourceBillType"]);
|
oModel.HSourceBillNo = DBUtility.ClsPub.isStrNull(oDs.Tables[0].Rows[0]["HSourceBillNo"]);
|
}
|
oCn.RunProc("Insert into " + MvarItemKey + " " +
|
" (HInterID,HBillNo,HBillType,HMaterID,HProcID,HWhID,HSCWHID" +
|
",HStockPlaceID,HOutStockPlaceID,HGroupID,HQty,HQtyMust,HPieceQty " +
|
",HBarCode,HAddr,HMaker,HMakeDate " +
|
",HSourceInterID,HSourceEntryID,HSourceBillType,HSourceBillNo" +
|
",HRelationInterID,HRelationEntryID,HRelationBillNo) " +
|
" Values(" + oModel.HInterID.ToString() + ",'" + oModel.HBillNo + "','" + oModel.HBillType + "'," + oModel.HMaterID.ToString() + "," + oModel.HProcID.ToString() + "," + oModel.HWhID.ToString() + "," + oModel.HSCWHID.ToString() +
|
"," + oModel.HStockPlaceID.ToString() + "," + oModel.HOutStockPlaceID.ToString() + "," + oModel.HGroupID.ToString() + "," + oModel.HQty.ToString() + "," + oModel.HQtyMust.ToString() + "," + oModel.HPieceQty.ToString() +
|
",'" + oModel.HBarCode + "','" + oModel.HAddr + "','" + oModel.HMaker + "',getdate()" +
|
"," + oModel.HSourceInterID.ToString() + "," + oModel.HSourceEntryID.ToString() + ",'" + oModel.HSourceBillType + "','" + oModel.HSourceBillNo + "'" +
|
"," + oModel.HRelationInterID.ToString() + "," + oModel.HRelationEntryID.ToString() + ",'" + oModel.HRelationBillNo + "')", ref DBUtility.ClsPub.sExeReturnInfo);
|
//修改上级为非末级代码
|
//oCn.RunProc("Update " + MvarItemKey + " set HEndflag=0 where HItemID=" + oModel.HParentID, ref DBUtility.ClsPub.sExeReturnInfo);
|
oCn.Commit();
|
oCn.CnClose();
|
oCn.CnDispose();
|
return true;
|
}
|
catch (Exception e)
|
{
|
oCn.RollBack();
|
throw (e);
|
}
|
}
|
|
//新增(一张单据,存在相同物料)
|
public bool AddNew_More_Select()
|
{
|
SQLHelper.ClsCN oCn = new SQLHelper.ClsCN();
|
try
|
{
|
oCn.BeginTran();
|
//箱号条码,批量新增
|
oCn.RunProc("exec h_p_KF_PonderationBillMain_Temp_Add_Select " + oModel.HInterID.ToString() + ",'" + oModel.HBillNo + "','" + oModel.HBillType + "','" + oModel.HBarCode + "','" + oModel.HMaker + "'," + oModel.HSourceInterID + "," + oModel.HSourceEntryID, ref DBUtility.ClsPub.sExeReturnInfo);
|
oCn.Commit();
|
oCn.CnClose();
|
oCn.CnDispose();
|
return true;
|
}
|
catch (Exception e)
|
{
|
oCn.RollBack();
|
throw (e);
|
}
|
}
|
|
//新增(出入库单据已经生成,需要关联条码记录时)
|
public bool AddNew_Check(ref string sReturn)
|
{
|
SQLHelper.ClsCN oCn = new SQLHelper.ClsCN();
|
try
|
{
|
oCn.BeginTran();
|
//箱号条码,批量新增
|
oCn.RunProc("exec h_p_KF_PonderationBillMain_Temp_Add_Check " + oModel.HInterID.ToString() + ",'" + oModel.HBillNo + "','" + oModel.HBillType + "'," + oModel.HMaterID.ToString() + "," + oModel.HQty.ToString() + ",'" + oModel.HBarCode + "','" + oModel.HMaker + "'," + Convert.ToString(oModel.HRedBlueFlag ? 1 : 0), ref DBUtility.ClsPub.sExeReturnInfo);
|
oCn.Commit();
|
oCn.CnClose();
|
oCn.CnDispose();
|
sReturn = "保存成功!";
|
return true;
|
}
|
catch (Exception e)
|
{
|
sReturn = e.Message;
|
oCn.RollBack();
|
throw (e);
|
}
|
}
|
|
//新增(常规物料条码记录)
|
public bool AddNew_More_ChangGui(long HInterID, long HMaterID, string sBillType, int sQty)
|
{
|
SQLHelper.ClsCN oCn = new SQLHelper.ClsCN();
|
try
|
{
|
oCn.BeginTran();
|
//批量新增
|
oCn.RunProc("exec h_p_KF_PonderationBillMain_Temp_Add_ChangGui " + HInterID + ",'" + sBillType + "'," + HMaterID + "," + sQty, ref DBUtility.ClsPub.sExeReturnInfo);
|
oCn.Commit();
|
oCn.CnClose();
|
oCn.CnDispose();
|
return true;
|
}
|
catch (Exception e)
|
{
|
oCn.RollBack();
|
throw (e);
|
}
|
}
|
|
//新增(常规物料条码记录)
|
public bool AddNew_More_ChangGui(long HInterID, long HMaterID, Int64 HAuxPropID, Int64 HWhID, Int64 HSPID, Int64 HSCWhID, Int64 HSCSPID, string HBatchNo, Int64 HSourceInterID, Int64 HSourceEntryID, string sBarCode, string sBillType, int sQty)
|
{
|
SQLHelper.ClsCN oCn = new SQLHelper.ClsCN();
|
try
|
{
|
oCn.BeginTran();
|
//批量新增
|
oCn.RunProc("exec h_p_KF_PonderationBillMain_Temp_Add_BatchNo " + HInterID + ",'" + sBillType + "'" +
|
"," + HMaterID +
|
"," + HAuxPropID +
|
"," + HWhID +
|
"," + HSPID +
|
"," + HSCWhID +
|
"," + HSCSPID +
|
",'" + HBatchNo + "'" +
|
"," + HSourceInterID +
|
"," + HSourceEntryID +
|
",'" + sBarCode + "'" +
|
"," + sQty, ref DBUtility.ClsPub.sExeReturnInfo);
|
oCn.Commit();
|
oCn.CnClose();
|
oCn.CnDispose();
|
return true;
|
}
|
catch (Exception e)
|
{
|
oCn.RollBack();
|
throw (e);
|
}
|
}
|
|
//减少(常规物料条码记录)
|
public bool AddNew_Clear_ChangGui(long HInterID, long HMaterID, Int64 HAuxPropID, Int64 HWhID, Int64 HSPID, Int64 HSCWhID, Int64 HSCSPID, string HBatchNo, Int64 HSourceInterID, Int64 HSourceEntryID, string sBarCode, string sBillType, int sQty)
|
{
|
SQLHelper.ClsCN oCn = new SQLHelper.ClsCN();
|
try
|
{
|
oCn.BeginTran();
|
//批量新增
|
oCn.RunProc("exec h_p_KF_PonderationBillMain_Temp_Clear_BatchNo " + HInterID + ",'" + sBillType + "'" +
|
"," + HMaterID +
|
"," + HAuxPropID +
|
"," + HWhID +
|
"," + HSPID +
|
"," + HSCWhID +
|
"," + HSCSPID +
|
",'" + HBatchNo + "'" +
|
"," + HSourceInterID +
|
"," + HSourceEntryID +
|
",'" + sBarCode + "'" +
|
"," + sQty, ref DBUtility.ClsPub.sExeReturnInfo);
|
oCn.Commit();
|
oCn.CnClose();
|
oCn.CnDispose();
|
return true;
|
}
|
catch (Exception e)
|
{
|
oCn.RollBack();
|
throw (e);
|
}
|
}
|
|
|
//修改
|
public override bool ModifyByID(Int64 sItemID)
|
{
|
SQLHelper.ClsCN oCn = new SQLHelper.ClsCN();
|
try
|
{
|
oCn.BeginTran();
|
//oCn.RunProc("Update " + MvarItemKey + " set " +
|
// " HNumber='" + oModel.HNumber + "'" +
|
// ",HName='" + oModel.HName + "'" +
|
// ",HShortNumber='" + oModel.HShortNumber + "'" +
|
// ",HHelpCode='" + oModel.HHelpCode + "'" +
|
// ",HLevel=" + oModel.HLevel.ToString() +
|
// ",HParentID=" + oModel.HParentID.ToString() +
|
// ",HEndflag=" + Convert.ToString(oModel.HEndFlag ? 1 : 0) +
|
// ",HStopflag=" + Convert.ToString(oModel.HStopflag ? 1 : 0) +
|
// ",HEnglishName='" + oModel.HEnglishName + "'" +
|
// ",HRemark= '" + oModel.HRemark + "' Where HItemID=" + sItemID, ref DBUtility.ClsPub.sExeReturnInfo);
|
//修改子项目代码
|
//oCn.RunProc("exec h_p_Gy_UpdateNumber '" + MvarItemKey + "','" + oModel.HNumber + ".','" + this.HOldNumber + ".'", ref DBUtility.ClsPub.sExeReturnInfo);
|
////将上级 为非末级
|
//oCn.RunProc("Update " + MvarItemKey + " set HEndflag=0 where HItemID=" + oModel.HParentID, ref DBUtility.ClsPub.sExeReturnInfo);
|
//
|
oCn.CnClose();
|
oCn.CnDispose();
|
oCn.Commit();
|
return true;
|
}
|
catch (Exception e)
|
{
|
oCn.RollBack();
|
throw (e);
|
}
|
}
|
//根据代码判断信息
|
public override bool HavParentCode(string sCode, Int64 sItemID)
|
{
|
DataSet DS;
|
try
|
{
|
//DS = oCn.RunProcReturn("Select * from " + MvarItemKey + " Where HStopflag=0 and HNumber='" + sCode + "' and HItemID<>" + sItemID, MvarItemKey, ref Pub_Class.ClsPub.sExeReturnInfo);
|
//if (DS.Tables[0].Rows.Count == 0)
|
// return false;
|
//else
|
//{
|
// oModel.HItemID = Convert.ToInt64(DS.Tables[0].Rows[0]["HItemID"]);
|
return true;
|
//}
|
}
|
catch (Exception e)
|
{
|
throw (e);
|
}
|
}
|
|
|
//判断条码临时表中是否存在
|
public bool IsBarCode(string sBarCode, long HInterID, string sBillType)
|
{
|
SQLHelper.ClsCN oCn = new SQLHelper.ClsCN();
|
DataSet DS;
|
try
|
{
|
DS = oCn.RunProcReturn("Select * from KF_PonderationBillMain_Temp Where HInterID=" + HInterID.ToString() + " and HBarCode='" + sBarCode + "' and HBillType='" + sBillType + "'", "KF_PonderationBillMain_Temp", ref DBUtility.ClsPub.sExeReturnInfo);
|
if (DS.Tables[0].Rows.Count == 0)
|
{
|
|
oCn.CnClose();
|
oCn.CnDispose();
|
return true; //不存在相同条码
|
}
|
else
|
{
|
oCn.CnClose();
|
oCn.CnDispose();
|
return false;
|
}
|
}
|
catch (Exception e)
|
{
|
throw (e);
|
}
|
}
|
|
////判断明细表中条码扫描数量是否超过条码本身额定数量
|
//public bool IsBarCode_Sub(long HInterID, string sBillType, long HMaterID, string HBatchNo, Int64 HSourceInterID, Int64 HSourceEntryID, ref string sReturn)
|
//{
|
// SQLHelper.ClsCN oCn = new SQLHelper.ClsCN();
|
// DataSet DS;
|
// DataSet DS2;
|
// string sBarCode;
|
// double sQty;
|
// string sWhere = "";
|
// try
|
// {
|
// DS = oCn.RunProcReturn("Select HBarCode,sum(HQty) HQty from KF_PonderationBillMain_Temp Where HQty<>0 and HInterID=" + HInterID.ToString() +
|
// " and HBillType='" + sBillType + "'" +
|
// " and HMaterID=" + HMaterID +
|
// " and (HBatchNo='" + HBatchNo + "' or '" + HBatchNo + "' ='')" +
|
// " and HSourceInterID=" + HSourceInterID +
|
// " and HSourceEntryID=" + HSourceEntryID +
|
// sWhere +
|
// " Group by HBarCode", "KF_PonderationBillMain_Temp", ref DBUtility.ClsPub.sExeReturnInfo);
|
|
// if (DS == null || DS.Tables[0].Rows.Count == 0)
|
// {
|
// oCn.CnClose();
|
// oCn.CnDispose();
|
// sReturn = "正常!";
|
// return true;
|
// }
|
// for (int i = 0; i <= DS.Tables[0].Rows.Count - 1; i++)
|
// {
|
// sBarCode = DBUtility.ClsPub.isStrNull(DS.Tables[0].Rows[i]["HBarCode"].ToString());
|
// sQty = DBUtility.ClsPub.isDoule(DS.Tables[0].Rows[i]["HQty"].ToString());
|
|
// DS2 = oCn.RunProcReturn("exec h_p_K3_IsBarCodeQty '" + sBarCode + "'," + sQty.ToString(), "h_p_K3_IsBarCodeQty", ref DBUtility.ClsPub.sExeReturnInfo);
|
// if (DS2.Tables[0].Rows.Count == 0 && DBUtility.ClsPub.isDoule(DS2.Tables[1].Rows[0]["HQty"]) >= sQty)
|
// {
|
// oCn.CnClose();
|
// oCn.CnDispose();
|
// sReturn = "正常!";
|
// return true;
|
// }
|
// else if (DBUtility.ClsPub.isDoule(DS2.Tables[0].Rows[0]["HQty"]) <= 0)
|
// {
|
// oCn.CnClose();
|
// oCn.CnDispose();
|
// sReturn = "条码" + sBarCode + "已被其他单据扫描!";
|
// return false;
|
// }
|
// else if (sQty > DBUtility.ClsPub.isDoule(DS2.Tables[0].Rows[0]["HQty"]))
|
// {
|
// oCn.CnClose();
|
// oCn.CnDispose();
|
// sReturn = "条码" + sBarCode + "的扫描数量" + sQty + "大于该条码未扫描数量" + DBUtility.ClsPub.isDoule(DS.Tables[0].Rows[0]["HQty"]) + "!";
|
// return false;
|
// }
|
// else
|
// {
|
|
// }
|
// }
|
// }
|
// catch (Exception e)
|
// {
|
// sReturn = e.Message;
|
// throw (e);
|
// }
|
// return false;
|
//}
|
|
//判断源单是否已核对过
|
public bool IsSourceBill(long sHInterID, string sHBillType)
|
{
|
SQLHelper.ClsCN oCn = new SQLHelper.ClsCN();
|
DataSet DS;
|
try
|
{
|
DS = oCn.RunProcReturn("Select * from Kf_ICStockBillSub_WMS Where HInterID=" + sHInterID.ToString() + " and HBillType='" + sHBillType + "'", "Kf_ICStockBillSub_WMS", ref DBUtility.ClsPub.sExeReturnInfo);
|
if (DS.Tables[0].Rows.Count == 0)
|
{
|
|
oCn.CnClose();
|
oCn.CnDispose();
|
return true; //未核对过
|
}
|
else
|
{
|
oCn.CnClose();
|
oCn.CnDispose();
|
return false;
|
}
|
}
|
catch (Exception e)
|
{
|
throw (e);
|
}
|
}
|
|
//删除条码出入库记录
|
public bool DeleteByICStockBill(Int64 sHInterID, string sHBillType)
|
{
|
try
|
{
|
oCn.RunProc("Delete from Kf_ICStockBillSub_WMS where HInterID=" + sHInterID.ToString() + " and HBillType='" + sHBillType + "'", ref DBUtility.ClsPub.sExeReturnInfo);
|
return true;
|
}
|
catch (Exception e)
|
{
|
throw (e);
|
}
|
}
|
|
//生成盘点单时 判断实际条码盘点数量和条码库存数量是否一致
|
public bool IsCheckStock_ICInventory(long sHInterID)
|
{
|
SQLHelper.ClsCN oCn = new SQLHelper.ClsCN();
|
DataSet DS;
|
try
|
{
|
DS = oCn.RunProcReturn(" exec h_p_Kf_CheckStockBill_ICInventory " + sHInterID, "h_p_Kf_CheckStockBill_ICInventory", ref DBUtility.ClsPub.sExeReturnInfo);
|
if (DBUtility.ClsPub.isDoule(DS.Tables[0].Rows[0][0]) == 0)
|
{
|
oCn.CnClose();
|
oCn.CnDispose();
|
return true;
|
}
|
else
|
{
|
oCn.CnClose();
|
oCn.CnDispose();
|
return false; //实际条码盘点数量和条码库存数量不一致
|
}
|
}
|
catch (Exception e)
|
{
|
throw (e);
|
}
|
}
|
|
// 回填条码临时表字段 HRelationInterID=1(条码出入库记录生成成功后回填)
|
public bool UpDateByRelationInterID(Int64 sHInterID, string sHBillType)
|
{
|
try
|
{
|
oCn.RunProc("UpDate KF_PonderationBillMain_Temp set HRelationInterID=1 Where HInterID=" + sHInterID.ToString() + " and HBillType='" + sHBillType + "'", ref DBUtility.ClsPub.sExeReturnInfo);
|
return true;
|
}
|
catch (Exception e)
|
{
|
throw (e);
|
}
|
}
|
|
|
|
|
//构造函数
|
public ClsKF_PonderationBillMain_Temp_Ctl()
|
{
|
MvarItemKey = "KF_PonderationBillMain_Temp";
|
MvarReportTitle = "出入库条码临时表";
|
oModel = new Model.ClsKF_PonderationBillMain_Temp();
|
}
|
}
|
}
|