Kamis, 24 November 2011

Form 32A-34C

Public Class Form32A
    Dim dt As New DataTable
    Dim conect As New OleDb.OleDbConnection("PROVIDER = MICROSOFT.ACE.OLEDB.12.0; DATA SOURCE =" & Application.StartupPath & "/Databarang.ACCDB")
    Public Sub ami()
        Dim fm As New OleDb.OleDbDataAdapter
        fm = New OleDb.OleDbDataAdapter("select * from barang", conect)
        dt.Rows.Clear()
        fm.Fill(dt)
        fm.Dispose()
    End Sub
    Private Sub latihan32A_36109017_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        ami()
        dgv_021.DataSource = dt
    End Sub

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

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

        Form32C.t1_021.Text = dgv_021.CurrentRow.Cells("kodebarang").Value
        Form32C.t2_021.Text = dgv_021.CurrentRow.Cells("namabarang").Value
        Form32C.t3_021.Text = dgv_021.CurrentRow.Cells("hargajual").Value
        Form32C.t4_021.Text = dgv_021.CurrentRow.Cells("jumlahbarang").Value
        Form32C.KB.Text = dgv_021.CurrentRow.Cells("kodebarang").Value

        Form32C.Show()
    End Sub
End Class








Public Class Form32B

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


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

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

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

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

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

        nurul = New OleDb.OleDbCommand("insert into barang (kodebarang, namabarang, hargajual, jumlahbarang) values ('" & t1_021.Text & "','" & t2_021.Text & "'," & Val(t3_021.Text) & "," & Val(t4_021.Text) & ")", conect)
        conect.Open()
        nurul.ExecuteNonQuery()
        conect.Close()
        nurul.Dispose()

        t1_021.Text = ""
        t2_021.Text = ""
        t3_021.Text = ""
        t4_021.Text = ""

        Form32A.ami()

    End Sub
End Class






Public Class Form32C

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

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

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

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

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

        If t1_021.Text <> KB.Text Then
            ami.AturPencarianDataBase("Barang", "KodeBarang", t1_021.Text, 1, conect)
            If ami.JumlanBaris > 0 Then
                MsgBox("Adami kode barang seperti itu")
                Exit Sub
            End If
        End If

        nurul = New OleDb.OleDbCommand("update barang set kodebarang = '" & t1_021.Text & "', namabarang = '" & t2_021.Text & "', hargajual = " & Val(t3_021.Text) & ", jumlahbarang = " & Val(t4_021.Text) & " where kodebarang = '" & KB.Text & "'", conect)

        conect.Open()
        nurul.ExecuteNonQuery()
        conect.Close()
        nurul.Dispose()

        t1_021.Text = ""
        t2_021.Text = ""
        t3_021.Text = ""
        t4_021.Text = ""
        KB.Text = ""

        Form32A.ami()
    End Sub
End Class





Public Class Form33A

    Dim ami As New DataTable
    Dim nurul As New OleDb.OleDbCommand
    Dim irma As New OleDb.OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source='" & Application.StartupPath & "\DATABARANG.accdb'")

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

    Private Sub button3_021_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles button3_021.Click
        If Form33B.Visible = False Then
            Form33B.Show()
        Else
            Form33B.Activate()
        End If
        Form33B.KB.Text = dgv_021.CurrentRow.Cells("kodebarang").Value
        Form33B.t1_021.Text = dgv_021.CurrentRow.Cells("kodebarang").Value
        Form33B.t2_021.Text = dgv_021.CurrentRow.Cells("namabarang").Value
        Form33B.t3_021.Text = dgv_021.CurrentRow.Cells("hargajual").Value
        Form33B.t4_021.Text = dgv_021.CurrentRow.Cells("jumlahbarang").Value
    End Sub

    Private Sub Form33A_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim adapter As New OleDb.OleDbDataAdapter
        adapter = New OleDb.OleDbDataAdapter("select * from barang", irma)
        ami.Rows.Clear()
        adapter.Fill(ami)
        adapter.Dispose()
        dgv_021.DataSource = ami
    End Sub

    Private Sub button1_021_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles button1_021.Click
        Dim ara As String = "delete * from barang where kodebarang = '" & dgv_021.CurrentRow.Cells("kodebarang").Value & "'"
        nurul = New OleDb.OleDbCommand(ara, irma)
        irma.Open()
        nurul.ExecuteNonQuery()
        irma.Close()
        nurul.Dispose()

        Dim adapter As New OleDb.OleDbDataAdapter
        adapter = New OleDb.OleDbDataAdapter("select * from barang", irma)
        ami.Rows.Clear()
        adapter.Fill(ami)
        adapter.Dispose()
        dgv_021.DataSource = ami
    End Sub
