解决方案: |
在未出补丁时可用以下办法暂时解决,即修改存储过程SA_CancelSureFHD后当审核期初发货单时软件会报期初发货单不能弃审!
/* 江苏省药材公司
期初发货单能弃审
2003-07-07
南京用友维护部 丁德安
*/
IF EXISTS(SELECT * FROM sysobjects WHERE name='SA_CancelSureFHD' and type='P')
DROP PROC SA_CancelSureFHD
GO
CREATE PROC SA_CancelSureFHD(
@VouchType as varchar(3),
@VouchID As Int)
AS
--删除出库单、删除货位、修改现存量
Declare @AutoID As Int
Declare @cWhCode As Varchar(10)
Declare @cInvCode As Varchar(20)
Declare @cFree1 As Varchar(20)
Declare @cFree2 As Varchar(20)
Declare @iQuantity As Float
Declare @iNum As Float
Declare @iDispQuantity As Float
Declare @iDispNum As Float
/* 增加判断条件
判断是否为期初发货单,即RdRecord.cVouchtype='34'
如为期初发货单则不能弃审
2003-07-07
*/
Declare @cVouchType as varchar(10)
SELECT DISTINCT @cVouchType=r.cVouchType FROM RdRecord r inner join rdrecords rs on r.id=rs.id inner join
DispatchLists ds on rs.iDLsID=ds.iDLsID inner join DispatchList d on d.DLID=ds.DLID
WHERE d.DLID=@VouchID
IF @cVouchType='34'
Begin
SELECT 0 AS iRet,'期初发货单不能弃审!' AS Info
Return
End
--弃审时如果生成的是红字销售出库单则如果指定了货位,就不能弃审
--在删除货位结存时要判断不等于'货位调整'
--SET @AutoID=(SELECT Count(AutoID) FROM RdRecord INNER JOIN RdRecords ON RdRecord.ID=RdRecords.ID
-- WHERE cVouchType='32' AND bRdFlag=0 AND iQuantity<0 AND RdRecord.cDLCode = @VouchID
-- AND AutoID IN (SELECT RdsID FROM InvPosition WHERE IsNull(cSource,'')=''))
--If IsNull(@AutoID,0)=0
-- Begin
--删除货位
if @VouchType='FHD' OR @VouchType='WT'
if @VouchType='FHD'
DELETE FROM InvPosition WHERE IsNull(cSource,'')='' AND RdsID IN
(SELECT RdRecords.AutoID FROM (RdRecord INNER JOIN RdRecords ON RdRecord.ID=RdRecords.ID) inner join dispatchlists on rdrecords.idlsid=dispatchlists.idlsid WHERE DLID = @VouchID AND cVouchType='32')
Else
DELETE FROM InvPosition WHERE IsNull(cSource,'')='' AND RdsID IN
(SELECT RdRecords.AutoID FROM (RdRecord INNER JOIN RdRecords ON RdRecord.ID=RdRecords.ID) inner join EnDispatchs on rdrecords.iEnsid=EnDispatchs.AutoID WHERE EDID = @VouchID AND cVouchType='32')
else
DELETE FROM InvPosition WHERE IsNull(cSource,'')='' AND RdsID IN
(SELECT RdRecords.AutoID FROM (RdRecord INNER JOIN RdRecords ON RdRecord.ID=RdRecords.ID) inner join salebillvouchs on rdrecords.isbsid=salebillvouchs.autoid WHERE sbvid = @VouchID AND cVouchType='32')
--修改现存量表
if @VouchType='FHD' OR @VouchType='WT'
if @VouchType='FHD'
DECLARE cur_CurrentStock CURSOR FOR
SELECT DispatchLists.cWhCode,DispatchLists.cInvCode,DispatchLists.cFree1,DispatchLists.cFree2,Rdrecords.iQuantity,RdRecords.iNum,DispatchLists.iQuantity,DispatchLists.iNum
FROM (RdRecord INNER JOIN RdRecords ON RdRecord.ID = RdRecords.ID) inner join DispatchLists on dispatchlists.idlsid=rdrecords.idlsid
WHERE DLID = @VouchID AND cVouchType='32' AND cBusType<>'委托代销'
FOR READ ONLY
Else
DECLARE cur_CurrentStock CURSOR FOR
SELECT EnDispatchs.cWhCode,EnDispatchs.cInvCode,EnDispatchs.cFree1,EnDispatchs.cFree2,Rdrecords.iQuantity,RdRecords.iNum,EnDispatchs.iQuantity,EnDispatchs.iNum
FROM (RdRecord INNER JOIN RdRecords ON RdRecord.ID = RdRecords.ID) inner join EnDispatchs on EnDispatchs.AutoID=rdrecords.iEnsid
WHERE EDID = @VouchID AND cVouchType='32'
FOR READ ONLY
else
DECLARE cur_CurrentStock CURSOR FOR
SELECT Salebillvouchs.cWhCode,Salebillvouchs.cInvCode,Salebillvouchs.cFree1,Salebillvouchs.cFree2,Rdrecords.iQuantity,RdRecords.iNum,Salebillvouchs.iQuantity,Salebillvouchs.iNum
FROM (RdRecord INNER JOIN RdRecords ON RdRecord.ID = RdRecords.ID) inner join Salebillvouchs on Salebillvouchs.autoid=rdrecords.isbsid
WHERE sbvid = @VouchID AND cVouchType='32'
FOR READ ONLY
OPEN cur_CurrentStock
FETCH NEXT FROM cur_CurrentStock INTO @cWhCode,@cInvCode,@cFree1,@cFree2,@iQuantity,@iNum,@iDispQuantity,@iDispNum
WHILE @@FETCH_STATUS>=0
Begin
-- If @VouchType='WT'
-- UPDATE CurrentStock SET fOutQuantity=cast(isnull(fOutQuantity,0)+@iDispQuantity as decimal(20,6)),fOutNum=cast(isnull(fOutNum,0)+@iDispNum as decimal(20,6)),
-- iQuantity=cast(isnull(iQuantity,0)+@iQuantity as decimal(20,6)),iNum=cast(isnull(iNum,0)+@iNum as decimal(20,6))
-- WHERE cWhCode = @cWhCode AND cInvCode = @cInvCode AND IsNull(cFree1,'') = IsNull(@cFree1,'') AND IsNull(cFree2,'') = IsNull(@cFree2,'')
-- Else
If @iDispQuantity>0
UPDATE CurrentStock SET fOutQuantity=cast(isnull(fOutQuantity,0)+@iDispQuantity as decimal(20,6)),fOutNum=cast(isnull(fOutNum,0)+@iDispNum as decimal(20,6)),
iQuantity=cast(isnull(iQuantity,0)+@iQuantity as decimal(20,6)),iNum=cast(isnull(iNum,0)+@iNum as decimal(20,6))
WHERE cWhCode = @cWhCode AND cInvCode = @cInvCode AND IsNull(cFree1,'') = IsNull(@cFree1,'') AND IsNull(cFree2,'') = IsNull(@cFree2,'')
Else
UPDATE CurrentStock SET fInQuantity=cast(isnull(fInQuantity,0)+Abs(@iDispQuantity) as decimal(20,6)),fInNum=cast(isnull(fInNum,0)+Abs(@iDispNum) as decimal(20,6)),
iQuantity=cast(isnull(iQuantity,0)-Abs(@iQuantity) as decimal(20,6)),iNum=cast(isnull(iNum,0)-Abs(@iNum) as decimal(20,6))
WHERE cWhCode = @cWhCode AND cInvCode = @cInvCode AND IsNull(cFree1,'') = IsNull(@cFree1,'') AND IsNull(cFree2,'') = IsNull(@cFree2,'')
If @@Error<>0
Begin
SELECT 0 AS iRet,'修改现存量错!' AS Info
Return
End
FETCH NEXT FROM cur_CurrentStock INTO @cWhCode,@cInvCode,@cFree1,@cFree2,@iQuantity,@iNum,@iDispQuantity,@iDispNum
End
CLOSE cur_CurrentStock
DEALLOCATE cur_CurrentStock
if @VouchType='FHD' OR @VouchType='WT'
if @VouchType='FHD'
DELETE FROM RdRecords WHERE IsNull(iEnsID,0)=0 And iDLsID IN (SELECT iDLsID FROM DispatchLists WHERE DLID=@VouchID)
Else
DELETE FROM RdRecords WHERE IsNull(iEnsID,0)<>0 And iEnsID IN (SELECT AutoID FROM EnDispatchs WHERE EDID=@VouchID)
else
DELETE FROM RdRecords WHERE iSBsid IN (SELECT autoid FROM salebillvouchs WHERE sbvid=@VouchID)
If @@Error<>0
Begin
SELECT 0 AS iRet,'删除出库单表体记录错!' AS Info
Return
End
--if @VouchType='FHD'
delete from rdrecord where id in (select rdrecord.id from rdrecord left join rdrecords on rdrecord.id=rdrecords.id where rdrecords.id is null)
--else
-- DELETE FROM RdRecord WHERE cBillCode = @VouchID AND cVouchType='32'
If @@Error<>0
Begin
SELECT 0 AS iRet,'删除出库单表头记录错!' AS Info
Return
End
-- End
--Else
-- Begin
-- SELECT 0 AS iRet,'号发货单对应的红字出库单已经指定货位,不能弃审!' AS Info
-- Return
-- End
if @VouchType='FHD' OR @VouchType='WT'
if @VouchType='FHD'
UPDATE DispatchList SET cSaleOut='' WHERE DLID=@VouchID
Else
UPDATE EnDispatch SET cSaleOut='' WHERE EDID=@VouchID
else
UPDATE Salebillvouch SET cSaleOut='' WHERE SBVID=@VouchID
If @@Error<>0
Begin
SELECT 0 AS iRet,'修改发货单错!' AS Info
Return
End
SELECT 1 AS iRet,'' As Info
Return
|