(Form Menu Utama Dan Form Tamu)
Design Form Utama
Listing Program
Public Class Form1
Private Sub DataTamuToolStripMenuItem_Click(ByVal sender As
System.Object, ByVal e As
System.EventArgs) Handles
DataTamuToolStripMenuItem.Click
Form2.Show()
End Sub
Private Sub DataPesananToolStripMenuItem_Click(ByVal sender As
System.Object, ByVal e As
System.EventArgs) Handles
DataPesananToolStripMenuItem.Click
Form3.Show()
End Sub
Private Sub DataLayananToolStripMenuItem_Click(ByVal sender As
System.Object, ByVal e As
System.EventArgs) Handles
DataLayananToolStripMenuItem.Click
Form4.Show()
End Sub
Private Sub DataRuanganToolStripMenuItem_Click(ByVal sender As
System.Object, ByVal e As
System.EventArgs) Handles
DataRuanganToolStripMenuItem.Click
Form5.Show()
End Sub
Private Sub KeluarProgramToolStripMenuItem_Click(ByVal sender As
System.Object, ByVal e As
System.EventArgs) Handles
KeluarProgramToolStripMenuItem.Click
End
End Sub
Private Sub LapTamuToolStripMenuItem_Click(ByVal sender As
System.Object, ByVal e As
System.EventArgs) Handles
LapTamuToolStripMenuItem.Click
Dim
laporan As New
CrystalReport1
cetak1.CrystalReportViewer1.ReportSource = laporan
cetak1.Show()
End Sub
Private Sub LapPesananToolStripMenuItem_Click(ByVal sender As
System.Object, ByVal e As
System.EventArgs) Handles
LapPesananToolStripMenuItem.Click
Dim
laporan As New
CrystalReport2
cetak2.CrystalReportViewer1.ReportSource = laporan
cetak2.Show()
End Sub
Private Sub LapLayananToolStripMenuItem_Click(ByVal sender As
System.Object, ByVal e As
System.EventArgs) Handles
LapLayananToolStripMenuItem.Click
Dim
laporan As New
CrystalReport3
cetak3.CrystalReportViewer1.ReportSource = laporan
cetak3.Show()
End Sub
Private Sub LapRuanganToolStripMenuItem_Click(ByVal sender As
System.Object, ByVal e As
System.EventArgs) Handles
LapRuanganToolStripMenuItem.Click
Dim
laporan As New
CrystalReport4
cetak4.CrystalReportViewer1.ReportSource = laporan
cetak4.Show()
End Sub
End Class
Listing Program Module
Imports
System.Data.OleDb
Module Module1
Public DB As OleDbConnection
Public CMD As OleDbCommand
Public ADP As OleDbDataAdapter
Public DR As OleDbDataReader
Public DS As New DataSet
Public SQL As String
Public Sub Opendb()
Dim
LOKASI = "Provider=Microsoft.Jet.OLEDB.4.0;Data
Source =C:\vb4\karaoke.mdb"
DB = New
OleDbConnection(LOKASI)
If
DB.State = ConnectionState.Closed Then
DB.Open()
End If
End Sub
Sub
tampilrecord(ByVal NamaTabel As String, ByVal obj As
DataGridView)
ADP = New
OleDbDataAdapter("select * from "
& NamaTabel, DB)
DS = New
DataSet
ADP.Fill(DS, NamaTabel)
obj.DataSource = DS.Tables(NamaTabel)
End Sub
Sub
clearfrom(ByVal frm As
Form)
Dim
ctrl As Control
Dim
txtcontrol As TextBox
Dim
cmbcontrol As ComboBox
For Each ctrl In
frm.Controls
If TypeOf ctrl Is
TextBox Then
txtcontrol = ctrl
txtcontrol.Text = ""
ElseIf
TypeOf ctrl Is
ComboBox Then
cmbcontrol = ctrl
cmbcontrol.Text = ""
End
If
Next
End Sub
End Module
Design Dan Hasil
Setelah Dijalankan
Listing Program
Imports
System.Data.OleDb
Public Class Form2
Dim SQL As String
Sub
buttonbaru()
Btnbaru.Enabled = True
Btnsimpan.Enabled = False
Btnedit.Enabled = False
Btnhapus.Enabled = False
Btnbatal.Enabled = False
Btnkeluar.Enabled = True
End Sub
Sub
buttonedit()
Btnbaru.Enabled = False
Btnsimpan.Enabled = False
Btnedit.Enabled = True
Btnhapus.Enabled = True
Btnbatal.Enabled = True
Btnkeluar.Enabled = False
End Sub
Sub
buttonsimpan()
Btnbaru.Enabled = False
Btnsimpan.Enabled = True
Btnedit.Enabled = False
Btnhapus.Enabled = False
Btnbatal.Enabled = True
Btnkeluar.Enabled = False
End Sub
Sub
HapusText()
Call
clearfrom(Me)
Call
buttonbaru()
End Sub
Private Sub Btnhapus_Click(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles Btnhapus.Click
Call
prosesdb(2)
End Sub
Private Sub Btnbaru_Click(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles Btnbaru.Click
Call
HapusText()
No_Bukti.Focus()
End Sub
Private Sub Btnkeluar_Click(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles Btnkeluar.Click
Me.Close()
End Sub
Sub
tampilkodePesanan()
Kd_Pesan.Items.Clear()
SQL = "select
* from Pesanan"
CMD = New
OleDbCommand(SQL, DB)
DR = CMD.ExecuteReader
While
DR.Read
Kd_Pesan.Items.Add(DR("Kd_Pesan"))
End While
DR.Close()
End Sub
Sub
tampilkodePaket()
Kd_Paket.Items.Clear()
SQL = "select
* from Paket"
CMD = New
OleDbCommand(SQL, DB)
DR = CMD.ExecuteReader
While
DR.Read
Kd_Paket.Items.Add(DR("Kd_Paket"))
End While
DR.Close()
End Sub
Sub
tampilkoderuangan()
Kd_Ruangan.Items.Clear()
SQL = "select
* from ruangan"
CMD = New
OleDbCommand(SQL, DB)
DR = CMD.ExecuteReader
While
DR.Read
Kd_Ruangan.Items.Add(DR("Kd_Ruangan"))
End While
DR.Close()
End Sub
Private Sub Form2_Load(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Call
Opendb()
Call
HapusText()
Call
tampilrecord("tamu",
DataGridView1)
Call
tampilkodePesanan()
Call
tampilkodePaket()
Call
tampilkoderuangan()
End Sub
Private Sub No_Bukti_KeyPress(ByVal
sender As Object,
ByVal e As
System.Windows.Forms.KeyPressEventArgs) Handles
No_Bukti.KeyPress
Dim
tombol As Integer
= Asc(e.KeyChar)
Dim
xkode As String
Dim xkd
As String = ""
Dim
xkdPaket As String
= ""
Dim
xkdruangan As String
= ""
If
tombol = 13 Then
SQL = "SELECT
*FROM tamu where No_Bukti='" & No_Bukti.Text & "'"
CMD = New
OleDbCommand(SQL, DB)
DR = CMD.ExecuteReader
DR.Read()
If
DR.HasRows = True Then
Nama.Text = DR.Item(1)
No_Hp.Text = DR.Item(2)
xkd = DR.Item(3)
Harga.Text = DR.Item(4)
xkdPaket = DR.Item(5)
Jlh_Orang.Text = DR.Item(6)
Lm_Waktu.Text = DR.Item(7)
xkdruangan = DR.Item(8)
Jenis.Text = DR.Item(9)
Call
buttonedit()
MsgBox("Data
ditemukan...! ")
Else
xkode = No_Bukti.Text
Call
HapusText()
No_Bukti.Text = xkode
Kd_Paket.Text = xkdPaket
Kd_Ruangan.Text = xkdruangan
Call
buttonsimpan()
End
If
DR.Close()
Nama.Focus()
Kd_Pesan.Text = xkd
Kd_Paket.Text = xkdPaket
Kd_Ruangan.Text = xkdruangan
End If
End Sub
Private Sub Btnbatal_Click(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles Btnbatal.Click
Call
HapusText()
No_Bukti.Focus()
End Sub
Private Sub Btnedit_Click(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles Btnedit.Click
Call
prosesdb(1)
End Sub
Private Sub Btnsimpan_Click(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles Btnsimpan.Click
Call
prosesdb(0)
End Sub
Private Sub Kd_Pesan_SelectedIndexChanged(ByVal sender As
System.Object, ByVal e As
System.EventArgs) Handles
Kd_Pesan.SelectedIndexChanged
SQL = "SELECT
*FROM Pesanan where Kd_Pesan='" & Kd_Pesan.Text & "'"
CMD = New
OleDbCommand(SQL, DB)
DR = CMD.ExecuteReader
If
DR.HasRows Then
DR.Read()
Pesan.Text = DR("Nm_Pesan")
End If
End Sub
Private Sub Kd_Paket_SelectedIndexChanged(ByVal sender As
System.Object, ByVal e As
System.EventArgs) Handles
Kd_Paket.SelectedIndexChanged
SQL = "SELECT
*FROM Paket where Kd_Paket='" & Kd_Paket.Text & "'"
CMD = New
OleDbCommand(SQL, DB)
DR = CMD.ExecuteReader
If
DR.HasRows Then
DR.Read()
Paket.Text = DR("Nm_Paket")
End If
End Sub
Sub
prosesdb(ByVal aktifitas As Byte)
Select Case aktifitas
Case
0
SQL = "INSERT
INTO tamu(No_Bukti, Nama, No_Hp, Pesan, Harga, Paket, Jlh_Orang, Lm_Waktu,
Ruangan, Jenis) " & _
"
values('" & No_Bukti.Text & "','"
& _
Nama.Text
& "','" & _
No_Hp.Text
& "','" & _
Pesan.Text
& "','" & _
Harga.Text
& "','" & _
Paket.Text
& "','" & _
Jlh_Orang.Text & "','"
& _
Lm_Waktu.Text & "','"
& _
Ruangan.Text & "','"
& _
Jenis.Text & "')"
Case
1
SQL = "UPDATE
tamu SET Nama='" & Nama.Text & "',"
& _
"No_Hp='" & No_Hp.Text & "'," & _
"Pesan='" & Kd_Pesan.Text & "'," & _
"Harga='" & Harga.Text & "'," & _
"Paket='" & Kd_Paket.Text & "'," & _
"Jlh_Orang='" & Jlh_Orang.Text &
"'," & _
"Lm_Waktu='" & Lm_Waktu.Text & "'," & _
"Ruangan='" & Kd_Ruangan.Text & "'," & _
" Jenis='" & Jenis.Text & "' " & _
" Where No_Bukti='" & No_Bukti.Text
& "'"
Case
2
SQL = "DELETE
*FROM tamu Where No_Bukti='" & No_Bukti.Text & "'"
End Select
CMD = New
OleDbCommand(SQL, DB)
CMD.ExecuteNonQuery()
Call
HapusText()
Call
tampilrecord("tamu",
DataGridView1)
Call
tampilkodePesanan()
Call
tampilkodePaket()
Call
tampilkoderuangan()
End Sub
Private Sub Kd_Ruangan_SelectedIndexChanged_1(ByVal sender As
System.Object, ByVal e As
System.EventArgs) Handles
Kd_Ruangan.SelectedIndexChanged
SQL = "SELECT
*FROM ruangan where Kd_Ruangan='" & Kd_Ruangan.Text & "'"
CMD = New
OleDbCommand(SQL, DB)
DR = CMD.ExecuteReader
If
DR.HasRows Then
DR.Read()
Ruangan.Text = DR("Nm_Ruangan")
End If
End Sub
End Class
Hasil Laporan
Tidak ada komentar:
Posting Komentar