当前位置: 首页>>代码示例>>C#>>正文


C# SqlTransaction类代码示例

本文整理汇总了C#中SqlTransaction的典型用法代码示例。如果您正苦于以下问题:C# SqlTransaction类的具体用法?C# SqlTransaction怎么用?C# SqlTransaction使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


SqlTransaction类属于命名空间,在下文中一共展示了SqlTransaction类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: BatchInsert

        /// <summary>
        /// 批量插入订单商品促销信息
        /// </summary>
        /// <param name="productPromotes">促销信息列表</param>
        /// <param name="transaction">数据库事务</param>
        /// <returns>插入的记录数</returns>
        public int BatchInsert(List<Order_Product_Promote> productPromotes, SqlTransaction transaction)
        {
            if (productPromotes != null && productPromotes.Count > 0)
            {
                var dt = this.BuildDataTable(productPromotes);

                var paramsList = new List<SqlParameter>
                                     {
                                         new SqlParameter("OPP", SqlDbType.Structured)
                                             {
                                                 TypeName =
                                                     "[dbo].OrderProductPromoteTable",
                                                 Value = dt,
                                                 Direction =
                                                     ParameterDirection
                                                     .Input
                                             },
                                         this.SqlServer.CreateSqlParameter(
                                             "Count",
                                             SqlDbType.Int,
                                             null,
                                             ParameterDirection.Output)
                                     };

                this.SqlServer.ExecuteNonQuery(
                    CommandType.StoredProcedure,
                    "sp_Order_Product_Promote_BatchInsert",
                    paramsList,
                    transaction);

                return (int)paramsList.Find(parameter => parameter.ParameterName == "Count").Value;
            }
            throw new NotImplementedException();
        }
开发者ID:jxzly229190,项目名称:OnlineStore,代码行数:40,代码来源:OrderProductPromoteDA.cs

示例2: DeleteByID

        /// <summary>
        /// 删除指定角色编号的角色权限关系
        /// </summary>
        /// <param name="roleID">
        /// 角色编号
        /// </param>
        /// <param name="transaction">
        /// 事务对象
        /// </param>
        public void DeleteByID(int roleID, out SqlTransaction transaction)
        {
            if (roleID <= 0)
            {
                throw new ArgumentNullException("roleID");
            }

            var parameters = new List<SqlParameter>
                                 {
                                     this.SqlServer.CreateSqlParameter(
                                         "RoleID",
                                         SqlDbType.Int,
                                         roleID,
                                         ParameterDirection.Input)
                                 };

            try
            {
                this.SqlServer.BeginTransaction();
                transaction = this.SqlServer.Transaction;

                this.SqlServer.ExecuteNonQuery(CommandType.StoredProcedure, "sp_System_Role_Permission_DeleteRow", parameters, transaction);
            }
            catch (Exception exception)
            {
                throw new Exception(exception.Message, exception);
            }
        }
开发者ID:jxzly229190,项目名称:OnlineStore,代码行数:37,代码来源:SystemRolePermissionDA.cs

示例3: Insert

        /// <summary>
        /// 添加满额优惠活动范围.
        /// </summary>
        /// <param name="promoteMeetMoneyScope">
        /// Promote_MeetMoney_Scope 的对象实例.
        /// </param>
        /// <param name="transaction">
        /// 数据事务.
        /// </param>
        /// <returns>
        /// 满额优惠活动范围编号.
        /// </returns>
        public int Insert(Promote_MeetMoney_Scope promoteMeetMoneyScope, SqlTransaction transaction)
        {
            if (promoteMeetMoneyScope == null)
            {
                throw new ArgumentNullException("promoteMeetMoneyScope");
            }

            var parameters = new List<SqlParameter>
                                 {
                                     this.SqlServer.CreateSqlParameter(
                                         "MeetMoneyID",
                                         SqlDbType.Int,
                                         promoteMeetMoneyScope.MeetMoneyID,
                                         ParameterDirection.Input),
                                     this.SqlServer.CreateSqlParameter(
                                         "Scope",
                                         SqlDbType.VarChar,
                                         promoteMeetMoneyScope.Scope,
                                         ParameterDirection.Input),
                                     this.SqlServer.CreateSqlParameter(
                                         "ReferenceID",
                                         SqlDbType.Int,
                                         null,
                                         ParameterDirection.Output)
                                 };

            this.SqlServer.ExecuteNonQuery(
                CommandType.StoredProcedure,
                "sp_Promote_MeetMoney_Scope_Insert",
                parameters,
                null);
            return (int)parameters.Find(parameter => parameter.ParameterName == "ReferenceID").Value;
        }
