Vibrant discussion about CSLA .NET and using the framework to build great business applications.
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 StringGet'Declare the variablesDim decTaxAmount As DecimalDim decEstimCost As DecimalDim decTotalEstCost As DecimalDim strTotalEstCost As String
If GSTHSTAmount <> "" ThendecTaxAmount = Decimal.Parse(GSTHSTAmount)ElsedecTaxAmount = 0End If
If CstAmtDlrsStr <> "" ThendecEstimCost = Decimal.Parse(CstAmtDlrsStr)ElsedecEstimCost = 0End If
decTotalEstCost = decTaxAmount + decEstimCost
If decTotalEstCost = 0 ThenstrTotalEstCost = String.EmptyElsestrTotalEstCost = decTotalEstCostEnd 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 # 2008ValidationRules.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