SISTEM INFORMASI PEMESANAAN DAN PENJUALAN SUKU CADANG MOBIL UD.STAR DIESEL
DESAIGN-MENU
INPUT
HASIL INPUT
CETAK
LISTING MENU
Public Class Form1
Private Sub NOVIToolStripMenuItem_Click(ByVal sender As
System.Object, ByVal e As
System.EventArgs) Handles
NOVIToolStripMenuItem.Click
Form2.Show()
End Sub
Private Sub KELUARToolStripMenuItem_Click(ByVal sender As
System.Object, ByVal e As
System.EventArgs) Handles
KELUARToolStripMenuItem.Click
Me.Close()
End Sub
Private Sub LAPDATABARANGToolStripMenuItem_Click(ByVal sender As
System.Object, ByVal e As
System.EventArgs) Handles
LAPDATABARANGToolStripMenuItem.Click
Dim
laporan As New
DATA
Form3.CRV.ReportSource = laporan
Form3.Show()
End Sub
End Class
LISTING INPUT
Imports
MySql.Data.MySqlClient
Public Class Form2
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=jual_db"
Try
db.ConnectionString = sql
db.Open()
Catch ex
As Exception
MessageBox.Show(ex.Message)
End Try
End Sub
Private Sub bagian_Load(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Call
opendb()
Call
Bersih()
Call
buattabel()
Call
IsiTabel()
End Sub
Sub
Bersih()
KD.Text = ""
JNS.Text = ""
SATUAN.Text = ""
HRG.Text = ""
JMLH.Text = ""
HRG.Text = ""
RubahButton(True,
False, False, False, True)
KD.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)
BR.Enabled = Btn1
SMPN.Enabled = Btn2
HPS.Enabled = Btn3
BTL.Enabled = Btn4
KLR.Enabled = Btn5
End Sub
Sub
ShowDB()
rs.Read()
KD.Text = rs("kode")
JNS.Text = rs("jenis")
SATUAN.Text = rs("satuan")
JMLH.Text = rs("jumlah")
HRG.Text = rs("harga")
RubahButton(False,
True, True, True, False)
SMPN.Text = "Edit"
KD.Enabled = False
End Sub
Sub
prosesdb(ByVal log As
Integer)
Dim
pesan As String
= ""
Select Case log
Case
0
sql = "Insert
into barang(kode,jenis,satuan,jumlah,harga)" & _
" values('" & KD.Text & _
"','" & JNS.Text & _
"','" & SATUAN.Text & _
"','" & JMLH.Text & _
"','" & HRG.Text & "')"
pesan = "Data Telah Tersimpan"
Case
1
sql = "update
barang set jenis='" & JNS.Text & "'"
& _
"satuan='" & SATUAN.Text & "'," & _
"jumlah='" & JMLH.Text & "'," & _
"harga='" & HRG.Text & "' " & _
"where kode='" & KD.Text & "',"
pesan = "Data Telah Terupdate"
Case
2
sql = "Delete
from barang where kode='" & KD.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
IsiTabel()
lv.Items.Clear()
sql = "Select
* from barang"
cmd = New
MySqlCommand(sql, db)
rs = cmd.ExecuteReader
Try
While
rs.Read
Dim
lst As New
ListViewItem
lst.Text = rs("kode")
lst.SubItems.Add(rs("jenis"))
lst.SubItems.Add(rs("satuan"))
lst.SubItems.Add(rs("jumlah"))
lst.SubItems.Add(rs("harga"))
lv.Items.Add(lst)
End
While
Catch
ex As Exception
MsgBox(ex.Message)
End Try
rs.Close()
End Sub
Sub
buattabel()
lv.View = View.Details
lv.GridLines = True
lv.FullRowSelect = True
lv.Columns.Add("kode")
lv.Columns.Add("jenis")
lv.Columns.Add("satuan")
lv.Columns.Add("jumlah")
lv.Columns.Add("harga")
End Sub
Private Sub BR_Click(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles BR.Click
Call
Bersih()
KD.Focus()
End Sub
Private Sub BTL_Click(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles BTL.Click
Call
Bersih()
KD.Focus()
End Sub
Private Sub KLR_Click(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles KLR.Click
Me.Close()
End Sub
Private Sub SMPN_Click(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles SMPN.Click
If
SMPN.Text = "Simpan" Then prosesdb(0) Else
prosesdb(1)
End Sub
Private Sub HPS_Click(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles HPS.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 KD_KeyPress(ByVal
sender As Object,
ByVal e As
System.Windows.Forms.KeyPressEventArgs) Handles
KD.KeyPress
Dim
tombol As Integer
= Asc(e.KeyChar)
If
tombol = 13 Then
Dim
x As String
If
KD.Text = "" Then
MsgBox("Isi
kode terlebih dahulu")
Else
sql = "select
* from barang where kode='" & KD.Text & "'"
cmd = New
MySqlCommand(sql, db)
rs = cmd.ExecuteReader
Try
Call
ShowDB()
Catch
ex As Exception
x = KD.Text
Bersih()
KD.Text = x
RubahButton(False, True, False, True, False)
SMPN.Text = "Simpan"
End
Try
JNS.Focus()
rs.Close()
End
If
End If
End Sub
End Class
0 komentar:
Posting Komentar