Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

question abt collection

Status
Not open for further replies.

purplehaze1

Programmer
Jul 23, 2003
86
US
if a Customer has multiple address (temp, permanent)
and multiple phone and email address, should I make collection
for address, phone and email so I can later save to database?
How else can I handle such situation? Thanks.

The following works, is there better way to handle this?

Private Sub SaveCustomerAddress()

Dim oPhone As Phone
Dim oEmail As Email

With oCustomer
If txtAddr1.Text <> "" Then
oRecipAddress = New Address()
With oRecipAddress
.ID = oCustomer.ID
.AddressTypeID = oRecipAddress.AddressType.permanent
.Address1 = txtAddr1.Text.Trim()
.Address2 = txtAddr2.Text.Trim()
.Address3 = txtAddr3.Text.Trim()
.City = txtCity.Text.Trim()
.StateID = cbState.SelectedValue
.PostalZip = txtZip.Text.Trim()
.CountryID = CbCountry.SelectedValue()
End With
.AddAddress(oRecipAddress)
End If

If txtTempAddr1.Text <> "" Then
oRecipAddress = New Address()
With oRecipAddress
.ID = oCustomer.ID
.AddressTypeID = oRecipAddress.AddressType.temporary
.Address1 = txtTempAddr1.Text.Trim()
.Address2 = txtTempAddr2.Text.Trim()
.Address3 = txtTempAddr3.Text.Trim()
.City = txtTempCity.Text.Trim()
.StateID = cbTempState.SelectedValue
.PostalZip = txtTempZip.Text.Trim()
.CountryID = cbTempCountry.SelectedValue
End With
.AddAddress(oRecipAddress)
End If

If txtHomePhone.Text <> "" Then
oPhone = New Phone()
With oPhone
.Phone = txtHomePhone.Text.Trim()
.PhoneTypeID = oPhone.PhoneType.home
.ID = oCustomer.ID
End With
.AddPhone(oPhone)
End If

If txtOfficePhone.Text <> "" Then
oPhone = New Phone()
With oPhone
.Phone = txtOfficePhone.Text.Trim()
.PhoneTypeID = .PhoneType.office
.ID = oCustomer.ID
End With
.AddPhone(oPhone)
End If

If txtMobilePhone.Text <> "" Then
oPhone = New Phone()
With oPhone
.Phone = txtMobilePhone.Text.Trim()
.PhoneTypeID = .PhoneType.mobile
.ID = oCustomer.ID
End With
.AddPhone(oPhone)
End If

If txtPersonalEmail.Text <> "" Then
oEmail = New Email()
With oEmail
.Email = txtPersonalEmail.Text.Trim()
.eMailTypeID = .EmailType.personal
.ID = oCustomer.ID
End With
.AddEmail(oEmail)
End If

If txtOfficeEmail.Text <> "" Then
oEmail = New Email()
With oEmail
.Email = txtOfficeEmail.Text.Trim()
.eMailTypeID = .EmailType.office
.ID = oCustomer.ID
End With
.AddEmail(oEmail)
End If
.SaveCustomerAddress()
End With

End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top