Filtering Date in BO


Author
Message
Danny Doobay
Danny Doobay
StrataFrame User (170 reputation)StrataFrame User (170 reputation)StrataFrame User (170 reputation)StrataFrame User (170 reputation)StrataFrame User (170 reputation)StrataFrame User (170 reputation)StrataFrame User (170 reputation)StrataFrame User (170 reputation)StrataFrame User (170 reputation)
Group: StrataFrame Users
Posts: 40, Visits: 333
I have three properties in my customers BO. The first one cust_DateofBirth with a data type of DateTime and it is mapped to database datetime field. Other two are custom field property and they are defined in the BO as follows

<ComponentModel.Browsable(False), _
 MicroFour.StrataFrame.UI.Windows.Forms.BusinessFieldDisplayInEditor(), _
 ComponentModel.Description("DOBGMT"), _
 ComponentModel.DesignerSerializationVisibility(ComponentModel.DesignerSerializationVisibility.Hidden)> _
    Public Property DOBGMT() As Date
        Get
            Return DatePart(DateInterval.Year, Me.cust_DateofBirth).ToString & "-" & DatePart(DateInterval.Month, Me.cust_DateofBirth).ToString & "-" & DatePart(DateInterval.Day, Me.cust_DateofBirth).ToString
       End Get
        Set(value As Date)
            Me.cust_DateofBirth = value
        End Set
   End Property

<ComponentModel.Browsable(False), _
 MicroFour.StrataFrame.UI.Windows.Forms.BusinessFieldDisplayInEditor(), _
 ComponentModel.Description("DOByyyyMMdd"), _
 ComponentModel.DesignerSerializationVisibility(ComponentModel.DesignerSerializationVisibility.Hidden)> _
    Public ReadOnly Property DOByyyyMMdd() As String
        Get
          Return cust_DateofBirth.ToString("yyyy-MM-dd")
        End Get
    End Property

 Protected Overrides Function GetCustomBindablePropertyDescriptors() As MicroFour.StrataFrame.Business.FieldPropertyDescriptor()
        '-- Establish Locals
        Dim r As New List(Of FieldPropertyDescriptor)

        '-- Include all of the base descriptors
        Try
            r.AddRange(MyBase.GetCustomBindablePropertyDescriptors())
        Catch ex As Exception
        End Try

        '-- Add the custom descriptors       
        r.Add(New ReflectionPropertyDescriptor("DOBGMT", GetType(CustomersBO)))     
        r.Add(New ReflectionPropertyDescriptor("DOByyyyMMdd", GetType(CustomersBO)))
        '-- Return results
        Return r.ToArray()
 End Function

 Private Sub CustomersBO_CurrentDataTableInitialized() Handles Me.CurrentDataTableInitialized
        If Me.CurrentDataTable.Columns.Contains("DOBGMT") = False Then
            Me.CurrentDataTable.Columns.Add("DOBGMT", GetType(Date))
        End If
     
         If Me.CurrentDataTable.Columns.Contains("DOByyyyMMdd") = False Then
            Me.CurrentDataTable.Columns.Add("DOByyyyMMdd", System.Type.GetType("System.String"))
        End If
 End Sub

 Private Sub CustomersBO_CurrentDataTableRefilled() Handles Me.CurrentDataTableRefilled
        If Me.CurrentDataTable.Columns.Contains("DOBGMT") = False Then
            'Me.CurrentDataTable.Columns.Add("DOBGMT", System.Type.GetType("System.Date"))
             Me.CurrentDataTable.Columns.Add("DOBGMT", GetType(Date))
        End If
        If Me.CurrentDataTable.Columns.Contains("DOByyyyMMdd") = False Then
            Me.CurrentDataTable.Columns.Add("DOByyyyMMdd", System.Type.GetType("System.String"))
        End If
  End Sub

Now when I tried to filter the BO using all three column option I am not getting the result (I have one record in SQL database)

CustomersBO.Filter  = "cust_FirstName = 'John' AND cust_LastName = 'Smith' AND DOBGMT = '1962-09-19'"
CustomersBO.Filter  = "cust_FirstName = 'John' AND cust_LastName = 'Smith' AND DOByyyyMMdd = '1962-09-19'"
CustomersBO.Filter  = "cust_FirstName = 'John' AND cust_LastName = 'Smith' AND cust_DateofBirth = '1962-09-19'"

I tried to use CurrentDataTable with select statement and no result as well
?CustomersBO.CurrentDataTable.[Select]("cust_FirstName = 'John' AND cust_LastName = 'Smith'  AND DOBGMT = '1962-09-19'").Length
0
?CustomersBO.CurrentDataTable.[Select]("cust_FirstName = 'John' AND cust_LastName = 'Smith'  AND DOByyyyMMdd = '1962-09-19'").Length
0
?CustomersBO.CurrentDataTable.[Select]("cust_FirstName = 'John' AND cust_LastName = 'Smith'  AND cust_DateofBirth = '1962-09-19'").Length
0

But when I just use first and last names it is fine in both occasion
CustomersBO.Filter  = "cust_FirstName = 'John' AND cust_LastName = 'Smith'"
?CustomersBO.CurrentDataTable.[Select]("cust_FirstName = 'John' AND cust_LastName = 'Smith'").Length
1

Any help is appreciated.
Tags
Edited 7 Years Ago by Danny Doobay
GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...





Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search