APLIKASI PENJUALAN PLUS PPN DAN DISKON - VB.NET

 

 

 

 

 

 

 

 

 

Module :

 

Imports System.Data.OleDb

Imports CrystalDecisions.CrystalReports.Engine

Imports CrystalDecisions.Shared

 

 

Module Module1

 

    Public Conn As OleDbConnection

    Public DA As OleDbDataAdapter

    Public DS As DataSet

    Public CMD As OleDbCommand

    Public DR As OleDbDataReader

 

    Public cryRpt As New ReportDocument

    Public crtableLogoninfos As New TableLogOnInfos

    Public crtableLogoninfo As New TableLogOnInfo

    Public crConnectionInfo As New ConnectionInfo

    Public CrTables As Tables

    'Public CrTable As Table

 

    Public Sub seting_laporan()

        With crConnectionInfo

            .ServerName = (Application.StartupPath.ToString & "\DBPenjualan.mdb")

            .DatabaseName = (Application.StartupPath.ToString & "\DBPenjualan.mdb")

            .UserID = ""

            .Password = ""

        End With

 

        CrTables = cryRpt.Database.Tables

        For Each CrTable In CrTables

            crtableLogoninfo = CrTable.LogOnInfo

            crtableLogoninfo.ConnectionInfo = crConnectionInfo

            CrTable.ApplyLogOnInfo(crtableLogoninfo)

        Next

    End Sub

 

    Public Sub Koneksi()

        Try

            Conn = New OleDbConnection("provider=microsoft.jet.oledb.4.0;data source=DBPenjualan.mdb")

            Conn.Open()

        Catch ex As Exception

            MsgBox(ex.Message)

            End

        End Try

    End Sub

End Module

 

 

 

 

 

Imports System.Data.OleDb

Imports System.Text

 

Public Class masterLogin

 

    Private Sub TextBox1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress

        If e.KeyChar = Chr(13) Then TextBox2.Focus()

    End Sub

 

    Private Sub TextBox2_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox2.KeyPress

        If e.KeyChar = Chr(13) Then Button1.Focus()

    End Sub

 

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

 

        Call Koneksi()

        CMD = New OleDbCommand("select * from tbluser where nama_User= '" & TextBox1.Text & "' and pwd_user='" & TextBox2.Text & "'", Conn)

        DR = CMD.ExecuteReader

        DR.Read()

 

        If DR.HasRows Then

            If String.Compare(DR.Item("nama_User"), TextBox1.Text, False) Or String.Compare(DR.Item("pwd_user"), TextBox2.Text, False) Then

                MsgBox("Login Gagal")

                TextBox1.Clear()

                TextBox2.Clear()

                TextBox1.Focus()

                Exit Sub

            Else

                Me.Visible = False

                MasterMenu.Show()

                MasterMenu.Panel1.Text = DR.Item("Kode_user")

                MasterMenu.Panel2.Text = DR.Item("nama_User")

 

                MasterMenu.Panel3.Text = UCase(DR.Item("status_user"))

                If MasterMenu.Panel3.Text <> "ADMIN" Then

                    MasterMenu.Button1.Enabled = False

                Else

                    MasterMenu.Button1.Enabled = True

                End If

            End If

          

        Else

            MsgBox("Nama user dan password tidak cocok")

            TextBox1.Clear()

            TextBox2.Clear()

            TextBox1.Focus()

        End If

    End Sub

 

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click

        End

    End Sub

End Class

 

 

 

 

Imports System.Data.OleDb

 

