Hi
We are using CSLA version 2.0 on .NET 2.0 VS2005. In my project, I'm using a datagridview, with child data. In the design, we add extra rows to the datagridview on the Fetch. We do this so that the user doesn't have to add additional rows; they are only allowed a certain number. Any ways that works great, I specify the mandatory fields (all the ID's that I need), and the rows are added to my Datagridview.
In the datagridview, we have a column which does the calculation of other columns. So I created a new property "Public ReadOnly Property TotalEstCost() As String". Here is the bit of code...
Private _totalEstCost As String = String.Empty
Public ReadOnly Property TotalEstCost() As String
Get
'Declare the variables
Dim decTaxAmount As Decimal
Dim decEstimCost As Decimal
Dim decTotalEstCost As Decimal
Dim strTotalEstCost As String
If GSTHSTAmount <> "" Then
decTaxAmount = Decimal.Parse(GSTHSTAmount)
Else
decTaxAmount = 0
End If
If CstAmtDlrsStr <> "" Then
decEstimCost = Decimal.Parse(CstAmtDlrsStr)
Else
decEstimCost = 0
End If
decTotalEstCost = decTaxAmount + decEstimCost
If decTotalEstCost = 0 Then
strTotalEstCost = String.Empty
Else
strTotalEstCost = decTotalEstCost
End If
_totalEstCost = "0.00"
Return strTotalEstCost
End Get
there might be some unnecessary coding... but I'm trying everything now... Like I said everything works fine, until I add the Validation rules.
These are my validation rule that's giving me problems...
' Total Cost
' Rule # 2008
ValidationRules.AddRule(AddressOf Csla.Validation.CommonRules.StringRequired, "TotalEstCost")
ValidationRules.AddRule(AddressOf Csla.Validation.CommonRules.RegExMatch, New Csla.Validation.CommonRules.RegExRuleArgs("TotalEstCost", "^\d{1,11}(?:\.\d\d)?$"))
ValidationRules.AddRule(AddressOf Csla.Validation.CommonRules.StringMaxLength, New Csla.Validation.CommonRules.MaxLengthRuleArgs("TotalEstCost", 13))
When I load my windows form, I keep getting the red warning on the empty rows and when I try to save it obviously doesn't save because of validation issue.
Can anybody help me with this one. Am I making a mistake i the way I created my property or my declaration of my variable. Any help would be greatly appreciated.
Thanks
Kat
Copyright (c) Marimer LLC