Public Class frmAddEditUsers
    Private Sub btnClose_Click(sender As Object, e As EventArgs) Handles btnClose.Click
        Me.Close()
    End Sub

    Private Sub btnSave_Click(sender As Object, e As EventArgs) Handles btnSave.Click
        If lblId.Text = "" Then
            If txtName.Text = "" Or txtPass.Text = "" Or txtUname.Text = "" Then
                MsgBox("You must fill up all the textboxes in order to save.", MsgBoxStyle.Information)
            Else
                sql = "INSERT INTO `useraccounts` (`ACCOUNT_NAME`, `ACCOUNT_USERNAME`, `ACCOUNT_PASSWORD`, `ACCOUNT_TYPE`)" _
                & " VALUES ('" & txtName.Text & "','" & txtUname.Text & "',sha('" & txtPass.Text & "'),'" & cboType.Text & "')"
                messageTrue = "User has beeen saved."
                messageFalse = "Failed to save the user."
                CreateUpdateDeleteAllMessage(sql, messageTrue, messageFalse)
            End If
        Else
            sql = "UPDATE `useraccounts` SET `ACCOUNT_NAME`='" & txtName.Text _
                & "', `ACCOUNT_USERNAME`='" & txtUname.Text _
                & "', `ACCOUNT_PASSWORD`=sha('" & txtPass.Text & "'), `ACCOUNT_TYPE`='" & cboType.Text & "'" _
                & " WHERE ACCOUNT_ID='" & lblId.Text & "'"
            messageTrue = "User has beeen updated."
            messageFalse = "Failed to update the user."
            CreateUpdateDeleteAllMessage(sql, messageTrue, messageFalse)
        End If
    End Sub
    Private Sub txtName_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtName.TextChanged
        Try
            If IsNumeric(txtName.Text) = True Then

                txtName.Clear()
            End If
        Catch ex As Exception
            MsgBox(ex.Message)

        End Try
    End Sub

    Private Sub txtPass_Validated(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtPass.Validated
        'If txtPass.TextLength < 8 Then
        '    MsgBox("You have to put 8 to 16 characters.", MsgBoxStyle.Exclamation)
        'End If
    End Sub
    Private Sub lblId_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles lblId.TextChanged
        If lblId.Text = "" Then
        Else
            sql = "SELECT * FROM `useraccounts` WHERE ACCOUNT_ID='" & lblId.Text & "'"
            fillSpecifictxt(sql)
            lblId.Text = dt.Rows(0).Item(0)
            txtName.Text = dt.Rows(0).Item(1)
            txtUname.Text = dt.Rows(0).Item(2)
            'txtPass.Text = dt.Rows(0).Item(3)
            cboType.Text = dt.Rows(0).Item(4)
        End If

    End Sub

End Class