Jumat, 11 November 2011

TUGAS 27-30

RIDHAYANTI SALEH
361 09 015
3A-D3

- TUGAS 27

Public Class Form27_36109015

    Dim ridha As New ByIskandar.CariKeDataBaseByIskandar
    Dim risa As New OleDb.OleDbCommand
    Dim ahmad As New OleDb.OleDbConnection("PROVIDER = MICROSOFT.ACE.OLEDB.12.0; DATA SOURCE =" & Application.StartupPath & "/Databarang.ACCDB")

    Private Sub simpan_36109015_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles simpan_36109015.Click
        If t1_36109015.Text.Length = 0 Then
            MsgBox("Isi rong itu yang kosong")
            Exit Sub
        End If

        If t2_36109015.Text.Length = 0 Then
            MsgBox("Isi rong itu yang kosong")
            Exit Sub
        End If

        If Val(t3_36109015.Text) = 0 Then
            MsgBox("Isi rong itu yang kosong")
            Exit Sub
        End If

        If Val(t4_36109015.Text) = 0 Then
            MsgBox("Isi rong itu yang kosong")
            Exit Sub
        End If

        ridha.AturPencarianDataBase("Barang", "KodeBarang", t1_36109015.Text, 1, ahmad)
        If ridha.JumlanBaris > 0 Then
            MsgBox("Adami kode barang seperti itu")
            Exit Sub
        End If

        risa = New OleDb.OleDbCommand("insert into barang (kodebarang, namabarang, hargajual, jumlahbarang) values ('" & t1_36109015.Text & "','" & t2_36109015.Text & "'," & Val(t3_36109015.Text) & "," & Val(t4_36109015.Text) & ")", ahmad)
        ahmad.Open()
        risa.ExecuteNonQuery()
        ahmad.Close()
        risa.Dispose()

        t1_36109015.Text = ""
        t2_36109015.Text = ""
        t3_36109015.Text = ""
        t4_36109015.Text = ""
    End Sub
End Class


- TUGAS 28A


Public Class Form28A_36109015
    Dim ridha As New DataTable
    Dim ahmad As New OleDb.OleDbConnection("PROVIDER = MICROSOFT.ACE.OLEDB.12.0; DATA SOURCE =" & Application.StartupPath & "/Databarang.ACCDB")

    Public Sub risa()
        Dim ak As New OleDb.OleDbDataAdapter
        ak = New OleDb.OleDbDataAdapter("select * from barang", ahmad)
        ridha.Rows.Clear()
        ak.Fill(ridha)
        ak.Dispose()
    End Sub
    Private Sub Form28A_36109015_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        risa()
        DGV_36109015.DataSource = ridha
    End Sub

    Private Sub INPUT_36109015_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles INPUT_36109015.Click
        If Form28B_36109015vb.Visible = False Then
            Form28B_36109015vb.Show()
        Else
            Form28B_36109015vb.Activate()
        End If
    End Sub
End Class

- TUGAS 28B

Public Class Form28B_36109015vb

    Dim ridha As New ByIskandar.CariKeDataBaseByIskandar
    Dim risa As New OleDb.OleDbCommand
    Dim ahmad As New OleDb.OleDbConnection("PROVIDER = MICROSOFT.ACE.OLEDB.12.0; DATA SOURCE =" & Application.StartupPath & "/Databarang.ACCDB")

    Private Sub simpan_36109015_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles simpan_36109015.Click
        If t1_36109015.Text.Length = 0 Then
            MsgBox("Isi rong itu yang kosong")
            Exit Sub
        End If

        If t2_36109015.Text.Length = 0 Then
            MsgBox("Isi rong itu yang kosong")
            Exit Sub
        End If

        If Val(t3_36109015.Text) = 0 Then
            MsgBox("Isi rong itu yang kosong")
            Exit Sub
        End If

        If Val(t4_36109015.Text) = 0 Then
            MsgBox("Isi rong itu yang kosong")
            Exit Sub
        End If

        ridha.AturPencarianDataBase("Barang", "KodeBarang", t1_36109015.Text, 1, ahmad)
        If ridha.JumlanBaris > 0 Then
            MsgBox("Adami kode barang seperti itu")
            Exit Sub
        End If

        risa = New OleDb.OleDbCommand("insert into barang (kodebarang, namabarang, hargajual, jumlahbarang) values ('" & t1_36109015.Text & "','" & t2_36109015.Text & "'," & Val(t3_36109015.Text) & "," & Val(t4_36109015.Text) & ")", ahmad)
        ahmad.Open()
        risa.ExecuteNonQuery()
        ahmad.Close()
        risa.Dispose()

        t1_36109015.Text = ""
        t2_36109015.Text = ""
        t3_36109015.Text = ""
        t4_36109015.Text = ""

        Form28A_36109015.risa()

    End Sub
End Class

- TUGAS 29

