UJIAN UTS MENGGUNAKAN VISUAL STUDIO 2008
DENGAN DOSEN MESRAN.NET DALAM WAKTU
30 MENIT CUMAN OPEN BOOK
LANGAKAH PERTAMA DESAIN LHA TERLEBIH DAHULU DATABASE NYA MENGGUNAKAN MICROSOFT ACCESS SEPERTI GAMBAR DI BAWAH INI
SETELAH SELESAI DESAIN LHA MENU UTAMA NYA SEPERTI DI BAWAH INI
LISTING KAN PROGRAM NYA SEPERTI DIBAWAH INI
Public Class Form1
Private Sub MOBIToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MOBIToolStripMenuItem.Click
MOBIL.MdiParent = Me
MOBIL.Show()
End Sub
End Class
SETELAH SELESAI DESAIN DAN LISTING PROGRAM MAKA MASUK LHA KITA
KEPADA DESAIN KEPEMILIKAN MOBIL YANGA MANA DISINI DESAIN NYA SBB;
SETELAH SELESAI MENDESAIN SEPERTI GAMBAR DI ATAS KEMUDIAN BUAT LISTING PROGRAM NYA SEPERTI BAWAH INI;;;;;
Imports System.Data.OleDb
Public Class MOBIL
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:\UTS\DATABASE15.mdb"
DB = New OleDbConnection(LOKASI)
If DB.State = ConnectionState.Closed Then
DB.Open()
End If
End Sub
Sub RecordMOBIL()
ADP = New OleDbDataAdapter("SELECT * FROM MOBIL", DB)
DS = New DataSet
ADP.Fill(DS, "MOBIL")
DataGridView1.DataSource = DS.Tables("MOBIL")
End Sub
Sub butoonbaru()
Button1.Enabled = True
Button2.Enabled = False
Button3.Enabled = False
Button4.Enabled = False
Button5.Enabled = False
Button6.Enabled = True
End Sub
Sub butoonedit()
Button1.Enabled = False
Button2.Enabled = False
Button3.Enabled = True
Button4.Enabled = True
Button5.Enabled = True
Button6.Enabled = False
End Sub
Sub butoonsimpan()
Button1.Enabled = False
Button2.Enabled = True
Button3.Enabled = False
Button4.Enabled = False
Button5.Enabled = True
Button6.Enabled = False
End Sub
Sub hapustext()
TextBox1.Text = ""
TextBox2.Text = ""
TextBox3.Text = ""
ComboBox1.Text = ""
TextBox4.Text = ""
Call butoonbaru()
End Sub
Private Sub MOBIL_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Call OPENDB()
Call RecordMOBIL()
ComboBox1.Items.Add("HONDA")
ComboBox1.Items.Add("TOYOTA")
ComboBox1.Items.Add("SUZUKI")
End Sub
Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click
Me.Close()
End Sub
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
SQL = "DELETE FROM MOBIL Where PLAT='" & TextBox1.Text & "'"
CMD = New OleDbCommand(SQL, DB)
CMD.ExecuteNonQuery()
Call Button1_Click(sender, e)
Call RecordMOBIL()
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Call hapustext()
TextBox1.Focus()
End Sub
Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
Call hapustext()
TextBox1.Focus()
End Sub
Private Sub TextBox1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress
Dim tombol As Integer = Asc(e.KeyChar)
Dim xkode As String
If tombol = 13 Then
SQL = "SELECT * FROM MOBIL Where PLAT='" & TextBox1.Text & "'"
CMD = New OleDbCommand(SQL, DB)
DR = CMD.ExecuteReader
DR.Read()
If DR.HasRows = True Then
TextBox2.Text = DR.Item(2)
TextBox3.Text = DR.Item(3)
TextBox4.Text = DR.Item(5)
Call butoonedit()
MsgBox("DATA DITEMUKAN!")
Else
xkode = TextBox1.Text
Call hapustext()
TextBox1.Text = xkode
Call butoonsimpan()
End If
TextBox2.Focus()
End If
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
SQL = "UPDATE MOBIL SET PEMILIK='" & TextBox2.Text & "'," & _
"ALAMAT='" & TextBox3.Text & "'," & _
"MERK='" & ComboBox1.Text & "'," & _
"TAHUN='" & TextBox4.Text & "' " & _
"Where PLAT='" & TextBox1.Text & "'"
CMD = New OleDbCommand(SQL, DB)
CMD.ExecuteNonQuery()
Call Button1_Click(sender, e)
Call RecordMOBIL()
Call hapustext()
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
SQL = "INSERT INTO MOBIL (PLAT, PEMILIK, ALAMAT, MERK, TAHUN)" & _
"Values ('" & TextBox1.Text & "','" & _
TextBox2.Text & "','" & _
TextBox3.Text & "','" & _
ComboBox1.Text & "','" & _
TextBox4.Text & "')"
CMD = New OleDbCommand(SQL, DB)
CMD.ExecuteNonQuery()
Call Button1_Click(sender, e)
Call RecordMOBIL()
End Sub
End Class
SETELAH SELESAI COBA ANDA JALAN KAN APAKAH SEPERTI GAMBAR DIBAWAH INI
APABILA TIDAK SAMA HASIL NYA MAKA COBA ANDA PERHATIKAN BAIK-BAIK
PADA LISTING PROGRAM NYA MW PUN PADA DATABASE ATAU PADA DESAIN PROGRAM NYA,
semoga buat teman-teman yang membaca atau melihat program saya ini bermamfaat dan berguna
untuk di jadi kan tugas dari dosen nya,
dan apabila ada penyampaian yang kurang menyenangkan buat si pembaca
saya lantunkan 100 X maaf,
SEKIAN DAN TERIMAKASIH
Tidak ada komentar:
Posting Komentar