Public Class MasterUser

 

    Sub KodeOtomatis()

        CMD = New OleDbCommand("select kode_user from tbluser order by kode_user desc", Conn)

        DR = CMD.ExecuteReader

        DR.Read()

        If Not DR.HasRows Then

            TextBox1.Text = "USR01"

        Else

            TextBox1.Text = "USR" + Format(Microsoft.VisualBasic.Right(DR.Item("kode_user"), 2) + 1, "00")

        End If

    End Sub

 

    Sub Kosongkan()

        Call KodeOtomatis()

        TextBox1.Enabled = False

        TextBox2.Clear()

        ComboBox1.Text = ""

        TextBox3.Clear()

        TextBox6.Clear()

        TextBox2.Focus()

        Call TampilGrid()

    End Sub

 

    Sub DataBaru()

        TextBox2.Clear()

        ComboBox1.Text = ""

        TextBox3.Clear()

        TextBox6.Clear()

        TextBox2.Focus()

    End Sub

 

    Sub Ketemu()

        TextBox2.Text = DR.Item("nama_User")

        TextBox3.Text = DR.Item("pwd_User")

        ComboBox1.Text = DR.Item("Status_user")

        TextBox2.Focus()

    End Sub

 

    Sub TampilGrid()

        DA = New OleDbDataAdapter("select * from tblUser", CONN)

        DS = New DataSet

        DA.Fill(DS)

        DGV.DataSource = DS.Tables(0)

        DGV.ReadOnly = True

    End Sub

 

    Private Sub MasterUser_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        Call Koneksi()

        Call Kosongkan()

        ComboBox1.Items.Add("ADMIN")

        ComboBox1.Items.Add("USER")

    End Sub

 

    Private Sub ComboBox1_LostFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles ComboBox1.LostFocus

        ComboBox1.Text = UCase(ComboBox1.Text)

    End Sub

 

 

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

      

        CMD = New OleDbCommand("select * from tblUser where kode_User='" & TextBox1.Text & "'", Conn)

        DR = CMD.ExecuteReader

        DR.Read()

        Try

            If Not DR.HasRows Then

                CMD = New OleDbCommand("insert into tblUser values ('" & TextBox1.Text & "','" & TextBox2.Text & "','" & TextBox3.Text & "','" & ComboBox1.Text & "')", Conn)

                CMD.ExecuteNonQuery()

                Call Kosongkan()

            Else

                CMD = New OleDbCommand("update tblUser set nama_User='" & TextBox2.Text & "',Status_user='" & ComboBox1.Text & "',pwd_User='" & TextBox3.Text & "' where kode_User='" & TextBox1.Text & "'", Conn)

                CMD.ExecuteNonQuery()

                Call Kosongkan()

            End If

        Catch ex As Exception

            MsgBox(ex.Message)

        End Try

 

    End Sub

 

 

    Private Sub DGV_CellMouseClick(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellMouseEventArgs) Handles DGV.CellMouseClick

        On Error Resume Next

        TextBox1.Text = DGV.Rows(e.RowIndex).Cells(0).Value

        TextBox2.Text = DGV.Rows(e.RowIndex).Cells(1).Value

        TextBox3.Text = DGV.Rows(e.RowIndex).Cells(2).Value

        ComboBox1.Text = DGV.Rows(e.RowIndex).Cells(3).Value

        TextBox2.Focus()

    End Sub

 

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click

 

        CMD = New OleDbCommand("select kode_user from tbluser where kode_user='" & TextBox1.Text & "'", Conn)

        DR = CMD.ExecuteReader

        DR.Read()

        If Not DR.HasRows Then

            MsgBox("Kode user belum terdaftar, pilih dulu data dalam Grid")

            Call Kosongkan()

            Exit Sub

        End If

 

        CMD = New OleDbCommand("select distinct kode_user from tblpenjualan where kode_user='" & TextBox1.Text & "'", Conn)

        DR = CMD.ExecuteReader

        DR.Read()

        If DR.HasRows Then

            MsgBox("Kode user tidak dapat dihapus, karena sudah ada dalam transaksi penjualan")

            Call Kosongkan()

            Exit Sub

        End If

 

        If MessageBox.Show("yakin akan dihapus..?", "", MessageBoxButtons.YesNo) = Windows.Forms.DialogResult.Yes Then

            CMD = New OleDbCommand("delete * from tblUser where kode_User='" & TextBox1.Text & "'", Conn)

            CMD.ExecuteNonQuery()

            Call Kosongkan()

        Else

            Call Kosongkan()

        End If

    End Sub

 

    Private Sub TextBox6_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox6.TextChanged

        DA = New OleDbDataAdapter("select * from tblUser where nama_User like '%" & TextBox6.Text & "%'", Conn)

        DS = New DataSet

        DA.Fill(DS)

        DGV.DataSource = DS.Tables(0)

    End Sub

 

 

    Private Sub TextBox2_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox2.KeyPress

        If e.KeyChar = Chr(13) Then

            TextBox2.Text = UCase(TextBox2.Text)

            TextBox3.Focus()

        End If

    End Sub

 

    Private Sub TextBox3_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox3.KeyPress

        If e.KeyChar = Chr(13) Then

            ComboBox1.Focus()

        End If

    End Sub

 

    Private Sub combobox1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles ComboBox1.KeyPress

        If e.KeyChar = Chr(13) Then

            ComboBox1.Text = UCase(ComboBox1.Text)

            Button1.Focus()

        End If

    End Sub

 

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

        Call Kosongkan()

    End Sub

 

    Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click

        Me.Close()

    End Sub

 

 

