Imports
MySql.Data.MySqlClient
Public Class Form1
Public db As New
MySql.Data.MySqlClient.MySqlConnection
Public sql As String
Public cmd As MySqlCommand
Public DS As DataSet
Public rs As MySqlDataReader
Public Sub openDB()
sql = "server=localhost;uid=root;pwd;database=Inventaris"
Try
db.ConnectionString = sql
db.Open()
Catch
ex As Exception
MessageBox.Show(ex.Message)
End Try
End Sub
Sub
Bersih()
Kode.Text = ""
Nama.Text = ""
Harga.Text = ""
Satuan.Text = ""
Jumlah.Text = ""
KelompokPeralatan.Text = ""
Rubahbutton(True,
False, False, False, False, True)
Kode.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, ByVal btn6 As Boolean)
BtnTambah.Enabled = btn1
BtnSimpan.Enabled = btn2
BtnHapus.Enabled = btn3
BtnBatal.Enabled = btn4
BtnEdit.Enabled = btn5
BtnClose.Enabled = btn6
End Sub
Sub
showDB()
rs.Read()
Kode.Text = rs("npm")
Nama.Text = rs("nama")
Harga.Text = rs("jenjang")
Jumlah.Text = rs("jurusan")
Rubahbutton(False,
True, True, True, True, True)
BtnSimpan.Text = "Edit"
Kode.Enabled = False
End Sub
Sub
ButtonTambah()
BtnTambah.Enabled = True
BtnSimpan.Enabled = False
BtnEdit.Enabled = False
BtnHapus.Enabled = False
BtnBatal.Enabled = False
BtnClose.Enabled = True
End Sub
Sub
ButtonEdit()
BtnTambah.Enabled = False
BtnSimpan.Enabled = False
BtnEdit.Enabled = True
BtnHapus.Enabled = True
BtnBatal.Enabled = True
BtnClose.Enabled = False
End Sub
Sub
ButtonSimpan()
BtnTambah.Enabled = False
BtnSimpan.Enabled = True
BtnEdit.Enabled = False
BtnHapus.Enabled = False
BtnBatal.Enabled = True
BtnClose.Enabled = False
End Sub
Sub
HapusText()
Kode.Text = ""
Nama.Text = ""
Harga.Text = ""
Call
ButtonTambah()
End Sub
Sub
buattable()
LV.Columns.Add("NPM",
80, HorizontalAlignment.Center)
LV.Columns.Add("NAMA",
180, HorizontalAlignment.Left)
LV.Columns.Add("JENJANG",
80, HorizontalAlignment.Left)
LV.Columns.Add("JURUSAN",
100, HorizontalAlignment.Left)
LV.GridLines = True
LV.FullRowSelect = True
LV.View = View.Details
End Sub
Sub
isitable()
LV.Items.Clear()
sql = "select*from
Inventaris"
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("Nama"))
lst.SubItems.Add(rs("Harga"))
lst.SubItems.Add(rs("Jumlah"))
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 Inventaris (Kode,Nama,Harga,Satuan,Jumlah,Kelompok Peralatan) "
& _
"values
('" & Kode.Text & _
"','"
& Nama.Text & _
"','"
& Harga.Text & _
"','"
& Satuan.Text & _
"','"
& Jumlah.Text & _
"','"
& KelompokPeralatan.Text & "')"
pesan = "Data Tersimpan"
Case
1
sql = "update
Inventaris set Nama='" & Nama.Text * "',
" & _
"Harga='"
& Harga.Text & "'," &
_
"Jumlah='"
& Satuan.Text & "'," &
_
"where
Kode='" & Kode.Text & "'"
pesan = "Data Terupdate"
Case 2
sql = "delete
from Inventaris where Kode='" & Kode.Text & "'"
pesan = "Data Dihapus"
End Select
Try
cmd = New
MySqlCommand(sql, db)
cmd.ExecuteNonQuery()
MsgBox(pesan,
MsgBoxStyle.Information + MsgBoxStyle.OkOnly, "Konfirmasi")
Call
Bersih()
Casinos in Harrah's Atlantic City, NJ | MapYRO
BalasHapusCasinos 평택 출장마사지 in Harrah's Atlantic City 남원 출장안마 · Caesars Atlantic City 충청북도 출장샵 · Harrah's Atlantic 광주 출장안마 City · Harrah's · Harrah's Resort Atlantic City · Caesars Atlantic City · 용인 출장안마 Harrah's