|  |  |  | 
|---|
|  |  |  | oCN.RunProc($"update b  set b.HQty=b.HQty+{listCa[i].本次拣料数量} from JIT_SendGoodsBillMain a  with(nolock) inner join JIT_SendGoodsBillSub b with(nolock) on a.HInterID = b.HInterID  " + | 
|---|
|  |  |  | $"where  HMainSourceInterID ={SourceInterID} and b.HMaterID ={listCa[i].HMaterID} and a.HBillStatus =1 "); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | //修改调拨数量 | 
|---|
|  |  |  | oCN.RunProc($"update JIT_ComplementGoodsBillSub_LK set HSendQTY=HSendQTY+{listCa[i].本次拣料数量} where HMaterID={listCa[i].HMaterID} " + | 
|---|
|  |  |  | $" and HSourceInterID=(select top 1 HSourceInterID from JIT_ComplementGoodsBillSub_LK " + | 
|---|
|  |  |  | $"where HMaterID={listCa[i].HMaterID}  and HInterID={SourceInterID} order by HSourceInterID )  and HInterID={SourceInterID} "); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | DataSet dsTable = new DataSet(); | 
|---|
|  |  |  | //查询JIT_ComplementGoodsBillSub_LK | 
|---|
|  |  |  | dsTable = oCN.RunProcReturn($"select  * from JIT_ComplementGoodsBillSub_LK where HMaterID={listCa[i].HMaterID}  and HInterID={SourceInterID} order by HSourceInterID ", "JIT_ComplementGoodsBillSub_LK"); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | for (int j = 0; j < dsTable.Tables[0].Rows.Count; j++) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | if (double.Parse(dsTable.Tables[0].Rows[j]["HCallQTY"].ToString()) != double.Parse(dsTable.Tables[0].Rows[j]["HSendQTY"].ToString())) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | if (double.Parse(dsTable.Tables[0].Rows[j]["HSendQTY"].ToString()) + listCa[i].本次拣料数量 > double.Parse(dsTable.Tables[0].Rows[j]["HCallQTY"].ToString())) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | var HCallQTY = double.Parse(dsTable.Tables[0].Rows[j]["HCallQTY"].ToString()) - double.Parse(dsTable.Tables[0].Rows[j]["HSendQTY"].ToString()); | 
|---|
|  |  |  | //修改调拨数量 超出部分给予下一列数据 | 
|---|
|  |  |  | oCN.RunProc($"update JIT_ComplementGoodsBillSub_LK set HSendQTY=HSendQTY+{HCallQTY} where HMaterID={listCa[i].HMaterID} " + | 
|---|
|  |  |  | $" and HSourceInterID={double.Parse(dsTable.Tables[0].Rows[j]["HSourceInterID"].ToString())} and HInterID={SourceInterID} "); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | oCN.RunProc($"update JIT_ComplementGoodsBillSub_LK set HSendQTY=HSendQTY+{(listCa[i].本次拣料数量 - HCallQTY)} where HMaterID={listCa[i].HMaterID} " + | 
|---|
|  |  |  | $" and HSourceInterID={dsTable.Tables[0].Rows[j + 1]["HSourceInterID"].ToString()} and HInterID={SourceInterID} "); | 
|---|
|  |  |  | break; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | else | 
|---|
|  |  |  | { | 
|---|
|  |  |  | //修改调拨数量 | 
|---|
|  |  |  | oCN.RunProc($"update JIT_ComplementGoodsBillSub_LK set HSendQTY=HSendQTY+{listCa[i].本次拣料数量} where HMaterID={listCa[i].HMaterID} " + | 
|---|
|  |  |  | $" and HSourceInterID={dsTable.Tables[0].Rows[j]["HSourceInterID"].ToString()} and HInterID={SourceInterID} "); | 
|---|
|  |  |  | break; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | sReturn = "新增单据成功!"; | 
|---|