Вы находитесь на странице: 1из 26

www.konsultasivb.

com
Pusat Kursus VB.Net & Bimbingan Tugas Akhir

APLIKASI RAWAT INAP

VB.Net 2008, Database Access 2003, Crystal Report 8.5


uusrusmawan71@gmail.com

Imports System.Data.OleDb

Public Class Login

Private Sub TUser_KeyPress(ByVal sender As Object, ByVal e As


System.Windows.Forms.KeyPressEventArgs) Handles TUser.KeyPress
If e.KeyChar = Chr(13) Then
TPassword.Focus()
End If
End Sub

Private Sub TPassword_KeyPress(ByVal sender As Object, ByVal e As


System.Windows.Forms.KeyPressEventArgs) Handles TPassword.KeyPress
If e.KeyChar = Chr(13) Then
OK.Focus()
End If
End Sub

Private Sub OK_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles OK.Click
Call Koneksi()
CMD = New OleDbCommand("select * from tbluser where nama_user='" &
TUser.Text & "' and pwd_user='" & TPassword.Text & "'", CONN)
DR = CMD.ExecuteReader
DR.Read()
www.konsultasivb.com
Pusat Kursus VB.Net & Bimbingan Tugas Akhir

If Not DR.HasRows Then


MsgBox("Login gagal")
TUser.Focus()
Exit Sub
Else
Me.Visible = False
MenuUtama.Show()

MenuUtama.Panel1.Text = DR.Item("kode_user")
MenuUtama.Panel2.Text = DR.Item("nama_user")
MenuUtama.Panel3.Text = DR.Item("pwd_user")

If MenuUtama.Panel1.Text = "ADMIN" Then


MenuUtama.UserToolStripMenuItem.Visible = False
End If
End If

End Sub

Private Sub Cancel_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles Cancel.Click
Me.Close()
End Sub
End Class
www.konsultasivb.com
Pusat Kursus VB.Net & Bimbingan Tugas Akhir

Imports System.Data.OleDb

Public Class MasterUser

