0
Public Shared Function Save() As Boolean
    Using cmd As New SqlCommand()
        With cmd
            .CommandType = CommandType.StoredProcedure
            .CommandText = "Insert_Detail"
            .CommandTimeout = 100
            .Connection = Connection.GetConnection
            .Transaction = Connection.GetConnection.BeginTransaction(IsolationLevel.ReadCommitted)

            .Parameters.Add("@detailId", SqlDbType.BigInt).Direction = ParameterDirection.Output
            .Parameters.Add("@saleId", SqlDbType.BigInt).Value = Sale.SaleId
            .Parameters.Add("@foodId", SqlDbType.SmallInt).Value = Food.FoodId
            .Parameters.Add("@price", SqlDbType.Money).Value = Price
            .Parameters.Add("@qty", SqlDbType.SmallInt).Value = Qty
            .Parameters.Add("@discount", SqlDbType.SmallInt).Value = Food.Discount

            Try
                .ExecuteNonQuery()

                Dim _detailId As Long = .Parameters("@detailId").Value

                DetailSale.DetailId = _detailId
                DetailRemark.Save()

                .Transaction.Commit()
                Return True
            Catch ex As Exception
                .Transaction.Rollback()
                MsgBox(ex.Message, MsgBoxStyle.Exclamation, "Error")
                Return False
            End Try
        End With
    End Using
End Function

Public Shared Function Save() As Boolean
    Using cmd As New SqlCommand()
        With cmd
            .CommandType = CommandType.StoredProcedure
            .CommandText = "Insert_Detail_Remark"
            .CommandTimeout = 100
            .Connection = Connection.GetConnection

            .Parameters.Add("@detailId", SqlDbType.BigInt).Value = DetailSale.DetailId
            .Parameters.Add("@remarkIdAsString", SqlDbType.VarChar, 255).Value = RemarkIdAsString
            .Parameters.Add("@priceAsString", SqlDbType.VarChar, 255).Value = PriceAsString

            Try
                .ExecuteNonQuery()
                Return True
            Catch ex As Exception
                MsgBox(ex.Message, MsgBoxStyle.Exclamation, "Error")
                Return False
            End Try
        End With
    End Using
End Function

我有这两个函数来调用不同的程序。当我运行它时,它只能运行程序。功能 DetailRemark.Save() 它不起作用。我能怎么做?

4

1 回答 1

0

首先,这些函数是否存在于同一个类中?如果是这样,您不能拥有具有相同签名的多个功能。

其次,最好创建单独的函数(具有不同的名称),因为它们不相关。

于 2013-11-13T08:25:37.180 回答