|
|
@ -249,8 +249,10 @@ namespace ICSSoft.DataProject |
|
|
|
WHILE @needqty>0 |
|
|
|
BEGIN |
|
|
|
|
|
|
|
select top 1 @qty = quantity,@lotno = lotno from #barcodetemp where invcode = (select invcode from #maintemp where transSequence = @transSequence AND DetailID = @DetailID) ORDER BY mtime |
|
|
|
IF(@needqty-@qty>=0) |
|
|
|
select top 1 @qty = isnull(quantity,0),@lotno = isnull(lotno,'') from #barcodetemp a |
|
|
|
RIGHT JOIN (select invcode from #maintemp where transSequence = @transSequence AND DetailID = @DetailID) b on a.invcode=b.invcode ORDER BY mtime |
|
|
|
BEGIN |
|
|
|
IF(@needqty-@qty>=0 and ISNULL(@lotno, '')<>'') |
|
|
|
BEGIN |
|
|
|
insert INTO #resulttemp (lotno,TransCode,DetailID,Sequence,TransSequence,IssueQuantity,Quantity, |
|
|
|
Amount,InvCode,InvName,InvStd,InvUnit,LocationQty,AmountUnit, |
|
|
@ -262,7 +264,7 @@ namespace ICSSoft.DataProject |
|
|
|
delete from #barcodetemp where lotno = @lotno |
|
|
|
SET @needqty=@needqty-@qty |
|
|
|
END |
|
|
|
ELSE |
|
|
|
ELSE IF(@needqty-@qty<0 and ISNULL(@lotno, '')<>'') |
|
|
|
BEGIN |
|
|
|
insert INTO #resulttemp (lotno,TransCode,DetailID,Sequence,TransSequence,IssueQuantity,Quantity, |
|
|
|
Amount,InvCode,InvName,InvStd,InvUnit,LocationQty,AmountUnit, |
|
|
@ -274,6 +276,19 @@ namespace ICSSoft.DataProject |
|
|
|
update #barcodetemp set quantity = @qty-@needqty where lotno = @lotno |
|
|
|
SET @needqty=@needqty-@qty |
|
|
|
END |
|
|
|
ELSE |
|
|
|
BEGIN |
|
|
|
insert INTO #resulttemp (lotno,TransCode,DetailID,Sequence,TransSequence,IssueQuantity,Quantity, |
|
|
|
Amount,InvCode,InvName,InvStd,InvUnit,LocationQty,AmountUnit, |
|
|
|
ExtensionID,ProjectCode,BatchCode, Version,Brand,cFree1,cFree2,cFree3,cFree4,cFree5,cFree6,cFree7,cFree8,cFree9,cFree10,WorkPoint) |
|
|
|
SELECT @lotno,TransCode,DetailID,Sequence,TransSequence,IssueQuantity, Quantity, |
|
|
|
ISNULL(Amount, 0),InvCode,InvName,ISNULL(InvStd, ''),InvUnit,0,ISNULL(AmountUnit, ''), |
|
|
|
ExtensionID,ProjectCode,BatchCode, Version,Brand,cFree1,cFree2,cFree3,cFree4,cFree5,cFree6,cFree7,cFree8,cFree9,cFree10,WorkPoint from #maintemp |
|
|
|
where #maintemp.transSequence = @transSequence AND DetailID = @DetailID |
|
|
|
|
|
|
|
SET @needqty=0 |
|
|
|
END |
|
|
|
END |
|
|
|
END |
|
|
|
FETCH NEXT FROM tempCursor INTO @transSequence,@DetailID; |
|
|
|
END |
|
|
@ -385,8 +400,10 @@ namespace ICSSoft.DataProject |
|
|
|
WHILE @needqty>0 |
|
|
|
BEGIN |
|
|
|
|
|
|
|
select top 1 @qty = quantity,@lotno = lotno from #barcodetemp where invcode = (select invcode from #maintemp where transSequence = @transSequence AND DetailID = @DetailID) ORDER BY mtime |
|
|
|
IF(@needqty-@qty>=0) |
|
|
|
select top 1 @qty = isnull(quantity,0),@lotno = isnull(lotno,'') from #barcodetemp a |
|
|
|
RIGHT JOIN (select invcode from #maintemp where transSequence = @transSequence AND DetailID = @DetailID) b on a.invcode=b.invcode ORDER BY mtime |
|
|
|
BEGIN |
|
|
|
IF(@needqty-@qty>=0 and ISNULL(@lotno, '')<>'') |
|
|
|
BEGIN |
|
|
|
insert INTO #resulttemp (lotno,TransCode,DetailID,Sequence,TransSequence,IssueQuantity,Quantity, |
|
|
|
Amount,InvCode,InvName,InvStd,InvUnit,LocationQty,AmountUnit, |
|
|
@ -398,7 +415,7 @@ namespace ICSSoft.DataProject |
|
|
|
delete from #barcodetemp where lotno = @lotno |
|
|
|
SET @needqty=@needqty-@qty |
|
|
|
END |
|
|
|
ELSE |
|
|
|
ELSE IF(@needqty-@qty<0 and ISNULL(@lotno, '')<>'') |
|
|
|
BEGIN |
|
|
|
insert INTO #resulttemp (lotno,TransCode,DetailID,Sequence,TransSequence,IssueQuantity,Quantity, |
|
|
|
Amount,InvCode,InvName,InvStd,InvUnit,LocationQty,AmountUnit, |
|
|
@ -410,6 +427,19 @@ namespace ICSSoft.DataProject |
|
|
|
update #barcodetemp set quantity = @qty-@needqty where lotno = @lotno |
|
|
|
SET @needqty=@needqty-@qty |
|
|
|
END |
|
|
|
ELSE |
|
|
|
BEGIN |
|
|
|
insert INTO #resulttemp (lotno,TransCode,DetailID,Sequence,TransSequence,IssueQuantity,Quantity, |
|
|
|
Amount,InvCode,InvName,InvStd,InvUnit,LocationQty,AmountUnit, |
|
|
|
ExtensionID,ProjectCode,BatchCode, Version,Brand,cFree1,cFree2,cFree3,cFree4,cFree5,cFree6,cFree7,cFree8,cFree9,cFree10,WorkPoint) |
|
|
|
SELECT @lotno,TransCode,DetailID,Sequence,TransSequence,IssueQuantity, Quantity, |
|
|
|
ISNULL(Amount, 0),InvCode,InvName,ISNULL(InvStd, ''),InvUnit,0,ISNULL(AmountUnit, ''), |
|
|
|
ExtensionID,ProjectCode,BatchCode, Version,Brand,cFree1,cFree2,cFree3,cFree4,cFree5,cFree6,cFree7,cFree8,cFree9,cFree10,WorkPoint from #maintemp |
|
|
|
where #maintemp.transSequence = @transSequence AND DetailID = @DetailID |
|
|
|
|
|
|
|
SET @needqty=0 |
|
|
|
END |
|
|
|
END |
|
|
|
END |
|
|
|
FETCH NEXT FROM tempCursor INTO @transSequence,@DetailID; |
|
|
|
END |
|
|
|