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
これらの 2 つの関数を使用して、異なるプロシージャを呼び出します。実行すると、手順のみで動作します。関数 DetailRemark.Save() は機能していません。どのようにできるのか?