开发者ID:jxzly229190,项目名称:OnlineStore,代码行数:45,代码来源:PromoteMeetMoneyScopeDA.cs

示例4: PrepareCommand

        private static void PrepareCommand(SqlCommand command, SqlConnection connection, SqlTransaction transaction, CommandType commandType, string commandText, SqlParameter[] parms)
        {
            if (connection.State != ConnectionState.Open) connection.Open();

            command.Connection = connection;
            command.CommandTimeout = CommandTimeOut;
            // 设置命令文本(存储过程名或SQL语句)
            command.CommandText = commandText;
            // 分配事务
            if (transaction != null)
            {
                command.Transaction = transaction;
            }
            // 设置命令类型.
            command.CommandType = commandType;
            if (parms != null && parms.Length > 0)
            {
                //预处理SqlParameter参数数组,将为NULL的参数赋值为DBNull.Value;
                foreach (SqlParameter parameter in parms)
                {
                    if ((parameter.Direction == ParameterDirection.InputOutput || parameter.Direction == ParameterDirection.Input) && (parameter.Value == null))
                    {
                        parameter.Value = DBNull.Value;
                    }
                }
                command.Parameters.AddRange(parms);
            }
        }
开发者ID:pcstx,项目名称:DBHelper,代码行数:28,代码来源:SqlHelper2.cs

示例5: Insert

        /// <summary>
        /// 插入订单商品促销信息
        /// </summary>
        /// <param name="orderProductPromote">插入的对象</param>
        /// <param name="transaction">数据库事务</param>
        /// <returns>返回新增的数据编码</returns>
        public int Insert(Order_Product_Promote orderProductPromote, SqlTransaction transaction)
        {
            /*
             [OrderID]
              ,[OrderProductID]
              ,[PromoteType]
              ,[PromoteID]
              ,[Remark]
              ,[ExtField]
              ,[CreateTime]
             */
            var paras = new List<SqlParameter>
                            {
                                this.SqlServer.CreateSqlParameter(
                                    "OrderID",
                                    SqlDbType.Int,
                                    orderProductPromote.OrderID,
                                    ParameterDirection.Input),
                                this.SqlServer.CreateSqlParameter(
                                    "OrderProductID",
                                    SqlDbType.Int,
                                    orderProductPromote.OrderProductID,
                                    ParameterDirection.Input),
                                this.SqlServer.CreateSqlParameter(
                                    "PromoteType",
                                    SqlDbType.Int,
                                    orderProductPromote.PromoteType,
                                    ParameterDirection.Input),
                                this.SqlServer.CreateSqlParameter(
                                    "PromoteID",
                                    SqlDbType.Int,
                                    orderProductPromote.PromoteID,
                                    ParameterDirection.Input),
                                this.SqlServer.CreateSqlParameter(
                                    "Remark",
                                    SqlDbType.NVarChar,
                                    orderProductPromote.Remark,
                                    ParameterDirection.Input),
                                this.SqlServer.CreateSqlParameter(
                                    "ExtField",
                                    SqlDbType.NVarChar,
                                    orderProductPromote.ExtField,
                                    ParameterDirection.Input),
                                this.SqlServer.CreateSqlParameter(
                                    "CreateTime",
                                    SqlDbType.DateTime,
                                    DateTime.Now,
                                    ParameterDirection.Input),
                                this.SqlServer.CreateSqlParameter(
                                    "ReferenceID",
                                    SqlDbType.Int,
                                    null,
                                    ParameterDirection.Output)
                            };

            this.SqlServer.ExecuteNonQuery(CommandType.StoredProcedure, "sp_Order_Product_Promote_Insert", paras, transaction);

            return (int)paras.Find(p => p.ParameterName == "ReferenceID").Value;
        }
