zoukankan      html  css  js  c++  java
  • ASP.NET 事务存储过程

    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);
                }
            }
    

      

  • 相关阅读:
    adodb.stream文件操作类详解
    Html中Label标记的作用和使用介绍
    正则表达式的威力轻松消除HTML代码
    只需一行代码就能让IE 6崩溃
    码农干货系列【17】Wind.js与Promise.js
    码农干货系列【3】割绳子(cut the rope)制作点滴:旋转(rotation)
    HTML5 Canvas开发者和读者的福音
    码农干货系列【8】世界上最简单的3D渲染(no webgl)
    码农干货系列【18】getting started with Promise.js(总)
    ProgressForm
  • 原文地址:https://www.cnblogs.com/LYshuqian/p/2169316.html
Copyright © 2011-2022 走看看