Jika anda baru join di tutorial kali ini, pastikan anda telah mengikuti tutorial sebelumnya :
Membuat Aplikasi Penjualan Part 1
Membuat Aplikasi Penjualan Part 2
Mari kita lanjutkan kembali :
Buatlah tabel dengan nama : tbl_pelanggan
design tabel pelanggan adalah sebagai berikut :
Jika sudah, mari kita lanjut ke Project aplikasi penjualannya..
silahkan klik Project --> Add Form
Buatlah form dengan nama : FormMasterPelanggan
Buatlah design Form Pelanggan seperti gambar diatas
kemudian masukan koding dibawah ini :
Imports System.Data.Odbc
Public Class FormMasterPelanggan
Sub KondisiAwal()
TextBox1.Text = ""
TextBox2.Text = ""
TextBox3.Text = ""
TextBox4.Text = ""
TextBox1.Enabled = False
TextBox2.Enabled = False
TextBox3.Enabled = False
TextBox4.Enabled = False
Button1.Enabled = True
Button2.Enabled = True
Button3.Enabled = True
Button1.Text = "Input"
Button2.Text = "Edit"
Button3.Text = "Hapus"
Button4.Text = "Tutup"
Call Koneksi()
Da = New OdbcDataAdapter("Select * From tbl_pelanggan", Conn)
Ds = New DataSet
Da.Fill(Ds, "tbl_Pelanggan")
DataGridView1.DataSource = Ds.Tables("tbl_pelanggan")
DataGridView1.ReadOnly = True
End Sub
Sub SiapIsi()
TextBox1.Enabled = True
TextBox2.Enabled = True
TextBox3.Enabled = True
TextBox4.Enabled = True
End Sub
Private Sub FormMasterPelanggan_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Call KondisiAwal()
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If Button1.Text = "Input" Then
Button1.Text = "Simpan"
Button2.Enabled = False
Button3.Enabled = False
Button4.Text = "Batal"
Call SiapIsi()
Else
If TextBox1.Text = "" Or TextBox2.Text = "" Or TextBox3.Text = "" Or Textbox4.Text = "" Then
MsgBox("Silahkan isi semua Field")
Else
Call Koneksi()
Dim InputData As String = "insert into tbl_pelanggan values('" & TextBox1.Text & "','" & TextBox2.Text & "','" & TextBox3.Text & "','" & TextBox4.Text & "')"
Cmd = New OdbcCommand(InputData, Conn)
Cmd.ExecuteNonQuery()
MsgBox("Input Data Berhasil")
Call KondisiAwal()
End If
End If
End Sub
Private Sub TextBox1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress
If e.KeyChar = Chr(13) Then
Call Koneksi()
Cmd = New OdbcCommand("Select * From tbl_pelanggan where kodepelanggan='" & TextBox1.Text & "'", Conn)
Rd = Cmd.ExecuteReader
Rd.Read()
If Not Rd.HasRows Then
MsgBox("Kode Pelanggan tidak Ada")
Else
TextBox1.Text = Rd.Item("KodePelanggan")
TextBox2.Text = Rd.Item("NamaPelanggan")
TextBox3.Text = Rd.Item("AlamatPelanggan")
TextBox4.Text = Rd.Item("telppelanggan")
End If
End If
End Sub
Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged
End Sub
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
If Button4.Text = "Tutup" Then
Me.Close()
Else
Call KondisiAwal()
End If
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
If Button3.Text = "Hapus" Then
Button3.Text = "Delete"
Button1.Enabled = False
Button2.Enabled = False
Button4.Text = "Batal"
Call SiapIsi()
Else
If TextBox1.Text = "" Or TextBox2.Text = "" Or TextBox3.Text = "" Or Textbox4.Text = "" Then
MsgBox("Silahkan isi semua Field")
Else
Call Koneksi()
Dim HapusData As String = "Delete from tbl_pelanggan where kodepelanggan='" & TextBox1.Text & "'"
Cmd = New OdbcCommand(HapusData, Conn)
Cmd.ExecuteNonQuery()
MsgBox("Hapus Data Berhasil")
Call KondisiAwal()
End If
End If
End Sub
End Class
Link Video di Youtube silahkan buka link dibawah ini :
https://www.youtube.com/watch?v=Tmz_N52ZLJY
Demikian Tutorial Membuat Aplikasi Penjualan VB .NET Database MySQL - #Part 3, ikuti terus tutorial selanjutnya.
0 Response to "Membuat Aplikasi Penjualan VB .NET Database MySQL - #Part 3"
Post a Comment