DESIGN DATABASE
FIELD NAME
|
TYPE
|
SIZE
|
NO KWITNASI
|
CHAR
|
20
|
KODE_PENERIMA
|
CHAR
|
20
|
NAMA_PENERIMA
|
CHAR
|
20
|
ALAMAT_PENERIMA
|
CHAR
|
20
|
KODE_POS
|
CHAR
|
20
|
PROVINSI
|
CHAR
|
20
|
KABUPATEN_KOTA
|
CHAR
|
20
|
BERAT
|
CHAR
|
20
|
HARGA_PAKET
|
CHAR
|
20
|
DESIGN FORM HARGA PAKET
LISTING PROGRAM HARGA PAKET
Imports
MySql.Data.MySqlClient
Public Class harga_paket
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=
dwijuliani"
Try
db.ConnectionString = sql
db.Open()
Catch
ex As Exception
MessageBox.Show(ex.Message)
End Try
End Sub
Sub
bersih()
no_kwitansi.Text = ""
kode_penerima.Text = ""
nama_penerima.Text = ""
alamat_penerima.Text = ""
kodepos.Text = ""
provinsi.Text = ""
kabupaten_kota.Text = ""
berat.Text = ""
hargapaket.Text = ""
rubahtombol(True,
False, False, False, True)
no_kwitansi.Enabled = True
End Sub
Sub
rubahtombol(ByRef btn1 As
Boolean, ByVal
btn2 As Boolean,
ByVal btn3 As Boolean, ByVal btn4 As Boolean, ByVal btn5 As Boolean)
baru.Enabled = btn1
simpan.Enabled = btn2
hapus.Enabled = btn3
batal.Enabled = btn4
keluar.Enabled = btn5
End Sub
Sub
buattabel()
lv.Columns.Add("no_kwitansi",
80, HorizontalAlignment.Center)
lv.Columns.Add("kode_penerima",
100, HorizontalAlignment.Left)
lv.Columns.Add("nama_penerima",
100, HorizontalAlignment.Left)
lv.Columns.Add("alamat_penerima",
120, HorizontalAlignment.Left)
lv.Columns.Add("kode_pos",
100, HorizontalAlignment.Left)
lv.Columns.Add("provinsi",
100, HorizontalAlignment.Center)
lv.Columns.Add("kabupaten_kota",
150, HorizontalAlignment.Left)
lv.Columns.Add("berat",
80, HorizontalAlignment.Left)
lv.Columns.Add("harga_paket",
100, HorizontalAlignment.Left)
lv.GridLines = True
lv.FullRowSelect = True
lv.View = View.Details
End Sub
Sub
isitabel()
lv.Items.Clear()
sql = "select*from
harga_paket"
cmd = New
MySqlCommand(sql, db)
rs = cmd.ExecuteReader
Try
While
rs.Read
Dim
lst As New
ListViewItem
lst.Text = rs("no_kwitansi")
lst.SubItems.Add(rs("kode_penerima"))
lst.SubItems.Add(rs("nama_penerima"))
lst.SubItems.Add(rs("alamat_penerima"))
lst.SubItems.Add(rs("kode_pos"))
lst.SubItems.Add(rs("provinsi"))
lst.SubItems.Add(rs("kabupaten_kota"))
lst.SubItems.Add(rs("berat"))
lst.SubItems.Add(rs("harga_paket"))
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
harga_paket(no_kwitansi,kode_penerima,nama_penerima,alamat_penerima,kode_pos,provinsi,kabupaten_kota,berat,harga_paket)"
& _
"values('"
& no_kwitansi.Text & _
"','"
& kode_penerima.Text & _
"','"
& nama_penerima.Text & _
"','"
& alamat_penerima.Text & _
"','"
& kodepos.Text & _
"','"
& provinsi.Text & _
"','"
& kabupaten_kota.Text & _
"','"
& berat.Text & _
"','"
& hargapaket.Text & "')"
pesan = "data telah tersimpan"
Case
1
sql = "update
harga_paket set kode_penerima='" & kode_penerima.Text & "', " & _
"nama_penerima='"
& nama_penerima.Text & "',"
& _
"alamat_penerima='"
& alamat_penerima.Text & "',"
& _
"kode_pos='"
& kodepos.Text & "', "
& _
"provinsi='"
& provinsi.Text & "', "
& _
"kabupaten_kota='"
& kabupaten_kota.Text & "',"
& _
"berat='"
& berat.Text & "', " &
_
"harga_paket='"
& hargapaket.Text & "'"
& _
"where
no_kwitansi='" & no_kwitansi.Text & "'"
pesan = "data telah terupdate"
Case
2
sql = "delete
from harga_paket where no_kwitansi='" & no_kwitansi.Text & "'"
pesan = "data telah dihapus"
End Select
Try
cmd = New
MySqlCommand(sql, db)
cmd.ExecuteNonQuery()
MsgBox(pesan,
MsgBoxStyle.Information + MsgBoxStyle.OkOnly, "konfirmasi")
Call
bersih()
Call
isitabel()
Catch
ex As Exception
MessageBox.Show(ex.Message)
End Try
End Sub
Sub
showdb()
rs.Read()
no_kwitansi.Text = rs("no_kwitansi")
kode_penerima.Text = rs("kode_penerima")
nama_penerima.Text = rs("nama_penerima")
alamat_penerima.Text = rs("alamat_penerima")
kodepos.Text = rs("kode_pos")
provinsi.Text = rs("provinsi")
kabupaten_kota.Text = rs("kabupaten_kota")
berat.Text = rs("berat")
hargapaket.Text = rs("harga_paket")
rubahtombol(False,
True, True, True, True)
simpan.Text = "Edit"
no_kwitansi.Enabled = False
End Sub
Sub
tampilkode_pos()
sql = "Select
* from kode_pos"
cmd = New
MySqlCommand(sql, db)
rs = cmd.ExecuteReader
Try
While
rs.Read
kodepos.Items.Add(rs("kode_pos"))
End
While
Catch
ex As Exception
MsgBox(ex.Message)
End Try
rs.Close()
End Sub
Sub
tampilkode_penerima()
sql = "Select
* from penerima"
cmd = New
MySqlCommand(sql, db)
rs = cmd.ExecuteReader
Try
While
rs.Read
kode_penerima.Items.Add(rs("kode_penerima"))
End
While
Catch
ex As Exception
MsgBox(ex.Message)
End Try
rs.Close()
End Sub
Private Sub harga_paket_Load(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Call
opendb()
Call
bersih()
Call
buattabel()
Call
isitabel()
Call
tampilkode_penerima()
Call
tampilkode_pos()
End Sub
Private Sub baru_Click(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles baru.Click
Call
bersih()
no_kwitansi.Focus()
End Sub
Private Sub simpan_Click(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles simpan.Click
If
simpan.Text = "SIMPAN" Then prosesdb(1) Else
prosesdb(0)
End Sub
Private Sub hapus_Click(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles hapus.Click
Dim x As String
x = MsgBox("anda
yakin akan dihapus", MsgBoxStyle.Information + MsgBoxStyle.YesNo, "hapus")
If x =
vbYes Then
Call
prosesdb(2)
End If
End Sub
Private Sub batal_Click(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles batal.Click
Call
bersih()
no_kwitansi.Focus()
End Sub
Private Sub kodepos_SelectedIndexChanged(ByVal sender As
System.Object, ByVal e As
System.EventArgs) Handles
kodepos.SelectedIndexChanged
If
kodepos.Text = "" Then Exit Sub
sql = "select
*from kode_pos where kode_pos='" & kodepos.Text & "'"
cmd = New
MySqlCommand(sql, db)
rs = cmd.ExecuteReader
Try
rs.Read()
provinsi.Text = rs("provinsi")
kabupaten_kota.Text = rs("kabupaten_kota")
Catch
ex As Exception
MsgBox(ex.Message)
End Try
rs.Close()
End Sub
Private Sub kode_penerima_SelectedIndexChanged(ByVal sender As
System.Object, ByVal e As
System.EventArgs) Handles
kode_penerima.SelectedIndexChanged
If
kode_penerima.Text = "" Then Exit Sub
sql = "select
*from penerima where kode_penerima='" & kode_penerima.Text
& "'"
cmd = New
MySqlCommand(sql, db)
rs = cmd.ExecuteReader
Try
rs.Read()
nama_penerima.Text = rs("nama_penerima")
alamat_penerima.Text = rs("alamat_penerima")
Catch
ex As Exception
MsgBox(ex.Message)
End Try
rs.Close()
End Sub
Private Sub no_kwitansi_KeyPress(ByVal
sender As Object,
ByVal e As
System.Windows.Forms.KeyPressEventArgs) Handles
no_kwitansi.KeyPress
Dim
tombol As Integer
= Asc(e.KeyChar)
If
tombol = 13 Then
Dim
x As String
If
no_kwitansi.Text = "" Then
MsgBox("isi
no kwitansi terlebih dahulu")
Else
sql = "select
* from harga_paket where no_kwitansi='" & no_kwitansi.Text
& "'"
cmd = New
MySqlCommand(sql, db)
rs = cmd.ExecuteReader
Try
Call showdb()
Catch
ex As Exception
x = no_kwitansi.Text
bersih()
no_kwitansi.Text = x
rubahtombol(False, True, False, True, False)
simpan.Text = "simpan"
End
Try
kode_penerima.Focus()
rs.Close()
End
If
End If
End Sub
Private Sub keluar_Click(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles keluar.Click
End
End Sub
End Class
DESIGN CETAK HARGA PAKET
DESIGN CETAK RELASI