End Class









Public Class Form33B

    Dim ami As New ByIskandar.CariKeDataBaseByIskandar
    Dim nurul As New OleDb.OleDbCommand
    Dim irma As New OleDb.OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source='" & Application.StartupPath & "\DATABARANG.accdb'")

    Private Sub button_021_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles button_021.Click
        If KB.Text = "" Then
            ami.AturPencarianDataBase("Barang", "KodeBarang", KB.Text, 1, irma)
            If ami.JumlanBaris > 0 Then
                MsgBox("kode barang telah ada")
                t1_021.Text = ""
                Exit Sub
            ElseIf t1_021.Text.Length = 0 Then
                MsgBox("kode barang harus tercantum")
                Exit Sub
            ElseIf t2_021.Text.Length = 0 Then
                MsgBox("nama barang harus tercantum")
                Exit Sub
            ElseIf t3_021.Text.Length = 0 Then
                MsgBox("harga jual harus tercantum")
                Exit Sub
            ElseIf t4_021.Text.Length = 0 Then
                MsgBox("jumlah barang harus tercantum")
                Exit Sub
            End If
            Dim soe As String = "insert into barang (kodebarang, namabarang, hargajual, jumlahbarang) values ('" & t1_021.Text & "','" & t2_021.Text & "'," & Val(t3_021.Text) & "," & Val(t4_021.Text) & ")"
            nurul = New OleDb.OleDbCommand(soe, irma)
            irma.Open()
            nurul.ExecuteNonQuery()
            irma.Close()
            nurul.Dispose()
            t1_021.Text = ""
            t2_021.Text = ""
            t3_021.Text = ""
            t4_021.Text = ""
        Else
            If KB.Text <> t1_021.Text Then
                ami.AturPencarianDataBase("Barang", "KodeBarang", t1_021.Text, 1, irma)
                If ami.JumlanBaris > 0 Then
                    MsgBox("kode barang tidak dapat diupdate")
                    Exit Sub
                End If
            End If
            If t1_021.Text.Length = 0 Then
                MsgBox("kode barang harus tercantum")
                Exit Sub
            ElseIf t2_021.Text.Length = 0 Then
                MsgBox("nama barang harus tercantum")
                Exit Sub
            ElseIf t3_021.Text.Length = 0 Then
                MsgBox("harga jual harus tercantum")
                Exit Sub
            ElseIf t4_021.Text.Length = 0 Then
                MsgBox("jumlah barang harus tercantum")
                Exit Sub
            End If
            Dim soe As String = "update barang set kodebarang = '" & t1_021.Text & "', namabarang = '" & t2_021.Text & "', hargajual = " & Val(t3_021.Text) & ", jumlahbarang = " & Val(t4_021.Text) & " where kodebarang = '" & KB.Text & "'"
            nurul = New OleDb.OleDbCommand(soe, irma)
            irma.Open()
            nurul.ExecuteNonQuery()
            irma.Close()
            nurul.Dispose()
            KB.Text = "-"
            t1_021.Text = ""
            t2_021.Text = ""
            t3_021.Text = ""
            t4_021.Text = ""
        End If
    End Sub
End Class







Public Class Form34A

    Private Sub DATABARANGToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DAFTARBARANGToolStripMenuItem.Click
        If Form34B.Visible = False Then
            Form34B.MdiParent = Me
            Form34B.Show()
        Else
            Form34B.Activate()
        End If
    End Sub
    Private Sub INPUTBARANGToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles INPUTBARANGToolStripMenuItem.Click
        If Form34C.Visible = False Then
            Form34C.MdiParent = Me
            Form34C.Show()
        Else
            Form34C.Activate()
        End If

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

    End Sub
    Private Sub ToolStripButton2_021_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton2_021.Click
        If Form34C.Visible = False Then
            Form34C.MdiParent = Me
            Form34C.Show()
        Else
            Form34B.Activate()
        End If
    End Sub
End Class







