Private Sub CmdSimpan_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CmdSimpan.Click
If TextBox1.Text = "" Or TextBox2.Text = "" Or TextBox3.Text = "" Or ComboBox1.Text = "" Then
MsgBox("Data Belum Lengkap")
Exit Sub
Else
cmd = New OleDbCommand("Select * from karyawan where kodeptg='" & TextBox1.Text & "'", Conn)
rd = cmd.ExecuteReader
rd.Read()
If Not rd.HasRows Then
Dim sqltambah As String = "Insert into karyawan(kodeptg,username,password,status) values " & _
"('" & TextBox1.Text & "','" & TextBox2.Text & "','" & TextBox3.Text & "','" & ComboBox1.Text & "')"
cmd = New OleDbCommand(sqltambah, Conn)
cmd.ExecuteNonQuery()
Call Kosongkan()
Call Tampilkan()
BtnBuka()
Call TxtKunci()
CmdSimpan.Enabled = False
CmdBatal.Enabled = False
Else
Dim sqledit As String = "update karyawan set username ='" & TextBox2.Text & _
"', password ='" & TextBox3.Text & _
"', status ='" & ComboBox1.Text & _
"' where kodeptg = '" & TextBox1.Text & "'"
cmd = New OleDbCommand(sqledit, Conn)
cmd.ExecuteNonQuery()
Call Kosongkan()
Call Tampilkan()
Conn.Close()
End If
End If
End Sub