开发者ID:jxzly229190,项目名称:OnlineStore,代码行数:65,代码来源:OrderProductPromoteDA.cs

示例6: Insert

        /// <summary>
        /// 插入一条订单状态跟踪信息
        /// </summary>
        /// <param name="orderStatusTracking">
        /// 订单状态跟踪对象
        /// </param>
        /// <param name="transaction">
        /// 数据库事务对象
        /// </param>
        /// <returns>
        /// 新增的记录编码
        /// </returns>
        public int Insert(Order_Status_Tracking orderStatusTracking, SqlTransaction transaction)
        {
            var paras = new List<SqlParameter>
                            {
                                this.SqlServer.CreateSqlParameter(
                                    "EmployeeID",
                                    SqlDbType.Int,
                                    orderStatusTracking.EmployeeID,
                                    ParameterDirection.Input),
                                this.SqlServer.CreateSqlParameter(
                                    "UserID",
                                    SqlDbType.Int,
                                    orderStatusTracking.UserID,
                                    ParameterDirection.Input),
                                this.SqlServer.CreateSqlParameter(
                                    "OrderID",
                                    SqlDbType.Int,
                                    orderStatusTracking.OrderID,
                                    ParameterDirection.Input),
                                this.SqlServer.CreateSqlParameter(
                                    "Remark",
                                    SqlDbType.NVarChar,
                                    orderStatusTracking.Remark,
                                    ParameterDirection.Input),
                                this.SqlServer.CreateSqlParameter(
                                    "ExpressNumber",
                                    SqlDbType.NVarChar,
                                    orderStatusTracking.ExpressNumber,
                                    ParameterDirection.Input),
                                this.SqlServer.CreateSqlParameter(
                                    "MailNo",
                                    SqlDbType.NVarChar,
                                    orderStatusTracking.MailNo,
                                    ParameterDirection.Input),
                                this.SqlServer.CreateSqlParameter(
                                    "Status",
                                    SqlDbType.Int,
                                    orderStatusTracking.Status,
                                    ParameterDirection.Input),
                                this.SqlServer.CreateSqlParameter(
                                    "CreateTime",
                                    SqlDbType.DateTime,
                                    DateTime.Now,
                                    ParameterDirection.Input),
                                this.SqlServer.CreateSqlParameter(
                                    "ReferenceID",
                                    SqlDbType.Int,
                                    null,
                                    ParameterDirection.Output)
                            };

            this.SqlServer.ExecuteNonQuery(
                CommandType.StoredProcedure,
                "sp_Order_Status_Tracking_Insert",
                paras,
                transaction);
            return (int)paras.Find(parameter => parameter.ParameterName == "ReferenceID").Value;
        }
开发者ID:jxzly229190,项目名称:OnlineStore,代码行数:70,代码来源:OrderStatusTrackingDA.cs

示例7: Insert

        /// <summary>
        /// 插入一条CPS记录
        /// </summary>
        /// <param name="linkRecord">记录对象</param>
        /// <param name="transaction"></param>
        /// <returns>新增的ID</returns>
        public int Insert(Cps_LinkRecord linkRecord, SqlTransaction transaction)
        {
            //Create Procedure sp_Cps_LinkRecord_Insert
            //    @CpsID int,
            //    @URL nvarchar(1024),
            //    @TargetURL nvarchar(4000),
            //    @CreateTime datetime,
            //    @IsDelete int=default,
            //    @ExtField nvarchar(50)=default,
            //    @ReferenceID int output
            //As

            var paras = new List<SqlParameter>
                            {
                                this.sqlServer.CreateSqlParameter(
                                    "CpsID",
                                    SqlDbType.Int,
                                    linkRecord.CpsID,
                                    ParameterDirection.Input),
                                this.sqlServer.CreateSqlParameter(
                                    "URL",
                                    SqlDbType.NVarChar,
                                    linkRecord.URL,
                                    ParameterDirection.Input),
                                this.sqlServer.CreateSqlParameter(
                                    "TargetURL",
                                    SqlDbType.NVarChar,
                                    linkRecord.TargetURL,
                                    ParameterDirection.Input),
                                this.sqlServer.CreateSqlParameter(
                                    "CreateTime",
                                    SqlDbType.DateTime,
                                    DateTime.Now,
                                    ParameterDirection.Input),
                                this.sqlServer.CreateSqlParameter(
                                    "IsDelete",
                                    SqlDbType.Int,
                                    0,
                                    ParameterDirection.Input),
                                this.sqlServer.CreateSqlParameter(
                                    "ExtField",
                                    SqlDbType.NVarChar,
                                    linkRecord.ExtField,
                                    ParameterDirection.Input),
                                this.sqlServer.CreateSqlParameter(
                                    "ReferenceID",
                                    SqlDbType.Int,
                                    null,
                                    ParameterDirection.Output)
                            };

            this.sqlServer.ExecuteNonQuery(CommandType.StoredProcedure, "sp_Cps_LinkRecord_Insert", paras, transaction);

            return (int)paras.Find(p => p.ParameterName == "ReferenceID").Value;
        }
