From menu
listing
program menu
Public Class Form1
Public Class Form1
Private Sub DATADOKTERToolStripMenuItem_Click(ByVal sender As
System.Object, ByVal e As
System.EventArgs) Handles
DATADOKTERToolStripMenuItem.Click
MEDIS_LISA.Show()
End Sub
Private Sub KELUARToolStripMenuItem_Click(ByVal sender As
System.Object, ByVal e As
System.EventArgs) Handles
KELUARToolStripMenuItem.Click
End
End Sub
Private Sub Form1_Load(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
End Sub
End Class
FROM DATA DOKTER SPECIALIS
listining program
Imports MySql.Data.MySqlClient
Public Class MEDIS_LISA
Public db As New
MySql.Data.MySqlClient.MySqlConnection
Public sql As String
Public cmd As MySqlCommand
Public rs As MySqlDataReader
Sub
opendb()
sql = "server=localhost;uid=root;pwd;database=dokterlisa"
Try
db.ConnectionString = sql
db.Open()
Catch
ex As Exception
MessageBox.Show(ex.Message)
End Try
End Sub
Sub
bersih()
kodedokter.Text = ""
namadokter.Text = ""
specialis.Text = ""
alamat.Text = ""
rubahbutton(True,
False, False, False, False, True)
kodedokter.Enabled = True
End Sub
Sub
rubahbutton(ByVal btn1 As
Boolean, ByVal
btn2 As Boolean,
ByVal btn3 As Boolean, ByVal btn4 As Boolean, ByVal btn5 As Boolean, ByVal btn6 As Boolean)
btnbaru.Enabled = btn1
btnsimpan.Enabled = btn2
btnedit.Enabled = btn3
btnhapus.Enabled = btn4
btnbatal.Enabled = btn5
btnkeluar.Enabled = btn6
End Sub
Sub
buattable()
lv.Columns.Add("kode_dokter",
80, HorizontalAlignment.Center)
lv.Columns.Add("nama_dokter",
180, HorizontalAlignment.Left)
lv.Columns.Add("specialis",
80, HorizontalAlignment.Left)
lv.Columns.Add("alamat",
100, HorizontalAlignment.Left)
lv.GridLines = True
lv.FullRowSelect = True
lv.View = View.Details
End Sub
Sub
isitable()
lv.Items.Clear()
sql = "select
* from dokter"
cmd = New
MySqlCommand(sql, db)
rs = cmd.ExecuteReader
Try
While
rs.Read
Dim
lst As New
ListViewItem
lst.Text = rs("kode_dokter")
lst.SubItems.Add(rs("nama_dokter"))
lst.SubItems.Add(rs("specialis"))
lst.SubItems.Add(rs("alamat"))
lv.Items.Add(lst)
End
While
Catch
ex As Exception
MsgBox(ex.Message)
End Try
rs.Close()
End Sub
Sub
prosesdb(ByVal log As
Integer)
Dim
pesan As String
= ""
Select Case log
Case
0
sql = "insert
into dokter values(kode_dokter,nama_dokter,specialis,alamat)" &
_
"values('"
& kodedokter.Text & _
"','"
& namadokter.Text & _
"','"
& specialis.Text & _
"','"
& alamat.Text & "')"
pesan = "data telah tersimpan"
Case
1
sql = "update
dokter set nama_dokter='" & namadokter.Text & "'," & _
"specialis='"
& specialis.Text & "',"
& _
"alamat='"
& alamat.Text & "'," &
_
"where
kode_alamat='" & kodedokter.Text & "'"
pesan = "data telah terupdate"
Case
2
sql = "delete
from dokter where kode_dokter='" & kodedokter.Text & "'"
pesan = "data telah dihapus"
End Select
Try
cmd = New
MySqlCommand(sql, db)
cmd.ExecuteNonQuery()
MsgBox(pesan,
MsgBoxStyle.Information + MsgBoxStyle.OkOnly, "konfirmsi")
Call
bersih()
Call
isitable()
Catch
ex As Exception
MessageBox.Show(ex.Message)
End Try
End Sub
Sub
showdb()
rs.Read()
kodedokter.Text = rs("kode_dokter")
namadokter.Text = rs("nama_dokter")
specialis.Text = rs("specialis")
alamat.Text = rs("alamat")
rubahbutton(False,
False, True, True, True, False)
btnsimpan.text = "edit"
kodedokter.Enabled = False
End Sub
Private Sub form1_Load(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Call
opendb()
Call
bersih()
Call
buattable()
Call
isitable()
End Sub
Private Sub baru_Click(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles btnbaru.Click
Call
bersih()
kodedokter.Focus()
End Sub
Private Sub batal_Click(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles btnbatal.Click
Call
bersih()
kodedokter.Focus()
End Sub
Private Sub keluar_Click(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles btnkeluar.Click
End
End Sub
Private Sub hapus_Click(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles btnhapus.Click
Dim x As String
x = MsgBox("anda
yakin akan menghapus", MsgBoxStyle.Information + MsgBoxStyle.YesNo,
"hapus")
If x =
vbYes Then
Call
prosesdb(2)
End If
End Sub
Private Sub simpan_Click(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles btnsimpan.Click
If
btnsimpan.text = "simpan" Then prosesdb(0) Else
prosesdb(1)
End Sub
Private Sub kodedokter_KeyPress(ByVal
sender As Object,
ByVal e As
System.Windows.Forms.KeyPressEventArgs) Handles
kodedokter.KeyPress
Dim
tombol As Integer
= Asc(e.KeyChar)
If
tombol = 13 Then
Dim
x As String
If
kodedokter.Text = "" Then
MsgBox("isi
No kamar terlebih dahulu")
Else
sql = "select
* from dokter where kode_dokter='" & kodedokter.Text & "'"
cmd = New
MySqlCommand(sql, db)
rs = cmd.ExecuteReader
Try
Call
showdb()
Catch
ex As Exception
x = kodedokter.Text
bersih()
kodedokter.Text = x
rubahbutton(False, True, False, False, True, False)
btnsimpan.Text = "simpan"
End
Try
namadokter.Focus()
rs.Close()
End
If
End If
End Sub
TAMPILAN FROM CETAK LAPORAN
DEMIKIANLAH POSTINGAN SAYA.....
NAMA : Mahdalisa Fitri Tanjung
NPM : 1102090
Tidak ada komentar:
Posting Komentar