DATA BASES
M.accses
No
|
Kode pasien
|
Nama
|
jeniskel
|
Umur
|
Agama
|
Alamat
|
1
|
111
|
LISA
|
perempuan
|
21
|
islam
|
SM RAJA
|
2
|
112
|
FEEHILY
|
LAKI-LAKI
|
21
|
ISLAM
|
TEMBUNG
|
3
|
113
|
DONGHO
|
LAKI-LAKI
|
21
|
ISLAM
|
AEK KANOPAN
|
Imports
System.Data.OleDb
Public Class Form1
Public DB As OleDbConnection
Public CMD As OleDbCommand
Public ADP As OleDbDataAdapter
Public DR As OleDbDataReader
Public DS As New DataSet
Dim SQL As String
Public Sub OPENDB()
Dim
LOKASI = "Provider =
Microsoft.Jet.OLEDB.4.0;Data Source=C:\VB2\rekam medis1.mdb"
DB = New
OleDbConnection(LOKASI)
If
DB.State = ConnectionState.Closed Then
DB.Open()
End If
End Sub
Sub
tampilrecordpasien()
ADP = New
OleDbDataAdapter("SELECT * FROM pasien",
DB)
DS = New
DataSet
ADP.Fill(DS, "pasien")
DataGridView1.DataSource = DS.Tables("pasien")
End Sub
Sub
butoonbaru()
BTNBARU.Enabled = True
BTNSIMPAN.Enabled = False
BTNEDIT.Enabled = False
BTNHAPUS.Enabled = False
BTNBATAL.Enabled = False
End Sub
Sub
butoonedit()
BTNBARU.Enabled = False
BTNSIMPAN.Enabled = False
BTNEDIT.Enabled = True
BTNHAPUS.Enabled = True
BTNBATAL.Enabled = False
End Sub
Sub
butoonsimpan()
BTNBARU.Enabled = False
BTNSIMPAN.Enabled = True
BTNEDIT.Enabled = False
BTNHAPUS.Enabled = False
BTNBATAL.Enabled = True
End Sub
Sub
hapustext()
kodepasien.Text = ""
namapasien.Text = ""
Call
butoonbaru()
End Sub
Private Sub Form1_Load(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Call
OPENDB()
Call
hapustext()
Call
tampilrecordpasien()
jeniskelamin.Items.Add("laki-laki")
jeniskelamin.Items.Add("perempuan")
agama.Items.Add("islam")
agama.Items.Add("kristen")
agama.Items.Add("hindu")
End Sub
Private Sub BTNBARU_Click(ByVal
sender As System.Object, ByVal e As
System.EventArgs)
Call
hapustext()
kodepasien.Focus()
End Sub
Private Sub BTNHAPUS_Click(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles BTNHAPUS.Click
SQL = "DELETE
FROM pasien Where [kode pasien]='" & kodepasien.Text & "'"
CMD = New
OleDbCommand(SQL, DB)
CMD.ExecuteNonQuery()
Call
BTNBARU_Click(sender, e)
Call
tampilrecordpasien()
End Sub
Private Sub kodepasien_KeyPress(ByVal
sender As Object,
ByVal e As
System.Windows.Forms.KeyPressEventArgs) Handles
kodepasien.KeyPress
Dim
tombol As Integer
= Asc(e.KeyChar)
Dim
xkode As String
If
tombol = 13 Then
SQL = "SELECT
* FROM pasien Where [kode pasien]='" & kodepasien.Text & "'"
CMD = New
OleDbCommand(SQL, DB)
DR = CMD.ExecuteReader
DR.Read()
If
DR.HasRows = True Then
namapasien.Text = DR.Item(1)
Call
butoonedit()
MsgBox("DATA
DITEMUKAN!")
Else
xkode = kodepasien.Text
Call
hapustext()
kodepasien.Text = xkode
Call
butoonsimpan()
End
If
kodepasien.Focus()
End If
End Sub
Private Sub BTNBATAL_Click(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles BTNBATAL.Click
Call
hapustext()
kodepasien.Focus()
End Sub
Private Sub BTNEDIT_Click(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles BTNEDIT.Click
SQL = "UPDATE
pasien SET nama='" & namapasien.Text & "'," & _
"jeniskel='" & jeniskelamin.Text
& "'," & _
"umur='" & umur.Text & "'," & _
"agama='" & agama.Text & "' " & _
"alamat='" & alamat.Text & "' " & _
"Where [kode pasien]='" &
kodepasien.Text & "'"
CMD = New
OleDbCommand(SQL, DB)
CMD.ExecuteNonQuery()
Call
BTNBARU_Click(sender, e)
Call
tampilrecordpasien()
End Sub
Private Sub BTNSIMPAN_Click(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles BTNSIMPAN.Click
SQL = "insert
into pasien ([kode pasien], nama, jeniskel, umur, agama, alamat)"
& _
"Values
('" & kodepasien.Text & "','"
& _
namapasien.Text & "','" & _
jeniskelamin.Text & "','" & _
umur.Text & "','" & _
agama.Text & "','" & _
alamat.Text & "')"
CMD = New
OleDbCommand(SQL, DB)
CMD.ExecuteNonQuery()
Call
BTNBARU_Click(sender, e)
Call
tampilrecordpasien()
End Sub
End Class