End Class

 

 

 

 

Imports System.Data.OleDb

 

Public Class MasterBarang

 

    Sub KodeOtomatis()

        CMD = New OleDbCommand("select kode_Barang from tblBarang order by kode_Barang desc", Conn)

        DR = CMD.ExecuteReader

        DR.Read()

        If Not DR.HasRows Then

            TextBox1.Text = "B0001"

        Else

            TextBox1.Text = "B" + Format(Microsoft.VisualBasic.Right(DR.Item("kode_Barang"), 4) + 1, "0000")

        End If

    End Sub

 

    Sub Kosongkan()

        Call KodeOtomatis()

        TextBox1.Enabled = False

        TextBox2.Clear()

        ComboBox1.Text = ""

        TextBox3.Clear()

        TextBox4.Clear()

        TextBox6.Clear()

        TextBox2.Focus()

        Call TampilGrid()

    End Sub

 

    Sub DataBaru()

        TextBox2.Clear()

        ComboBox1.Text = ""

        TextBox3.Clear()

        TextBox4.Clear()

        TextBox6.Clear()

        TextBox2.Focus()

    End Sub

 

    Sub Ketemu()

        TextBox2.Text = DR.Item("nama_Barang")

        ComboBox1.Text = DR.Item("satuan")

        TextBox3.Text = DR.Item("harga")

        TextBox4.Text = DR.Item("stok")

        TextBox2.Focus()

    End Sub

 

    Sub TampilGrid()

        DA = New OleDbDataAdapter("select * from tblBarang", Conn)

        DS = New DataSet

        DA.Fill(DS)

        DGV.DataSource = DS.Tables(0)

        DGV.ReadOnly = True

    End Sub

 

    Sub Tampilsatuan()

        CMD = New OleDbCommand("select distinct satuan from tblbarang", CONN)

        DR = CMD.ExecuteReader

        ComboBox1.Items.Clear()

        Do While DR.Read

            ComboBox1.Items.Add(DR.Item("Satuan"))

        Loop

    End Sub

 

    Private Sub MasterBarang_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        Call Koneksi()

        Call Kosongkan()

        Call Tampilsatuan()

    End Sub

 

    Private Sub ComboBox1_LostFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles ComboBox1.LostFocus

        ComboBox1.Text = UCase(ComboBox1.Text)

    End Sub

 

 

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

        CMD = New OleDbCommand("select * from tblBarang where kode_Barang='" & TextBox1.Text & "'", Conn)

        DR = CMD.ExecuteReader

        DR.Read()

        Try

            If Not DR.HasRows Then

                CMD = New OleDbCommand("insert into tblBarang values ('" & TextBox1.Text & "','" & TextBox2.Text & "','" & ComboBox1.Text & "','" & TextBox3.Text & "','" & TextBox4.Text & "')", Conn)

                CMD.ExecuteNonQuery()

                Call Kosongkan()

            Else

                CMD = New OleDbCommand("update tblBarang set nama_Barang='" & TextBox2.Text & "',satuan='" & ComboBox1.Text & "',harga='" & TextBox3.Text & "',stok='" & TextBox4.Text & "' where kode_Barang='" & TextBox1.Text & "'", Conn)

                CMD.ExecuteNonQuery()

                Call Kosongkan()

            End If

        Catch ex As Exception

            MsgBox(ex.Message)

        End Try

 

    End Sub

 

 

    Private Sub DGV_CellMouseClick(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellMouseEventArgs) Handles DGV.CellMouseClick

        On Error Resume Next

        TextBox1.Text = DGV.Rows(e.RowIndex).Cells(0).Value

        TextBox2.Text = DGV.Rows(e.RowIndex).Cells(1).Value

        ComboBox1.Text = DGV.Rows(e.RowIndex).Cells(2).Value

        TextBox3.Text = DGV.Rows(e.RowIndex).Cells(3).Value

        TextBox4.Text = DGV.Rows(e.RowIndex).Cells(4).Value

        TextBox2.Focus()

    End Sub

 

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click

 

        CMD = New OleDbCommand("select kode_Barang from tblBarang where kode_Barang='" & TextBox1.Text & "'", Conn)

        DR = CMD.ExecuteReader

        DR.Read()

        If Not DR.HasRows Then

            MsgBox("Kode Barang belum terdaftar, pilih dulu data dalam Grid")

            Call Kosongkan()

            Exit Sub

        End If

 

        CMD = New OleDbCommand("select distinct kode_Barang from tbldetail where kode_Barang='" & TextBox1.Text & "'", Conn)

        DR = CMD.ExecuteReader

        DR.Read()

        If DR.HasRows Then

            MsgBox("Kode Barang tidak dapat dihapus karena sudah ada dalam transaksi")

            Call Kosongkan()

            Exit Sub

        End If

 

        If MessageBox.Show("yakin akan dihapus..?", "", MessageBoxButtons.YesNo) = Windows.Forms.DialogResult.Yes Then

            CMD = New OleDbCommand("delete * from tblBarang where kode_Barang='" & TextBox1.Text & "'", Conn)

            CMD.ExecuteNonQuery()

            Call Kosongkan()

        Else

            Call Kosongkan()

        End If

    End Sub

 

    Private Sub TextBox6_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox6.TextChanged

        DA = New OleDbDataAdapter("select * from tblBarang where nama_Barang like '%" & TextBox6.Text & "%' or satuan like '%" & TextBox6.Text & "%'", Conn)

        DS = New DataSet

        DA.Fill(DS)

        DGV.DataSource = DS.Tables(0)

    End Sub

 

 

    Private Sub TextBox2_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox2.KeyPress

        If e.KeyChar = Chr(13) Then

            TextBox2.Text = UCase(TextBox2.Text)

            ComboBox1.Focus()

        End If

    End Sub

 

    Private Sub combobox1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles ComboBox1.KeyPress

        If e.KeyChar = Chr(13) Then

            ComboBox1.Text = UCase(ComboBox1.Text)

            TextBox3.Focus()

        End If

    End Sub

 

    Private Sub TextBox3_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox3.KeyPress

        If e.KeyChar = Chr(13) Then

            TextBox4.Focus()

        End If

        If Not ((e.KeyChar >= "0" And e.KeyChar <= "9") Or e.KeyChar = vbBack) Then e.Handled = True

    End Sub

 

    Private Sub TextBox4_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox4.KeyPress

        If e.KeyChar = Chr(13) Then

            Button1.Focus()

        End If

        If Not ((e.KeyChar >= "0" And e.KeyChar <= "9") Or e.KeyChar = vbBack) Then e.Handled = True

    End Sub

 

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

        Call Kosongkan()

    End Sub

 

    Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click

        Me.Close()

    End Sub

 

