Program Penjualan Baju Mengunakan Data Base mysql versi visual basic by riki darman
nah kali ini ane bakalan buat program penjualan menggunakan data base, nah dalam menggunakan data base kita harus jeli merancang data basenya ada tahapan juga loh dalam perancangannya mulai dari tahap normalisai 1nf sampai 5 nf, namun sampi 3 aja udah cukup dan akurat kok.hehe
langsung aja ni programnyya.
ini skipnya ,dipahami ya :)
Imports MySql.Data.MySqlClient
Public Class Form1
Dim kon As New MySqlConnection("server=localhost;user id=root;database=tokobaju")
Dim perintah As New MySqlCommand
Dim data As New MySqlDataAdapter
Dim rd As MySqlDataReader
Dim ds As New DataSet
Sub bersih()
TextBox1.Text = ""
TextBox2.Text = ""
TextBox3.Text = ""
TextBox4.Text = ""
TextBox5.Text = ""
ComboBox1.Text = ""
ComboBox2.Text = ""
ComboBox3.Text = ""
End Sub
Sub tampildata()
kon.Open()
perintah.Connection = kon
perintah.CommandType = CommandType.Text
perintah.CommandText = "select baju.kode,namapelanggan,merk,size,harga,kualitas,jeniskain,panjang from baju INNER JOIN kain on baju.kode=kain.kode"
data.SelectCommand = perintah
ds.Tables.Clear()
data.Fill(ds, "baju")
DataGridView1.DataSource = ds.Tables("baju")
kon.Close()
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
tampildata()
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
kon.Open()
perintah.Connection = kon
perintah.CommandType = CommandType.Text
perintah.CommandText = "insert into baju values('" & TextBox1.Text & "','" & TextBox2.Text & "','" & ComboBox1.Text & "','" & ComboBox2.Text & "','" & TextBox3.Text & "')"
perintah.ExecuteNonQuery()
perintah.CommandText = "insert into kain values('" & TextBox1.Text & "','" & ComboBox3.Text & "','" & TextBox4.Text & "','" & TextBox5.Text & "')"
perintah.ExecuteNonQuery()
kon.Close()
tampildata()
MsgBox("Data Sukses Tersimpan", MsgBoxStyle.Information, "Pesan")
bersih()
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
Dim clear As String
clear = MsgBox("Yakin Akan Menghapus " + TextBox2.Text + "?", MsgBoxStyle.YesNo, "Hapus Nama")
If clear = vbYes Then
kon.Open()
perintah.Connection = kon
perintah.CommandType = CommandType.Text
perintah.CommandText = "delete from baju where kode='" & TextBox1.Text & "'"
perintah.ExecuteNonQuery()
perintah.CommandText = "delete from kain where kode='" & TextBox1.Text & "'"
perintah.ExecuteNonQuery()
kon.Close()
tampildata()
bersih()
End If
End Sub
Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
kon.Open()
perintah.Connection = kon
perintah.CommandType = CommandType.Text
perintah.CommandText = " select * from baju where kode = '" & TextBox1.Text & "'"
rd = perintah.ExecuteReader
If rd.Read Then
TextBox1.Text = rd.Item("kode")
TextBox2.Text = rd.Item("namapelanggan")
ComboBox1.Text = rd.Item("merk")
ComboBox2.Text = rd.Item("size")
TextBox3.Text = rd.Item("harga")
rd.Close()
Else
MessageBox.Show("Data Not Found...Entry New Data", "Warning", MessageBoxButtons.OK)
bersih()
TextBox1.Focus()
End If
kon.Close()
kon.Open()
perintah.Connection = kon
perintah.CommandType = CommandType.Text
perintah.CommandText = " select * from kain where kode = '" & TextBox1.Text & "'"
rd = perintah.ExecuteReader
If rd.Read Then
ComboBox3.Text = rd.Item("kualitas")
TextBox4.Text = rd.Item("jeniskain")
TextBox5.Text = rd.Item("panjang")
rd.Close()
Else
bersih()
TextBox1.Focus()
End If
kon.Close()
End Sub
Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click
End
End Sub
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
bersih()
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
kon.Open()
perintah.Connection = kon
perintah.CommandType = CommandType.Text
perintah.CommandText = "update baju set namapelanggan= '" & TextBox2.Text & "', merk='" & ComboBox1.Text & "',size='" & ComboBox2.Text & "',harga='" & TextBox3.Text & "' where kode = '" & TextBox1.Text & "'"
perintah.ExecuteNonQuery()
perintah.CommandText = "update kain set kualitas= '" & ComboBox3.Text & "', jeniskain='" & TextBox4.Text & "',panjang='" & TextBox5.Text & "' where kode = '" & TextBox1.Text & "'"
perintah.ExecuteNonQuery()
kon.Close()
Show()
MsgBox("Data Ter-Update", MsgBoxStyle.Information, "Pesan")
tampildata()
End Sub
End Class
langsung aja ni programnyya.
ini skipnya ,dipahami ya :)
Imports MySql.Data.MySqlClient
Public Class Form1
Dim kon As New MySqlConnection("server=localhost;user id=root;database=tokobaju")
Dim perintah As New MySqlCommand
Dim data As New MySqlDataAdapter
Dim rd As MySqlDataReader
Dim ds As New DataSet
Sub bersih()
TextBox1.Text = ""
TextBox2.Text = ""
TextBox3.Text = ""
TextBox4.Text = ""
TextBox5.Text = ""
ComboBox1.Text = ""
ComboBox2.Text = ""
ComboBox3.Text = ""
End Sub
Sub tampildata()
kon.Open()
perintah.Connection = kon
perintah.CommandType = CommandType.Text
perintah.CommandText = "select baju.kode,namapelanggan,merk,size,harga,kualitas,jeniskain,panjang from baju INNER JOIN kain on baju.kode=kain.kode"
data.SelectCommand = perintah
ds.Tables.Clear()
data.Fill(ds, "baju")
DataGridView1.DataSource = ds.Tables("baju")
kon.Close()
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
tampildata()
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
kon.Open()
perintah.Connection = kon
perintah.CommandType = CommandType.Text
perintah.CommandText = "insert into baju values('" & TextBox1.Text & "','" & TextBox2.Text & "','" & ComboBox1.Text & "','" & ComboBox2.Text & "','" & TextBox3.Text & "')"
perintah.ExecuteNonQuery()
perintah.CommandText = "insert into kain values('" & TextBox1.Text & "','" & ComboBox3.Text & "','" & TextBox4.Text & "','" & TextBox5.Text & "')"
perintah.ExecuteNonQuery()
kon.Close()
tampildata()
MsgBox("Data Sukses Tersimpan", MsgBoxStyle.Information, "Pesan")
bersih()
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
Dim clear As String
clear = MsgBox("Yakin Akan Menghapus " + TextBox2.Text + "?", MsgBoxStyle.YesNo, "Hapus Nama")
If clear = vbYes Then
kon.Open()
perintah.Connection = kon
perintah.CommandType = CommandType.Text
perintah.CommandText = "delete from baju where kode='" & TextBox1.Text & "'"
perintah.ExecuteNonQuery()
perintah.CommandText = "delete from kain where kode='" & TextBox1.Text & "'"
perintah.ExecuteNonQuery()
kon.Close()
tampildata()
bersih()
End If
End Sub
Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
kon.Open()
perintah.Connection = kon
perintah.CommandType = CommandType.Text
perintah.CommandText = " select * from baju where kode = '" & TextBox1.Text & "'"
rd = perintah.ExecuteReader
If rd.Read Then
TextBox1.Text = rd.Item("kode")
TextBox2.Text = rd.Item("namapelanggan")
ComboBox1.Text = rd.Item("merk")
ComboBox2.Text = rd.Item("size")
TextBox3.Text = rd.Item("harga")
rd.Close()
Else
MessageBox.Show("Data Not Found...Entry New Data", "Warning", MessageBoxButtons.OK)
bersih()
TextBox1.Focus()
End If
kon.Close()
kon.Open()
perintah.Connection = kon
perintah.CommandType = CommandType.Text
perintah.CommandText = " select * from kain where kode = '" & TextBox1.Text & "'"
rd = perintah.ExecuteReader
If rd.Read Then
ComboBox3.Text = rd.Item("kualitas")
TextBox4.Text = rd.Item("jeniskain")
TextBox5.Text = rd.Item("panjang")
rd.Close()
Else
bersih()
TextBox1.Focus()
End If
kon.Close()
End Sub
Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click
End
End Sub
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
bersih()
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
kon.Open()
perintah.Connection = kon
perintah.CommandType = CommandType.Text
perintah.CommandText = "update baju set namapelanggan= '" & TextBox2.Text & "', merk='" & ComboBox1.Text & "',size='" & ComboBox2.Text & "',harga='" & TextBox3.Text & "' where kode = '" & TextBox1.Text & "'"
perintah.ExecuteNonQuery()
perintah.CommandText = "update kain set kualitas= '" & ComboBox3.Text & "', jeniskain='" & TextBox4.Text & "',panjang='" & TextBox5.Text & "' where kode = '" & TextBox1.Text & "'"
perintah.ExecuteNonQuery()
kon.Close()
Show()
MsgBox("Data Ter-Update", MsgBoxStyle.Information, "Pesan")
tampildata()
End Sub
End Class
0 Response to "Program Penjualan Baju Mengunakan Data Base mysql versi visual basic by riki darman"
Post a Comment