zoukankan      html  css  js  c++  java
  • 事物

      #region IOrder 成员

            bool IDal.IOrder.ProcessOrder(IList<Modal.CartItem> li, string user)
            {
                using (SqlConnection connection = new SqlConnection(Common.Common.cn))
                {
                    connection.Open();
                   SqlTransaction sqlTran = connection.BeginTransaction();

                  SqlCommand command = connection.CreateCommand();
                    command.Transaction = sqlTran;

                    try
                    {
                        command.CommandText =
                          "select id from Users where Name=" + user;
                     int userID= Convert.ToInt32(  command.ExecuteScalar());
                        command.CommandText =
                          "INSERT INTO Orders(UserId,OrderTime,BillNo,State,Des) VALUES(userID,getdate(),convert(nvarchar(10),userID)+'-'+'...',0,'')";
                        command.ExecuteNonQuery();
                        command.CommandText =
                            "select max(id) from Orders";
                        int oID = Convert.ToInt32(command.ExecuteScalar());
                        sqlTran.Commit();
                        return true;
                    }
                    catch (Exception ex)
                    {
                     
                        sqlTran.Rollback();
                        return false;
                    }

                }
            }

            #endregion

  • 相关阅读:
    python安装教程
    protobuf安装教程
    PlantUML安装教程
    题解-CF1140E Palindrome-less Arrays
    FST
    线段树
    题解-CF677D Vanya and Treasure
    最短路
    后缀自动机
    虚树
  • 原文地址:https://www.cnblogs.com/cdaq/p/3450445.html
Copyright © 2011-2022 走看看