日期:2014-05-18 浏览次数:20453 次
create proc DingDan_Add ( @VIPID varchar(50), @TaoXiID int, @ShopID int, @TaoXiText nvarchar(1000), @Time1 varchar(50), @Time2 varchar(50), @Time3 varchar(50), @BeiZhu nvarchar(1000), @DD_Type int, @DD_PayType int, @DD_Money float, @End int, @Give int, @ZengSongID int, --以下为Pay表数据 @Pay_Money float, @InTime datetime, @JingShou int, @P1 int, @P2 int, @P3 int, @P4 int, @Pay_Type int, @Pay_PayType int ) as DECLARE @Error_DingDan int,@Error_Pay int,@Error_EditVIPScore int,@Error_ZengSong int,@Error_ZengSongDingDan int,@DingDanID int,@ZengSongDingDanID int,@ZengSongTaoXiText nvarchar(1000) begin transaction DingDan insert DingDan values(@VIPID,@TaoXiID,@ShopID,@TaoXiText,@Time1,@Time2,@Time3,@BeiZhu,@DD_Type,@DD_PayType,@DD_Money,@End,@Give) Set @DingDanID=@@identity Set @Error_DingDan=@@Error if(@ZengSongID>0) Set @ZengSongTaoXiText=(select T_Text from TaoXi where T_ID=@ZengSongID) if(@ZengSongID>0) insert DingDan values(@VIPID,@ZengSongID,@ShopID,@ZengSongTaoXiText,'','','','',@DD_Type,0,0,@End,0) Set @ZengSongDingDanID=@@identity Set @Error_ZengSongDingDan=@@Error if(@ZengSongID>0) insert ZengSong values(@DingDanID,@ZengSongDingDanID) Set @Error_ZengSong=@@Error insert Pay values(@DingDanID,@Pay_Money,@InTime,@JingShou,@P1,@P2,@P3,@P4,@Pay_Type,@Pay_PayType) Set @Error_Pay=@@Error update VIP Set V_Score=V_Score+@Pay_Money where V_ID=@VIPID Set @Error_EditVIPScore=@@Error if @Error_DingDan>0 or @Error_Pay>0 or @Error_EditVIPScore>0 or @Error_ZengSong>0 or @Error_ZengSongDingDan>0 begin Rollback transaction DingDan end else commit transaction DingDan go