解决方案: |
但能不能让"对应入库单号"项目显示真正的对应入库单号呢?方法还是有的,经分析发现,项目"对应入库单号"并不是直接从TransVouchs表中取cInVouchCode字段的值,而是通过视图transd取得数据的,这样就可以通过修改视图transd来显示真正的对应入库单号了。通过关联RdRecord表,以RdRecord.cCode取代transvouchs.cinvouchcode即可,视图的SQL语句如下:(以同样思路也可取到"对应出库单号")
ALTER view dbo.transd
as
select inventory.cinvname, inventory.cinvaddcode, inventory.creplaceitem,
inventory.cinvstd, inventory.cposition,
computationunit.ccomunitname as cinvm_unit, inventory.cinvdefine1,
inventory.cinvdefine2, inventory.cinvdefine3, inventory.cinvdefine4,
inventory.cinvdefine5, inventory.cinvdefine6, inventory.cinvdefine7,
inventory.cinvdefine8, inventory.cinvdefine9, inventory.cinvdefine10,
inventory.cinvdefine11, inventory.cinvdefine12, inventory.cinvdefine13,
inventory.cinvdefine14, inventory.cinvdefine15, inventory.cinvdefine16, inventory.iid,
transvouchs.ctvbatch, transvouchs.itvnum,
(case when inventory.igrouptype=1 then ComputationUnit2.iChangRate else
(case when inventory.igrouptype=0 then null else (case when (transvouchs.itvnum = 0 or
transvouchs.itvnum is null ) or (transvouchs.itvquantity = 0 or
transvouchs.itvquantity is null ) then null
else transvouchs.itvquantity / transvouchs.itvnum end) end)
end ) as iinvexchrate,
transvouchs.itvquantity, transvouchs.itvacost, transvouchs.itvaprice,
transvouchs.itvpcost, transvouchs.itvpprice, transvouchs.cfree1,
transvouchs.cfree2, transvouchs.cfree3, transvouchs.cfree4, transvouchs.cfree5,
transvouchs.cfree6, transvouchs.cfree7, transvouchs.cfree8, transvouchs.cfree9,
transvouchs.cfree10, computationunit2.ccomunitname as cinva_unit,
transvouchs.ctvcode, transvouchs.cinvcode, transvouchs.rdsid, transvouchs.id,
transvouchs.cbarcode, transvouchs.cassunit, transvouchs.ddisdate,
transvouchs.autoid, transvouchs.cdefine22, transvouchs.cdefine23,
transvouchs.cdefine24, transvouchs.cdefine25, transvouchs.cdefine26,
transvouchs.cdefine27, transvouchs.cdefine28, transvouchs.cdefine29,
transvouchs.cdefine30, transvouchs.cdefine31, transvouchs.cdefine32,
transvouchs.cdefine33, transvouchs.cdefine34, transvouchs.cdefine35,
transvouchs.cdefine36, transvouchs.cdefine37, transvouchs.citemcode,
transvouchs.impoids, transvouchs.citem_class, transvouchs.fsalecost,
transvouchs.fsaleprice, transvouchs.cname, transvouchs.citemcname,
transvouchs.imassdate,transvouchs.dmadedate,
transvouchs.cbvencode, RdIn.cCode as cInVouchCode, vendor .cvenname
from ((((transvouchs left join
inventory on transvouchs.cinvcode = inventory.cinvcode) left join
computationunit on inventory.ccomunitcode = computationunit.ccomunitcode) left
join
computationunit as computationunit2 on
transvouchs.cassunit = computationunit2.ccomunitcode) left join
vendor on transvouchs.cbvencode = vendor .cvencode) left join
(select rdrecord.cCode as cCode,rdrecords.itrids as itrids
from rdrecord inner join rdrecords on rdrecord.id=rdrecords.id
where rdrecord.brdflag=1 and csource='调拨'
and cvouchtype='08') as rdin on transvouchs.autoid=rdin.itrids
|