Imports System.Data.OleDb
Public Class Report

    Private dbc As New OleDbConnection(conStr)

    Private Sub loadt()
        Dim dba As New OleDbDataAdapter("SELECT ORNum AS [OR Number], SaleDate AS [Transaction Date/Time], CustomerName AS [Customer], TotalBill AS [Bill], Amount AS [Payment] FROM tbSale;", dbc)
        Dim dbs As New DataSet
        dba.Fill(dbs)
        Me.DataGridView1.DataSource = dbs.Tables(0).DefaultView
    End Sub
    Private Sub loads()
        Dim dba As New OleDbDataAdapter("SELECT SUM(TotalBill) FROM tbSale;", dbc)
        Dim dbs As New DataSet
        dba.Fill(dbs)
        Me.TextBox1.Text = dbs.Tables(0).DefaultView.Item(0).Item(0)
    End Sub
   


    Private Sub Form8_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        loadt()
        loads()

    End Sub

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        Dim mo As String = ""
        Dim mo2 As String = ""
        If Me.ComboBox1.SelectedItem.Equals("January") Then

            mo = "1/1/" & Me.TextBox2.Text & " 12:00:00 AM"
            mo2 = "1/31/" & Me.TextBox2.Text & " 11:59:59 PM"
        End If
        If Me.ComboBox1.SelectedItem.Equals("February") Then

            mo = "2/1/" & Me.TextBox2.Text & " 12:00:00 AM"
            mo2 = "2/29/" & Me.TextBox2.Text & " 11:59:59 PM"
        End If
        If Me.ComboBox1.SelectedItem.Equals("March") Then

            mo = "3/1/" & Me.TextBox2.Text & " 12:00:00 AM"
            mo2 = "3/31/" & Me.TextBox2.Text & " 11:59:59 PM"
        End If
        If Me.ComboBox1.SelectedItem.Equals("April") Then
            mo = "4/1/" & Me.TextBox2.Text & " 12:00:00 AM"
            mo2 = "4/30/" & Me.TextBox2.Text & " 11:59:59 PM"

        End If
        If Me.ComboBox1.SelectedItem.Equals("May") Then
            mo = "5/1/" & Me.TextBox2.Text & " 12:00:00 AM"
            mo2 = "5/31/" & Me.TextBox2.Text & " 11:59:59 PM"

        End If
        If Me.ComboBox1.SelectedItem.Equals("June") Then
            mo = "6/1/" & Me.TextBox2.Text & " 12:00:00 AM"
            mo2 = "6/30/2015 11:59:59 PM"


        End If
        If Me.ComboBox1.SelectedItem.Equals("July") Then
            mo = "7/1/" & Me.TextBox2.Text & " 12:00:00 AM"
            mo2 = "7/31/" & Me.TextBox2.Text & " 11:59:59 PM"

        End If
        If Me.ComboBox1.SelectedItem.Equals("August") Then

            mo = "8/1/" & Me.TextBox2.Text & " 12:00:00 AM"
            mo2 = "8/31/" & Me.TextBox2.Text & " 11:59:59 PM"

        End If
        If Me.ComboBox1.SelectedItem.Equals("September") Then

            mo = "9/1/" & Me.TextBox2.Text & " 12:00:00 AM"
            mo2 = "9/30/" & Me.TextBox2.Text & " 11:59:59 PM"


        End If
        If Me.ComboBox1.SelectedItem.Equals("October") Then

            mo = "10/1/" & Me.TextBox2.Text & " 12:00:00 AM"
            mo2 = "10/31/" & Me.TextBox2.Text & " 11:59:59 PM"
        End If
        If Me.ComboBox1.SelectedItem.Equals("November") Then

            mo = "11/1/" & Me.TextBox2.Text & " 12:00:00 AM"
            mo2 = "11/30/" & Me.TextBox2.Text & " 11:59:59 PM"

        End If
        If Me.ComboBox1.SelectedItem.Equals("December") Then

            mo = "12/1/" & Me.TextBox2.Text & " 12:00:00 AM"
            mo2 = "12/30/" & Me.TextBox2.Text & " 11:59:59 PM"

        End If
        Dim dba As New OleDbDataAdapter("SELECT ORNum AS [OR Number], SaleDate AS [Transaction Date/Time], CustomerName AS [Customer], TotalBill AS [Bill], Amount AS [Payment]FROM tbSale WHERE SaleDate BETWEEN #" & mo & "# AND #" & mo2 & "#;", dbc)
        Dim dbs As New DataSet
        dba.Fill(dbs)
        Me.DataGridView1.DataSource = dbs.Tables(0).DefaultView

        Dim dba1 As New OleDbDataAdapter("SELECT SUM([TotalBill]) AS Chu FROM tbSale WHERE SaleDate BETWEEN #" & mo & "# AND #" & mo2 & "#;", dbc)
        Dim dbs1 As New DataSet
        dba1.Fill(dbs1)
        If dbs1.Tables(0).DefaultView.Count > 0 Then
            Me.TextBox1.Text = dbs1.Tables(0).DefaultView.Item(0).Item(0).ToString
        Else
            Me.TextBox1.Text = "0"
        End If

    End Sub
End Class