0% found this document useful (0 votes)
36 views10 pages

Modul Okok

The document describes a database called "klinik" that contains tables for patients, doctors, and registrations. It includes SQL commands to create the tables, insert, update, delete and select data. It also includes code for 3 forms - Form1 allows viewing, adding, editing and deleting registrations. Form2 and Form3 allow selecting patient and doctor details to populate Form1 fields.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
36 views10 pages

Modul Okok

The document describes a database called "klinik" that contains tables for patients, doctors, and registrations. It includes SQL commands to create the tables, insert, update, delete and select data. It also includes code for 3 forms - Form1 allows viewing, adding, editing and deleting registrations. Form2 and Form3 allow selecting patient and doctor details to populate Form1 fields.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 10

Modul

Imports MySql.Data.MySqlClient
Module Module1
Public strkon As String = "server=localhost;uid=root;database=klinik"
Public kon As New MySqlConnection(strkon)
Public perintah As New MySqlCommand
Public cek As MySqlDataReader
Public mda As New MySqlDataAdapter
Public ds As New DataSet
End Module

DATABASE

USE klinik;

CREATE TABLE pasien(

kodepasien CHAR(10) PRIMARY KEY,

namapasien VARCHAR (30),

alamatpasien VARCHAR (30)

)ENGINE INNODB;

CREATE TABLE dokter(

kodedokter CHAR(10) PRIMARY KEY,

namadokter VARCHAR (30),

alamatdokter VARCHAR (30)

)ENGINE INNODB;

CREATE TABLE pendaftaran (

kodependaftaran CHAR (10) PRIMARY KEY,

tgl DATE,

dafkodepasien CHAR(10),
dafkodedokter CHAR(10),

biayaberobat VARCHAR (30)

)ENGINE INNODB;

SELECT
kodependaftaran,tgl,kodepasien,namapasien,alamatpasien,kodedokter,namadokt
er,biayadokter,biayaberobat,(biayadokter+biayaberobat) FROM pendaftaran JOIN
pasien ON dafkodepasien=kodepasien JOIN dokter ON dafkodedokter=kodedokter;

SELECT * FROM PASIEN;

SELECT * FROM DOKTER;

INSERT INTO pendaftaran VALUES('','','','','');

DELETE FROM pendaftaran WHERE kodependaftaran='';

UPDATE pendaftaran SET tgl='', daftarkodepasien='', dafkodedokter='',


biayaberobat='' WHERE kodependaftaran='';

FORM 1