Public Class Form34B

    Dim DT As New DataTable
    Dim CM As New OleDb.OleDbCommand
    Dim MM As New OleDb.OleDbConnection("PROVIDER = MICROSOFT.ACE.OLEDB.12.0; DATA SOURCE =" & Application.StartupPath & "/Databarang.ACCDB")
    Private Sub button2_021_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles button2_021.Click
        If Form34C.Visible = False Then
            Form34C.Show()
        Else
            Form34C.Activate()
        End If
    End Sub
    Private Sub button3_021_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles button3_021.Click
        If Form34C.Visible = False Then
            Form34C.Show()
        Else
            Form34C.Activate()
        End If
        Form34C.t1_021.Text = dgv_021.CurrentRow.Cells("kodebarang").Value
        Form34C.t2_021.Text = dgv_021.CurrentRow.Cells("namabarang").Value
        Form34C.t3_021.Text = dgv_021.CurrentRow.Cells("hargajual").Value
        Form34C.t4_021.Text = dgv_021.CurrentRow.Cells("jumlahbarang").Value
        Form34C.KB.Text = dgv_021.CurrentRow.Cells("kodebarang").Value
    End Sub
    Private Sub button1_021_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles button1_021.Click
        Dim ICHMI As String = "delete * from barang where kodebarang = '" & dgv_021.CurrentRow.Cells("kodebarang").Value & "'"
        CM = New OleDb.OleDbCommand(ICHMI, MM)
        MM.Open()
        CM.ExecuteNonQuery()
        MM.Close()
        CM.Dispose()

        Dim MILK As New OleDb.OleDbDataAdapter
        MILK = New OleDb.OleDbDataAdapter("select * from barang", MM)
        DT.Rows.Clear()
        MILK.Fill(DT)
        MILK.Dispose()
        dgv_021.DataSource = DT
    End Sub
    Private Sub Form34B_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim MILK As New OleDb.OleDbDataAdapter
        MILK = New OleDb.OleDbDataAdapter("Select * from barang", MM)
        DT.Rows.Clear()
        MILK.Fill(DT)
        MILK.Dispose()
        dgv_021.DataSource = DT
    End Sub
End Class






Public Class Form34C

    Dim ami As New ByIskandar.CariKeDataBaseByIskandar
    Dim OD As New OleDb.OleDbCommand
    Dim DB As New OleDb.OleDbConnection("PROVIDER = MICROSOFT.ACE.OLEDB.12.0; DATA SOURCE =" & Application.StartupPath & "/Databarang.ACCDB")
    Private Sub button_021_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles button_021.Click
        If KB.Text = "" Then
            ami.AturPencarianDataBase("Barang", "KodeBArang", t1_021.Text, 1, DB)
            If ami.JumlanBaris > 0 Then
                MsgBox("Kode barang sudah ada")
                t1_021.Text = ""
                Exit Sub
            ElseIf t1_021.Text.Length = 0 Then
                MsgBox("Kode barang harus ada")
                Exit Sub
            ElseIf t2_021.Text.Length = 0 Then
                MsgBox("Kode barang harus ada")
                Exit Sub
            ElseIf t3_021.Text.Length = 0 Then
                MsgBox("Kode barang harus ada")
                Exit Sub
            ElseIf t4_021.Text.Length = 0 Then
                MsgBox("Kode barang harus ada")
                Exit Sub
            End If

            Dim nurul As String = "insert into barang (kodebarang, namabarang, hargajual, jumlahbarang) values ('" & t1_021.Text & "','" & t2_021.Text & "'," & Val(t3_021.Text) & "," & Val(t4_021.Text) & ")"
            OD = New OleDb.OleDbCommand(nurul, DB)
            DB.Open()
            OD.ExecuteNonQuery()
            DB.Close()
            OD.Dispose()
            t1_021.Text = ""
            t2_021.Text = ""
            t3_021.Text = ""
            t4_021.Text = ""
        Else
            If KB.Text <> t1_021.Text Then
                ami.AturPencarianDataBase("Barang", "KodeBarang", t1_021.Text, 1, DB)
                If ami.JumlanBaris > 0 Then
                    MsgBox("Kode barang sudah ada")
                    Exit Sub
                End If
            End If
            If t1_021.Text.Length = 0 Then
                MsgBox("Kode barang harus ada")
                Exit Sub
            ElseIf t2_021.Text.Length = 0 Then
                MsgBox("Kode barang harus ada")
                Exit Sub
            ElseIf Val(t3_021.Text) = 0 Then
                MsgBox("Kode barang harus ada")
                Exit Sub
            ElseIf Val(t4_021.Text) = 0 Then
                MsgBox("Kode barang harus ada")
                Exit Sub
            End If

            Dim nurul As String = "update barang set kodebarang = '" & t1_021.Text & "', namabarang = '" & t2_021.Text & "', hargajual = " & Val(t3_021.Text) & ", jumlahbarang = " & Val(t4_021.Text) & " where kodebarang = '" & KB.Text & "'"
            OD = New OleDb.OleDbCommand(nurul, DB)
            DB.Open()
            OD.ExecuteNonQuery()
            DB.Close()
            OD.Dispose()
            KB.Text = "-"
            t1_021.Text = ""
            t2_021.Text = ""
            t3_021.Text = ""
            t4_021.Text = ""
        End If
    End Sub
End Class

Tidak ada komentar:

Posting Komentar