Lampiran 2: Source Code Dalam Setiap Form
Kode Program 1 Kode Program untuk Module
Imports System.Data Imports System.Data.OleDb Module Module1
Public isi As String Public TabData() As Array Public cn As OleDbConnection Public cmd As OleDbCommand Public da As OleDbDataAdapter Public brsrec As New BindingSource Public ds As DataSet
Public str As String Public dt As DataTable
Sub koneksi()
str = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source= " & System.Environment.CurrentDirectory.ToString() & _
"\PuriReminder.mdb" cn = New OleDbConnection(str)
If cn.State = ConnectionState.Closed Then cn.Open()
End If
End Sub
End Module
Kode Program 2 Kode Program untuk Form Login
Public Class F_Login
Private Sub F_Login_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
TextUser.PasswordChar = "" TextPass.PasswordChar = "*"
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButCancel.Click
Me.Close() End Sub
Private Sub ButOK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButOK.Click
If Me.TextUser.Text = "purchasing" And Me.TextPass.Text = "system" Then MsgBox("Login Berhasil")
F_Tampil.Show() Call bersih() Else
MsgBox("Terjadi Kesalahan")
End If
End Sub
Sub bersih()
TextUser.Text = "" TextPass.Text = "" End Sub
Private Sub TextPass_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextPass.TextChanged
Dim pass As String pass = Me.TextPass.PasswordChar
End Sub
Private Sub PictureBox1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox1.Click
Kode Program 3 Kode program untuk Form Tampil
Public Class F_Tampil
Private Sub F_Tampil_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Timer1.Enabled = True End Sub
Private Sub ButSJ_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButSJ.Click
F_SJ.Show() End Sub
Private Sub ButPO_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButTghn.Click
F_Faktur.Show() End Sub
Private Sub ButTghn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButPO.Click
F_PO.Show() End Sub
Private Sub ButAlrm_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButAlrm.Click
F_Alarm.Show() End Sub
Private Sub ButSup_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButSup.Click
F_Pemasok.Show() End Sub
Private Sub ButBrg_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButBrg.Click
F_Barang.Show() End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Label7.Text = Now.ToString("hh:mm:ss tt") Label8.Text = Format(Now, "dddd, dd-MMMM-yyyy") End Sub
End Class
Kode Program 4 Kode Program untuk Form Surat Jalan
Imports System.Data Imports System.Data.OleDb Public Class F_SJ
Sub bersih()
TextSJ.Text = "" DTP_SJ.Text = ""
End Sub
Private Sub ButView_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButCancel.Click
bersih() End Sub
Private Sub ButCancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButNext.Click
F_PO.TextSJ.Text = Me.TextSJ.Text F_PO.TextTgl.Text = Me.DTP_SJ.Text
F_PO.Show()
Kode Program 5 Kode Program untuk Form PO Belum Terpenuhi
Imports System.Data Imports System.Data.OleDb Public Class F_PO
Inherits System.Windows.Forms.Form Dim brs As Integer = 0
Dim Jml_Baris As Integer Dim StrCari As String Dim i As Integer
Private Sub F_PO_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Call koneksi() Call listview() Call nampil()
TextCari.MaxLength = 8 TextCari.Text = "" End Sub
Sub nampil()
'tambahkan syarat where no faktur yang kosong pada perintah select berikut ini
Dim sql1 = "SELECT T_DetailPO.No_PO, T_DetailPO.ID_Material, T_Barang.Nama_Material, T_DetailPO.QTY,
T_DetailPO.No_Faktur,T_PO.ID_Vendor,T_SUPPLIER.NAMA_VENDOR " & _ "FROM T_DetailPO, T_Barang, T_PO, T_SupplieR "& _ "WHERE T_DetailPO.No_PO=t_po.NO_PO AND
T_DetailPO.ID_Material=T_Barang.id_Material AND T_PO.ID_Vendor=T_SUPPLIER.ID_VENDOR " & _ " AND (t_DetailPO.No_Faktur Is Null) "
da = New Data.OleDb.OleDbDataAdapter(sql1, cn) dt = New DataTable
da.Fill(dt)
For i As Integer = 0 To dt.Rows.Count - 1 With ListView1
.Items.Add(dt.Rows(i)("No_PO"))
With .Items(.Items.Count - 1).SubItems .Add(dt.Rows(i)("ID_Material")) .Add(dt.Rows(i)("Nama_Material")) .Add(dt.Rows(i)("QTY"))
.Add(dt.Rows(i)("ID_VENDOR")) .Add(dt.Rows(i)("NAMA_VENDOR")) End With
End With Next
End Sub
Private Sub ButOK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButOK.Click
Dim j As Integer
Dim itemnya(5) As String Dim ItemList As ListViewItem j = 0
For i As Integer = 0 To dt.Rows.Count - 1 'MsgBox(ListView1.Items.Item(i).SubItems(0).Text & ListView1.Items.Item(i).Selected)
If ListView1.Items.Item(i).Selected Then itemnya(0) = ListView1.Items.Item(i).SubItems(0).Text itemnya(1) = ListView1.Items.Item(i).SubItems(1).Text itemnya(2) = ListView1.Items.Item(i).SubItems(2).Text itemnya(3) = ListView1.Items.Item(i).SubItems(3).Text itemnya(4) = ListView1.Items.Item(i).SubItems(3).Text itemnya(5) = "0"
ItemList = New ListViewItem(itemnya) F_Faktur.ListView1.Items.Add(ItemList)
F_Faktur.TextVend.Text = ListView1.Items.Item(i).SubItems(5).Text F_Faktur.TextTIDVENDOR.Text =
ListView1.Items.Item(i).SubItems(4).Text
F_Faktur.TextSJ.Text = Me.TextSJ.Text F_Faktur.TextTGLSJ.Text = Me.TextTgl.Text
End If Next
Sub listview()
Me.ListView1.View = View.Details Me.ListView1.GridLines = True Me.ListView1.FullRowSelect = True
ListView1.Columns.Add("No PO", 100, HorizontalAlignment.Center) ListView1.Columns.Add("ID", 100, HorizontalAlignment.Center) ListView1.Columns.Add("Material", 100, HorizontalAlignment.Center) ListView1.Columns.Add("QTY", 100, HorizontalAlignment.Center) ListView1.Columns.Add("idVENDOR", 1, HorizontalAlignment.Center) ListView1.Columns.Add("VENDOR", 1, HorizontalAlignment.Center)
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim kriteria As String Dim urut As Integer Dim ketemu As Boolean kriteria = InputBox _
("Masukkan PO yang akan dicari (1 karakter)") If kriteria = "" Then Exit Sub
ketemu = False urut = 0
For i = 2 To 0 Step -1
'If TabData(i).IsFixedSize = kriteria Then MsgBox("data '" & kriteria & _
"' ditemukan setelah dibalik" &Chr(13) & _ "berada pada urutan ke-" & urut + 1 & "", _ vbInformation)
ketemu = True
F_Faktur.TextSJ.Text = Me.TextSJ.Text
F_Faktur.TextVend.Text = Me.TextPengirim.Text F_Faktur.Show()
'End If urut = urut + 1
Next i
If ketemu = False Then
MsgBox("Data " & kriteria & " tidak ditemukan", _ vbCritical)
Else
Exit Sub End If
End Sub
Private Sub ButUbah_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButUbah.Click
ListView1.SelectedItems(0).SubItems(3).Text = Me.Txt_No_Faktur.Text ListView1.SelectedItems(0).SubItems(4).Text= Me.Txt_QTY_Faktur.Text ListView1.SelectedItems(0).SubItems(5).Text= Me.Txt_Harga_Faktur.Text
End Sub
Private Sub ListView1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles ListView1.Click
If ListView1.SelectedItems.Count > 0 Then
End If End Sub
Private Sub ListView1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListView1.SelectedIndexChanged
If ListView1.SelectedItems.Count > 0 Then
Me.Txt_No_Faktur.Text = ListView1.SelectedItems(0).SubItems(0).Text Me.Txt_QTY_Faktur.Text = ListView1.SelectedItems(0).SubItems(0).Text Me.Txt_Harga_Faktur.Text = ListView1.SelectedItems(0).SubItems(0).Text Me.TextPengirim.Text = ListView1.SelectedItems(0).SubItems(5).Text End If
End Sub End Class
Kode Program 6 Kode Program untuk Form Faktur
Inherits System.Windows.Forms.Form Dim indeks As Byte = 0
Private Jml_Data As Byte = 3 Dim kode As String
Dim Jml_Baris As Integer = 0 Dim faktur() As String Dim SJ() As String Dim vendor() As String Dim wkt() As DateTimePicker
Private Sub F_Faktur_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Call koneksi() Call hitung() End Sub
Sub hitung()
da = New Data.OleDb.OleDbDataAdapter("Select * From T_Barang", cn) ds = New DataSet
da.Fill(ds)
Jml_Baris = ds.Tables(0).Rows.Count End Sub
Private Sub ButSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButSave.Click
Try
Call koneksi()
da = New OleDbDataAdapter("Select * From T_SJ where No_SJ like '" & TextSJ.Text & "%'", cn)
Dim sj As New DataTable sj.Clear()
da.Fill(sj)
If sj.Rows.Count = Nothing Then 'simpan sj
Dim StrSimpanSJ As String = "Insert into T_SJ(No_SJ,Tgl_SJ) values (" & _
"'" & Me.TextSJ.Text & "'," & _
"#" &CDate(Me.TextTGLSJ.Text) & "# " & _ ")"
Dim com_simpan As New OleDbCommand com_simpan.Connection = cn
com_simpan.CommandType = CommandType.Text com_simpan.CommandText = StrSimpanSJ com_simpan.ExecuteNonQuery()
MsgBox("Berhasil Menyimpan Surat Jalan")
'simpan faktur
Dim StrSimpan As String = "Insert into T_FAKTUR(No_Faktur, No_SJ,Tgl_Jth_Temp) values (" & _
"'" & Me.TextFakt.Text & "', " & _ "'" & Me.TextSJ.Text & "'," & _
"#" &CDate(Me.DT_Temp.Text) & "# " & _ ")"
Dim com_simpanf As New OleDbCommand com_simpanf.Connection = cn
com_simpanf.CommandType = CommandType.Text com_simpanf.CommandText = StrSimpan com_simpanf.ExecuteNonQuery() MsgBox("Berhasil Menyimpan Faktur")
'simpan detailPO Dim i As Integer Dim nofaktur As String Dim qtyfaktur As String Dim hrgfaktur As String Dim nopo As String Dim idmaterial As String nofaktur = Me.TextFakt.Text
For i = 0 To Me.ListView1.Items.Count - 1 nopo = ListView1.Items.Item(i).SubItems(0).Text
idmaterial = ListView1.Items.Item(i).SubItems(1).Text qtyfaktur = ListView1.Items.Item(i).SubItems(3).Text hrgfaktur = ListView1.Items.Item(i).SubItems(4).Text
"where no_po=" & CLng(nopo) & " and id_material=" & CLng(idmaterial) & " "
Dim com_simpanDF As New OleDbCommand com_simpanDF.Connection = cn
com_simpanDF.CommandType = CommandType.Text com_simpanDF.CommandText = StrSimpanDF com_simpanDF.ExecuteNonQuery()
Next
MsgBox("Berhasil Menyimpan detil faktur")
Else
MsgBox("No Surat Jalan Sudah Ada")
End If
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.Information, "Attention") End Try
Call bersih()
End Sub Sub insert()
TextSJ.Text = "" Me.DT_Temp.Text = "" End Sub
Private Sub ButCancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButCancel.Click
Call bersih() End Sub
Sub bersih()
TextFakt.Text = "" TextSJ.Text = "" TextVend.Text = "" DT_Temp.Text = "" End Sub
Private Sub ListView1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles ListView1.Click
If ListView1.SelectedItems.Count > 0 Then
End If End Sub
Private Sub ListView1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListView1.SelectedIndexChanged
If ListView1.SelectedItems.Count > 0 Then
'MsgBox(ListView1.SelectedItems(0).SubItems(0).Text & "-" & ListView1.SelectedItems(0).SubItems(1).Text)
Me.txt_hrgsatfaktur.Text = ListView1.SelectedItems(0).SubItems(5).Text Me.txt_qtyfaktur.Text = ListView1.SelectedItems(0).SubItems(4).Text
End If 'Close()
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If indeks > Jml_Data - 1 Then MsgBox("List Sudah Penuh")
Else
faktur(indeks) = TextFakt.Text SJ(indeks) = TextSJ.Text vendor(indeks) = TextVend.Text 'wkt(indeks) = DT_Temp.Text
TextFakt.Text = "" indeks = indeks + 1
End If End Sub
Private Sub BtnUbahItemFaktur_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnUbahItemFaktur.Click
ListView1.SelectedItems(0).SubItems(5).Text = Me.txt_hrgsatfaktur.Text ListView1.SelectedItems(0).SubItems(4).Text = Me.txt_qtyfaktur.Text
Kode Program 7 Kode Program untuk Form Alarm
Imports System.Data Imports System.Data.OleDb 'logika alarm
'cek saat ini tgl brp
'jika saat ini lebih dari tgl 25 bulan lalu atau kurang dari sama dengan tgl 10 mk ' ambil dr tabel t_faktur utk tgl_jth_temp yg lebih dari tgl 25 bulan lalu atau kurang dari tgl 10 dan detilpo yg sdh berisi no_faktur
'jika saat ini lebih dari tgl 10 dan kurang dari sama dengan tgl 25 mk
' ambil dr tabel t_faktur utk tgl_jth_temp yg lebih dari tgl 10 dan kurang dari tgl 25 dan detilpo yg sdh berisi no_faktur
'tampilkan data nya di listview!
Public Class F_Alarm
Inherits System.Windows.Forms.Form
Dim TotalTenthDetik, TotalDetik, TentDetik, detik As Integer Dim sekarang As Date
Private Sub F_Alarm_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Call koneksi() Call nampil() Call listview() Timer2.Enabled = True Timer1.Enabled = True End Sub
' ==============Setting Alarm===========================
Private Sub Timer2_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer2.Tick
Label1.Text = Format(Now, "dddd, dd-MMMM-yyyy") End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
'TotalTenthDetik = TotalTenthDetik + 1 'TentDetik = TotalTenthDetik Mod 10 'TotalDetik = Int(TotalTenthDetik / 10) 'detik = TotalDetik Mod 60
'If Len(detik) = 1 Then ' detik = "0" & detik 'End If
If Date.Today > sekarang Then nampil()
End If End Sub
Private Sub ButStart_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButStart.Click
'insalansi total sepersuluh detik TotalTenthDetik = -1
Timer1.Enabled = True
'If ListView1.SelectedItems("Tgl_Jth_Temp") > Label1.Text Then 'End If
'Timer1.Enabled = True
End Sub
Private Sub ButStop_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButStop.Click
Timer1.Enabled = Not Timer1.Enabled
End Sub Sub nampil()
Dim BlnSkrg As Integer = Month(Now()) Dim thnskrg As Integer = Year(Now())
Dim tgl10Skrg As Date = CDate(Format("dd MMMM yyyy", "10 " & MonthName(BlnSkrg) & " " & thnskrg))
Dim tgl25Skrg As Date = CDate(Format("dd MMMM yyyy", "25 " & MonthName(BlnSkrg) & " " & thnskrg))
Dim Skrg As Date = Date.Today Dim HrSkrg As Integer = Skrg.Day Dim strFaktur As String
'jika saat ini lebih dari tgl 25 bulan lalu atau kurang dari sama dengan tgl 10 mk
If Date.Today > tgl25Lalu And Date.Today <= tgl10Skrg Then strFaktur = ("SELECT T_Faktur.No_Faktur, T_Faktur.Tgl_Jth_Temp " & _ " FROM T_Faktur, T_DetailPO " & _
"WHERE T_Faktur.No_Faktur=t_detailpo.no_faktur " & _
" AND T_Faktur.tgl_jth_temp between #" & tgl25Lalu & "# and #" & tgl10Skrg & "# group by T_Faktur.No_Faktur, T_Faktur.Tgl_Jth_Temp")
ElseIf Date.Today > tgl10Skrg And Date.Today <= tgl25Skrg Then 'jika saat ini lebih dari tgl 10 dan kurang dari sama dengan tgl 25 mk
strFaktur = ("SELECT T_Faktur.No_Faktur, T_Faktur.Tgl_Jth_Temp " & _ " FROM T_Faktur, T_DetailPO " & _
"WHERE T_Faktur.No_Faktur=t_detailpo.no_faktur " & _
" AND T_Faktur.tgl_jth_temp between #" & tgl10Skrg & "# AND #" & tgl25Skrg & "# group by T_Faktur.No_Faktur, T_Faktur.Tgl_Jth_Temp")
End If
da = New Data.OleDb.OleDbDataAdapter(strFaktur, cn) dt = New DataTable
da.Fill(dt)
For i As Integer = 0 To dt.Rows.Count - 1 With ListView1
.Items.Add(dt.Rows(i)("No_Faktur")) With .Items(.Items.Count - 1).SubItems
.Add(dt.Rows(i)("Tgl_Jth_Temp")) End With
End With Next
End Sub
Sub listview()
Me.ListView1.View = View.Details Me.ListView1.GridLines = True Me.ListView1.FullRowSelect = True
ListView1.Columns.Add("No Faktur", 100, HorizontalAlignment.Center) ListView1.Columns.Add("Tgl Jatuh Tempo", 100, HorizontalAlignment.Center)
End Sub
Private Sub Label2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label2.Click
'label2 = Detik & ":" & TentDetik&"" End Sub
End Class
Kode Program 8 Kode Program untuk Fom Supplier
Imports System.DataImports System.Data.OleDb Public Class F_Pemasok
Inherits System.Windows.Forms.Form Dim Jml_Baris As Integer = 0 Dim brs As Integer
Private Sub F_Pemasok_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Call koneksi() Call nampil() Call hitung()
ButSave.Enabled = False TextID.MaxLength = 7 TextID.Text = "" End Sub
Sub nampil()
da = New Data.OleDb.OleDbDataAdapter("Select * From T_Supplier order by Nama_Vendor", cn)
ds = New DataSet da.Fill(ds)
Dim sup As New DataTable sup.Clear()
da.Fill(sup)
TextID.Text = ds.Tables(0).Rows(brs).Item(0) TextNama.Text = ds.Tables(0).Rows(brs).Item(1) TextAlamat.Text = ds.Tables(0).Rows(brs).Item(2) TextKota.Text = ds.Tables(0).Rows(brs).Item(3) TextPos.Text = ds.Tables(0).Rows(brs).Item(4) TextTlp.Text = ds.Tables(0).Rows(brs).Item(5) TextFax.Text = ds.Tables(0).Rows(brs).Item(6) TextMail.Text = ds.Tables(0).Rows(brs).Item(7) Catch ex As Exception
End Try End Sub Sub hitung()
da = New Data.OleDb.OleDbDataAdapter("Select * From T_Supplier", cn) ds = New DataSet
da.Fill(ds)
Jml_Baris = ds.Tables(0).Rows.Count End Sub
Sub tampilteks()
TextID.Text = ds.Tables(0).Rows(brs).Item(0) TextNama.Text = ds.Tables(0).Rows(brs).Item(1) TextAlamat.Text = ds.Tables(0).Rows(brs).Item(2) TextKota.Text = ds.Tables(0).Rows(brs).Item(3) TextPos.Text = ds.Tables(0).Rows(brs).Item(4) TextTlp.Text = ds.Tables(0).Rows(brs).Item(5) TextFax.Text = ds.Tables(0).Rows(brs).Item(6) TextMail.Text = ds.Tables(0).Rows(brs).Item(7) End Sub
Sub hidup()
TextID.ReadOnly = False TextAlamat.ReadOnly = False TextKota.ReadOnly = False TextPos.ReadOnly = False TextTlp.ReadOnly = False TextFax.ReadOnly = False TextMail.ReadOnly = False TextCari.ReadOnly = False
End Sub Sub mati()
TextID.ReadOnly = True TextAlamat.ReadOnly = True TextKota.ReadOnly = True TextPos.ReadOnly = True TextTlp.ReadOnly = True TextCari.ReadOnly = True TextMail.ReadOnly = True
End Sub
Private Sub ButCari_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButCari.Click
If Me.TextCari.Text = "" Then MsgBox("Isi Kata Kunci Pencarian") Me.TextCari.Focus()
Exit Sub End If Try
If RDB_ID.Checked = True Then
da = New OleDbDataAdapter("Select * From T_Supplier where ID_Vendor like '" & TextCari.Text & "%'", cn)
Else
da = New OleDbDataAdapter("Select * From T_Supplier where Nama_Vendor like '" & TextCari.Text & "%'", cn)
End If dt = New DataTable da.Fill(dt)
If dt.Rows.Count = Nothing Then
MsgBox("Kata Kunci yang Anda Cari Tidak Ditemukan", MsgBoxStyle.Information, "Attention")
Me.TextCari.Clear() Me.TextCari.Focus()
Exit Sub 'Else
' TextID.Text = ds.Tables(0).Rows(brs).Item(0)
'TextPos.Text = ds.Tables(0).Rows(brs).Item(4) 'TextTlp.Text = ds.Tables(0).Rows(brs).Item(5) 'TextFax.Text = ds.Tables(0).Rows(brs).Item(6) 'TextMail.Text = ds.Tables(0).Rows(brs).Item(7) End If
DGVPemasok.DataSource = dt ds = New DataSet
da.Fill(ds)
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.Information, "Attention") End Try
End Sub
Private Sub ButIns_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButIns.Click
Call bersih() Call koneksi() hidup()
ButEdt.Enabled = False ButDelt.Enabled = False ButSave.Enabled = True End Sub
Sub bersih()
TextID.Text = "" TextNama.Text = "" TextAlamat.Text = "" TextKota.Text = "" TextPos.Text = "" TextTlp.Text = "" TextFax.Text = "" TextMail.Text = "" TextCari.Text = ""
End Sub
Private Sub ButEdt_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButEdt.Click
ButEdt.Visible = True GroupBox1.Visible = True Me.ButEdt.Text = "OK"
Me.ButEdt.ForeColor = Color.CornflowerBlue If Me.TextID.Text = "" Then
MsgBox("Kode Vendor Belum Terisi") Me.TextID.Focus()
Exit Sub End If
Dim ComUpdate As New OleDbCommand Dim StrUpdate As String
StrUpdate = "Update T_Supplier Set" & _ "Nama_Vendor= '" & Me.TextNama.Text & "'," & _ "Alamat = '" & Me.TextAlamat.Text & "'," & _ "Kota = '" & Me.TextKota.Text & "'," & _ "Kode_Pos = '" & Me.TextPos.Text & "'," & _ "No_Tlp = '" & Me.TextTlp.Text & "'," & _ "No_Fax = '" & Me.TextFax.Text & "'," & _ "Email = '" & Me.TextMail.Text & "'," & _ "Where ID_Vendor= '" & Me.TextID.Text & "'"
ComUpdate.Connection = cn
da.SelectCommand.CommandText = StrUpdate da.SelectCommand.ExecuteNonQuery()
dt.Clear() da.Fill(ds)
Call hitung() Call bersih()
MsgBox("Data Berhasil Diupdate") Me.ButEdt.Text = "Edit"
Me.ButEdt.ForeColor = Color.BlueViolet Me.TextCari.Focus()
GroupBox1.Visible = False
End Sub
Sub ambildata()
da = New Data.OleDb.OleDbDataAdapter("Select * From T_Supplier order by Nama_Vendor", cn)
Jml_Baris = ds.Tables(0).Rows.Count DGVPemasok.DataSource = ds
End Sub
Private Sub ButSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButSave.Click
Try
da = New OleDbDataAdapter("Select * from T_Supplier where ID_Vendor like '" & TextID.Text & "%'", cn)
Dim vendor As New DataTable vendor.Clear()
da.Fill(vendor)
If vendor.Rows.Count = Nothing Then
Dim StrSimpan As String = "Insert into T_Supplier values(" & _ "'" & Me.TextID.Text & "', " & _
"'" & Me.TextNama.Text & "', " & _ "'" & Me.TextAlamat.Text & "', " & _ "'" & Me.TextKota.Text & "', " & _ "'" & Me.TextPos.Text & "', " & _ "'" & Me.TextTlp.Text & "'," & _ "'" & Me.TextFax.Text & "'," & _ "'" & Me.TextMail.Text & "') " Dim com_simpan As New OleDbCommand com_simpan.Connection = cn
com_simpan.CommandType = CommandType.Text com_simpan.CommandText = StrSimpan com_simpan.ExecuteNonQuery() MsgBox("Data Berhasil di simpan")
Else
MsgBox("ID Vendor Sudah Ada") End If
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.Information, "Attention") 'Call ambildata()
Call hitung() Call bersih()
GroupBox1.Visible = False End Try
mati()
ButSave.Enabled = False ButEdt.Enabled = True ButDelt.Enabled = True
End Sub
Private Sub ButClose_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButClose.Click
Me.Close() End Sub
Private Sub ButDelt_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButDelt.Click
If TextCari.Text = "" Then MsgBox("Kode Vendor Belum Terisi") TextCari.Focus()
Exit Sub End If Try
If MessageBox.Show("Yakin akan dihapus?", "", MessageBoxButtons.YesNo) = Windows.Forms.DialogResult.Yes Then
Dim ComDelt As New OleDbCommand ComDelt.Connection = cn
ComDelt.CommandText = "Delete from T_Supplier where ID_Vendor =" & _
"'" & TextID.Text & "'" ComDelt.ExecuteNonQuery()
If Me.DGVPemasok.Visible = False Then Else
Me.DGVPemasok.Visible = True End If
Me.TextID.Focus()
Call bersih() Call hitung() MsgBox("Data Berhasil Dihapus")
End If
MsgBox(ex.ToString()) End Try End Sub
Private Sub DGVPemasok_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles DGVPemasok.Click
ButIns.Enabled = False ButSave.Enabled = False ButEdt.Enabled = True ButDelt.Enabled = True Try
brs = DGVPemasok.CurrentCell.RowIndex tampilteks()
Catch ex As Exception MsgBox(ex.ToString())
End Try End Sub
Private Sub ButCancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButCancel.Click
Call bersih() End Sub
End Class
Kode Program 9 Kode Program untuk Form Barang
Imports System.DataImports System.Data.OleDb Public Class F_Barang
Dim baris As Integer Dim brs As Integer = 0 Dim StrCari As String
Private Sub F_Barang_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Call koneksi() Call tampil() Call hitung()
ButSave.Enabled = False TxtID.MaxLength = 8 TxtID.Text = "" TxtNama.Text = "" End Sub
Sub tampil() 'Jml_Baris()
'TxtID.Text = ds.Tables(0).Rows(brs).Item(0) 'TxtNama.Text = ds.Tables(0).Rows(brs).Item(1)
da = New Data.OleDb.OleDbDataAdapter("Select * From T_Barang order by ID_Material", cn)
ds = New DataSet da.Fill(ds)
Dim sup As New DataTable sup.Clear()
da.Fill(sup)
DGVBrg.DataSource = sup Try
TxtID.Text = ds.Tables(0).Rows(brs).Item(0) TxtNama.Text = ds.Tables(0).Rows(brs).Item(1)
DGVBrg.AlternatingRowsDefaultCellStyle.BackColor = Color.AliceBlue Catch ex As Exception
End Try
End Sub Sub hitung()
da = New Data.OleDb.OleDbDataAdapter("Select * From T_Barang", cn) ds = New DataSet
da.Fill(ds)
brs = ds.Tables(0).Rows.Count End Sub
Sub hidup()
TxtID.ReadOnly = False TxtNama.ReadOnly = False End Sub
Sub mati()
End Sub Sub bersih()
TxtID.Text = "" TxtNama.Text = "" End Sub
Private Sub ButInsert_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButInsert.Click
ButSave.Enabled = True ButSearch.Enabled = False Call bersih()
'Call koneksi() End Sub
Private Sub ButSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButSave.Click
If TxtID.Text = "" Or TxtNama.Text = "" Then MsgBox("Data Belum Lengkap")
Exit Sub End If Try
da = New OleDbDataAdapter("Select * from T_Barang where ID_Material like '" & TxtID.Text & "%'", cn)
Dim barang As New DataTable barang.Clear()
da.Fill(barang)
If barang.Rows.Count = Nothing Then
Dim StrSimpan As String = "Insert into T_Barang values(" & _ "'" & Me.TxtID.Text & "', " & _
"'" & Me.TxtNama.Text & "')" Dim com_simpan As New OleDbCommand com_simpan.Connection = cn
com_simpan.CommandType = CommandType.Text com_simpan.CommandText = StrSimpan com_simpan.ExecuteNonQuery() MsgBox("Data Berhasil di Simpan")
Else
MsgBox("ID Material Sudah Ada")
End If
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.Information, "Attention") 'Call ambildata()
Call hitung() Call bersih()
GroupBox1.Visible = False End Try
mati()
ButSave.Enabled = False ButInsert.Enabled = True
End Sub
Sub ambildata()
da = New Data.OleDb.OleDbDataAdapter("Select * from T_Barang order by ID_Material", cn)
ds = New DataSet da.Fill(ds)
brs = ds.Tables(0).Rows.Count DGVBrg.DataSource = ds End Sub
Private Sub ButSearch_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButSearch.Click
If Me.TextCari.Text = "" Then MsgBox("Isi Kata Kunci Pencarian") Me.TextCari.Focus()
Exit Sub End If Try
If RDB_ID.Checked = True Then
da = New OleDbDataAdapter("Select * From T_Barang where ID_Material like '" & TextCari.Text & "%'", cn)
Else
da = New OleDbDataAdapter("Select * From T_Barang where Nama_Material like '" & TextCari.Text & "%'", cn)
dt = New DataTable da.Fill(dt)
If dt.Rows.Count = Nothing Then
MsgBox("Kata Kunci yang Anda Cari Tidak Ditemukan", MsgBoxStyle.Information, "Attention")
Me.TextCari.Clear() Me.TextCari.Focus()
Exit Sub
End If
DGVBrg.DataSource = dt ds = New DataSet
da.Fill(ds)
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.Information, "Attention") End Try
End Sub
Private Sub ButClose_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButClose.Click
Me.Close() End Sub
Private Sub ButCancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButCancel.Click
Call bersih()
ButSearch.Enabled = True ButSave.Enabled = False End Sub
Private Sub TxtID_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TxtID.TextChanged