End Class

 

 

 

Imports System.Data.OleDb

 

Public Class MasterCustomer

 

    Sub KodeOtomatis()

        CMD = New OleDbCommand("select kode_Customer from tblCustomer order by kode_Customer desc", Conn)

        DR = CMD.ExecuteReader

        DR.Read()

        If Not DR.HasRows Then

            TextBox1.Text = "CUS01"

        Else

            TextBox1.Text = "CUS" + Format(Microsoft.VisualBasic.Right(DR.Item("kode_Customer"), 2) + 1, "00")

        End If

    End Sub

 

    Sub Kosongkan()

        Call KodeOtomatis()

        TextBox1.Enabled = False

        TextBox2.Clear()

        TextBox3.Clear()

        TextBox4.Clear()

        TextBox5.Clear()

        TextBox6.Clear()

        TextBox2.Focus()

        Call TampilGrid()

    End Sub

 

    Sub DataBaru()

        TextBox2.Clear()

        TextBox3.Clear()

        TextBox4.Clear()

        TextBox5.Clear()

        TextBox6.Clear()

        TextBox2.Focus()

    End Sub

 

    Sub Ketemu()

        TextBox2.Text = DR.Item("nama_Customer")

        TextBox3.Text = DR.Item("ALAMAT_CUSTOMER")

        TextBox4.Text = DR.Item("TELEPON_CUSTOMER")

        TextBox5.Text = DR.Item("FAX_CUSTOMER")

        TextBox2.Focus()

    End Sub

 

    Sub TampilGrid()

        DA = New OleDbDataAdapter("select * from tblCustomer", Conn)

        DS = New DataSet

        DA.Fill(DS)

        DGV.DataSource = DS.Tables(0)

        DGV.ReadOnly = True

    End Sub

 

    Private Sub MasterCustomer_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        Call Koneksi()

        Call Kosongkan()

    End Sub

 

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

        CMD = New OleDbCommand("select * from tblCustomer where kode_Customer='" & TextBox1.Text & "'", Conn)

        DR = CMD.ExecuteReader

        DR.Read()

        Try

            If Not DR.HasRows Then

                CMD = New OleDbCommand("insert into tblCustomer values ('" & TextBox1.Text & "','" & TextBox2.Text & "','" & TextBox3.Text & "','" & TextBox4.Text & "','" & TextBox5.Text & "')", Conn)

                CMD.ExecuteNonQuery()

                Call Kosongkan()

            Else

                CMD = New OleDbCommand("update tblCustomer set nama_Customer='" & TextBox2.Text & "',ALAMAT_CUSTOMER='" & TextBox3.Text & "',TELEPON_CUSTOMER='" & TextBox4.Text & "',FAX_CUSTOMER='" & TextBox5.Text & "' where kode_Customer='" & TextBox1.Text & "'", Conn)

                CMD.ExecuteNonQuery()

                Call Kosongkan()

            End If

        Catch ex As Exception

            MsgBox(ex.Message)

        End Try

 

    End Sub

 

 

    Private Sub DGV_CellMouseClick(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellMouseEventArgs) Handles DGV.CellMouseClick

        On Error Resume Next

        TextBox1.Text = DGV.Rows(e.RowIndex).Cells(0).Value

        TextBox2.Text = DGV.Rows(e.RowIndex).Cells(1).Value

        TextBox3.Text = DGV.Rows(e.RowIndex).Cells(2).Value

        TextBox4.Text = DGV.Rows(e.RowIndex).Cells(3).Value

        TextBox5.Text = DGV.Rows(e.RowIndex).Cells(4).Value

        TextBox2.Focus()

    End Sub

 

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click

 

        CMD = New OleDbCommand("select kode_Customer from tblCustomer where kode_Customer='" & TextBox1.Text & "'", Conn)

        DR = CMD.ExecuteReader

        DR.Read()

        If Not DR.HasRows Then

            MsgBox("Kode Customer belum terdaftar, pilih dulu data dalam Grid")

            Call Kosongkan()

            Exit Sub

        End If

 

        CMD = New OleDbCommand("select distinct kode_Customer from tblPENJUALAN where kode_Customer='" & TextBox1.Text & "'", Conn)

        DR = CMD.ExecuteReader

        DR.Read()

        If DR.HasRows Then

            MsgBox("Kode Customer tidak dapat dihapus karena sudah ada dalam transaksi")

            Call Kosongkan()

            Exit Sub

        End If

 

        If MessageBox.Show("yakin akan dihapus..?", "", MessageBoxButtons.YesNo) = Windows.Forms.DialogResult.Yes Then

            CMD = New OleDbCommand("delete * from tblCustomer where kode_Customer='" & TextBox1.Text & "'", Conn)

            CMD.ExecuteNonQuery()

            Call Kosongkan()

        Else

            Call Kosongkan()

        End If

    End Sub

 

    Private Sub TextBox6_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox6.TextChanged

        DA = New OleDbDataAdapter("select * from tblCustomer where nama_Customer like '%" & TextBox6.Text & "%' or ALAMAT_CUSTOMER like '%" & TextBox6.Text & "%'", Conn)

        DS = New DataSet

        DA.Fill(DS)

        DGV.DataSource = DS.Tables(0)

    End Sub

 

 

    Private Sub TextBox2_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox2.KeyPress

        If e.KeyChar = Chr(13) Then

            TextBox2.Text = UCase(TextBox2.Text)

            TextBox3.Focus()

        End If

    End Sub

 

 

    Private Sub TextBox3_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox3.KeyPress

        If e.KeyChar = Chr(13) Then

            TextBox4.Focus()

        End If

        'If Not ((e.KeyChar >= "0" And e.KeyChar <= "9") Or e.KeyChar = vbBack) Then e.Handled = True

    End Sub

 

    Private Sub TextBox4_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox4.KeyPress

        If e.KeyChar = Chr(13) Then

            TextBox5.Focus()

        End If

        'If Not ((e.KeyChar >= "0" And e.KeyChar <= "9") Or e.KeyChar = vbBack) Then e.Handled = True

    End Sub

 

    Private Sub TextBox5_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox5.KeyPress

        If e.KeyChar = Chr(13) Then

            Button1.Focus()

        End If

        'If Not ((e.KeyChar >= "0" And e.KeyChar <= "9") Or e.KeyChar = vbBack) Then e.Handled = True

    End Sub

 

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

        Call Kosongkan()

    End Sub

 

    Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click

        Me.Close()

    End Sub