开发者ID:jxzly229190,项目名称:OnlineStore,代码行数:61,代码来源:CpsLinkRecordDA.cs

示例8: Insert

        /// <summary>
        /// 新增一条订单状态日志
        /// </summary>
        /// <param name="orderStatusLog">
        /// 订单状态日志
        /// </param>
        /// <param name="transaction">
        /// 数据库事务对象
        /// </param>
        /// <returns>
        /// 新增的订单状态日子编码
        /// </returns>
        public int Insert(Order_Status_Log orderStatusLog, SqlTransaction transaction)
        {
            /*
             Create Procedure sp_Order_Status_Log_Insert
                @OrderID int,
                @EmployeeID int,
                @Status int,
                @Remark nvarchar(512),
                @CreateTime datetime,
                @ReferenceID int output
            As
             */
            var paras = new List<SqlParameter>
                            {
                                this.SqlServer.CreateSqlParameter(
                                    "OrderID",
                                    SqlDbType.Int,
                                    orderStatusLog.OrderID,
                                    ParameterDirection.Input),
                                this.SqlServer.CreateSqlParameter(
                                    "EmployeeID",
                                    SqlDbType.Int,
                                    orderStatusLog.EmployeeID,
                                    ParameterDirection.Input),
                                this.SqlServer.CreateSqlParameter(
                                    "Status",
                                    SqlDbType.Int,
                                    orderStatusLog.Status,
                                    ParameterDirection.Input),
                                this.SqlServer.CreateSqlParameter(
                                    "Remark",
                                    SqlDbType.NVarChar,
                                    orderStatusLog.Remark,
                                    ParameterDirection.Input),
                                this.SqlServer.CreateSqlParameter(
                                    "CreateTime",
                                    SqlDbType.DateTime,
                                    DateTime.Now,
                                    ParameterDirection.Input),
                                this.SqlServer.CreateSqlParameter(
                                    "ReferenceID",
                                    SqlDbType.Int,
                                    null,
                                    ParameterDirection.Output)
                            };

            this.SqlServer.ExecuteNonQuery(CommandType.StoredProcedure, "sp_Order_Status_Log_Insert", paras, transaction);
            return (int)paras.Find(e => e.ParameterName == "ReferenceID").Value;
        }
开发者ID:jxzly229190,项目名称:OnlineStore,代码行数:61,代码来源:OrderStatusLogDA.cs

