1.
log in
Imports System.Data.Odbc
Public Class Login
Dim Hitung As Integer = 0
Private Sub btnOK_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnOK.Click
Call Koneksi()
CMD = New OdbcCommand("select * from tbluser where nama_user='" &
txtnamauser.Text & "' and pwd_user='" & txtpassword.Text & "'", Conn)
DR = CMD.ExecuteReader
DR.Read()
If Not DR.HasRows Then
MsgBox("Login gagal")
Hitung = Hitung + 1
If Hitung > 2 Then
End
End If
Exit Sub
Else
If txtpassword.Text <> DR.Item("pwd_user") Then
MsgBox("password salah")
txtpassword.Focus()
Exit Sub
End If
Me.Visible = False
MenuUtama.Show()
MenuUtama.Panel1.Text = DR.Item("kode_user")
MenuUtama.Panel2.Text = DR.Item("nama_user")
MenuUtama.Panel3.Text = UCase(DR.Item("status"))
If MenuUtama.Panel3.Text <> "ADMIN" Then
MenuUtama.btnuser.Visible = False
End If
End If
End Sub
Private Sub btnCancel_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnCancel.Click
Me.Close()
End Sub
End Class
2. menu utama
Imports System.Data.Odbc
Public Class BarangMasuk
Sub Kosongkan()
txtnomor.Clear()
cbokodesupplier.Text = ""
lblnamasupplier.Text = ""
txtcaribarang.Clear()
lbltotalmasuk.Text = ""
DGV.Rows.Clear()
End Sub
Sub TampilKodeSupplier()
CMD = New odbcCommand("select kode_supplier from tblsupplier", Conn)
DR = CMD.ExecuteReader
cbokodesupplier.Items.Clear()
Do While DR.Read
cbokodesupplier.Items.Add(DR.Item("kode_supplier"))
Loop
End Sub
Sub TampilBarang()
DA = New OdbcDataAdapter("select * from tblbarang", Conn)
DS = New DataSet
DA.Fill(DS)
DGVBarang.DataSource = DS.Tables(0)
DGVBarang.ReadOnly = True
DGVBarang.Columns(0).Visible = False
DGVBarang.Columns(2).Visible = False
DGVBarang.Columns(3).Visible = False
End Sub
Private Sub BarangMasuk_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Call Kosongkan()
Call Koneksi()
Call TampilKodeSupplier()
Call TampilBarang()
End Sub
Private Sub cbokodesupplier_SelectedIndexChanged(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles cbokodesupplier.SelectedIndexChanged
CMD = New odbcCommand("select * from tblsupplier where kode_supplier='" &
cbokodesupplier.Text & "'", Conn)
DR = CMD.ExecuteReader
DR.Read()
If DR.HasRows Then
lblnamasupplier.Text = DR.Item("nama_supplier")
Else
MsgBox("kode supplier tidak terdaftar")
End If
End Sub
Sub TotalMasuk()
Dim hitung As Integer = 0
For baris As Integer = 0 To DGV.RowCount - 1
hitung = hitung + DGV.Rows(baris).Cells(3).Value
Next
lbltotalmasuk.Text = hitung
End Sub
Private Sub DGV_CellEndEdit(ByVal sender As Object, ByVal e As
System.Windows.Forms.DataGridViewCellEventArgs) Handles DGV.CellEndEdit
If e.ColumnIndex = 3 Then
Try
DGV.Rows(e.RowIndex).Cells(4).Value =
DGV.Rows(e.RowIndex).Cells(2).Value + DGV.Rows(e.RowIndex).Cells(3).Value
Call TotalMasuk()
Catch ex As Exception
MsgBox("harus angka")
SendKeys.Send("{UP}")
DGV.Rows(e.RowIndex).Cells(3).Value = 0
End Try
End If
End Sub
Private Sub btnbatal_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnbatal.Click
Call Kosongkan()
End Sub
Private Sub btntutup_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btntutup.Click
Me.Close()
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 '=escape
DGV.Rows.Remove(DGV.CurrentRow)
Call TotalMasuk()
End If
End Sub
Private Sub txtcaribarang_TextChanged(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles txtcaribarang.TextChanged
DA = New OdbcDataAdapter("select * from tblbarang where nama_barang like
'%" & txtcaribarang.Text & "%'", Conn)
DS = New DataSet
DA.Fill(DS)
DGVBarang.DataSource = DS.Tables(0)
DGVBarang.ReadOnly = True
DGVBarang.Columns(0).Visible = False
DGVBarang.Columns(2).Visible = False
DGVBarang.Columns(3).Visible = False
End Sub
Private Sub txtnomor_KeyPress(ByVal sender As Object, ByVal e As
System.Windows.Forms.KeyPressEventArgs) Handles txtnomor.KeyPress
txtnomor.MaxLength = 10
If e.KeyChar = Chr(13) Then
CMD = New odbcCommand("select no_masuk from tblbarangmasuk where
no_masuk='" & txtnomor.Text & "'", Conn)
DR = CMD.ExecuteReader
DR.Read()
If DR.HasRows Then
MsgBox("Nomor ini sudah digunakan")
txtnomor.Focus()
Exit Sub
Else
dtptanggal.Focus()
End If
End If
End Sub
Private Sub DGVBarang_CellMouseClick(ByVal sender As Object, ByVal e As
System.Windows.Forms.DataGridViewCellMouseEventArgs) Handles
DGVBarang.CellMouseClick
On Error Resume Next
DGV.Focus()
Dim baris As Integer = DGV.RowCount - 1
DGV.Rows.Add(DGVBarang.Rows(e.RowIndex).Cells(0).Value,
DGVBarang.Rows(e.RowIndex).Cells(1).Value,
DGVBarang.Rows(e.RowIndex).Cells(3).Value)
txtcaribarang.Clear()
For barisatas As Integer = 0 To DGV.RowCount - 1
For barisbawah As Integer = barisatas + 1 To DGV.RowCount - 1
If DGV.Rows(barisbawah).Cells(0).Value =
DGV.Rows(barisatas).Cells(0).Value Then
DGV.Rows(barisatas).Cells(3).Value =
DGV.Rows(barisatas).Cells(3).Value + 1
DGV.Rows(barisatas).Cells(4).Value =
DGV.Rows(barisatas).Cells(2).Value + DGV.Rows(barisatas).Cells(3).Value
DGV.Rows.RemoveAt(barisbawah)
DGV.CurrentCell = DGV(2, baris)
SendKeys.Send("{TAB}")
Call TotalMasuk()
Exit Sub
End If
Next
Next
CMD = New OdbcCommand("select * from tblbarang where kode_barang='" &
DGV.Rows(baris).Cells(0).Value & "'", Conn)
DR = CMD.ExecuteReader
DR.Read()
If DR.HasRows Then
DGV.Rows(baris).Cells(1).Value = DR.Item("nama_Barang")
DGV.Rows(baris).Cells(2).Value = DR.Item("stok")
DGV.CurrentCell = DGV(2, baris)
SendKeys.Send("{TAB}")
Else
MsgBox("kode barang tidak terdaftar")
End If
Call TotalMasuk()
End Sub
End Class
3. barang keluar
Imports System.Data.Odbc
Public Class BarangKeluar
Sub NomorOtotamatis()
txtnomor.Enabled = False
CMD = New odbcCommand("select No_Keluar from tblbarangkeluar order by
No_Keluar desc", Conn)
DR = CMD.ExecuteReader
DR.Read()
If Not DR.HasRows Then
txtnomor.Text = Format(Today, "yyMMdd") + "0001"
Else
If Microsoft.VisualBasic.Left(DR.Item("No_Keluar"), 6) = Format(Today,
"yyMMdd") Then
txtnomor.Text = DR.Item("No_Keluar") + 1
Else
txtnomor.Text = Format(Today, "yyMMdd") + "0001"
End If
End If
End Sub
Sub Kosongkan()
cbokodecustomer.Text = ""
lblnamacustomer.Text = ""
txtcaribarang.Clear()
lbltotalkeluar.Text = ""
DGV.Rows.Clear()
End Sub
Sub TampilKodecustomer()
CMD = New odbcCommand("select kode_customer from tblcustomer", Conn)
DR = CMD.ExecuteReader
cbokodecustomer.Items.Clear()
Do While DR.Read
cbokodecustomer.Items.Add(DR.Item("kode_customer"))
Loop
End Sub
Sub TampilBarang()
DA = New OdbcDataAdapter("select * from tblbarang", Conn)
DS = New DataSet
DA.Fill(DS)
DGVBarang.DataSource = DS.Tables(0)
DGVBarang.ReadOnly = True
DGVBarang.Columns(0).Visible = False
DGVBarang.Columns(2).Visible = False
DGVBarang.Columns(3).Visible = False
End Sub
Private Sub BarangKeluar_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Call Kosongkan()
Call Koneksi()
Call NomorOtotamatis()
Call TampilKodecustomer()
Call TampilBarang()
End Sub
Private Sub cbokodecustomer_SelectedIndexChanged(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles cbokodecustomer.SelectedIndexChanged
CMD = New odbcCommand("select * from tblcustomer where kode_customer='" &
cbokodecustomer.Text & "'", Conn)
DR = CMD.ExecuteReader
DR.Read()
If DR.HasRows Then
lblnamacustomer.Text = DR.Item("nama_customer")
Else
MsgBox("kode customer tidak terdaftar")
End If
End Sub
Private Sub ListBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal
e As System.EventArgs)
'On Error Resume Next
Dim baris As Integer = DGV.RowCount - 1
txtcaribarang.Clear()
For barisatas As Integer = 0 To DGV.RowCount - 1
For barisbawah As Integer = barisatas + 1 To DGV.RowCount - 1
If DGV.Rows(barisbawah).Cells(0).Value =
DGV.Rows(barisatas).Cells(0).Value Then
DGV.Rows(barisatas).Cells(3).Value =
DGV.Rows(barisatas).Cells(3).Value + 1
If DGV.Rows(barisatas).Cells(3).Value >
DGV.Rows(barisatas).Cells(2).Value Then
MsgBox("Stok barang tidak cukup, hanya ada " &
DGV.Rows(barisatas).Cells(3).Value & "")
DGV.Rows(barisatas).Cells(3).Value =
DGV.Rows(barisatas).Cells(2).Value
Else
DGV.Rows(barisatas).Cells(4).Value =
DGV.Rows(barisatas).Cells(2).Value - DGV.Rows(barisatas).Cells(3).Value
End If
DGV.Rows.RemoveAt(barisbawah)
Call TotalKeluar()
Exit Sub
End If
Next
Next
CMD = New OdbcCommand("select * from tblbarang where kode_barang='" &
DGV.Rows(baris).Cells(0).Value & "'", Conn)
DR = CMD.ExecuteReader
DR.Read()
If DR.HasRows Then
DGV.Rows(baris).Cells(1).Value = DR.Item("nama_Barang")
DGV.Rows(baris).Cells(2).Value = DR.Item("stok")
DGV.CurrentCell = DGV(3, baris)
SendKeys.Send("{TAB}")
Else
MsgBox("kode barang tidak terdaftar")
End If
End Sub
Sub TotalKeluar()
Dim hitung As Integer = 0
For baris As Integer = 0 To DGV.RowCount - 1
hitung = hitung + DGV.Rows(baris).Cells(3).Value
Next
lbltotalkeluar.Text = hitung
End Sub
Private Sub btnbatal_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnbatal.Click
Call Kosongkan()
End Sub
Private Sub btntutup_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btntutup.Click
Me.Close()
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 '=escape
DGV.Rows.Remove(DGV.CurrentRow)
Call TotalKeluar()
End If
End Sub
Private Sub txtcaribarang_TextChanged(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles txtcaribarang.TextChanged
DA = New OdbcDataAdapter("select * from tblbarang where nama_barang like
'%" & txtcaribarang.Text & "%'", Conn)
DS = New DataSet
DA.Fill(DS)
DGVBarang.DataSource = DS.Tables(0)
DGVBarang.ReadOnly = True
DGVBarang.Columns(0).Visible = False
DGVBarang.Columns(2).Visible = False
DGVBarang.Columns(3).Visible = False
End Sub
Private Sub DGVBarang_CellMouseClick(ByVal sender As Object, ByVal e As
System.Windows.Forms.DataGridViewCellMouseEventArgs) Handles
DGVBarang.CellMouseClick
On Error Resume Next
DGV.Focus()
Dim baris As Integer = DGV.RowCount - 1
DGV.Rows.Add(DGVBarang.Rows(e.RowIndex).Cells(0).Value,
DGVBarang.Rows(e.RowIndex).Cells(1).Value,
DGVBarang.Rows(e.RowIndex).Cells(3).Value)
txtcaribarang.Clear()
For barisatas As Integer = 0 To DGV.RowCount - 1
For barisbawah As Integer = barisatas + 1 To DGV.RowCount - 1
If DGV.Rows(barisbawah).Cells(0).Value =
DGV.Rows(barisatas).Cells(0).Value Then
DGV.Rows(barisatas).Cells(3).Value =
DGV.Rows(barisatas).Cells(3).Value + 1
If DGV.Rows(barisatas).Cells(3).Value >
DGV.Rows(barisatas).Cells(2).Value Then
MsgBox("Stok barang tidak cukup, hanya ada " &
DGV.Rows(barisatas).Cells(3).Value & "")
DGV.Rows(barisatas).Cells(3).Value =
DGV.Rows(barisatas).Cells(2).Value
Else
DGV.Rows(barisatas).Cells(4).Value =
DGV.Rows(barisatas).Cells(2).Value - DGV.Rows(barisatas).Cells(3).Value
End If
DGV.Rows.RemoveAt(barisbawah)
Call TotalKeluar()
Exit Sub
End If
Next
Next
CMD = New OdbcCommand("select * from tblbarang where kode_barang='" &
DGV.Rows(baris).Cells(0).Value & "'", Conn)
DR = CMD.ExecuteReader
DR.Read()
If DR.HasRows Then
DGV.Rows(baris).Cells(1).Value = DR.Item("nama_Barang")
DGV.Rows(baris).Cells(2).Value = DR.Item("stok")
DGV.CurrentCell = DGV(2, baris)
SendKeys.Send("{TAB}")
Else
MsgBox("kode barang tidak terdaftar")
End If
End Sub
End Class
4. laporan master
Private Sub btnbarang_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnbarang.Click
CRV.ReportSource = Nothing
CRV.ReportSource = "barang.rpt"
CRV.RefreshReport()
End Sub
5. laporan barang masuk
Private Sub ListBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles ListBox1.SelectedIndexChanged
If ListBox1.Text = "" Then
MsgBox("pilih nomor terlebih dahulu")
Exit Sub
End If
CRV.ReportSource = Nothing
CRV.SelectionFormula = "{tblbarangmasuk.no_masuk}='" & ListBox1.Text & "'"
CRV.ReportSource = "barang masuk.rpt"
CRV.RefreshReport()
End Sub
6. laporan barang keluar
Private Sub ListBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles ListBox1.SelectedIndexChanged
If ListBox1.Text = "" Then
MsgBox("pilih nomor terlebih dahulu")
Exit Sub
End If
CRV.ReportSource = Nothing
CRV.SelectionFormula = "{tblbarangKeluar.no_Keluar}='" & ListBox1.Text &
"'"
CRV.ReportSource = "barang Keluar.rpt"
CRV.RefreshReport()
End Sub
7. laporan stok barang
Private Sub btnharian_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnharian.Click
If ListBox1.Text = "" Then
MsgBox("pilih barang terlebih dahulu")
Exit Sub
End If
CRV.SelectionFormula = "Totext({tblstok.tanggal})='" & dtpharian.Text & "'
and {tblstok.kode_barang}='" & Microsoft.VisualBasic.Right(ListBox1.Text, 5) & "'"
CRV.ReportSource = "lap stok.rpt"
CRV.RefreshReport()
End Sub
8. stok barang umum
Private Sub btnbulanumum_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnbulanumum.Click
CRV.SelectionFormula = "MONTH({tblstok.tanggal})=(" &
Month(dtpbulanan.Text) & ") and YEAR({tblstok.tanggal})=(" & Year(dtpbulanan.Text)
& ")"
CRV.ReportSource = "LAP stok umum ok.rpt"
CRV.RefreshReport()
End Sub