Minggu, 04 Desember 2011

Form 34

Form 34A

Public Class Form34A_36109023
    Private Sub DaftarBarangToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DAFTARBARANGToolStripMenuItem.Click
        If Form34B_36109023.Visible = False Then
            Form34B_36109023.MdiParent = Me
            Form34B_36109023.Show()
        Else
            Form34B_36109023.Activate()
        End If
    End Sub

    Private Sub INPUTBARANGToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles INPUTBARANGToolStripMenuItem.Click
        If Form34C_36109023.Visible = False Then
            Form34C_36109023.MdiParent = Me
            Form34C_36109023.Show()
        Else
            Form34C_36109023.Activate()
        End If
    End Sub
    Private Sub ToolStripButton1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton1.Click
        If Form34B_36109023.Visible = False Then
            Form34B_36109023.MdiParent = Me
            Form34B_36109023.Show()
        Else
            Form34B_36109023.Activate()
        End If
    End Sub

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

Form 34B

Public Class Form34B_36109023
    Dim aa As New DataTable
    Dim cm As New OleDb.OleDbCommand
    Dim ame As New OleDb.OleDbConnection("PROVIDER = MICROSOFT.ACE.OLEDB.12.0; DATA SOURCE =" & Application.StartupPath & "/Databarang.ACCDB")

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


    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        If Form34C_36109023.Visible = False Then
            Form34C_36109023.Show()
        Else
            Form34C_36109023.Activate()
        End If
        Form34C_36109023.t1_36109023.Text = dgv36109023.CurrentRow.Cells("kodebarang").Value
        Form34C_36109023.t2_36109023.Text = dgv36109023.CurrentRow.Cells("namabarang").Value
        Form34C_36109023.t3_36109023.Text = dgv36109023.CurrentRow.Cells("hargajual").Value
        Form34C_36109023.t4_36109023.Text = dgv36109023.CurrentRow.Cells("jumlahbarang").Value
        Form34C_36109023.KB36109023.Text = dgv36109023.CurrentRow.Cells("kodebarang").Value
    End Sub


    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        Dim bb As String = "delete * from barang where kodebarang = '" & dgv36109023.CurrentRow.Cells("kodebarang").Value & "'"
        cm = New OleDb.OleDbCommand(bb, ame)
        ame.Open()
        cm.ExecuteNonQuery()
        ame.Close()
        cm.Dispose()

        Dim dd As New OleDb.OleDbDataAdapter
        dd = New OleDb.OleDbDataAdapter("select *from barang", ame)
        aa.Rows.Clear()
        dd.Fill(aa)
        dd.Dispose()
        dgv36109023.DataSource = aa
    End Sub

    Private Sub Form34B_36109023_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim pororo As New OleDb.OleDbDataAdapter
        pororo = New OleDb.OleDbDataAdapter("select * from barang", ame)
        aa.Rows.Clear()
        pororo.Fill(aa)
        pororo.Dispose()
        dgv36109023.DataSource = aa
    End Sub
End Class

Form 34C
Public Class Form34C_36109023
    Dim amelia As New ByIskandar.CariKeDataBaseByIskandar
    Dim cm As New OleDb.OleDbCommand
    Dim ame As New OleDb.OleDbConnection("PROVIDER = MICROSOFT.ACE.OLEDB.12.0; DATA SOURCE =" & Application.StartupPath & "/Databarang.ACCDB")
  
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        If KB36109023.Text = "" Then
            amelia.AturPencarianDataBase("Barang", "KodeBArang", t1_36109023.Text, 1, ame)
            If amelia.JumlanBaris > 0 Then
                MsgBox("Kode barang sudah ada")
                t1_36109023.Text = ""
                Exit Sub
            ElseIf t1_36109023.Text.Length = 0 Then
                MsgBox("Kode barang harus ada")
                Exit Sub
            ElseIf t2_36109023.Text.Length = 0 Then
                MsgBox("Kode barang harus ada")
                Exit Sub
            ElseIf t3_36109023.Text.Length = 0 Then
                MsgBox("Kode barang harus ada")
                Exit Sub
            ElseIf t4_36109023.Text.Length = 0 Then
                MsgBox("Kode barang harus ada")
                Exit Sub
            End If

            Dim pororo As String = "insert into barang (kodebarang, namabarang, hargajual, jumlahbarang) values ('" & t1_36109023.Text & "','" & t2_36109023.Text & "'," & Val(t3_36109023.Text) & "," & Val(t4_36109023.Text) & "'"
            cm = New OleDb.OleDbCommand(pororo, ame)
            ame.Open()
            cm.ExecuteNonQuery()
            ame.Close()
            cm.Dispose()
            t1_36109023.Text = ""
            t2_36109023.Text = ""
            t3_36109023.Text = ""
            t4_36109023.Text = ""
        Else
            If KB36109023.Text <> t1_36109023.Text Then
                amelia.AturPencarianDataBase("Barang", "KodeBarang", t1_36109023.Text, 1, ame)
                If amelia.JumlanBaris > 0 Then
                    MsgBox("Kode barang sudah ada")
                    Exit Sub
                End If
            End If
            If t1_36109023.Text.Length = 0 Then
                MsgBox("Kode barang harus ada")
                Exit Sub
            ElseIf t2_36109023.Text.Length = 0 Then
                MsgBox("Kode barang harus ada")
                Exit Sub
            ElseIf Val(t3_36109023.Text) = 0 Then
                MsgBox("Kode barang harus ada")
                Exit Sub
            ElseIf Val(t4_36109023.Text) = 0 Then
                MsgBox("Kode barang harus ada")
                Exit Sub
            End If

            Dim sp As String = "update barang set kodebarang = '" & t1_36109023.Text & "', namabarang = '" & t2_36109023.Text & "', hargajual = " & Val(t3_36109023.Text) & ", jumlahbarang = " & Val(t4_36109023.Text) & " where kodebarang = '" & KB36109023.Text & "'"
            cm = New OleDb.OleDbCommand(sp, ame)
            ame.Open()
            cm.ExecuteNonQuery()
            ame.Close()
            cm.Dispose()
            KB36109023.Text = "-"
            t1_36109023.Text = ""
            t2_36109023.Text = ""
            t3_36109023.Text = ""
            t4_36109023.Text = ""
        End If
    End Sub
End Class

0 komentar:

 

This Template Is Available On Me, Myself and Time - RSS icons by ComingUpForAir