• 事物


      #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

  • 相关阅读:
    java域名解析
    JDK8新特性面试
    java设计模式--单例模式
    EclipseEE导入项目出现的那些问题
    Eclipse配置Git发布项目到Github
    SVN本地服务器的搭建
    APK的反编译
    Oracle系列--级联删除和级联更新
    Oracle创建表空间和用户
    全方面了解和学习PHP框架 PHP培训教程
  • 原文地址:https://www.cnblogs.com/cdaq/p/3450445.html
Copyright © 2020-2023  润新知