594
社区成员
发帖
与我相关
我的任务
分享
Begin Try
Begin TransAction
insert into TBSalesBarcode(Sales_ID,SBarcode_ID)
SELECT @Sales_ID as Sales_ID, ID FROM TBSBarcode WHERE (LBarcode_ID = @LBarcode_ID)
set @TmpROWCOUNT=@@ROWCOUNT
SELECT @SalesDetail_id=id FROM TBSalesDetail where [Sales_id]=@Sales_id and [ProductBatchNo_ID]=@ProductBatchNo_ID
if isnull(@SalesDetail_id,N'')=N''
BEGIN
insert into TBSalesDetail(Sales_ID,ProductBatchNo_ID,Qty,Price)
select @Sales_ID,@ProductBatchNo_ID, @TmpROWCOUNT,@Price
set @SalesDetail_ID=@@identity
END
ELSE
BEGIN
UPDATE TBSalesDetail SET Qty = Qty + @TmpROWCOUNT where ID=@SalesDetail_id and [ProductBatchNo_ID]=@ProductBatchNo_ID
END
SELECT @KNumber,@FitemID --检查参数赋值
update KingdeeOrder
set ActualQty=ActualQty+1
where KingdeeNumber=@KNumber and FitemID=@FitemID
UPDATE TBSBarcode SET State = '2' WHERE LBarcode_ID=@LBarcode_ID and (State = '1' ) and ( not ProductBatchNo_ID is null )
set @TmpROWCOUNT2=@@ROWCOUNT
if @TmpROWCOUNT2=0
BEGIN
SET @strErr='错误!!'
RAISERROR(16,1,'错误!!')
END
set @strErr=''
commit TransAction
End Try
Begin Catch
IF ISNULL(@strErr,'')=''
set @strErr='网络异常'
RAISERROR(16,1,@strErr)
Rollback TRANSACTION
End Catch
Begin Try
Begin TransAction
insert into TBSalesBarcode(Sales_ID,SBarcode_ID)
SELECT @Sales_ID as Sales_ID, ID FROM TBSBarcode WHERE (LBarcode_ID = @LBarcode_ID)
set @TmpROWCOUNT=@@ROWCOUNT
SELECT @SalesDetail_id=id FROM TBSalesDetail where [Sales_id]=@Sales_id and [ProductBatchNo_ID]=@ProductBatchNo_ID
if isnull(@SalesDetail_id,N'')=N''
BEGIN
insert into TBSalesDetail(Sales_ID,ProductBatchNo_ID,Qty,Price)
select @Sales_ID,@ProductBatchNo_ID, @TmpROWCOUNT,@Price
set @SalesDetail_ID=@@identity
END
ELSE
BEGIN
UPDATE TBSalesDetail SET Qty = Qty + @TmpROWCOUNT where ID=@SalesDetail_id and [ProductBatchNo_ID]=@ProductBatchNo_ID
END
update KingdeeOrder
set ActualQty=ActualQty+1
where KingdeeNumber=@KNumber and FitemID=@FitemID
UPDATE TBSBarcode SET State = '2' WHERE LBarcode_ID=@LBarcode_ID and (State = '1' ) and ( not ProductBatchNo_ID is null )
set @TmpROWCOUNT2=@@ROWCOUNT
if @TmpROWCOUNT2=0
BEGIN
Rollback TransAction
set @strErr= '错误!!'
END
else
BEGIN
set @strErr=''
commit TransAction
end
End Try
Begin Catch
Rollback TransAction
set @strErr='网络异常'
End Catch
if isnull(@strErr,N'')<>N''
BEGIN
return
END
END