row(0)是啥意思
duwamish7中的代码,business/rules/customer.vb,这是新增记录的代码,当中有句理解不来With customer.Tables(CustomerData.CUSTOMERS_TABLE).Rows(0),rows(0)是啥意思?(代码下,红色部分)
Public Function Insert (ByVal customer as CustomerData) As Boolean
'
' Check Preconditions
'
ApplicationAssert.CheckCondition(Not customer Is Nothing,"customer Parameter cannot be null",ApplicationAssert.LineNumber)
ApplicationAssert.CheckCondition(customer.Tables(CustomerData.CUSTOMERS_TABLE).Rows.Count = 1,"customer Parameter can only contain 1 row",ApplicationAssert.LineNumber)
Dim tmpCustomer As CustomerData 'used to see if the customer already exists
Dim result as Boolean
With customer.Tables(CustomerData.CUSTOMERS_TABLE).Rows(0)
'
' Do core validation
'
result = Validate (customer.Tables(CustomerData.CUSTOMERS_TABLE).Rows(0))
'
' Do additional validation
'
If Len(.GetColumnError (CustomerData.EMAIL_FIELD)) < 1 Then
'
' Email address passed format verification, now ensure that it
' does not already exist in the database.
'
tmpCustomer = GetCustomerByEmail(CStr(.Item(CustomerData.EMAIL_FIELD)))
If tmpCustomer Is Nothing Then
'email is unique, Save off the new customer
If result Then
With New Customers
result = .InsertCustomer(customer)
End With
End If
Else
'
' Email is not unique, flag the error
'
.SetColumnError(CustomerData.EMAIL_FIELD, CustomerData.EMAIL_FIELD_NOT_UNIQUE) 'email field is not unique
.RowError = CustomerData.INVALID_FIELDS
result = false
End If
End If
End With
'
' Return the result of the operation
'
Insert = result
End Function