Vibrant discussion about CSLA .NET and using the framework to build great business applications.

Forum has moved

New location: CSLA .NET forum

CSLA .NET Resources:
  • CSLA .NET forum
  • CSLA .NET home page
  • Validation

    rated by 0 users
    Not Answered This post has 0 verified answers | 0 Replies | 1 Follower

    Not Ranked
    13 Posts
    ksavoie posted on Wed, Jan 26 2011 9:50 AM


    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
    'Declare the variables
    Dim decTaxAmount As Decimal
    decEstimCost As Decimal
    decTotalEstCost As Decimal
    strTotalEstCost As String

    If GSTHSTAmount <> "" Then
    decTaxAmount = Decimal.Parse(GSTHSTAmount)
    decTaxAmount = 0
    End If

    If CstAmtDlrsStr <> "" Then
    decEstimCost = Decimal.Parse(CstAmtDlrsStr)
    decEstimCost = 0
    End If

    decTotalEstCost = decTaxAmount + decEstimCost

    If decTotalEstCost = 0 Then
    strTotalEstCost = String.Empty
    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.



    Page 1 of 1 (1 items) | RSS

    Copyright (c) 2006-2014 Marimer LLC. All rights reserved.
    Email admin@lhotka.net for support.
    Powered by Community Server (Non-Commercial Edition), by Telligent Systems