Monday, 12 November 2012

Drop Down Select Date Records Should Displays

        If isDropDown = False Then
                'CbDates.SelectedIndex = exIndex
                Exit Sub
            End If
            exIndex = CbDates.SelectedIndex
            isDropDown = False

            Dim n As Long
            Dim n1 As Integer
            Dim das, da1, da2 As Date
            Dim date1 As Date
            date1 = Date.Today
            Dim intTmp As Integer, intTmp1 As Integer
            Dim myDate As Date = Date.Today ''.ToString("dd-MMM-yyyy")
            Dim i As Long
            Bfrom.Enabled = False
            Bto.Enabled = False
            Select Case CbDates.SelectedItem
                Case "All"
                    FromDate = BegingIngDate ''.ToString("dd-MMM-yyyy")
                    ToDate = EndDate ''.ToString("dd-MMM-yyyy")

                Case "Today"

                    FromDate = myDate '.ToString("dd-MMM-yyyy")
                    ToDate = myDate '.ToString("dd-MMM-yyyy")
                    '---------------{END}---------------------
                Case "This Week"

                    FromDate = myDate.AddDays(-(myDate.DayOfWeek - 1))
                    ToDate = FromDate.AddDays(6)
                Case "This Week to date"

                    FromDate = myDate.AddDays(-(myDate.DayOfWeek - 1))
                    ToDate = myDate '.ToString("dd-MMM-yyyy")
                Case "This Month"
                    FromDate = myDate.AddDays(-(myDate.Day - 1)) ''.ToString("dd-MMM-yyyy")
                    ToDate = FromDate.AddMonths(1) ''.ToString("dd-MMM-yyyy")
                    ToDate = ToDate.AddDays(-1)

                Case "This Month to date"

                    FromDate = myDate.AddDays(-(myDate.Day - 1)) ''.ToString("dd-MMM-yyyy")
                    ToDate = myDate.ToString("dd-MMM-yyyy")

                Case "This Fiscal Quarter"
                    intTmp = myDate.Month
                    intTmp1 = intTmp Mod 3
                    If intTmp1 > 0 Then
                        FromDate = myDate.AddMonths(-(intTmp - 1)) ''.ToString("dd-MMM-yyyy")
                    Else
                        FromDate = myDate.AddMonths(-2) ''.ToString("dd-MMM-yyyy")
                    End If
                    FromDate = CType(FromDate.Month & "-" & 1 & "-" & FromDate.Year, Date)
                    ToDate = FromDate.AddMonths(3) ''.ToString("dd-MMM-yyyy")
                    ToDate = ToDate.AddDays(-1)

                Case "This Fiscal Quarter to date"
                    intTmp = myDate.Month
                    intTmp1 = intTmp Mod 3
                    If intTmp1 > 0 Then
                        FromDate = myDate.AddMonths(-(intTmp - 1)) ''.ToString("dd-MMM-yyyy")
                    Else
                        FromDate = myDate.AddMonths(-2) ''.ToString("dd-MMM-yyyy")
                    End If
                    FromDate = CType(FromDate.Month & "-" & 1 & "-" & FromDate.Year, Date)
                    ToDate = myDate.ToString("dd-MMM-yyyy")

                Case "This Fiscal Year"
                    FromDate = CType(1 & "-" & 1 & "-" & myDate.Year, Date)
                    ToDate = FromDate.AddYears(1) ''.ToString("dd-MMM-yyyy")
                    ToDate = ToDate.AddDays(-1)

                Case "This Fiscal  Year to date"
                    FromDate = CType(1 & "-" & 1 & "-" & myDate.Year, Date)
                    ToDate = myDate.ToString("dd-MMM-yyyy")

                Case "Yesterday"
                    FromDate = myDate.AddDays(-1)
                    ToDate = FromDate

                Case "Last Week"
                    myDate = myDate.AddDays(-7)
                    FromDate = myDate.AddDays(-(myDate.DayOfWeek - 1))
                    ToDate = FromDate.AddDays(6)

                Case "Last Week to date"
                    ToDate = myDate
                    myDate = myDate.AddDays(-7)
                    FromDate = myDate.AddDays(-(myDate.DayOfWeek - 1))

                Case "Last Month"
                    myDate = myDate.AddMonths(-1)
                    FromDate = myDate.AddDays(-(myDate.Day - 1)) ''.ToString("dd-MMM-yyyy")
                    ToDate = FromDate.AddMonths(1) ''.ToString("dd-MMM-yyyy")
                    ToDate = ToDate.AddDays(-1)

                Case "Last Month to date"
                    ToDate = myDate
                    myDate = myDate.AddMonths(-1)
                    FromDate = myDate.AddDays(-(myDate.Day - 1))

                Case "Last Fiscal Quarter"
                    myDate = myDate.AddMonths(-3)
                    intTmp = myDate.Month
                    intTmp1 = intTmp Mod 3
                    If intTmp1 > 0 Then
                        FromDate = myDate.AddMonths(-(intTmp - 1)) ''.ToString("dd-MMM-yyyy")
                    Else
                        FromDate = myDate.AddMonths(-2) ''.ToString("dd-MMM-yyyy")
                    End If
                    FromDate = CType(FromDate.Month & "-" & 1 & "-" & FromDate.Year, Date)
                    ToDate = FromDate.AddMonths(3) ''.ToString("dd-MMM-yyyy")
                    ToDate = ToDate.AddDays(-1)
                Case "Last Fiscal Quarter to date"
                    ToDate = myDate
                    myDate = myDate.AddMonths(-3)
                    intTmp = myDate.Month
                    intTmp1 = intTmp Mod 3
                    If intTmp1 > 0 Then
                        FromDate = myDate.AddMonths(-(intTmp - 1)) ''.ToString("dd-MMM-yyyy")
                    Else
                        FromDate = myDate.AddMonths(-2) ''.ToString("dd-MMM-yyyy")
                    End If
                    FromDate = CType(FromDate.Month & "-" & 1 & "-" & FromDate.Year, Date)

                Case "Last Fiscal to Year"
                    myDate = myDate.AddYears(-1)
                    FromDate = CType(1 & "-" & 1 & "-" & myDate.Year, Date)
                    ToDate = FromDate.AddYears(1) ''.ToString("dd-MMM-yyyy")
                    ToDate = ToDate.AddDays(-1)
                Case "Last Fiscal Year to date"
                    ToDate = myDate
                    myDate = myDate.AddYears(-1)
                    FromDate = CType(1 & "-" & 1 & "-" & myDate.Year, Date)

                Case "Next Week"
                    FromDate = ToDate
                    ToDate = FromDate.AddDays(7)

                Case "Next 4 Week"
                    FromDate = ToDate
                    ToDate = FromDate.AddDays(28)

                Case "Next Month"
                    FromDate = ToDate
                    ToDate = FromDate.AddMonths(1)

                Case "Next Fiscal Quarter"
                    FromDate = ToDate

                    ToDate = FromDate.AddMonths(3)
                    'TFrom.Text = FromDate.ToString("dd-MMM-yyyy")
                    'TTo.Text = ToDate.ToString("dd-MMM-yyyy")
                    'refreshDataSet()
                    'If memo = 2 Then
                    '    strlength()
                    'End If
                    'populateData()
                Case "Next Fiscal Year"
                    FromDate = ToDate
                    ToDate = FromDate.AddYears(1)
                    'TFrom.Text = FromDate.ToString("dd-MMM-yyyy")
                    'TTo.Text = ToDate.ToString("dd-MMM-yyyy")
                    'refreshDataSet()
                    'If memo = 2 Then
                    '    strlength()
                    'End If
                    'populateData()

                Case "Custom"

                    Bfrom.Enabled = True
                    Bto.Enabled = True

                    FromDate = myDate
                    ToDate = myDate
                    'TFrom.Text = FromDate.ToString("dd-MMM-yyyy")
                    'TTo.Text = ToDate.ToString("dd-MMM-yyyy")
                    'refreshDataSet()
                    'If memo = 2 Then
                    '    strlength()
                    'End If
                    'populateData()
            End Select

            TFrom.Text = FromDate.ToString("dd-MMM-yyyy")
            TTo.Text = ToDate.ToString("dd-MMM-yyyy")

                If Cmbdd1.SelectedValue <> "" Then
                refreshDataSet()
            End If
        

No comments:

Post a Comment