TUGAS TA BELAJAR PEMOGRAMAN
Desain data supplier:
Listing program data supplier:
Imports
System.Data.OleDb
Public Class data_supplier
Public DB As OleDbConnection
Public CMD As OleDbCommand
Public ADP As OleDbDataAdapter
Public DR As OleDbDataReader
Public DS As New DataSet
Dim SQL As String
Public Sub OPENDB()
Dim
LOKASI = "Provider =
Microsoft.Jet.OLEDB.4.0;Data Source=C:\vb5\penjualan1.mdb"
DB = New
OleDbConnection(LOKASI)
If
DB.State = ConnectionState.Closed Then
DB.Open()
End If
End Sub
Sub
Recordanggota()
ADP = New
OleDbDataAdapter("SELECT * FROM barang",
DB)
DS = New
DataSet
ADP.Fill(DS, "barang")
DataGridView1.DataSource = DS.Tables("barang")
End Sub
Sub
butoonbaru()
Btn_baru.Enabled = True
btn_simpan.Enabled = False
Btn_edit.Enabled = False
Btn_hapus.Enabled = False
Btn_batal.Enabled = False
Btn_keluar.Enabled = True
End Sub
Sub butoonedit()
Btn_baru.Enabled = False
btn_simpan.Enabled = False
Btn_edit.Enabled = True
Btn_hapus.Enabled = True
Btn_batal.Enabled = True
Btn_keluar.Enabled = False
End Sub
Sub
butoonsimpan()
Btn_baru.Enabled = False
btn_simpan.Enabled = True
Btn_edit.Enabled = False
Btn_hapus.Enabled = False
Btn_batal.Enabled = True
Btn_keluar.Enabled = False
End Sub
Sub
hapustext()
kode.Text = ""
nama.Text = ""
alamat.Text = ""
tlpn.Text = ""
penghubung.Text = ""
pemimpin.Text = ""
Call
butoonbaru()
End Sub
Private Sub Form1_Load(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Call
OPENDB()
Call
hapustext()
Call
Recordanggota()
Call
butoonsimpan()
alamat.Items.Add("medan")
alamat.Items.Add("ranto")
alamat.Items.Add("kisaran")
tlpn.Items.Add("0616879")
tlpn.Items.Add("0616878")
tlpn.Items.Add("0616877")
pemimpin.Items.Add("mesran")
pemimpin.Items.Add("ikQbal")
pemimpin.Items.Add("andi")
penghubung.Items.Add("PT")
penghubung.Items.Add("CV")
penghubung.Items.Add("PERSEROAN")
End Sub
Private Sub HPS_Click(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles btn_hapus.Click
SQL = "DELETE
FROM LATIHAN Where kodeANGGOTA='" & kode.Text & "'"
CMD = New
OleDbCommand(SQL, DB)
CMD.ExecuteNonQuery()
Call
BR_Click(sender, e)
Call
Recordanggota()
End Sub
Private Sub BR_Click(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles btn_baru.Click
Call
hapustext()
kode.Focus()
End Sub
Private Sub KLR_Click(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles btn_keluar.Click
Me.Close()
End Sub
Private Sub NO_KeyPress(ByVal
sender As Object,
ByVal e As
System.Windows.Forms.KeyPressEventArgs) Handles
kode.KeyPress
Dim
tombol As Integer
= Asc(e.KeyChar)
Dim
xkode As String
If
tombol = 13 Then
SQL = "SELECT
* FROM LATIHAN Where kodeANGGOTA='" & kode.Text & "'"
CMD = New
OleDbCommand(SQL, DB)
DR = CMD.ExecuteReader
DR.Read()
If
DR.HasRows = True Then
nama.Text = DR.Item(1)
Call
butoonedit()
MsgBox("DATA
DITEMUKAN!")
Else
xkode = kode.Text
Call
hapustext()
kode.Text = xkode
Call
butoonsimpan()
End
If
nama.Focus()
End If
End Sub
Private Sub BTL_Click(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles btn_batal.Click
Call
hapustext()
kode.Focus()
End Sub
Private Sub DIT_Click(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles btn_edit.Click
SQL = "UPDATE
LATIHAN SET NAMA='" & nama.Text & "',"
& _
"alama='" & alamat.Text & "'," & _
"tlpn='" & tlpn.Text & "' " & _
"penghubung='" & penghubung.Text
& "' " & _
"pemimpin='" & pemimpin.Text & "' " & _
"Where kodeANGGOTA='" & kode.Text
& "'"
CMD = New
OleDbCommand(SQL, DB)
CMD.ExecuteNonQuery()
Call
BR_Click(sender, e)
Call
Recordanggota()
End Sub
Private Sub SMPN_Click(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles btn_simpan.Click
SQL = "INSERT
INTO LATIHAN (kodeANGGOTA, NAMA, ALAMA,TLPN,PENGHUBUNG,PEMIMPIN, JENJANG)"
& _
"Values ('" & kode.Text & "','" & _
nama.Text & "','" &
_
alamat.Text & "','"
& _
tlpn.Text & "','" &
_
penghubung.Text & "','"
& _
pemimpin.Text & "')"
CMD = New
OleDbCommand(SQL, DB)
CMD.ExecuteNonQuery()
Call
BR_Click(sender, e)
Call
Recordanggota()
End Sub
Private Sub alamat_SelectedIndexChanged(ByVal sender As
System.Object, ByVal e As
System.EventArgs) Handles alamat.SelectedIndexChanged
alamat.Items.Clear()
If
alamat.Text = "medan" Then
alamat.Items.Add("ranto")
alamat.Items.Add("kisaran")
End If
If
tlpn.Text = "0616879" Then
tlpn.Items.Add("0616878")
tlpn.Items.Add("0616877")
End If
If
pemimpin.Text = "mesran" Then
pemimpin.Items.Add("ikQbal")
pemimpin.Items.Add("andi")
End If
If
penghubung.Text = "D1" Then
penghubung.Items.Add("PT")
penghubung.Items.Add("CV")
penghubung.Items.Add("PERSERO")
End If
End Sub
End Class
Hasil data supplier:
Hasil laporan data
suplier:
Desain data pegawai:
Listing program data pegawai:
Imports
System.Data.OleDb
Public Class data_pegawai
Public DB As OleDbConnection
Public CMD As OleDbCommand
Public ADP As OleDbDataAdapter
Public DR As OleDbDataReader
Public DS As New DataSet
Dim SQL As String
Public Sub OPENDB()
Dim
LOKASI = "Provider =
Microsoft.Jet.OLEDB.4.0;Data Source=C:\vb5\penjualan1.mdb"
DB = New
OleDbConnection(LOKASI)
If
DB.State = ConnectionState.Closed Then
DB.Open()
End If
End Sub
Sub
Recordanggota()
ADP = New
OleDbDataAdapter("SELECT * FROM pegawai",
DB)
DS = New
DataSet
ADP.Fill(DS, "pegawai")
DataGridView1.DataSource = DS.Tables("pegawai")
End Sub
Sub
butoonbaru()
Btn_baru.Enabled = True
btn_simpan.Enabled = False
Btn_edit.Enabled = False
Btn_hapus.Enabled = False
Btn_batal.Enabled = False
Btn_keluar.Enabled = True
End Sub
Sub
butoonedit()
Btn_baru.Enabled = False
btn_simpan.Enabled = False
Btn_edit.Enabled = True
Btn_hapus.Enabled = True
Btn_batal.Enabled = True
Btn_keluar.Enabled = False
End Sub
Sub
butoonsimpan()
Btn_baru.Enabled = False
btn_simpan.Enabled = True
Btn_edit.Enabled = False
Btn_hapus.Enabled = False
Btn_batal.Enabled = True
Btn_keluar.Enabled = False
End Sub
Sub
hapustext()
kode_pegawai.Text = ""
nama_pegawai.Text = ""
jenis_kelamin.Text = ""
alamat.Text = ""
telepon.Text = ""
Call
butoonbaru()
End Sub
Private Sub Form1_Load(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Call
OPENDB()
Call
hapustext()
Call
Recordanggota()
Call
butoonsimpan()
alamat.Items.Add("jakarta")
alamat.Items.Add("bandung")
alamat.Items.Add("jogja")
alamat.Items.Add("solo")
telepon.Items.Add("0616879")
telepon.Items.Add("0616878")
telepon.Items.Add("0616877")
jenis_kelamin.Items.Add("laki-laki")
jenis_kelamin.Items.Add("perempuan")
End Sub
Private Sub HPS_Click(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles btn_hapus.Click
SQL = "DELETE
FROM LATIHAN Where kodepegawai='" & kode_pegawai.Text & "'"
CMD = New
OleDbCommand(SQL, DB)
CMD.ExecuteNonQuery()
Call
BR_Click(sender, e)
Call
Recordanggota()
End Sub
Private Sub BR_Click(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles btn_baru.Click
Call
hapustext()
kode_pegawai.Focus()
End Sub
Private Sub KLR_Click(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles btn_keluar.Click
Me.Close()
End Sub
Private Sub NO_KeyPress(ByVal
sender As Object,
ByVal e As
System.Windows.Forms.KeyPressEventArgs) Handles
kode_pegawai.KeyPress
Dim
tombol As Integer
= Asc(e.KeyChar)
Dim
xkode As String
If
tombol = 13 Then
SQL = "SELECT
* FROM LATIHAN Where kodepegawai='" & kode_pegawai.Text & "'"
CMD = New
OleDbCommand(SQL, DB)
DR = CMD.ExecuteReader
DR.Read()
If
DR.HasRows = True Then
nama_pegawai.Text = DR.Item(1)
Call
butoonedit()
MsgBox("DATA
DITEMUKAN!")
Else
xkode = kode_pegawai.Text
Call
hapustext()
kode_pegawai.Text = xkode
Call
butoonsimpan()
End
If
nama_pegawai.Focus()
End If
End Sub
Private Sub BTL_Click(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles btn_batal.Click
Call
hapustext()
kode_pegawai.Focus()
End Sub
Private Sub DIT_Click(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles btn_edit.Click
SQL = "UPDATE
LATIHAN SET NAMA='" & nama_pegawai.Text & "'," & _
"alama='" & alamat.Text & "'," & _
"tlpn='" & telepon.Text & "' " & _
"jenis kelamin='" &
jenis_kelamin.Text & "' "
& _
"Where kode_pegawai='" &
kode_pegawai.Text & "'"
CMD = New
OleDbCommand(SQL, DB)
CMD.ExecuteNonQuery()
Call
BR_Click(sender, e)
Call Recordanggota()
End Sub
Private Sub SMPN_Click(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles btn_simpan.Click
SQL = "INSERT
INTO LATIHAN (kode_pegawai, nama_pegawai, ALAMA,TLPN, Jenisk_kelamin)"
& _
"Values ('" & kode_pegawai.Text
& "','" & _
nama_pegawai.Text & "','"
& _
alamat.Text & "','"
& _
telepon.Text & "','" & _
jenis_kelamin.Text & "')"
CMD = New
OleDbCommand(SQL, DB)
CMD.ExecuteNonQuery()
Call
BR_Click(sender, e)
Call
Recordanggota()
End Sub
Private Sub alamat_SelectedIndexChanged(ByVal sender As
System.Object, ByVal e As
System.EventArgs) Handles
alamat.SelectedIndexChanged
alamat.Items.Clear()
If
alamat.Text = "medan" Then
alamat.Items.Add("ranto")
alamat.Items.Add("kisaran")
End If
If
telepon.Text = "067549" Then
telepon.Items.Add("764545")
telepon.Items.Add("853206")
telepon.Items.Add("765328")
End If
If
jenis_kelamin.Text = "laki-laki" Then
jenis_kelamin.Items.Add("perempuan")
End If
End Sub
End Class
Hasil data pegawai:
Hasil laporan pegawai:
Tidak ada komentar:
Posting Komentar