Public Class Form9
    Dim db_informatique4 As New class4
    Dim db_informatique2 As New class2
    Dim masroufi As Double
    Dim thf, tmf, tsf As Integer



    Private Sub Form9_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
     
        db_informatique2.Myreq = "select*from factureachat"
        db_informatique2.Connecting_in_informatique()
        ListView2.Items.Clear()
        Do While db_informatique2.rdr.Read()

            Dim testd As Date = (db_informatique2.rdr(8).ToString)

            Dim s3 As Long = DateDiff(DateInterval.Day, Today, testd)


            If s3 < NumericUpDown1.Text And (db_informatique2.rdr(4).ToString) > 0 Then
                ListView2.Items.Add(New ListViewItem({(db_informatique2.rdr(0).ToString), (db_informatique2.rdr(1).ToString), (db_informatique2.rdr(4).ToString), (db_informatique2.rdr(8).ToString)}))

            End If
            For i = 0 To ListView2.Items.Count - 1 Step 1
                Dim testd2 As Date = ListView2.Items(i).SubItems(3).Text
                Dim s4 As Long = DateDiff(DateInterval.Day, Today, testd2)

                If s4 <= 0 Then
                    ListView2.Items(i).BackColor = Color.Red
                Else
                    ListView2.Items(i).BackColor = Color.Yellow

                End If
            Next

        Loop
        db_informatique2.Disconnecting_in_informatique()
    End Sub

    Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button7.Click
        Me.Hide()
        Form5.Show()

    End Sub

    Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click
        Me.Hide()
        Form8.Show()

    End Sub

    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        Me.Hide()
        Form4.Show()
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Me.Hide()
        Form3.Show()
    End Sub

    Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
        Me.Hide()
        Form2.Show()
    End Sub

    Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
        Me.Hide()
        Form1.Show()
    End Sub

   
    Private Sub Form9_FormClosed(ByVal sender As System.Object, ByVal e As System.Windows.Forms.FormClosedEventArgs) Handles MyBase.FormClosed
        End
    End Sub

    Private Sub NumericUpDown1_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles NumericUpDown1.ValueChanged
        db_informatique2.Myreq = "select*from factureachat"
        db_informatique2.Connecting_in_informatique()
        ListView2.Items.Clear()
        Do While db_informatique2.rdr.Read()

            Dim testd As Date = (db_informatique2.rdr(8).ToString)

            Dim s3 As Long = DateDiff(DateInterval.Day, Today, testd)


            If s3 < NumericUpDown1.Text And (db_informatique2.rdr(4).ToString) > 0 Then
                ListView2.Items.Add(New ListViewItem({(db_informatique2.rdr(0).ToString), (db_informatique2.rdr(1).ToString), (db_informatique2.rdr(4).ToString), (db_informatique2.rdr(8).ToString)}))

            End If
            For i = 0 To ListView2.Items.Count - 1 Step 1
                Dim testd2 As Date = ListView2.Items(i).SubItems(3).Text
                Dim s4 As Long = DateDiff(DateInterval.Day, Today, testd2)

                If s4 <= 0 Then
                    ListView2.Items(i).BackColor = Color.Red
                Else
                    ListView2.Items(i).BackColor = Color.Yellow

                End If
            Next

        Loop
        db_informatique2.Disconnecting_in_informatique()
    End Sub
End Class
