Jumat, 18 November 2011

TUGAS 27-34

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

- TUGAS 31A

Public Class Form31A_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 Form31A_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 Form31B_36109015.Visible = False Then
            Form31B_36109015.Show()
        Else
            Form31B_36109015.Activate()
        End If

        Form31B_36109015.t1_36109015.Text = dgv_36109015.CurrentRow.Cells("kodebarang").Value
        Form31B_36109015.t2_36109015.Text = dgv_36109015.CurrentRow.Cells("namabarang").Value
        Form31B_36109015.t3_36109015.Text = dgv_36109015.CurrentRow.Cells("hargajual").Value
        Form31B_36109015.t4_36109015.Text = dgv_36109015.CurrentRow.Cells("jumlahbarang").Value
        Form31B_36109015.KB_36109015.Text = dgv_36109015.CurrentRow.Cells("kodebarang").Value

        Form31B_36109015.Show()
    End Sub
End Class

- TUGAS 31B

Public Class Form31B_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 Button1_36109015_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1_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

        If t1_36109015.Text <> t2_36109015.Text Then
            risa.AturPencarianDataBase("Barang", "KodeBarang", t1_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 = '" & t1_36109015.Text & "', namabarang = '" & t2_36109015.Text & "', hargajual = " & Val(t3_36109015.Text) & ", jumlahbarang = " & Val(t4_36109015.Text) & " where kodebarang = '" & KB_36109015.Text & "'", ahmad)

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

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

        Form31A_36109015.risa()
    End Sub
End Class

- TUGAS 32A

Public Class Form32A_36109015

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

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

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

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

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

        Form32C_36109015.t1_36109015.Text = DGV_36109015.CurrentRow.Cells("kodebarang").Value
        Form32C_36109015.t2_36109015.Text = DGV_36109015.CurrentRow.Cells("namabarang").Value
        Form32C_36109015.t3_36109015.Text = DGV_36109015.CurrentRow.Cells("hargajual").Value
        Form32C_36109015.t4_36109015.Text = DGV_36109015.CurrentRow.Cells("jumlahbarang").Value
        Form32C_36109015.KB_36109015.Text = DGV_36109015.CurrentRow.Cells("kodebarang").Value

        Form32C_36109015.Show()
    End Sub
End Class

- TUGAS 32B

Public Class Form32B_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 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

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

        ridha = 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()
        ridha.ExecuteNonQuery()
        ahmad.Close()
        ridha.Dispose()

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

        Form32A_36109015.ridha()
    End Sub
End Class

- TUGAS 32C

Public Class Form32C_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 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

        If t1_36109015.Text <> KB_36109015.Text Then
            risa.AturPencarianDataBase("Barang", "KodeBarang", t1_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 = '" & t1_36109015.Text & "', namabarang = '" & t2_36109015.Text & "', hargajual = " & Val(t3_36109015.Text) & ", jumlahbarang = " & Val(t4_36109015.Text) & " where kodebarang = '" & KB_36109015.Text & "'", ahmad)

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

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

        Form32A_36109015.ridha()
    End Sub
End Class

- TUGAS 33A

Public Class Form33A_36109015

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

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

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

    Private Sub hps_36109015_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles hps_36109015.Click

        ridha = New OleDb.OleDbCommand("delete * from barang where kodebarang = '" & dgv_36109015.CurrentRow.Cells("kodebarang").Value & "'", ahmad)
        ahmad.Open()
        ridha.ExecuteNonQuery()
        ahmad.Close()
        ridha.Dispose()

        eku()
       
    End Sub

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

        Form33B_36109015.t1_36109015.Text = dgv_36109015.CurrentRow.Cells("kodebarang").Value
        Form33B_36109015.t2_36109015.Text = dgv_36109015.CurrentRow.Cells("namabarang").Value
        Form33B_36109015.t3_36109015.Text = dgv_36109015.CurrentRow.Cells("hargajual").Value
        Form33B_36109015.t4_36109015.Text = dgv_36109015.CurrentRow.Cells("jumlahbarang").Value
        Form33B_36109015.t5_36109015.Text = dgv_36109015.CurrentRow.Cells("kodebarang").Value

        Form33B_36109015.Show()
    End Sub

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

        Form33B_36109015.t1_36109015.Text = ""
        Form33B_36109015.t2_36109015.Text = ""
        Form33B_36109015.t3_36109015.Text = ""
        Form33B_36109015.t4_36109015.Text = ""
        Form33B_36109015.t5_36109015.Text = "-"
    End Sub

- TUGAS 33B

Public Class Form33B_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 simpan_36109015_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles simpan_36109015.Click
        If t5_36109015.Text = "-" Then
            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
            risa.AturPencarianDataBase("Barang", "KodeBarang", t1_36109015.Text, 1, ahmad)
            If risa.JumlanBaris > 0 Then
                MsgBox("Adami kode barang seperti itu")
                Exit Sub
            End If

            ridha = 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()
            ridha.ExecuteNonQuery()
            ahmad.Close()
            ridha.Dispose()

            t1_36109015.Text = ""
            t2_36109015.Text = ""
            t3_36109015.Text = ""
            t4_36109015.Text = ""
        Else
            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
            If t1_36109015.Text <> t5_36109015.Text Then
                risa.AturPencarianDataBase("Barang", "KodeBarang", t1_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 = '" & t1_36109015.Text & "', namabarang = '" & t2_36109015.Text & "', hargajual = " & Val(t3_36109015.Text) & ", jumlahbarang = " & Val(t4_36109015.Text) & " where kodebarang = '" & t5_36109015.Text & "'", ahmad)

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

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

        End If
    End Sub
End Class

- TUGAS 34A

ublic Class Form34A_36109015


    Private Sub DAFTARBARANGToolStripMenuItem_36109015_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DAFTARBARANGToolStripMenuItem_36109015.Click
        If Form34B_36109015.Visible = False Then
            Form34B_36109015.MdiParent = Me
            Form34B_36109015.Show()
        Else
            Form34B_36109015.Activate()
        End If
    End Sub

    Private Sub INPUTBARANGToolStripMenuItem_36109015_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles INPUTBARANGToolStripMenuItem_36109015.Click
        If Form34C_36109015.Visible = False Then
            Form34C_36109015.MdiParent = Me
            Form34C_36109015.Show()
        Else
            Form34C_36109015.Activate()
        End If
    End Sub

    Private Sub ToolStripButton1_36109015_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton1_36109015.Click
        If Form34B_36109015.Visible = False Then
            Form34B_36109015.MdiParent = Me
            Form34C_36109015.Show()
        Else
            Form34B_36109015.Activate()
        End If
    End Sub

    Private Sub ToolStripButton2_36109015_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton2_36109015.Click
        If Form34C_36109015.Visible = False Then
            Form34C_36109015.MdiParent = Me
            Form34C_36109015.Show()
        Else
            Form34C_36109015.Activate()
        End If
    End Sub
End Class

- TUGAS 34B

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

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

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

    Private Sub hapus_36109015_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles hapus_36109015.Click
        ridha = New OleDb.OleDbCommand("delete * from barang where kodebarang = '" & dgv_36109015.CurrentRow.Cells("kodebarang").Value & "'", ahmad)
        ahmad.Open()
        ridha.ExecuteNonQuery()
        ahmad.Close()
        ridha.Dispose()

        aku()
    End Sub

    Private Sub tambah_36109015_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tambah_36109015.Click
        If Form34C_36109015.Visible = False Then
            Form34C_36109015.MdiParent = Me.MdiParent
            Form34C_36109015.Show()
        Else
            Form34C_36109015.Activate()
        End If
        Form34C_36109015.Show()
    End Sub

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

        Form34C_36109015.t1_36109015.Text = ""
        Form34C_36109015.t2_36109015.Text = ""
        Form34C_36109015.t3_36109015.Text = ""
        Form34C_36109015.t4_36109015.Text = ""
        Form34C_36109015.KB_36109015.Text = "-"
    End Sub
End Class

- TUGAS 34C

Public Class Form34C_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 simpan_36109015_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles simpan_36109015.Click
        If KB_36109015.Text = "-" Then
            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
            risa.AturPencarianDataBase("Barang", "KodeBarang", t1_36109015.Text, 1, ahmad)
            If risa.JumlanBaris > 0 Then
                MsgBox("Adami kode barang seperti itu")
                Exit Sub
            End If

            ridha = 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()
            ridha.ExecuteNonQuery()
            ahmad.Close()
            ridha.Dispose()

            t1_36109015.Text = ""
            t2_36109015.Text = ""
            t3_36109015.Text = ""
            t4_36109015.Text = ""
        Else
            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
            If t1_36109015.Text <> KB_36109015.Text Then
                risa.AturPencarianDataBase("Barang", "KodeBarang", t1_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 = '" & t1_36109015.Text & "', namabarang = '" & t2_36109015.Text & "', hargajual = " & Val(t3_36109015.Text) & ", jumlahbarang = " & Val(t4_36109015.Text) & " where kodebarang = '" & KB_36109015.Text & "'", ahmad)

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

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

        End If
    End Sub
End Class

Tidak ada komentar:

Posting Komentar