示例9: InertHwUpdateLog

        /// <summary>
        /// 写入HWERP 回写日志信息
        /// </summary>
        /// <param name="log"></param>
        /// <param name="transaction"></param>
        /// <returns></returns>
        public int InertHwUpdateLog(Hw_Log log, SqlTransaction transaction)
        {
            /*@Number nvarchar(50),
                @Content ntext,
                @State tinyint,
                @CreateTime datetime,
                @ExtField nvarchar(50),
             */

            var paras = new List<SqlParameter>
                            {
                                this.sqlServer.CreateSqlParameter(
                                    "Number",
                                    SqlDbType.VarChar,
                                    log.Number,
                                    ParameterDirection.Input),
                                this.sqlServer.CreateSqlParameter(
                                    "Content",
                                    SqlDbType.NVarChar,
                                    log.Content,
                                    ParameterDirection.Input),
                                this.sqlServer.CreateSqlParameter(
                                    "State",
                                    SqlDbType.Int,
                                    log.State,
                                    ParameterDirection.Input),
                                this.sqlServer.CreateSqlParameter(
                                    "ExtField",
                                    SqlDbType.NVarChar,
                                    log.ExtField,
                                    ParameterDirection.Input),
                                this.sqlServer.CreateSqlParameter(
                                    "CreateTime",
                                    SqlDbType.DateTime,
                                    DateTime.Now.ToLocalTime(),
                                    ParameterDirection.Input),
                                this.sqlServer.CreateSqlParameter(
                                    "ReferenceID",
                                    SqlDbType.Int,
                                    null,
                                    ParameterDirection.Output)
                            };

            this.sqlServer.ExecuteNonQuery(CommandType.StoredProcedure, "sp_hw_Log_Insert", paras, transaction);

            return (int)paras.Find(p => p.ParameterName == "ReferenceID").Value;
        }
开发者ID:jxzly229190,项目名称:OnlineStore,代码行数:53,代码来源:OrderErpLogDA.cs

示例10: DeleteByMeetAmountID

        /// <summary>
        /// 删除指定的促销规则.
        /// </summary>
        /// <param name="meetAmountID">
        /// 满件优惠活动促销规则编号.
        /// </param>
        /// <param name="transaction">
        /// 数据事务.
        /// </param>
        public void DeleteByMeetAmountID(int meetAmountID, SqlTransaction transaction)
        {
            var parameters = new List<SqlParameter>
                                 {
                                     this.SqlServer.CreateSqlParameter(
                                         "PromoteMeetAmountID",
                                         SqlDbType.Int,
                                         meetAmountID,
                                         ParameterDirection.Input)
                                 };

            this.SqlServer.ExecuteNonQuery(
                CommandType.StoredProcedure,
                "sp_Promote_MeetAmount_Rule_Brand_Delete",
                parameters,
                transaction);
        }
开发者ID:jxzly229190,项目名称:OnlineStore,代码行数:26,代码来源:PromoteMeetAmountRuleBrandDA.cs

示例11: DeleteByRuleID

        /// <summary>
        /// 删除满足条件减现金促销规则.
        /// </summary>
        /// <param name="ruleID">
        /// 满就送活动规则编号.
        /// </param>
        /// <param name="transaction">
        /// 数据事务.
        /// </param>
        public void DeleteByRuleID(int ruleID, SqlTransaction transaction)
        {
            var parameters = new List<SqlParameter>
                                 {
                                     this.SqlServer.CreateSqlParameter(
                                         "MeetRuleID",
                                         SqlDbType.Int,
                                         ruleID,
                                         ParameterDirection.Input)
                                 };

            this.SqlServer.ExecuteNonQuery(
                CommandType.StoredProcedure,
                "sp_Promote_Meet_DecreaseCash_Delete",
                parameters,
                transaction);
        }
开发者ID:jxzly229190,项目名称:OnlineStore,代码行数:26,代码来源:PromoteMeetDecreaseCashDA.cs

示例12: Delete

        /// <summary>
        /// 删除指定的促销规则.
        /// </summary>
        /// <param name="id">
        /// 满件优惠活动促销规则编号.
        /// </param>
        /// <param name="transaction">
        /// 数据事务.
        /// </param>
        public void Delete(int id, SqlTransaction transaction)
        {
            var parameters = new List<SqlParameter>
                                 {
                                     this.SqlServer.CreateSqlParameter(
                                         "ID",
                                         SqlDbType.Int,
                                         id,
                                         ParameterDirection.Input)
                                 };

            this.SqlServer.ExecuteNonQuery(
                CommandType.StoredProcedure,
                "sp_Promote_MeetAmount_Rule_Full_DeleteRow",
                parameters,
                transaction);
        }
开发者ID:jxzly229190,项目名称:OnlineStore,代码行数:26,代码来源:PromoteMeetAmountRuleFullDA.cs

