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() 它不起作用。我能怎么做?