set ANSI_NULLS ON set QUOTED_IDENTIFIER ON go ALTER procedure [dbo].[proc_newOfferKongmingdeng] @userid int, @username varchar(20), @usename varchar(20)='', @dengnum varchar(50), @dengtype bigint, @dengshopid bigint, @wishcontent varchar(350), @x varchar(20), @y varchar(20) as begin declare @num as int set @num=01000; begin tran select @num=max(number)+1 from kongmingdeng if(@num is null) set @num=0; insert into kongmingdeng(userid,username,usename,dengnum,dengtype, dengshopid,wishcontent,addtime,x,y,number) values(@userid,@username,@usename,@dengnum,@dengtype,@dengshopid, @wishcontent,getdate(),@x,@y,@num) commit tran end public static bool newOfferKongmingdeng(kongmingdeng den,SqlTransaction Tran) { SqlParameter[] Parameters = new SqlParameter[] { new SqlParameter("@userid",SqlDbType.Int,10), new SqlParameter("@username",SqlDbType.VarChar,20), new SqlParameter("@usename",SqlDbType.VarChar,20), new SqlParameter("@dengnum",SqlDbType.VarChar,50), new SqlParameter("@dengtype",SqlDbType.BigInt), new SqlParameter("@dengshopid",SqlDbType.BigInt), new SqlParameter("@wishcontent",SqlDbType.VarChar,350), new SqlParameter("@x",SqlDbType.VarChar,20), new SqlParameter("@y",SqlDbType.VarChar,20) }; Parameters[0].Value = den.Userid; Parameters[1].Value = den.Username; Parameters[2].Value = den.Usename; Parameters[3].Value = den.Dengnum; Parameters[4].Value = den.Dengtype; Parameters[5].Value = den.Dengshopid; Parameters[6].Value = den.Wishcontent; Parameters[7].Value = den.X; Parameters[8].Value = den.Y; try { BDA.Provider Provider = new Heaven.BaseDataAccess.Provider(); return Provider.ExcuteNonQuery(Tran, "proc_newOfferKongmingdeng", Parameters, CommandType.StoredProcedure) > 0 ? true : false; } catch (Exception e) { throw new Exception(e.Message); } } public static int OfferKonMingDengFromStoreBox(kongmingdeng kon,storebox storebox) { BDA.Provider Provider = new Heaven.BaseDataAccess.Provider(); SqlTransaction Tran = Provider.BeginTran(); try { storebox store= StoreBoxDA.GetstoreboxById(storebox.Storeid,storebox.Userid); if(store==null || store.Shopid!=kon.Dengshopid) { Tran.Rollback(); return -1; } kon.Dengtype = store.Typeid; if (newOfferKongmingdeng(kon, Tran) == false) { Tran.Rollback(); return -2; } if (StoreBoxDA.getProductFromStoreBox_(storebox, Tran) == false) { Tran.Rollback(); return -3; } Tran.Commit(); return 1; } catch (Exception e) { Tran.Rollback(); throw new Exception(e.Message); } }