Minggu, 28 Oktober 2012

TUGAS DATABASE


Ø  Desain Form


Ø  SCRIPT
Imports System
Imports System.Data
Imports System.Data.OleDb

Public Class Form1

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        If TextBox1.Text = "" Then
            MessageBox.Show("id gk boleh kosong!!!!", "warning!!!!!", MessageBoxButtons.OK)
            TextBox1.Focus()
        Else
            Dim koneksi As New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=D:\tugas_pak jay\PERPUS.accdb")
            koneksi.Open()
            Dim input As String = "insert into perpustakaan(id_buku,id_anggota,id_karyawan,tgl_pinjam,tgl_kembali,denda_telat,denda_rusak)values('" & TextBox1.Text & "','" & TextBox2.Text & "','" & TextBox3.Text & "','" & TextBox4.Text & "','" & TextBox5.Text & "','" & TextBox6.Text & "','" & TextBox7.Text & "')"
            Dim command As New OleDbCommand(input, koneksi)
            Dim reader As OleDbDataReader = command.ExecuteReader()
            reader.Close()
            koneksi.Close()
            TextBox1.Text = ""
            TextBox2.Text = ""
            TextBox3.Text = ""
            TextBox4.Text = ""
            TextBox5.Text = ""
            TextBox6.Text = ""
            TextBox7.Text = ""
            TextBox1.Focus()

        End If

    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        Dim koneksi As New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=D:\tugas_pak jay\PERPUS.accdb")
        koneksi.Open()
        Dim input As String = "select * from perpustakaan where id_buku='" & TextBox8.Text & "'"
        Dim command As New OleDbCommand(input, koneksi)
        Dim reader As OleDbDataReader = command.ExecuteReader()
        If reader.Read Then
            TextBox1.Text = reader("id_buku").ToString
            TextBox2.Text = reader("id_anggota").ToString
            TextBox3.Text = reader("id_karyawan").ToString
            TextBox4.Text = reader("tgl_pinjam").ToString
            TextBox5.Text = reader("tgl_kembali").ToString
            TextBox6.Text = reader("denda_telat").ToString
            TextBox7.Text = reader("denda_rusak").ToString
        Else
            MessageBox.Show("isi dulu nimnya!!!!", "peringatan", MessageBoxButtons.OK)
            TextBox8.Focus()
        End If

    End Sub


    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        Close()

    End Sub
End Class

0 komentar:

Posting Komentar

Popular Posts