Sub NomorUserotomatis()
CMD = New OleDbCommand("select kode_User from tblUser order by
kode_User desc", CONN)
DR = CMD.ExecuteReader
DR.Read()
If Not DR.HasRows Then
TextBox1.Text = "USR" + "01"
Else
TextBox1.Text = "USR" +
Format(Microsoft.VisualBasic.Right(DR.Item("kode_User"), 2) + 1, "00")
End If
TextBox1.Enabled = False
End Sub

Sub Kosongkan()
Call NomorUserotomatis()
TextBox2.Clear()
TextBox3.Clear()
ComboBox1.Text = ""
TxtCari.Clear()
TextBox2.Focus()
End Sub
www.konsultasivb.com
Pusat Kursus VB.Net & Bimbingan Tugas Akhir

Sub DataBaru()
TextBox2.Clear()
TextBox3.Clear()
ComboBox1.Text = ""
TxtCari.Clear()
TextBox2.Focus()
End Sub

Sub TampilStatus()
CMD = New OleDbCommand("select distinct Status_user from tbluser",
CONN)
DR = CMD.ExecuteReader
ComboBox1.Items.Clear()
Do While DR.Read
ComboBox1.Items.Add(DR.Item("Status_User"))
Loop
End Sub

Sub TampilGrid()
DA = New OleDbDataAdapter("Select * from tblUser", CONN)
DS = New DataSet
DA.Fill(DS)
DGV.DataSource = DS.Tables(0)
DGV.ReadOnly = True
End Sub

Sub Ketemu()
On Error Resume Next
TextBox2.Text = DR.Item(1)
TextBox3.Text = DR.Item(2)
ComboBox1.Text = DR.Item(3)
TextBox2.Focus()
End Sub

Sub CariKodeUser()
CMD = New OleDbCommand("Select * from tblUser where kode_User='" &
TextBox1.Text & "'", CONN)
DR = CMD.ExecuteReader
DR.Read()
End Sub

Private Sub MasterUser_Load(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles MyBase.Load
Call Koneksi()
Call TampilGrid()
Call TampilStatus()
Call NomorUserotomatis()
TextBox2.Focus()
End Sub
www.konsultasivb.com
Pusat Kursus VB.Net & Bimbingan Tugas Akhir

Private Sub BTNTutup_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles BTNTutup.Click
Me.Close()
End Sub

Private Sub BTNBatal_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles BTNBatal.Click
Call Kosongkan()
Call NomorUserotomatis()
End Sub

Private Sub TextBox1_KeyPress(ByVal sender As Object, ByVal e As


System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress
If e.KeyChar = Chr(13) Then
Call CariKodeUser()
If DR.HasRows Then
Call Ketemu()
Else
Call DataBaru()
End If
End If
End Sub

Private Sub BTNSimpan_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles BTNSimpan.Click
If ComboBox1.Text <> "ADMIN" And ComboBox1.Text <> "USER" Then
MsgBox("Status user tidak valid, isilah 'ADMIN' atau 'USER'")
Exit Sub
End If
Try
Call CariKodeUser()
If Not DR.HasRows Then
Dim simpan As String = "insert into tblUser values('" &
TextBox1.Text & "','" & TextBox2.Text & "','" & TextBox3.Text & "','" &
ComboBox1.Text & "')"
CMD = New OleDbCommand(simpan, CONN)
CMD.ExecuteNonQuery()
Else
Dim edit As String = "Update tblUser set nama_User='" &
TextBox2.Text & "',pwd_User='" & TextBox3.Text & "',status_user='" &
ComboBox1.Text & "' where kode_User='" & TextBox1.Text & "'"
CMD = New OleDbCommand(edit, CONN)
CMD.ExecuteNonQuery()
End If
Call Kosongkan()
Call TampilGrid()
Call TampilStatus()
Call NomorUserotomatis()
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
www.konsultasivb.com
Pusat Kursus VB.Net & Bimbingan Tugas Akhir

Private Sub BTNHapus_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles BTNHapus.Click
If TextBox1.Text = "" Then
MsgBox("Kode User harus diisi")
Exit Sub
End If

Call CariKodeUser()
If Not DR.HasRows Then
MsgBox("Kode User tidak terdaftar")
Exit Sub
End If

CMD = New OleDbCommand("select kode_User from trpembayaran where


kode_User='" & TextBox1.Text & "'", CONN)
DR = CMD.ExecuteReader
DR.Read()
If DR.HasRows Then
MsgBox("kode User tidak dapat dihapus karena sudah ada dalam
transaksi")
Call Kosongkan()
Call NomorUserotomatis()
Exit Sub
End If

If MessageBox.Show("Hapus data ini...?", "", MessageBoxButtons.YesNo)


= Windows.Forms.DialogResult.Yes Then
Dim hapus As String = "delete * from tblUser where kode_User='" &
TextBox1.Text & "'"
CMD = New OleDbCommand(hapus, CONN)
CMD.ExecuteNonQuery()
Call Kosongkan()
Call TampilGrid()
Call TampilStatus()
Call NomorUserotomatis()
Else
Call Kosongkan()
Call NomorUserotomatis()
End If
End Sub

Private Sub DGV_CellMouseClick(ByVal sender As Object, ByVal e As


System.Windows.Forms.DataGridViewCellMouseEventArgs) Handles
DGV.CellMouseClick
On Error Resume Next
TextBox1.Text = DGV.Rows(e.RowIndex).Cells(0).Value
Call CariKodeUser()
If DR.HasRows Then
Call Ketemu()
End If
End Sub
www.konsultasivb.com
Pusat Kursus VB.Net & Bimbingan Tugas Akhir

Private Sub TxtCari_TextChanged(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles TxtCari.TextChanged
DA = New OleDbDataAdapter("select * from tblUser where kode_User like
'%" & TxtCari.Text & "%' or nama_User like '%" & TxtCari.Text & "%'", CONN)
DS = New DataSet
DA.Fill(DS)
DGV.DataSource = DS.Tables(0)
DGV.ReadOnly = True
End Sub
End Class
www.konsultasivb.com
Pusat Kursus VB.Net & Bimbingan Tugas Akhir
www.konsultasivb.com
Pusat Kursus VB.Net & Bimbingan Tugas Akhir
www.konsultasivb.com
Pusat Kursus VB.Net & Bimbingan Tugas Akhir
www.konsultasivb.com
Pusat Kursus VB.Net & Bimbingan Tugas Akhir
www.konsultasivb.com
Pusat Kursus VB.Net & Bimbingan Tugas Akhir

Imports System.Data.OleDb

Public Class Pembayaran

Sub Nomorotomatis()
CMD = New OleDbCommand("select nomor_Pembayaran from TRpembayaran
order by nomor_pembayaran desc", CONN)
DR = CMD.ExecuteReader
DR.Read()
If Not DR.HasRows Then
TextBox1.Text = "00001"
Else
TextBox1.Text = Format(DR.Item("nomor_pembayaran") + 1, "00000")
End If
End Sub
www.konsultasivb.com
Pusat Kursus VB.Net & Bimbingan Tugas Akhir

Sub Kosongkan()
Dim x As Control
For Each x In Me.GroupBox1.Controls
If TypeOf x Is TextBox Or TypeOf x Is ComboBox Then
x.Text = ""
End If
Next x
TxtCari.Clear()
End Sub

Sub TampilGrid()
DA = New OleDbDataAdapter("select * from TRPembayaran", CONN)
DS = New DataSet
DA.Fill(DS)
DGV.DataSource = DS.Tables(0)
DGV.ReadOnly = True
End Sub

Sub TampilRegistrasi()
CMD = New OleDbCommand("select * from TRRegistrasi where
status_Registrasi='TERDAFTAR'", CONN)
DR = CMD.ExecuteReader
ComboBox1.Items.Clear()
Do While DR.Read
ComboBox1.Items.Add(DR.Item("NOMOR_REGISTRASI"))
Loop
End Sub

Sub CariPasien()
CMD = New OleDbCommand("select * from tblpasien where kode_pasien='"
& TextBox3.Text & "'", CONN)
DR = CMD.ExecuteReader
DR.Read()
If DR.HasRows Then
TextBox4.Text = DR.Item("nama_pasien")
End If
End Sub

Sub CariKamar()
CMD = New OleDbCommand("select * from tblkamar where kode_kamar='" &
TextBox5.Text & "'", CONN)
DR = CMD.ExecuteReader
DR.Read()
If DR.HasRows Then
TextBox6.Text = DR.Item("nama_kamar")
TextBox7.Text = DR.Item("tarif_kamar")
End If
End Sub
www.konsultasivb.com
Pusat Kursus VB.Net & Bimbingan Tugas Akhir

Private Sub Pembayaran_Load(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles MyBase.Load
Call Koneksi()
Call Kosongkan()
Call Nol_kan()
Call Nomorotomatis()
Call TampilRegistrasi()
Call TampilGrid()
End Sub

Sub Nol_kan()
TextBox11.Text = 0
TextBox12.Text = 0
TextBox13.Text = 0
TextBox14.Text = 0
TextBox15.Text = 0
TextBox16.Text = 0
TextBox17.Text = 0
TextBox18.Text = "-"
End Sub

Sub TotalBiayaAlat()
On Error Resume Next
CMD = New OleDbCommand("select sum(biaya) from
TRperawatan,TRperawatandetail,TRregistrasi where
trperawatan.nomor_perawatan=trperawatandetail.nomor_perawatan and
trperawatan.nomor_registrasi=trregistrasi.nomor_registrasi and
trperawatandetail.kode_alat<>'-' and trregistrasi.nomor_registrasi='" &
ComboBox1.Text & "'", CONN)
DR = CMD.ExecuteReader
DR.Read()
If DR.HasRows Then
TextBox11.Text = DR.Item(0)
Else
TextBox11.Text = 0
End If
End Sub

Sub TotalBiayaDokter()
On Error Resume Next
CMD = New OleDbCommand("select sum(biaya) from
TRperawatan,TRperawatandetail,TRregistrasi where
trperawatan.nomor_perawatan=trperawatandetail.nomor_perawatan and
trperawatan.nomor_registrasi=trregistrasi.nomor_registrasi and
trperawatandetail.kode_dokter<>'-' and trregistrasi.nomor_registrasi='" &
ComboBox1.Text & "'", CONN)
DR = CMD.ExecuteReader
DR.Read()
If DR.HasRows Then
TextBox12.Text = DR.Item(0)
Else
www.konsultasivb.com
Pusat Kursus VB.Net & Bimbingan Tugas Akhir

TextBox12.Text = 0
End If
End Sub

Sub TotalBiayaObat()
On Error Resume Next
CMD = New OleDbCommand("select sum(biaya) from
TRperawatan,TRperawatandetail,TRregistrasi where
trperawatan.nomor_perawatan=trperawatandetail.nomor_perawatan and
trperawatan.nomor_registrasi=trregistrasi.nomor_registrasi and
trperawatandetail.kode_obat<>'-' and trregistrasi.nomor_registrasi='" &
ComboBox1.Text & "'", CONN)
DR = CMD.ExecuteReader
DR.Read()
If DR.HasRows Then
TextBox13.Text = DR.Item(0)
Else
TextBox13.Text = 0
End If
End Sub

Sub TotalBiayaTindakan()
On Error Resume Next
CMD = New OleDbCommand("select sum(biaya) from
TRperawatan,TRperawatandetail,TRregistrasi where
trperawatan.nomor_perawatan=trperawatandetail.nomor_perawatan and
trperawatan.nomor_registrasi=trregistrasi.nomor_registrasi and
trperawatandetail.kode_tindakan<>'-' and trregistrasi.nomor_registrasi='" &
ComboBox1.Text & "'", CONN)
DR = CMD.ExecuteReader
DR.Read()
If DR.HasRows Then
TextBox14.Text = DR.Item(0)
Else
TextBox14.Text = 0
End If
End Sub

Sub GrandBiaya()
TextBox15.Text = Val(TextBox10.Text) + Val(TextBox11.Text) +
Val(TextBox12.Text) + Val(TextBox13.Text) + Val(TextBox14.Text)
End Sub

Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object,


ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
CMD = New OleDbCommand("select * from TRregistrasi where
nomor_registrasi='" & ComboBox1.Text & "'", CONN)
DR = CMD.ExecuteReader
DR.Read()
If DR.HasRows Then
www.konsultasivb.com
Pusat Kursus VB.Net & Bimbingan Tugas Akhir

TextBox2.Text = DR.Item("Tgl_registrasi")
TextBox3.Text = DR.Item("kode_pasien")
TextBox5.Text = DR.Item("kode_kamar")
Call CariPasien()
Call CariKamar()
TextBox8.Text = Today

TextBox9.Text = DateDiff(DateInterval.Day,
DateValue(TextBox2.Text), Today)
If TextBox9.Text = 0 Then
TextBox9.Text = 1
End If
TextBox10.Text = Val(TextBox7.Text) * Val(TextBox9.Text)
Call Nol_kan()
Call TotalBiayaAlat()
Call TotalBiayaDokter()
Call TotalBiayaObat()
Call TotalBiayaTindakan()
Call GrandBiaya()
TextBox16.Focus()
End If
End Sub

Private Sub BTNBatal_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles BTNBatal.Click
Call Kosongkan()
Call Nol_kan()
Call Nomorotomatis()
End Sub

Private Sub BTNSimpan_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles BTNSimpan.Click
If ComboBox1.Text = "" Then
MsgBox("Nomor registrasi harus diisi")
ComboBox1.Focus()
Exit Sub
End If

Dim simpan As String = "insert into TRpembayaran values('" &


TextBox1.Text & "','" & DateTimePicker1.Value & "','" & ComboBox1.Text &
"','" & TextBox8.Text & "','" & TextBox9.Text & "','" & TextBox10.Text &
"','" & TextBox11.Text & "','" & TextBox12.Text & "','" & TextBox13.Text &
"','" & TextBox14.Text & "','" & TextBox15.Text & "','" & TextBox16.Text &
"','" & TextBox17.Text & "','USR01','" & TextBox18.Text & "')"
CMD = New OleDbCommand(simpan, CONN)
CMD.ExecuteNonQuery()

CMD = New OleDbCommand("select nomor_registrasi from TRregistrasi


where nomor_registrasi='" & ComboBox1.Text & "'", CONN)
DR = CMD.ExecuteReader
DR.Read()
If DR.HasRows Then
www.konsultasivb.com
Pusat Kursus VB.Net & Bimbingan Tugas Akhir

Dim editregistrasi As String = "update TRregistrasi set


status_registrasi='KELUAR' where nomor_registrasi='" & ComboBox1.Text & "'"
CMD = New OleDbCommand(editregistrasi, CONN)
CMD.ExecuteNonQuery()
End If

CMD = New OleDbCommand("select * from TBLkamar where kode_kamar='" &


TextBox5.Text & "'", CONN)
DR = CMD.ExecuteReader
DR.Read()
If DR.HasRows Then
Dim editkamar As String = "update TBLkamar set terisi='" &
DR.Item("terisi") - 1 & "' where kode_kamar='" & TextBox5.Text & "'"
CMD = New OleDbCommand(editkamar, CONN)
CMD.ExecuteNonQuery()

If DR.Item("terisi") < DR.Item("kapasitas") Then


Dim editkamartersedia As String = "update TBLkamar set
status_kamar='TERSEDIA' where kode_kamar='" & TextBox5.Text & "'"
CMD = New OleDbCommand(editkamartersedia, CONN)
CMD.ExecuteNonQuery()
Else
Dim editkamarpenuh As String = "update TBLkamar set
status_kamar='PENUH' where kode_kamar='" & TextBox5.Text & "'"
CMD = New OleDbCommand(editkamarpenuh, CONN)
CMD.ExecuteNonQuery()
End If
End If

CMD = New OleDbCommand("select * from TBLkamar where kode_kamar='" &


TextBox5.Text & "'", CONN)
DR = CMD.ExecuteReader
DR.Read()
If DR.HasRows Then
If DR.Item("terisi") < DR.Item("kapasitas") Then
Dim editkamartersedia As String = "update TBLkamar set
status_kamar='TERSEDIA' where kode_kamar='" & TextBox5.Text & "'"
CMD = New OleDbCommand(editkamartersedia, CONN)
CMD.ExecuteNonQuery()
End If
End If

If MessageBox.Show("Cetak bukti pembayaran...?", "",


MessageBoxButtons.YesNo) = Windows.Forms.DialogResult.Yes Then
Cetak.Show()
Cetak.CRV.SelectionFormula = "{TRpembayaran.nomor_pembayaran} ='"
& TextBox1.Text & "'"
cryRpt.Load("mstr_pembayaran.rpt")
Call seting_laporan()
Cetak.CRV.ReportSource = cryRpt
Cetak.CRV.RefreshReport()
End If
www.konsultasivb.com
Pusat Kursus VB.Net & Bimbingan Tugas Akhir

Call Kosongkan()
Call Nol_kan()
Call Nomorotomatis()
Call TampilGrid()
Call TampilRegistrasi()
End Sub

Private Sub BTNTutup_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles BTNTutup.Click
Me.Close()
End Sub

Private Sub TextBox16_KeyPress(ByVal sender As Object, ByVal e As


System.Windows.Forms.KeyPressEventArgs) Handles TextBox16.KeyPress
If Not (e.KeyChar >= "0" And e.KeyChar <= "9" Or e.KeyChar = vbBack)
Then
e.Handled = True
End If

If e.KeyChar = Chr(13) Then


BTNSimpan.Focus()
End If
End Sub

Private Sub TextBox16_TextChanged(ByVal sender As System.Object, ByVal e


As System.EventArgs) Handles TextBox16.TextChanged
If Val(TextBox16.Text) < Val(TextBox15.Text) Then
TextBox17.Text = 0
TextBox18.Text = "SISA " & Val(TextBox15.Text) -
Val(TextBox16.Text) & ""
ElseIf Val(TextBox16.Text) >= Val(TextBox15.Text) Then
TextBox17.Text = Val(TextBox16.Text) - Val(TextBox15.Text)
TextBox18.Text = "LUNAS"
End If
End Sub
End Class
www.konsultasivb.com
Pusat Kursus VB.Net & Bimbingan Tugas Akhir
www.konsultasivb.com
Pusat Kursus VB.Net & Bimbingan Tugas Akhir
www.konsultasivb.com
Pusat Kursus VB.Net & Bimbingan Tugas Akhir
www.konsultasivb.com
Pusat Kursus VB.Net & Bimbingan Tugas Akhir
www.konsultasivb.com
Pusat Kursus VB.Net & Bimbingan Tugas Akhir
www.konsultasivb.com
Pusat Kursus VB.Net & Bimbingan Tugas Akhir
www.konsultasivb.com
Pusat Kursus VB.Net & Bimbingan Tugas Akhir
www.konsultasivb.com
Pusat Kursus VB.Net & Bimbingan Tugas Akhir

Вам также может понравиться