UPDATE VS4TJobProductionM Set TJPMUsed=(1-TJPMUsed)
GO
UPDATE VS4TJobMaterial Set TJMtUseOrder=TJMtquantity-TJMtUseStock where TJMtUseOrder = 0 or TJMtUseOrder is null
GO
UPDATE VS4TJobMaterial Set TJMtUseOrder2=TJMtquantity2-TJMtUseStock2  where TJMtUseOrder2 = 0 or TJMtUseOrder2 is null
GO
UPDATE VS4TJobMaterial Set TJMtUseOrder3=TJMtquantity3-TJMtUseStock3  where TJMtUseOrder2 = 0 or TJMtUseOrder2 is null
GO
