if update(prod_id) or update(unit_id)
begin
update sto_io_detail
set unit_specs = dbo.f_get_prod_unit_specs(i.prod_id,i.unit_id),
unit_weight = dbo.f_get_prod_unit_weight(i.prod_id,i.unit_id),
unit_weight_net = dbo.f_get_prod_unit_weight_net(i.prod_id,i.unit_id),
unit_cube = dbo.f_get_prod_unit_cube(i.prod_id,i.unit_id)
from sto_io_detail sd, inserted i
where sd.iden_id = i.iden_id
if @@error <> 0
begin
raiserror('更新出入库明细档包装单位信息出错!',16,1)
return
end
end
if (update(status_flag) or update(io_type_id) or update(comp_id) or update(store_id) or update(site_id) or update(prod_id) or update(batch_id) or update(color_id) or update(unit_id) or update(unit_specs) or update(io_num) or update(price) ) --add by yy 2003-8-6
begin
declare io_cursor cursor for
select d.comp_id, d.store_id, d.site_id, d.prod_id, d.batch_id, d.color_id, d.unit_id, d.unit_specs,
d.io_num, d.status_flag, pt.io_flag, 'D' ,d.price --add by yy 2003-8-6
from deleted d, pub_io_type pt
where d.comp_id = pt.comp_id and
d.io_type_id = pt.io_type_id and
d.status_flag in ('NA', 'YA') and
d.unit_specs > 0
union all
select i.comp_id, i.store_id, i.site_id, i.prod_id, i.batch_id, i.color_id, i.unit_id, i.unit_specs,
i.io_num, i.status_flag, pt.io_flag, 'I' ,i.price --add by yy 2003-8-6
from inserted i, pub_io_type pt
where i.comp_id = pt.comp_id and
i.io_type_id = pt.io_type_id and
i.status_flag in ('NA', 'YA') and
i.unit_specs > 0
open io_cursor
if @@error <> 0
begin
close io_cursor
deallocate io_cursor
raiserror('打开游标错误!',16,1)
return
end
if update(status_flag) or update(store_id) or update(io_type_id)
begin
update sto_io_detail
set status_flag = i.status_flag,
store_id = i.store_id,
io_type_id = i.io_type_id
from sto_io_detail sd, inserted i
where sd.comp_id = i.comp_id and
sd.io_id = i.io_id
end
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[FK_sto_io_detail_sto_io_master]') and OBJECTPROPERTY(id, N'IsForeignKey') = 1)
ALTER TABLE [dbo].[sto_io_detail] DROP CONSTRAINT FK_sto_io_detail_sto_io_master
GO
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[sto_io_detail]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[sto_io_detail]
GO
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[sto_io_master]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[sto_io_master]
GO
CREATE TABLE [dbo].[sto_io_detail] (
[iden_id] [int] IDENTITY (1, 1) NOT NULL ,
[iden_order_detail_id] [int] NULL ,
[comp_id] varchar(24) NOT NULL ,
[io_id] varchar(24) NOT NULL ,
[order_id] varchar(24) NULL ,
[prod_id] varchar(24) NOT NULL ,
[color_id] varchar(24) NOT NULL ,
[batch_id] varchar(24) NOT NULL ,
[site_id] varchar(24) NOT NULL ,
[unit_id] varchar(24) NOT NULL ,
[unit_specs] [money] NULL ,
[unit_weight] [money] NOT NULL ,
[unit_weight_net] [money] NOT NULL ,
[unit_cube] [money] NOT NULL ,
[avail_num] [money] NULL ,
[plan_num] [money] NOT NULL ,
[io_num] [money] NOT NULL ,
[price] [money] NOT NULL ,
[relating_id] varchar(24) NULL ,
[relating_num] [money] NULL ,
[consign_bal_num] [money] NOT NULL ,
[consign_bal_flag] char(2) NOT NULL ,
[status_flag] char(2) NULL ,
[io_type_id] varchar(24) NULL ,
[tax_rate] [money] NOT NULL ,
[utax_amt] [money] NOT NULL ,
[tax_amt] [money] NOT NULL ,
[store_id] varchar(24) NULL ,
[amt] AS ([utax_amt] + [tax_amt]) ,
[sale_cost] [money] NULL ,
[view026_flag] [int] NULL ,
[view027_flag] [int] NULL ,
[view038_flag] [int] NULL ,
[iden_fit_detail_id] [int] NULL ,
[remark] varchar(255) NULL ,
[batch_rage] [varchar] (50) COLLATE Chinese_PRC_CI_AS NULL
) ON [PRIMARY]
GO