Imports System.Data
Imports System.Data.OleDb
Public Class Dividend
    Dim dr As OleDbDataReader
    Dim cmd As New OleDbCommand
    Dim gsql As String
    Private Sub Dividend_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        ConnectDatabase()
        GetDocNo()
        ComboBox1.Items.Add("1")
        ComboBox1.Items.Add("2")
        TextBox14.Text = 50
        TextBox10.Text = 10
        TextBox13.Text = 10
        TextBox12.Text = 20
        TextBox11.Text = 10
    End Sub
    Private Sub GetDocNo()
        gsql = "Select * From RUNDOC Where Doc_No = 'Divi'"
        With cmd
            .CommandType = CommandType.Text
            .CommandText = gsql
            .Connection = cnn
            dr = .ExecuteReader()
        End With
        dr.Read()
        If dr.HasRows Then
            txtSaleNo.Text = dr.Item("Run_No") + 1
        Else
            MessageBox.Show("ไม่พบข้อมูลเลขที่ใบสั่ง กรุณาตรวจสอบ")
        End If
        dr.Close()
    End Sub
    Private Sub UpdateDocNo()
        gsql = "Update RunDoc set Run_No='" & txtSaleNo.Text & "'" '
        gsql += " Where Doc_No = 'Divi'"
        With cmd
            .CommandType = CommandType.Text
            .CommandText = gsql
            .Connection = cnn
            .ExecuteNonQuery()

        End With

    End Sub

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

    Private Sub TextBox1_KeyPress(sender As Object, e As KeyPressEventArgs) Handles TextBox1.KeyPress
        If e.KeyChar = Chr(13) Then

            gsql = "Select * From Employee Where emp_id = '" & TextBox1.Text & "'"
            With cmd
                .CommandType = CommandType.Text
                .CommandText = gsql
                .Connection = cnn
                dr = .ExecuteReader()
            End With

            dr.Read()
            If dr.HasRows Then
                TextBox2.Text = dr.Item("emp_Name").ToString

            Else
                MessageBox.Show("ไม่พบข้อมูล")
            End If
            dr.Close()

        End If


    End Sub


End Class