时间:2021-07-01 10:21:17 帮助过:28人阅读
接下来贴出两个个详细的方法作参考:
internal static SqlParameter[] BuildOrderInforAddParameter(int UserId, string OrderCode, string Ids, ref StringBuilder strSql) { strSql = new StringBuilder(); strSql.Append("INSERT INTO OrderInfor("); strSql.Append("UserId,X_ProId,X_ProName,StockNum,BuyNum,UnitPrice,OrderCode,TotalPrice,IsOther)"); strSql.Append(" select UserId,X_ProId,X_ProName,StockNum,BuyNum,UnitPrice,@OrderCode,TotalPrice,IsOther from BasketDetail"); strSql.AppendFormat(" where UserId=@UserId and IsSubmit=‘false‘ and IsInquiry=2 and IsExpired=0 and BasketDetailId in ({0})", Ids); SqlParameter[] parameters = { new SqlParameter("@OrderCode", SqlDbType.NVarChar,100), new SqlParameter("@UserId", SqlDbType.Int) }; parameters[0].Value = OrderCode; parameters[1].Value = UserId; return parameters; }
internal static SqlParameter[] BuildUpdateParameter(int CouponId, int State, string OrderCode, ref StringBuilder strSql) { strSql = new StringBuilder(); strSql.Append("update Coupon set"); strSql.Append(" [State]=@State,OrderCode=@OrderCode"); strSql.AppendFormat(" where ID={0}", CouponId); SqlParameter[] parameters = { new SqlParameter("@State", SqlDbType.Int), new SqlParameter("@OrderCode", SqlDbType.NVarChar,50) }; parameters[0].Value = State; parameters[1].Value = OrderCode; return parameters; }
C#实现执行数据库事务案例
标签:lis code detail other ota val append false ref