-------------------------------------------------------------
--存储过程的功能:对表 Category 进行添加、更新、删除操作。
-------------------------------------------------------------
--参数说明:
-------------------------------------------------------------
/*
@DataAction 添加更新删除的标志位
@c_id 自增ID
@c_type 类别
@c_title 类别标题
@parent_id 父类别ID
*/
CREATE PROCEDURE [dbo].[CreateUpdateDelete_CategoryEntity]
@DataAction int,
@c_id int = 0,
@c_type int,
@c_title nvarchar(100),
@parent_id int
AS
if @DataAction=0
begin
insert into Category
(
[c_type],
[c_title],
[parent_id]
)
values
(
@c_type,
@c_title,
@parent_id
)
set
@c_id=scope_identity()
end
if @DataAction=1
begin
UPDATE [Category] SET
[c_type] = @c_type,
[c_title] = @c_title,
[parent_id] = @parent_id
WHERE
[c_id] = @c_id
end
if @DataAction=2
begin
delete from [Category] where [c_id] = @c_id
end
select @c_id
GO