我有一个Bill和PR课程,它们之间有一对多的关系(一个Bill到多个PR),如何根据Bill类中的Amount属性强制输入PR类? 只有当 Amount> = FIXED_AMOUNT 然后强制输入PR细节时,否则不要这样做。
<DefaultClassOptions()> _
Public Class Bill Inherits BaseObject
Public Sub New(ByVal session As Session)
MyBase.New(session)
End Sub
Public Overrides Sub AfterConstruction()
MyBase.AfterConstruction()
End Sub
Private _Amount As Decimal
Public Property Amount() As Decimal
Get
Return _Amount
End Get
Set(ByVal value As Decimal)
_Amount = value
End Set
End Property
Private _PR As PR
<Association("PR-Bill")>
Public Property PR As PR
Get
Return _PR
End Get
Set(ByVal value As PR)
SetPropertyValue("PR", _PR, value)
End Set
End Property
End Class
<DefaultClassOptions()> _
Public Class PR Inherits BaseObject
Public Sub New(ByVal session As Session)
MyBase.New(session)
End Sub
Public Overrides Sub AfterConstruction()
MyBase.AfterConstruction()
End Sub
Private _Name As String
Public Property Name() As String
Get
Return _Name
End Get
Set(ByVal value As String)
_Name = value
End Set
End Property
<Association("PR-Bill")>
Public ReadOnly Property Bill() As XPCollection(Of Bill)
Get
Return GetCollection(Of Bill)("Bill")
End Get
End Property
End Class
答案 0 :(得分:0)
使用DevExpress.Persistent.Validation
类似
[NotMapped, Browsable(false),
RuleFromBoolProperty("NeedsInputRule", DefaultContexts.Save,"You need to input PR ", UsedProperties = "Amount")]
public bool NeedsInput => Amount >= Fixed_Amount;