Imports System.Data
Imports System.Data.OleDb
Public Class salary
    Dim dr As OleDbDataReader
    Dim cmd As New OleDbCommand
    Dim gSQL As String
    Private Sub salary_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        Call connectdatabase()
        Call GetDocNo()
    End Sub
    Private Sub PictureBox2_Click(sender As Object, e As EventArgs)
        wel.Show()
        Hide()
    End Sub

    Private Sub Button4_Click(sender As Object, e As EventArgs) Handles Button4.Click
        Srem.ShowDialog()
    End Sub

    Private Sub Button6_Click(sender As Object, e As EventArgs) Handles Button6.Click
        Srad.ShowDialog()
    End Sub

    Private Sub PictureBox3_Click(sender As Object, e As EventArgs) Handles PictureBox3.Click
        wel.Show()
        Hide()
    End Sub

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        Dim soi As Integer
        Dim soii As Integer
        Dim tss As Integer
        Dim tt As Integer
        Dim total As Integer

        soi = (esalary.Text * esoi.Text / 100)
        soii = soi
        tss = (esalary.Text - soii) - TextBox3.Text
        tt = (TextBox5.Text - TextBox4.Text - TextBox1.Text)
        total = tss - tt
        Label12.Text = total
    End Sub
    Private Sub GetDocNo()
        gSQL = "Select * From RunDoc Where DocNo = 'SAL'"
        With cmd
            .CommandType = CommandType.Text
            .CommandText = gSQL
            .Connection = cnn
            dr = .ExecuteReader()
        End With
        dr.Read()
        If dr.HasRows Then
            TextBox7.Text = dr.Item("RunNo") + 1
        Else

        End If
        dr.Close()
    End Sub
    Private Sub UpdateDocNo()
        gSQL = "Update RunDoc Set RunNo = '" & TextBox7.Text & "'"
        gSQL += " Where DocNo = 'SAL'"
        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
        advSr.Show()
    End Sub

    Private Sub Button8_Click(sender As Object, e As EventArgs) Handles Button8.Click
        advSr.Show()
    End Sub

    Private Sub Button7_Click(sender As Object, e As EventArgs) Handles Button7.Click
        la.Show()
    End Sub

    Private Sub TextBox7_TextChanged(sender As Object, e As EventArgs) Handles TextBox7.TextChanged

    End Sub

    'Private Sub PictureBox6_Click(sender As Object, e As EventArgs) Handles PictureBox6.Click
    '    gSQL = "Insert Into Leave Values ("
    '    gSQL += "'" & tno.Text & "',"
    '    gSQL += "'" & tEno.Text & "',"
    '    gSQL += "'" & tEname.Text & "',"
    '    gSQL += "'" & TextBox1.Text & "',"
    '    gSQL += "'" & cboTL.SelectedValue & "')"
    '    With cmd
    '        .CommandType = CommandType.Text
    '        .CommandText = gSQL
    '        .Connection = cnn
    '        .ExecuteNonQuery()
    '    End With
    '    MessageBox.Show("เพิ่มรายการใหม่แล้ว", "เพิ่มขอ้มูล", MessageBoxButtons.OK, MessageBoxIcon.Information)
    '    Call UpdateDocNo()
    '    Call Cleartext()
    '    GetDocNo()
    'End Sub
End Class