Imports MySql.Data.MySqlClient
Public Class Form1
Sub tampil(ByVal sql As String)
kon.Open()
perintah.Connection = kon
perintah.CommandType = CommandType.Text
perintah.CommandText = Sql
mda.SelectCommand = perintah
ds.Tables.Clear()
mda.Fill(ds, "pendaftaran")
DGV.DataSource = ds.Tables("pendaftaran")
kon.Close()
End Sub
Sub proses(ByVal sql As String)
kon.Open()
perintah.Connection = kon
perintah.CommandType = CommandType.Text
perintah.CommandText = sql
perintah.ExecuteNonQuery()
kon.Close()
End Sub
Sub BERSIH()
TNO.Text = ""
TKOPAS.Text = ""
TNAPAS.Text = ""
TALAMAT.Text = ""
TKODEDOK.Text = ""
TNMDOK.Text = ""
TBIAYADOK.Text = ""
TBIAYAOBAT.Text = ""
TTOTAL.Text = ""
End Sub
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
tampil("SELECT
kodependaftaran,tgl,kodepasien,namapasien,alamatpasien,kodedokter,namadokter,biayadokt
er,biayaberobat,(biayadokter+biayaberobat)AS total FROM pendaftaran JOIN pasien ON
dafkodepasien=kodepasien JOIN dokter ON dafkodedokter=kodedokter")
End Sub

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click


Form2.Show()
End Sub

Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click


Form3.Show()
End Sub

Private Sub Button5_Click(sender As Object, e As EventArgs) Handles Button5.Click


proses("INSERT INTO pendaftaran VALUES('" & TNO.Text & "','" &
Format(DTP.Value, "yyyyMMdd") & "','" & TKOPAS.Text & "','" & TKODEDOK.Text & "','" &
TBIAYAOBAT.Text & "')")

MsgBox("data tersimpan")

tampil("SELECT
kodependaftaran,tgl,kodepasien,namapasien,alamatpasien,kodedokter,namadokter,biayadokt
er,biayaberobat,(biayadokter+biayaberobat)AS total FROM pendaftaran JOIN pasien ON
dafkodepasien=kodepasien JOIN dokter ON dafkodedokter=kodedokter")

TNO.Text = ""
TKOPAS.Text = ""
TNAPAS.Text = ""
TALAMAT.Text = ""
TKODEDOK.Text = ""
TNMDOK.Text = ""
TBIAYADOK.Text = ""
TBIAYAOBAT.Text = ""
TTOTAL.Text = ""
End Sub

Private Sub TBIAYAOBAT_TextChanged(sender As Object, e As EventArgs) Handles


TBIAYAOBAT.TextChanged
TTOTAL.Text = Val(TBIAYADOK.Text) + Val(TBIAYAOBAT.Text)
End Sub

Private Sub DGV_CellClick(sender As Object, e As DataGridViewCellEventArgs)


Handles DGV.CellClick
Dim I As Integer
I = DGV.CurrentRow.Index

TNO.Text = DGV.Rows.Item(I).Cells(0).Value
DTP.Value = DGV.Rows.Item(I).Cells(1).Value
TKOPAS.Text = DGV.Rows.Item(I).Cells(2).Value
TNAPAS.Text = DGV.Rows.Item(I).Cells(3).Value
TALAMAT.Text = DGV.Rows.Item(I).Cells(4).Value
TKODEDOK.Text = DGV.Rows.Item(I).Cells(5).Value
TNMDOK.Text = DGV.Rows.Item(I).Cells(6).Value
TBIAYADOK.Text = DGV.Rows.Item(I).Cells(7).Value
TBIAYAOBAT.Text = DGV.Rows.Item(I).Cells(8).Value
TTOTAL.Text = DGV.Rows.Item(I).Cells(9).Value

End Sub

Private Sub Button6_Click(sender As Object, e As EventArgs) Handles Button6.Click


proses("DELETE FROM pendaftaran WHERE kodependaftaran='" & TNO.Text & "'")

MsgBox("data terhapus")

tampil("SELECT
kodependaftaran,tgl,kodepasien,namapasien,alamatpasien,kodedokter,namadokter,biayadokt
er,biayaberobat,(biayadokter+biayaberobat)AS total FROM pendaftaran JOIN pasien ON
dafkodepasien=kodepasien JOIN dokter ON dafkodedokter=kodedokter")

TNO.Text = ""
TKOPAS.Text = ""
TNAPAS.Text = ""
TALAMAT.Text = ""
TKODEDOK.Text = ""
TNMDOK.Text = ""
TBIAYADOK.Text = ""
TBIAYAOBAT.Text = ""
TTOTAL.Text = ""
End Sub

Private Sub Button7_Click(sender As Object, e As EventArgs) Handles Button7.Click


proses("UPDATE pendaftaran SET tgl='" & Format(DTP.Value, "yyyyMMdd") & "',
dafkodepasien='" & TKOPAS.Text & "', dafkodedokter='" & TKODEDOK.Text & "',
biayaberobat='" & TBIAYAOBAT.Text & "' WHERE kodependaftaran='" & TNO.Text & "'")
MsgBox("data terupdate")

tampil("SELECT
kodependaftaran,tgl,kodepasien,namapasien,alamatpasien,kodedokter,namadokter,biayadokt
er,biayaberobat,(biayadokter+biayaberobat)AS total FROM pendaftaran JOIN pasien ON
dafkodepasien=kodepasien JOIN dokter ON dafkodedokter=kodedokter")

TNO.Text = ""
TKOPAS.Text = ""
TNAPAS.Text = ""
TALAMAT.Text = ""
TKODEDOK.Text = ""
TNMDOK.Text = ""
TBIAYADOK.Text = ""
TBIAYAOBAT.Text = ""
TTOTAL.Text = ""
End Sub

Private Sub Button4_Click(sender As Object, e As EventArgs) Handles Button4.Click

TNO.Text = ""
TKOPAS.Text = ""
TNAPAS.Text = ""
TALAMAT.Text = ""
TKODEDOK.Text = ""
TNMDOK.Text = ""
TBIAYADOK.Text = ""
TBIAYAOBAT.Text = ""
TTOTAL.Text = ""
End Sub
End Class

FORM2

Public Class Form2


Sub tampil(ByVal sql As String)
kon.Open()
perintah.Connection = kon
perintah.CommandType = CommandType.Text
perintah.CommandText = Sql
mda.SelectCommand = perintah
ds.Tables.Clear()
mda.Fill(ds, "pendaftaran")
DGV.DataSource = ds.Tables("pendaftaran")
kon.Close()
End Sub
Private Sub Form2_Load(sender As Object, e As EventArgs) Handles MyBase.Load
tampil("SELECT * FROM PASIEN")
End Sub

Private Sub DGV_CellClick(sender As Object, e As DataGridViewCellEventArgs)


Handles DGV.CellClick
Dim I As Integer
I = DGV.CurrentRow.Index

Form1.TKOPAS.Text = DGV.Rows.Item(I).Cells(0).Value
Form1.TNAPAS.Text = DGV.Rows.Item(I).Cells(1).Value
Form1.TALAMAT.Text = DGV.Rows.Item(I).Cells(2).Value
Me.Dispose()
End Sub

End Class

FORM 3
Public Class Form3
Sub tampil(ByVal sql As String)
kon.Open()
perintah.Connection = kon
perintah.CommandType = CommandType.Text
perintah.CommandText = Sql
mda.SelectCommand = perintah
ds.Tables.Clear()
mda.Fill(ds, "pendaftaran")
DGV.DataSource = ds.Tables("pendaftaran")
kon.Close()
End Sub
Private Sub Form3_Load(sender As Object, e As EventArgs) Handles MyBase.Load
tampil("SELECT * FROM DOKTER")
End Sub

Private Sub DGV_CellClick(sender As Object, e As DataGridViewCellEventArgs)


Handles DGV.CellClick
Dim I As Integer
I = DGV.CurrentRow.Index

Form1.TKODEDOK.Text = DGV.Rows.Item(I).Cells(0).Value
Form1.TNMDOK.Text = DGV.Rows.Item(I).Cells(1).Value
Form1.TBIAYADOK.Text = DGV.Rows.Item(I).Cells(2).Value
Me.Dispose()
End Sub
End Class
CREATE DATABASE BARANG;
USE BARANG;

CREATE TABLE BRG (


KODEBRG CHAR(10) PRIMARY KEY,
NAMABRG VARCHAR(30),
harga DOUBLE
)ENGINE INNODB;

CREATE TABLE TRANS (


FAKTUR CHAR(10) PRIMARY KEY,
TGL DATE,
TRANSKODEBRG CHAR(10),
JUMLAH INT
)ENGINE INNODB;

SELECT
FAKTUR,TGL,KODEBRG,NAMABRG,harga,TRANSKODEBRG,JUM
LAH, (harga*jumlah)FROM TRANS JOIN BRG ON
transkodebrg=kodebrg;
INSERT INTO trans ('','','','');

UPDATE trans SET faktur = '',tgl='', transkodebrg='', jumlah=''

Public Class Form1


Sub tampil(ByVal sql As String)
kon.Open()
perintah.Connection = kon
perintah.CommandType = CommandType.Text
perintah.CommandText = Sql
mda.SelectCommand = perintah
ds.Tables.Clear()
mda.Fill(ds, "trans")
DataGridView1.DataSource = ds.Tables("trans")
kon.Close()
End Sub
Sub proses(ByVal sql As String)
kon.Open()
perintah.Connection = kon
perintah.CommandType = CommandType.Text
perintah.CommandText = sql
perintah.ExecuteNonQuery()
kon.Close()
End Sub

Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load


tampil("SELECT FAKTUR,TGL,KODEBRG,NAMABRG,harga,TRANSKODEBRG,JUMLAH,
(harga*jumlah)FROM TRANS JOIN BRG ON transkodebrg=kodebrg")
End Sub

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click


Form2.Show()

End Sub

Private Sub TextBox6_TextChanged(sender As Object, e As EventArgs) Handles


TextBox6.TextChanged

End Sub

Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click


proses("insert into trans values ('" & TextBox1.Text & "','" &
Format(DateTimePicker1.Value, "yyyyMMdd") & "','" & TextBox2.Text & "','" &
TextBox5.Text & "') ")

MsgBox("data tersimpan")
tampil("SELECT FAKTUR,TGL,KODEBRG,NAMABRG,harga,TRANSKODEBRG,JUMLAH,
(harga*jumlah)FROM TRANS JOIN BRG ON transkodebrg=kodebrg")
End Sub
Private Sub TextBox5_TextChanged(sender As Object, e As EventArgs) Handles
TextBox5.TextChanged
TextBox6.Text = Val(TextBox5.Text) * Val(TextBox4.Text)
End Sub

Private Sub Button4_Click(sender As Object, e As EventArgs) Handles Button4.Click


proses("DELETE FROM trans WHERE faktur='" & TextBox1.Text & "'")

MsgBox("data terhapus")
tampil("SELECT KODEBRG,NAMABRG,harga,FAKTUR,TGL,TRANSKODEBRG,JUMLAH,
(harga*jumlah)FROM TRANS JOIN BRG ON transkodebrg=kodebrg")
End Sub

Private Sub Button5_Click(sender As Object, e As EventArgs) Handles Button5.Click


proses("update trans SET tgl='" & Format(DateTimePicker1.Value, "yyyyMMdd") &
"', transkodebrg='" & TextBox2.Text & "', jumlah='" & TextBox5.Text & "' WHERE
FAKTUR='" & TextBox1.Text & "'")

MsgBox("data terupdate")
tampil("SELECT KODEBRG,NAMABRG,harga,FAKTUR,TGL,TRANSKODEBRG,JUMLAH,
(harga*jumlah)FROM TRANS JOIN BRG ON transkodebrg=kodebrg")
End Sub

Private Sub DataGridView1_CellClick(sender As Object, e As


DataGridViewCellEventArgs) Handles DataGridView1.CellClick
Dim I As Integer
I = DataGridView1.CurrentRow.Index

TextBox1.Text = DataGridView1.Rows.Item(I).Cells(0).Value
DateTimePicker1.Value = DataGridView1.Rows.Item(I).Cells(1).Value
TextBox2.Text = DataGridView1.Rows.Item(I).Cells(2).Value
TextBox3.Text = DataGridView1.Rows.Item(I).Cells(3).Value
TextBox4.Text = DataGridView1.Rows.Item(I).Cells(4).Value
TextBox5.Text = DataGridView1.Rows.Item(I).Cells(5).Value
TextBox6.Text = DataGridView1.Rows.Item(I).Cells(6).Value

End Sub

Private Sub DataGridView1_CellContentClick(sender As Object, e As


DataGridViewCellEventArgs) Handles DataGridView1.CellContentClick

End Sub
End Class

Public Class Form2


Sub tampil(ByVal sql As String)
kon.Open()
perintah.Connection = kon
perintah.CommandType = CommandType.Text
perintah.CommandText = Sql
mda.SelectCommand = perintah
ds.Tables.Clear()
mda.Fill(ds, "trans")
DataGridView1.DataSource = ds.Tables("trans")
kon.Close()
End Sub
Sub proses(ByVal sql As String)
kon.Open()
perintah.Connection = kon
perintah.CommandType = CommandType.Text
perintah.CommandText = sql
perintah.ExecuteNonQuery()
kon.Close()
End Sub

Private Sub DataGridView1_CellClick(sender As Object, e As


DataGridViewCellEventArgs) Handles DataGridView1.CellClick
Dim I As Integer
I = DataGridView1.CurrentRow.Index

Form1.TextBox2.Text = DataGridView1.Rows.Item(I).Cells(0).Value
Form1.TextBox3.Text = DataGridView1.Rows.Item(I).Cells(1).Value
Form1.TextBox4.Text = DataGridView1.Rows.Item(I).Cells(2).Value
Me.Dispose()

End Sub
Private Sub DataGridView1_CellContentClick(sender As Object, e As
DataGridViewCellEventArgs) Handles DataGridView1.CellContentClick

End Sub

Private Sub Form2_Load(sender As Object, e As EventArgs) Handles MyBase.Load


tampil("SELECT * FROM brg")
End Sub
End Class

You might also like