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

    Private Sub btnSave_Click(sender As Object, e As EventArgs) Handles btnSave.Click
        If txtQID.Text = "" Or dptQidexpiry.Value = Today.Date() Then
            ErrorProvider1.SetError(txtQID, "Mandatory field.")
            ErrorProvider1.SetError(dptQidexpiry, "Mandatory field.")
        Else
            ErrorProvider1.Clear()
            If btnSave.Text = "SAVE" Then

                ExecuteSQLQuery(" INSERT INTO qid (EMPLOYEE_ID, QIDNumber, QIDExpiry) VALUES " &
                                " ('" + str_repl(txtEmpID.Text) + "', '" + str_repl(txtQID.Text) + "', '" & Format(dptQidexpiry.Value, "yyyy-MM-dd") & "') ")

            ElseIf btnSave.Text = "UPDATE" Then

                ExecuteSQLQuery(" UPDATE  qid SET  EMPLOYEE_ID='" + str_repl(txtEmpID.Text) + "', QIDNumber='" + str_repl(txtQID.Text) + "', QIDExpiry= '" & Format(dptQidexpiry.Value, "yyyy-MM-dd") & "' ")
            End If
            'txtQID.Text = ""
            'dptQidexpiry.Value = Today()
            MsgBox("Record has been saved successfully.", MsgBoxStyle.Information, "Information")
        End If

    End Sub
    Private Sub LoadData()
        ExecuteSQLQuery(" SELECT * FROM qid where EMPLOYEE_ID = '" + str_repl(txtEmpID.Text) + "'")
        If sqlDT.Rows.Count > 0 Then
            txtQID.Text = sqlDT.Rows(0)("QIDNumber")
            dptQidexpiry.Value = sqlDT.Rows(0)("QIDExpiry")
        End If
    End Sub
End Class