Public Class Form29_36109015

    Dim risa As New ByIskandar.CariKeDataBaseByIskandar
    Dim ridha As New OleDb.OleDbCommand
    Dim ahmad As New OleDb.OleDbConnection("PROVIDER = MICROSOFT.ACE.OLEDB.12.0; DATA SOURCE =" & Application.StartupPath & "/Databarang.ACCDB")

    Private Sub S_36109015_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles S_36109015.Click
        If KB2_36109015.Text.Length = 0 Then
            MsgBox("Isi rong itu yang kosong")
            Exit Sub
        End If

        If nb_36109015.Text.Length = 0 Then
            MsgBox("Isi rong itu yang kosong")
            Exit Sub
        End If

        If Val(hj_36109015.Text) = 0 Then
            MsgBox("Isi rong itu yang kosong")
            Exit Sub
        End If

        If Val(jb_36109015.Text) = 0 Then
            MsgBox("Isi rong itu yang kosong")
            Exit Sub
        End If

        If KB_36109015.Text <> KB2_36109015.Text Then

            risa.AturPencarianDataBase("Barang", "KodeBarang", KB2_36109015.Text, 1, ahmad)
            If risa.JumlanBaris > 0 Then
                MsgBox("Adami kode barang seperti itu")
                Exit Sub
            End If
        End If

        ridha = New OleDb.OleDbCommand("update barang set kodebarang = '" & KB2_36109015.Text & "', namabarang = '" & nb_36109015.Text & "', hargajual = " & Val(hj_36109015.Text) & ", jumlahbarang = " & Val(jb_36109015.Text) & " where kodebarang = '" & KB_36109015.Text & "'", ahmad)
        ahmad.Open()
        ridha.ExecuteNonQuery()
        ahmad.Close()
        ridha.Dispose()

        KB_36109015.Text = ""
        KB2_36109015.Text = ""
        nb_36109015.Text = ""
        hj_36109015.Text = ""
        jb_36109015.Text = ""
    End Sub
End Class

- TUGAS 30A

Public Class Form30A_36109015

    Dim ridha As New DataTable
    Dim ahmad As New OleDb.OleDbConnection("PROVIDER = MICROSOFT.ACE.OLEDB.12.0; DATA SOURCE =" & Application.StartupPath & "/Databarang.ACCDB")

    Public Sub risa()
        Dim fm As New OleDb.OleDbDataAdapter
        fm = New OleDb.OleDbDataAdapter("select * from barang", ahmad)
        ridha.Rows.Clear()
        fm.Fill(ridha)
        fm.Dispose()
    End Sub

    Private Sub Form30A_36109015_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        risa()
        dgv_36109015.DataSource = ridha
    End Sub

    Private Sub edit_36109015_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles edit_36109015.Click
        If Form30B_36109015.Visible = False Then
            Form30B_36109015.Show()
        Else
            Form30B_36109015.Activate()
        End If

        Form30B_36109015.KB_36109015.Text = dgv_36109015.CurrentRow.Cells("kodebarang").Value
        Form30B_36109015.KB2_36109015.Text = dgv_36109015.CurrentRow.Cells("kodebarang").Value
        Form30B_36109015.nb_36109015.Text = dgv_36109015.CurrentRow.Cells("namabarang").Value
        Form30B_36109015.hj_36109015.Text = dgv_36109015.CurrentRow.Cells("hargajual").Value
        Form30B_36109015.jb_36109015.Text = dgv_36109015.CurrentRow.Cells("jumlahbarang").Value

        Form30B_36109015.Show()
    End Sub
End Class

- TUGAS 30B

Public Class Form30B_36109015

    Dim risa As New ByIskandar.CariKeDataBaseByIskandar
    Dim ridha As New OleDb.OleDbCommand
    Dim ahmad As New OleDb.OleDbConnection("PROVIDER = MICROSOFT.ACE.OLEDB.12.0; DATA SOURCE =" & Application.StartupPath & "/Databarang.ACCDB")

    Private Sub S_36109015_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles S_36109015.Click
        If KB2_36109015.Text.Length = 0 Then
            MsgBox("Isi rong itu yang kosong")
            Exit Sub
        End If

        If nb_36109015.Text.Length = 0 Then
            MsgBox("Isi rong itu yang kosong")
            Exit Sub
        End If

        If Val(hj_36109015.Text) = 0 Then
            MsgBox("Isi rong itu yang kosong")
            Exit Sub
        End If

        If Val(jb_36109015.Text) = 0 Then
            MsgBox("Isi rong itu yang kosong")
            Exit Sub
        End If

        If KB_36109015.Text <> KB2_36109015.Text Then
            risa.AturPencarianDataBase("Barang", "KodeBarang", KB2_36109015.Text, 1, ahmad)
            If risa.JumlanBaris > 0 Then
                MsgBox("Adami kode barang seperti itu")
                Exit Sub
            End If
        End If

        ridha = New OleDb.OleDbCommand("update barang set kodebarang = '" & KB2_36109015.Text & "', namabarang = '" & nb_36109015.Text & "', hargajual = " & Val(hj_36109015.Text) & ", jumlahbarang = " & Val(jb_36109015.Text) & " where kodebarang = '" & KB_36109015.Text & "'", ahmad)

        ahmad.Open()
        ridha.ExecuteNonQuery()
        ahmad.Close()
        ridha.Dispose()

        KB_36109015.Text = ""
        KB2_36109015.Text = ""
        nb_36109015.Text = ""
        hj_36109015.Text = ""
        jb_36109015.Text = ""

        Form30A_36109015.risa()
    End Sub
End Class

0 komentar:

Posting Komentar