End Class

 

 

 

 

 

 

Imports System.Data.OleDb

 

Public Class TransaksiPenjualan

 

    Sub FakturOtomatis()

        CMD = New OleDbCommand("select no_faktur from tblpenjualan order by no_faktur desc", Conn)

        DR = CMD.ExecuteReader

        DR.Read()

        If Not DR.HasRows Then

            Label3.Text = "F0001"

        Else

            Label3.Text = "F" + Format(Microsoft.VisualBasic.Right(DR.Item("no_faktur"), 4) + 1, "0000")

        End If

    End Sub

 

 

    Private Sub TransaksiPenjualan_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        Call Koneksi()

        Call Bersihkan()

 

        Call FakturOtomatis()

        Label4.Text = Today

 

        CMD = New OleDbCommand("select * from tblcustomer", Conn)

        DR = CMD.ExecuteReader

        ListBox1.Items.Clear()

        Do While DR.Read

            ListBox1.Items.Add(DR.Item(0) & Space(2) & DR.Item(1))

        Loop

 

        CMD = New OleDbCommand("select * from tblbarang", Conn)

        DR = CMD.ExecuteReader

        ListBox2.Items.Clear()

        Do While DR.Read

            ListBox2.Items.Add(DR.Item(0) & Space(2) & DR.Item(1))

        Loop

    End Sub

 

    Sub HitungTransaksi()

        Dim x As Integer = 0

        For baris As Integer = 0 To DGV.RowCount - 1

            x = x + DGV.Rows(baris).Cells(3).Value

            Label6.Text = x

            Label6.Text = FormatNumber(Label6.Text, 0)

        Next

 

        Dim y As Integer = 0

        For baris As Integer = 0 To DGV.RowCount - 1

            y = y + DGV.Rows(baris).Cells(4).Value

            Label8.Text = y

            Label8.Text = FormatNumber(Label8.Text, 0)

        Next

 

                Label10.Text = Val(Microsoft.VisualBasic.Str(Label8.Text) * 10) / 100

        Label10.Text = FormatNumber(Label10.Text, 0)

 

        Label15.Text = Val(Microsoft.VisualBasic.Str(Label8.Text)) + Val(Microsoft.VisualBasic.Str(Label10.Text))

        Label15.Text = FormatNumber(Label15.Text, 0)

    End Sub

 

    Private Sub DGV_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles DGV.KeyPress

        On Error Resume Next

        If e.KeyChar = Chr(27) Then

            DGV.Rows.RemoveAt(DGV.CurrentCell.RowIndex)

            Call Hitungtransaksi()

        End If

 

        If e.KeyChar = Chr(13) Then

            TextBox1.Focus()

        End If

    End Sub

 

    Sub FormatGrid()

        DGV.Columns(2).DefaultCellStyle.Format = "###,###,###"

        DGV.Columns(2).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight

        DGV.Columns(3).DefaultCellStyle.Format = "###,###,###"

        DGV.Columns(3).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter

        DGV.Columns(4).DefaultCellStyle.Format = "###,###,###"

        DGV.Columns(4).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight

    End Sub

 

 

    Sub Bersihkan()

        DGV.Rows.Clear()

        Label6.Text = 0

        Label8.Text = 0

        Label10.Text = 0

        Label15.Text = 0

        Label16.Text = 0

        TextBox1.Text = 0

        TextBox2.Text = 0

        TextBox3.Clear()

    End Sub

 

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

        Me.Close()

    End Sub

 

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click

        Call Bersihkan()

    End Sub

 

    Private Sub TextBox1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress

        If Not ((e.KeyChar >= "0" And e.KeyChar <= "9") Or e.KeyChar = vbBack) Then e.Handled = True

        If e.KeyChar = Chr(13) Then

            TextBox1.Text = FormatNumber(TextBox1.Text, 0)

            Label15.Text = Val(Microsoft.VisualBasic.Str(Label15.Text)) - Val(Microsoft.VisualBasic.Str(TextBox1.Text))

            Label15.Text = FormatNumber(Label15.Text, 0)

            TextBox2.Focus()

        End If

    End Sub

 

    Private Sub TextBox2_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox2.KeyPress

        If Not ((e.KeyChar >= "0" And e.KeyChar <= "9") Or e.KeyChar = vbBack) Then e.Handled = True

        If e.KeyChar = Chr(13) Then

            TextBox2.Text = FormatNumber(TextBox2.Text, 0)

            If Val(TextBox2.Text) < Val(Label15.Text) Then

                MsgBox("Pembayaran kurang")

                Exit Sub

            ElseIf Val(TextBox2.Text) >= Val(Label15.Text) Then

                Label16.Text = Val(Microsoft.VisualBasic.Str(TextBox2.Text)) - Val(Microsoft.VisualBasic.Str(Label15.Text))

                Label16.Text = FormatNumber(Label16.Text, 0)

                Button1.Focus()

            End If

        End If

    End Sub

 

    Private Sub TextBox3_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox3.TextChanged

        CMD = New OleDbCommand("select * from tblbarang where nama_barang like '%" & TextBox3.Text & "%'", Conn)

        DR = CMD.ExecuteReader

        ListBox2.Items.Clear()

        Do While DR.Read

            ListBox2.Items.Add(DR.Item(0) & Space(2) & DR.Item(1))

        Loop

    End Sub

 

