设置: 2 个数据库 Lightswitch.applicationdata 与表客户 SQL.PlaceNamesData 与表国家,州,地方和邮政编码 AddCustomer 屏幕是一个新的数据屏幕。这个屏幕有 3 个自动完成框来过滤国家、州、地方。邮政编码与地点是一对一的关系。
问题:在提供的代码中,我试图将字段保存到新的客户记录中,但是选择的国家、州、地点和邮政编码没有与公司名称和其他详细信息一起保存。相反,PlaceNamesData DB 中的每个外键都根据 postcodenum 字段按升序保存。
这几天我一直在尝试不同的方法。如何将过滤后的屏幕值保存到客户记录中的外键?
Namespace LightSwitchApplication
Public Class AddCustomer
Private Sub AddCustomer_InitializeDataWorkspace(saveChangesTo As List(Of Microsoft.LightSwitch.IDataService))
' Write your code here.
Me.CustomerProperty = New Customer()
End Sub
Private Sub AddCustomer_Saved()
' Write your code here.
Me.Close(False)
Application.Current.ShowDefaultScreen(Me.CustomerProperty)
End Sub
Private Sub SaveCustomer_Execute()
Dim newCustomer As Customer = Me.CustomerProperty
Dim co As Country = Me.CountryProp.Country
Dim st As State = Me.StateProp.State
Dim pl As Place = Me.PlaceProp.Place
Dim po As PostCode = Me.PlaceProp.PostCode
With newCustomer
.CompanyName = Me.CustomerProperty.CompanyName
.Street = Me.CustomerProperty.Street
.AccountTerms = Me.CustomerProperty.AccountTerms
.TaxRate = Me.CustomerProperty.TaxRate
.Country = co
.State = st
.Place = pl
.PostCode = po
End With
End Sub
Private Sub AddCustomer_Saving(ByRef handled As Boolean)
' Write your code here.
handled = True
End Sub
End Class
End Namespace