﻿Public Class Form1
    Dim startdate As Date

    Private Sub TextBox2_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox2.TextChanged

    End Sub

    Private Sub ListBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListBox1.SelectedIndexChanged

    End Sub

    Private Sub Label5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label5.Click

    End Sub

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        'TODO: This line of code loads data into the 'MydataDataSet.students' table. You can move, or remove it, as needed.
        Me.StudentsTableAdapter.Fill(Me.MydataDataSet.students)
        'TODO: This line of code loads data into the 'MydataDataSet.teachers' table. You can move, or remove it, as needed.
        Me.TeachersTableAdapter.Fill(Me.MydataDataSet.teachers)
        'TODO: This line of code loads data into the 'MydataDataSet.teachers' table. You can move, or remove it, as needed.
        Me.TeachersTableAdapter.Fill(Me.MydataDataSet.teachers)
        'TODO: This line of code loads data into the 'MydataDataSet.students' table. You can move, or remove it, as needed.
        Me.StudentsTableAdapter.Fill(Me.MydataDataSet.students)
        CheckBox1.Visible = False
        CheckBox2.Visible = False
        GroupBox1.Visible = False
    End Sub

    Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
        Dim d1, d2 As Date
        Dim diff, vyears, vmonth, vday As Integer
        d1 = DateTimePicker1.Value
        d2 = DateTimePicker2.Value
        diff = DateDiff(DateInterval.Day, d1, d2)
        vyears = Int(diff / 365.25)
        vmonth = Int(((diff Mod 365.25) / 30.4375))
        'vmonth = (diff - (vyears * 365.25)) / 30.4375
        'vmonth = (diff Mod 365.25) / 30.4375
        vday = diff - ((vyears * 365.25) + (vmonth * 30.4375))
        TextBox5.Text = vyears & " سنوات " & vmonth & " أشهر " & vday & " يوم "
        If vyears >= 6 And vyears <= 10 Then
            GroupBox1.Visible = True
        Else
            GroupBox1.Visible = False
            If vyears < 4 Or vyears > 10 Then MsgBox("تأكد من تاريخ الميلاد")
        End If

        If vyears = 5 And vmonth >= 9 Then
            CheckBox1.Visible = True
        Else
            If vyears = 5 And vmonth >= 6 Then
                CheckBox2.Visible = True
            End If
        End If




    End Sub

    Private Sub CheckBox2_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox2.CheckedChanged
        If CheckBox2.Checked = True Then
            GroupBox1.Visible = True
        Else
            GroupBox1.Visible = False
        End If
    End Sub

    Private Sub CheckBox1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox1.CheckedChanged
        If CheckBox1.Checked = True Then
            GroupBox1.Visible = True
        Else
            GroupBox1.Visible = False
        End If

    End Sub
End Class