End Class

 

 

 

 

 

Public Class LaporanMaster

 

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

        cryRpt.Load("LAPORAN User.rpt")

        Call seting_laporan()

        CRV.ReportSource = cryRpt

        CRV.RefreshReport()

    End Sub

 

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click

        cryRpt.Load("LAPORAN BARANG.rpt")

        Call seting_laporan()

        CRV.ReportSource = cryRpt

        CRV.RefreshReport()

    End Sub

 

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

        cryRpt.Load("LAPORAN CUSTOMER.rpt")

        Call seting_laporan()

        CRV.ReportSource = cryRpt

        CRV.RefreshReport()

    End Sub

 

    Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click

        Me.Close()

    End Sub

End Class

 

 

 

 

 

 

 

Imports System.Data.OleDb

 

Public Class LaporanPenjualan

 

 

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

        Me.Close()

    End Sub

 

    Private Sub LaporanPenjualan_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        Call Koneksi()

        CMD = New OleDbCommand("select distinct tanggal from tblpenjualan", Conn)

        DR = CMD.ExecuteReader

        Do While DR.Read

            ComboBox1.Items.Add(DR.Item(0))

            ComboBox2.Items.Add(DR.Item(0))

            ComboBox3.Items.Add(DR.Item(0))

            ComboBox4.Items.Add(DR.Item(0))

            ComboBox5.Items.Add(DR.Item(0))

        Loop

    End Sub

 

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click

        CRV.SelectionFormula = "totext({tblPenjualan.TANGGAL}) ='" & ComboBox1.Text & "'"

        cryRpt.Load("laporan harian.rpt")

        Call seting_laporan()

        CRV.ReportSource = cryRpt

        CRV.RefreshReport()

    End Sub

 

    Private Sub ComboBox3_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox3.SelectedIndexChanged

        If ComboBox2.Text = "" Then

            MsgBox("Tanggal awal harus diisi")

            Exit Sub

        End If

        CRV.SelectionFormula = "{tblPenjualan.TANGGAL} in date ('" & ComboBox2.Text & "') to date ('" & ComboBox3.Text & "')"

        cryRpt.Load("laporan mingguan.rpt")

        Call seting_laporan()

        CRV.ReportSource = cryRpt

        CRV.RefreshReport()

    End Sub

 

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

        CRV.SelectionFormula = "month({tblPenjualan.TANGGAL}) = (" & Month(DateTimePicker1.Text) & ") and year({tblPenjualan.TANGGAL}) = (" & Year(DateTimePicker1.Text) & ")"

        cryRpt.Load("LAPORAN bulanan.rpt")

        Call seting_laporan()

        CRV.ReportSource = cryRpt

        CRV.RefreshReport()

    End Sub

 

    Private Sub ComboBox5_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox5.SelectedIndexChanged

        If ComboBox4.Text = "" Then

            MsgBox("Tanggal awal harus diisi")

            Exit Sub

        End If

        CRV.SelectionFormula = "{tblPenjualan.TANGGAL} in date ('" & ComboBox4.Text & "') to date ('" & ComboBox5.Text & "')"

        cryRpt.Load("grafik.rpt")

        Call seting_laporan()

        CRV.ReportSource = cryRpt

        CRV.RefreshReport()

    End Sub

 

    Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click

        CRV.SelectionFormula = "month({tblPenjualan.TANGGAL}) = (" & Month(DateTimePicker2.Text) & ") and year({tblPenjualan.TANGGAL}) = (" & Year(DateTimePicker2.Text) & ")"

        cryRpt.Load("grafik1.rpt")

        Call seting_laporan()

        CRV.ReportSource = cryRpt

        CRV.RefreshReport()

    End Sub

