Imports System.Data
Imports System.Data.OleDb
Public Class Form1
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dataset1.Reset()
        SQL = "select * from table1"
        dbconn.Open()
        Dim DataAdapter1 As New OleDbDataAdapter(SQL, dbconn)
        DataAdapter1.Fill(Dataset1, "table1")
        dbconn.Close()
        TextBox1.DataBindings.Add("text", Dataset1, "table1.name")
        TextBox2.DataBindings.Add("text", Dataset1, "table1.city")
        TextBox3.DataBindings.Add("text", Dataset1, "table1.mobile")
        changeposition()
    End Sub
    Private Sub CMDFirstRecord_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CMDFirstRecord.Click
        Me.BindingContext(Dataset1, "table1").Position = 0
        changeposition()
    End Sub
    Private Sub CMDNextRecord_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CMDNextRecord.Click
        Me.BindingContext(Dataset1, "table1").Position += 1
        changeposition()
    End Sub
    Private Sub CMDPreviousRecord_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CMDPreviousRecord.Click
        Me.BindingContext(Dataset1, "table1").Position -= 1
        changeposition()
    End Sub
    Private Sub CMDLastRecord_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CMDLastRecord.Click
        Me.BindingContext(Dataset1, "table1").Position = _
            Me.BindingContext(Dataset1, "table1").Count - 1
        changeposition()
    End Sub
    Public Sub changeposition()
        Label4.Text = " السجل " & Me.BindingContext(Dataset1, "table1").Position + 1 & _
            " من " & Me.BindingContext(Dataset1, "table1").Count
    End Sub
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Me.Hide()
        Form2.Show()
    End Sub

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

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click

        If MsgBox("هل تريد حذف السجل الحالي", MsgBoxStyle.OkCancel, "تأكيد عملية الحذف") _
             = MsgBoxResult.Cancel Then
            Exit Sub
        End If

        SQL = "delete from table1 where mobile ='" & TextBox3.Text & "'"
        Dim delete1 As New OleDbCommand(SQL, dbconn)
        dbconn.Open()
        delete1.ExecuteNonQuery()
        Dataset1.Clear()

        SQL = "select * from table1"
        Dim DataAdapter1 As New OleDbDataAdapter(SQL, dbconn)
        DataAdapter1.Fill(Dataset1, "table1")
        dbconn.Close()
        MsgBox("تمت عملية الحذف من قاعدة البيانات بنجاح")

        changeposition()

    End Sub

    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click

        Form3.TextBox1.Text = Me.TextBox1.Text
        Form3.TextBox2.Text = Me.TextBox2.Text
        Form3.TextBox3.Text = Me.TextBox3.Text

        mobile = TextBox3.Text

        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()
        Form4.Show()
        Dataset1.Reset()

    End Sub
End Class