示例13: SqlInternalTransaction

        internal SqlInternalTransaction(SqlInternalConnection innerConnection, TransactionType type, SqlTransaction outerTransaction, long transactionId) {
            Bid.PoolerTrace("<sc.SqlInternalTransaction.ctor|RES|CPOOL> %d#, Created for connection %d#, outer transaction %d#, Type %d\n",
                        ObjectID,
                        innerConnection.ObjectID,
                        (null != outerTransaction) ? outerTransaction.ObjectID : -1,
                        (int)type);

            _innerConnection = innerConnection;
            _transactionType = type;

            if (null != outerTransaction) {
                _parent = new WeakReference(outerTransaction);
            }

            _transactionId = transactionId;
            RestoreBrokenConnection = false;
            ConnectionHasBeenRestored = false;
        }
开发者ID:iskiselev,项目名称:JSIL.NetFramework,代码行数:18,代码来源:sqlinternaltransaction.cs

示例14: Insert

        /// <summary>
        /// 新增订单发票
        /// </summary>
        /// <param name="orderInvoice">
        /// 订单发票
        /// </param>
        /// <param name="transaction">
        /// 事务对象
        /// </param>
        /// <returns>
        /// 新增的订单编码
        /// </returns>
        public int Insert(Order_Invoice orderInvoice, SqlTransaction transaction)
        {
            var paras = new List<SqlParameter>
                            {
                                this.SqlServer.CreateSqlParameter(
                                    "OrderID",
                                    SqlDbType.Int,
                                    orderInvoice.OrderID,
                                    ParameterDirection.Input),
                                this.SqlServer.CreateSqlParameter(
                                    "InvoiceTypeID",
                                    SqlDbType.Int,
                                    orderInvoice.InvoiceTypeID,
                                    ParameterDirection.Input),
                                this.SqlServer.CreateSqlParameter(
                                    "InvoiceContentID",
                                    SqlDbType.Int,
                                    orderInvoice.InvoiceContentID,
                                    ParameterDirection.Input),
                                this.SqlServer.CreateSqlParameter(
                                    "InvoiceTitle",
                                    SqlDbType.NVarChar,
                                    orderInvoice.InvoiceTitle,
                                    ParameterDirection.Input),
                                this.SqlServer.CreateSqlParameter(
                                    "InvoiceCost",
                                    SqlDbType.Float,
                                    orderInvoice.InvoiceCost,
                                    ParameterDirection.Input),
                                this.SqlServer.CreateSqlParameter(
                                    "CreateTime",
                                    SqlDbType.DateTime,
                                    DateTime.Now,
                                    ParameterDirection.Input),
                                this.SqlServer.CreateSqlParameter(
                                    "ReferenceID",
                                    SqlDbType.Int,
                                    null,
                                    ParameterDirection.Output)
                            };

            this.SqlServer.ExecuteNonQuery(CommandType.StoredProcedure, "sp_Order_Invoice_Insert", paras, transaction);
            return (int)paras.Find(e => e.ParameterName == "ReferenceID").Value;
        }
开发者ID:jxzly229190,项目名称:OnlineStore,代码行数:56,代码来源:OrderInvoiceDA.cs

示例15: Delete

        /// <summary>
        /// 删除会员促销活动.
        /// </summary>
        /// <param name="id">
        /// 活动编号.
        /// </param>
        /// <param name="transaction">
        /// 数据库事务.
        /// </param>
        public void Delete(int id, out SqlTransaction transaction)
        {
            if (id <= 0)
            {
                throw new ArgumentNullException("id");
            }

            this.SqlServer.BeginTransaction(IsolationLevel.ReadCommitted);
            transaction = this.SqlServer.Transaction;
            var parameters = new List<SqlParameter>
                                 {
                                     this.SqlServer.CreateSqlParameter(
                                         "ID",
                                         SqlDbType.Int,
                                         id,
                                         ParameterDirection.Input)
                                 };

            this.SqlServer.ExecuteNonQuery(CommandType.StoredProcedure, "sp_Promote_Vip_DeleteRow", parameters, transaction);
        }
开发者ID:jxzly229190,项目名称:OnlineStore,代码行数:29,代码来源:PromoteVipDA.cs


注:本文中的SqlTransaction类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。