End Class

 

 

 

Imports System.Data.OleDb

 

Public Class RincianPenjualan

 

    Sub Bersihkan()

        DGV.Columns.Clear()

        Label6.Text = 0

        Label8.Text = 0

        Label10.Text = 0

        Label15.Text = 0

        Label16.Text = 0

        TextBox1.Text = 0

        TextBox2.Text = 0

    End Sub

 

    Private Sub RincianPenjualan_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        Call Koneksi()

        Call Bersihkan()

        CMD = New OleDbCommand("select no_faktur from tblpenjualan", Conn)

        DR = CMD.ExecuteReader

        ListBox1.Items.Clear()

        Do While DR.Read

            ListBox1.Items.Add(DR.Item(0))

        Loop

    End Sub

 

    Private Sub ListBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListBox1.SelectedIndexChanged

        CMD = New OleDbCommand("select * from tblpenjualan where no_faktur='" & ListBox1.Text & "'", Conn)

        DR = CMD.ExecuteReader

        DR.Read()

        If DR.HasRows Then

            Label3.Text = DR.Item("kode_customer")

            Label4.Text = DR.Item("tanggal")

            Label6.Text = DR.Item("jmlbarang")

            Label8.Text = DR.Item("grandtotal")

            Label10.Text = DR.Item("ppn")

            TextBox1.Text = DR.Item("diskon")

            Label15.Text = DR.Item("totalharga")

            TextBox2.Text = DR.Item("dibayar")

            Label16.Text = DR.Item("kembali")

            '===============================

            Label8.Text = FormatNumber(Label8.Text, 0)

            Label10.Text = FormatNumber(Label10.Text, 0)

            TextBox1.Text = FormatNumber(TextBox1.Text, 0)

            Label15.Text = FormatNumber(Label15.Text, 0)

            TextBox2.Text = FormatNumber(TextBox2.Text, 0)

            Label16.Text = FormatNumber(Label16.Text, 0)

 

            CMD = New OleDbCommand("select * from tblcustomer where kode_customer='" & Label3.Text & "'", Conn)

            DR = CMD.ExecuteReader

            DR.Read()

            If DR.HasRows Then

                Label3.Text = DR.Item("nama_customer")

            End If

        End If

 

        DA = New OleDbDataAdapter("select tbldetail.kode_barang as [Kode Barang],tblbarang.nama_barang as [Nama Barang],tbldetail.harga_jual as Harga,Qty,Total from tblbarang,tbldetail where tbldetail.kode_barang=tblbarang.kode_barang and tbldetail.no_faktur='" & ListBox1.Text & "'", Conn)

        DS = New DataSet

        DA.Fill(DS)

        DGV.DataSource = DS.Tables(0)

        DGV.ReadOnly = True

 

        DGV.DefaultCellStyle.BackColor = Color.AliceBlue

        DGV.AlternatingRowsDefaultCellStyle.BackColor = Color.AntiqueWhite

        DGV.Columns(2).DefaultCellStyle.Format = "###,###,###"

        DGV.Columns(2).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight

        DGV.Columns(3).DefaultCellStyle.Format = "###,###,###"

        DGV.Columns(3).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter

        DGV.Columns(4).DefaultCellStyle.Format = "###,###,###"

        DGV.Columns(4).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight

 

        DGV.Columns(1).Width = 180

        DGV.Columns(3).Width = 50

 

    End Sub

 

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

        Cetak.Show()

        Cetak.CRV.SelectionFormula = "{tblPenjualan.no_faktur} ='" & ListBox1.Text & "'"

        cryRpt.Load("laporan per faktur.rpt")

        Call seting_laporan()

        Cetak.CRV.ReportSource = cryRpt

        Cetak.CRV.RefreshReport()

    End Sub

End Class