Public Class frmSetting
    Private Sub LoadData()

        ExecuteSQLQuery("SELECT * FROM leavesetting")
        If sqlDT.Rows.Count > 0 Then
            txtAnnual1.Text = sqlDT.Rows(0)("Annual1")
            txtAnnual2.Text = sqlDT.Rows(0)("Annual2")
            txtAnnual3.Text = sqlDT.Rows(0)("Annual3")
        End If

    End Sub
    Private Sub btnLeaveSettingSave_Click(sender As Object, e As EventArgs) Handles btnLeaveSettingSave.Click
        If txtAnnual1.Text = "" Or txtAnnual2.Text = "" Or txtAnnual3.Text = "" Then
            ErrorProvider1.SetError(txtAnnual1, "Mandatory field.")
            ErrorProvider1.SetError(txtAnnual2, "Mandatory field.")
            ErrorProvider1.SetError(txtAnnual3, "Mandatory field.")
        Else
            ErrorProvider1.Clear()
            ExecuteSQLQuery("SELECT * FROM leavesetting")
            If sqlDT.Rows.Count > 0 Then
                ExecuteSQLQuery("UPDATE   leavesetting  SET Annual1='" + str_repl(txtAnnual1.Text) + "', Annual2='" + str_repl(txtAnnual2.Text) + "', Annual3='" + str_repl(txtAnnual3.Text) + "' ")

                MsgBox("Record updated successful.", MsgBoxStyle.Information, "Information")

            Else
                ExecuteSQLQuery(" INSERT INTO leavesetting (Annual1, Annual2, Annual3) VALUES " &
                                 " (" & num_fltr(txtAnnual1.Text) & ", '" + txtAnnual2.Text + "' ,'" + txtAnnual3.Text + "' ) ")
                MsgBox("Record has been saved successfully.", MsgBoxStyle.Information, "Information")
            End If

        End If
    End Sub

    Private Sub frmSetting_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        LoadData()
    End Sub
End Class