contoh kode simpan dan edit:
If btnsave.Text = "Save Add" Then
Try
If cbNama.SelectedItem = "- PILIH -" Then
MsgBox("Silahkan pilih Nama Karyawan terlebih dahulu", MsgBoxStyle.Information, "")
Exit Sub
End If
If cbRole.SelectedItem = "- PILIH -" Then
MsgBox("Silahkan pilih Otoritas User terlebih dahulu", MsgBoxStyle.Information, "")
Exit Sub
End If
Dim mYes_No As String = MsgBox("Anda yakin data mau disimpan ?", vbYesNo)
If mYes_No = vbYes Then
Dim NIK, RoleID As String
NIK = Microsoft.VisualBasic.Left(cbNama.SelectedItem, 4)
RoleID = Microsoft.VisualBasic.Left(cbRole.SelectedItem, 1)
MyConnectionUsers.AccessUserInsert(NIK, Trim(txtPassword.Text), _
RoleID)
NonAktif_Inputan()
btnsave.Enabled = False
btnsave.Text = "Save (Ctrl+S)"
btnadd.Focus()
Displaydata()
clear()
Else
NonAktif_Inputan()
clear()
btnadd.Focus()
End If
Catch When Err.Number <> 0
MsgBox("Tidak dapat melakukan proses simpan" _
& vbCrLf & Err.Description)
MyConnection.close()
End Try
ElseIf btnsave.Text = "Save Edit" Then
Try
Dim mYes_No As String = MsgBox("Anda yakin data mau diupdate ?", vbYesNo)
If mYes_No = vbYes Then
Dim NIK, RoleID As String
NIK = Microsoft.VisualBasic.Left(cbNama.SelectedItem, 4)
RoleID = Microsoft.VisualBasic.Left(cbRole.SelectedItem, 1)
MyConnectionUsers.AccessUserUpdate(NIK, RoleID)
NonAktif_Inputan()
btnsave.Text = "Save (Ctrl+S)"
btnsave.Enabled = False
btnadd.Focus()
Displaydata()
clear()
Else
NonAktif_Inputan()
clear()
btnadd.Focus()
End If
Catch When Err.Number <> 0
MsgBox("Tidak dapat melakukan proses update" _
& vbCrLf & Err.Description)
MyConnection.close()
End Try
End If
End Sub
contoh kode Hapus:
Try
If mProcess <> "View" Then
MsgBox("Lakukan pencarian terlebih dahulu, sebelum proses hapus", MsgBoxStyle.Information, "POS")
Else
If cbSearch.SelectedItem = "- PILIH -" Then
MsgBox("Pilih nama karyawan yang mau di hapus/ubah", MsgBoxStyle.Information, "")
Exit Sub
End If
Dim mYes_No As String = MsgBox("Anda yakin data mau dihapus ?", vbYesNo)
If mYes_No = vbYes Then
Dim NIK As String
NIK = Microsoft.VisualBasic.Left(cbNama.SelectedItem, 4)
MyConnectionUsers.AccessUserDelete(NIK)
NonAktif_Inputan()
clear()
Displaydata()
Else
NonAktif_Inputan()
clear()
btnadd.Focus()
End If
End If
Catch When Err.Number <> 0
MsgBox("Tidak dapat melakukan proses hapus" _
& vbCrLf & Err.Description)
MyConnection.close()
End Try
End Sub