• Tidak ada hasil yang ditemukan

analisis dan perancangan sistem informasi penjualan, pembelian, dan persediaan grosir pada cv indo stocklots

N/A
N/A
Protected

Academic year: 2021

Membagikan "analisis dan perancangan sistem informasi penjualan, pembelian, dan persediaan grosir pada cv indo stocklots"

Copied!
316
0
0

Teks penuh

(1)Hak cipta dan penggunaan kembali: Lisensi ini mengizinkan setiap orang untuk menggubah, memperbaiki, dan membuat ciptaan turunan bukan untuk kepentingan komersial, selama anda mencantumkan nama penulis dan melisensikan ciptaan turunan dengan syarat yang serupa dengan ciptaan asli. Copyright and reuse: This license lets you remix, tweak, and build upon work non-commercially, as long as you credit the origin creator and license it on your new creations under the identical terms.. Team project ©2017 Dony Pratidana S. Hum | Bima Agus Setyawan S. IIP.

(2) LAMPIRAN 1. Coding Program IndoStockLots 2. Petunjuk Instalasi Program IndoStockLots. 97 Analisis dan Perancangan ..., Kristian, FTI UMN, 2013.

(3) LAMPIRAN CODING PROGRAM 1. MODULE.VB Imports MySql.Data.MySqlClient Imports System.IO Imports System.Math Module Module1 Public ConnectionString As String Public myConn As MySqlConnection Public GID As String Public Awal As String = "123" Public Akhir As String = "ISL" 'Public instansiID As String Public Synch As String Sub Set_Connection() Dim F As New FileStream(System.IO.Directory.GetCurrentDirectory & "\connect.osn", FileMode.Open, FileAccess.Read) Dim sr As New StreamReader(F) Try ConnectionString = "User Id=root;password=;" ConnectionString &= sr.ReadLine myConn = New MySqlConnection(ConnectionString) Catch ex As Exception WarningMsgBox(ex.Message) Application.Exit() End Try End Sub Public Sub Flat_ComboBox(ByVal Control As Control) Dim flatComboBoxList As ArrayList = New ArrayList Dim flatComboBox As vbAccelerator.Components.Controls.FlatControl Dim ctl As Control For Each ctl In Control.Controls If (ctl.GetType().ToString = "System.Windows.Forms.ComboBox") Then flatComboBox = New vbAccelerator.Components.Controls.FlatControl flatComboBox.Attach(ctl) flatComboBoxList.Add(flatComboBox) End If Next End Sub Public Function EncryptPassword(ByVal conn As ADODB.Connection, ByVal pass As String) Dim query As String = "" Dim rsEncrypt As New ADODB.Recordset. 1 Analisis dan Perancangan ..., Kristian, FTI UMN, 2013.

(4) query = "SELECT SHA1('" & Awal & IP(pass.Trim) & Akhir & "')" Call SQLCommand(conn, rsEncrypt, query) If Not rsEncrypt.EOF Then Return rsEncrypt.Fields(0).Value End If Return "" End Function Sub Highlight_Text(ByVal AA As Object) AA.SelectionStart = 0 AA.SelectionLength() = Len(AA.Text) AA.Focus() End Sub Sub ShowMsgBox(ByVal msg As String) Dim frmWarning As FormWarning = New FormWarning frmWarning.LabelJudul.Text = "Harap diperhatikan!" frmWarning.TextKeterangan.Text = msg frmWarning.ButtonBatal.Visible = False frmWarning.ShowDialog() End Sub Sub WarningMsgBox(ByVal msg As String) Dim frmWarning As FormWarning = New FormWarning frmWarning.LabelJudul.BackColor = Color.Maroon frmWarning.LabelJudul.ForeColor = Color.White frmWarning.Label1.BackColor = Color.Gainsboro frmWarning.LabelJudul.Text = "Harap diperhatikan!" frmWarning.TextKeterangan.Text = msg frmWarning.ButtonBatal.Visible = False frmWarning.ShowDialog() End Sub Function AskMsgBox(ByVal msg As String) As Boolean Dim frmWarning As FormWarning = New FormWarning frmWarning.LabelJudul.BackColor = Color.Gold frmWarning.LabelJudul.ForeColor = Color.Black frmWarning.Label1.BackColor = Color.Gainsboro frmWarning.LabelJudul.Text = "Harap diperhatikan!" frmWarning.TextKeterangan.Text = msg frmWarning.ShowDialog() AskMsgBox = frmWarning.Answer End Function. 2 Analisis dan Perancangan ..., Kristian, FTI UMN, 2013.

(5) Sub SQLCommand(ByVal conn As ADODB.Connection, ByRef rs As ADODB.Recordset, ByVal query As String) rs = New ADODB.Recordset rs.CursorLocation = ADODB.CursorLocationEnum.adUseClient rs.CursorType = ADODB.CursorTypeEnum.adOpenForwardOnly rs.LockType = ADODB.LockTypeEnum.adLockReadOnly rs.Open(query, conn) End Sub Function TrimText(ByVal text As String) As String text = text.Replace(" ", "") text = text.Replace(".", "") text = text.Replace("'", "") text = text.Replace("_", "") text = text.Replace("-", "") text = text.Replace("/", "") text = text.Replace("\", "") text = text.Replace(",", "") text = text.Replace(";", "") text = text.Replace(Chr(34), "") TrimText = text End Function Function IP(ByVal a As Object) As Object If IsDBNull(a) Then IP = "" ElseIf a = "" Then IP = "" Else a = Trim(Replace(a, "'", "`")) a = Trim(Replace(a, "\", "")) IP = a End If End Function Function IA(ByVal a As Object) As Object If IsDBNull(a) Then IA = 0 ElseIf a.ToString = "" Then IA = 0 Else Try IA = CDbl(a) Catch ex As Exception WarningMsgBox("Ada angka yang salah [" & a & "]") IA = "" End Try End If End Function Sub Input_Time_Combo(ByVal BulanCombo As ComboBox, ByVal TahunCombo As ComboBox). 3 Analisis dan Perancangan ..., Kristian, FTI UMN, 2013.

(6) ' --- Add year --Dim yearNow As String Dim counter As Integer yearNow = Now.Year counter = yearNow - 5 While (counter <> yearNow) counter = counter + 1 TahunCombo.Items.Add(CStr(counter)) End While counter = yearNow While (counter <> yearNow + 1) counter = counter + 1 TahunCombo.Items.Add(CStr(counter)) End While TahunCombo.Text = yearNow ' --- Add month --BulanCombo.Items.Add("Januari") BulanCombo.Items.Add("Februari") BulanCombo.Items.Add("Maret") BulanCombo.Items.Add("April") BulanCombo.Items.Add("Mei") BulanCombo.Items.Add("Juni") BulanCombo.Items.Add("Juli") BulanCombo.Items.Add("Agustus") BulanCombo.Items.Add("September") BulanCombo.Items.Add("Oktober") BulanCombo.Items.Add("November") BulanCombo.Items.Add("Desember") BulanCombo.Text = Month_String2(Now.Month). End Sub Function Hari_String(ByVal i As Integer) As String Select Case i Case 1 Hari_String = "Senin" Case 2 Hari_String = "Selasa" Case 3 Hari_String = "Rabu" Case 4 Hari_String = "Kamis" Case 5 Hari_String = "Jumat". 4 Analisis dan Perancangan ..., Kristian, FTI UMN, 2013.

(7) Case 6 Hari_String = "Sabtu" Case 0 Hari_String = "Minggu" Case Else Hari_String = "" End Select End Function Function Month_String2(ByVal i As Integer) As String Select Case i Case 1 Month_String2 = "Januari" Case 2 Month_String2 = "Februari" Case 3 Month_String2 = "Maret" Case 4 Month_String2 = "April" Case 5 Month_String2 = "Mei" Case 6 Month_String2 = "Juni" Case 7 Month_String2 = "Juli" Case 8 Month_String2 = "Agustus" Case 9 Month_String2 = "September" Case 10 Month_String2 = "Oktober" Case 11 Month_String2 = "November" Case 12 Month_String2 = "Desember" Case Else Month_String2 = "" End Select End Function Function Month_String3(ByVal i As String) As Integer Select Case i Case "Januari" Month_String3 = 1 Case "Februari" Month_String3 = 2 Case "Maret" Month_String3 = 3 Case "April" Month_String3 = 4 Case "Mei" Month_String3 = 5. 5 Analisis dan Perancangan ..., Kristian, FTI UMN, 2013.

(8) Case "Juni" Month_String3 = 6 Case "Juli" Month_String3 = 7 Case "Agustus" Month_String3 = 8 Case "September" Month_String3 = 9 Case "Oktober" Month_String3 = 10 Case "November" Month_String3 = 11 Case "Desember" Month_String3 = 12 End Select End Function Function Month_String4(ByVal i As Integer) As String Select Case i Case 1 Month_String4 = "Januari" Case 2 Month_String4 = "Februari" Case 3 Month_String4 = "Maret" Case 4 Month_String4 = "April" Case 5 Month_String4 = "Mei" Case 6 Month_String4 = "Juni" Case 7 Month_String4 = "Juli" Case 8 Month_String4 = "Agustus" Case 9 Month_String4 = "September" Case 10 Month_String4 = "Oktober" Case 11 Month_String4 = "November" Case 12 Month_String4 = "Desember" Case Else Month_String4 = "" End Select End Function Function Generate_Table(ByVal ss As String, ByRef counter As Integer) As String ss += CStr(counter) counter += 1 Generate_Table = ss End Function. 6 Analisis dan Perancangan ..., Kristian, FTI UMN, 2013.

(9) Sub Set_Color_Grid(ByRef dgts As DataGridTableStyle) dgts.AlternatingBackColor = Color.WhiteSmoke dgts.BackColor = Color.Gainsboro dgts.ForeColor = Color.Black dgts.GridLineColor = Color.Silver dgts.HeaderForeColor = Color.White dgts.HeaderBackColor = Color.Black dgts.LinkColor = Color.DarkSlateBlue dgts.SelectionBackColor = Color.RoyalBlue dgts.SelectionForeColor = Color.White End Sub Sub Insert_Log(ByVal conn As ADODB.Connection, ByVal activity As String, ByVal User As String, ByVal modul As String, ByVal ID As String) Dim tanggal As String = Now.Year & "-" & Now.Month & "-" & Now.Day Dim jam As String = Now.Hour & ":" & Now.Minute & ":" & Now.Second Dim query As String query = "INSERT INTO LOG (" & AN(conn, "LOG") & ") VALUES ('" & IP(activity) & "','" & User & "','" & _ tanggal & "','" & jam & "','" & modul & "','" & ID & "')" Try 'Call Synchron(conn, query) conn.Execute(query) Catch err As Exception 'Do nothing End Try End Sub Function Format_Date(ByVal obj As Object) As String If IsDate(obj) Then Dim tgl As Date tgl = CDate(obj) Dim bln As String = "" If tgl.Month < 10 Then bln = "0" bln &= CStr(tgl.Month) Dim hari As String = "" If tgl.Day < 10 Then hari = "0" hari &= CStr(tgl.Day) Format_Date = tgl.Year & "-" & bln & "-" & hari Else Format_Date = "" End If End Function Function Angka(ByVal X As String) As String If IsNumeric(X) And X <> "" Then Dim i As Double = X.IndexOf(".") If i < 0 Then Angka = FormatNumber(X, 0, , , vbTrue). 7 Analisis dan Perancangan ..., Kristian, FTI UMN, 2013.

(10) Else Angka = FormatNumber(X.Substring(0, i), 0, , , vbTrue) Angka &= X.Substring(i) End If Else Angka = "" End If End Function Function Angka_Huruf(ByVal angka As Double) As String Dim s As String = "" Dim dec As String = "" Dim t As String = "" Dim u As String = "" Dim i As Integer = 0 Dim m As Integer = 0 Dim output As String = "" Dim result As String = "" If Not IsDBNull(angka) Then u = CStr(angka) ' --- Cari Decimalnya --For i = 1 To Len(u) If Mid(u, i, 1) = "." Then Exit For t = t & Mid(u, i, 1) Next i s = CStr(IP(t)) If i <= Len(u) Then dec = Right(u, Len(u) - i) End If ' --- Display 1000 Separator --If Len(s) > 3 Then m = Len(s) \ 3 For i = 1 To m + 1 t = Right(s, 3) If t <> "" Then If t <> "000" Then Select Case i Case 2 result = "Ribu " & result Case 3 result = "Juta " & result Case 4 result = "Milyar " & result End Select result = Angka_Ratusan(t) & result End If. 8 Analisis dan Perancangan ..., Kristian, FTI UMN, 2013.

(11) If Len(s) > 3 Then s = Left(s, Len(s) - 3) output = "." & t & output Else output = s & output s = "" End If End If Next i Else output = s End If If dec <> "" Then output = output & "," & dec End If If result <> "" Then Angka_Huruf = result.ToUpper Else Angka_Huruf = output.ToUpper End If Else Angka_Huruf = "" End If End Function Function IT(ByVal a As Object) As Object If IsDBNull(a) Or a = "" Then IT = "NULL" Else IT = "'" & a & "'" End If End Function Function IST(ByVal a As Object) As Object If IsDBNull(a) Or a = "" Then IST = "IS NULL" Else IST = "= '" & a & "'" End If End Function Function Angka_Ratusan(ByVal txt As String) As String Dim len As Integer = txt.Length Dim str As String = "" Dim output As String = "" Dim satuan As String = "" While len < 3 txt = "0" & txt. 9 Analisis dan Perancangan ..., Kristian, FTI UMN, 2013.

(12) len = txt.Length End While While (len > 0) str = txt.Substring(len - 1, 1) If str <> "0" Then If len = 2 Then If str <> "1" Then satuan = "Puluh " Else 'do nothing End If ElseIf len = 1 Then satuan = "Ratus " Else satuan = "" End If If len = 2 And str = "1" Then If txt.Substring(2, 1) = "0" Then output = "Sepuluh " Else output = output & "Belas " If output.ToUpper = "SATU BELAS " Then output = "Sebelas " End If End If ElseIf len = 3 And str = "1" Then output = "Satu " & output Else output = Bilangan_Angka(str) & satuan & output End If End If len -= 1 End While Angka_Ratusan = output End Function Function Bilangan_Angka(ByVal txt As String) As String Dim output As String = "" If txt = "1" Then output = "Se" ElseIf txt = "2" Then output = "Dua " ElseIf txt = "3" Then output = "Tiga " ElseIf txt = "4" Then output = "Empat " ElseIf txt = "5" Then output = "Lima ". 10 Analisis dan Perancangan ..., Kristian, FTI UMN, 2013.

(13) ElseIf txt = "6" Then output = "Enam " ElseIf txt = "7" Then output = "Tujuh " ElseIf txt = "8" Then output = "Delapan " ElseIf txt = "9" Then output = "Sembilan " ElseIf txt = "0" Then output = "" End If Bilangan_Angka = output End Function Function AN(ByVal conn As ADODB.Connection, ByVal db As String) As String Dim result As String = "" Dim query As String = "" Dim rs1 As New ADODB.Recordset query = "SHOW COLUMNS FROM " & db & " " Call SQLCommand(conn, rs1, query) rs1.Move(1) While Not rs1.EOF If result <> "" Then result &= "," End If result &= rs1.Fields(0).Value rs1.Move(1) End While Return result End Function Function Cari_ID(ByVal conn As ADODB.Connection, ByVal db As String, ByVal field As String, ByVal nama As String) Dim query As String = "" Dim rs1 As New ADODB.Recordset query = "SELECT " & db & "_ID FROM " & db & " WHERE " & field & " = '" & nama & "' " Call SQLCommand(conn, rs1, query) If Not rs1.EOF Then Return rs1.Fields(0).Value End If Return "" End Function Function Cari_Nama(ByVal conn As ADODB.Connection, ByVal db As String, ByVal field As String, ByVal id As String). 11 Analisis dan Perancangan ..., Kristian, FTI UMN, 2013.

(14) Dim query As String = "" Dim rsX As New ADODB.Recordset query = "SELECT " & field & " FROM " & db & " WHERE " & db & "_ID = '" & id & "' " Call SQLCommand(conn, rsX, query) If Not rsX.EOF Then Return rsX.Fields(0).Value End If Return "" End Function Public Function Generate_ID(ByVal conn As ADODB.Connection, ByVal db As String) As String ' --- ID : 001, 002 ... --Dim query As String Dim result As String = "" Dim filter As String = "" Dim rs As New ADODB.Recordset query = "SELECT HIGH_PRIORITY " & db & "_ID FROM " & db & " " & _ "WHERE " & db & "_ID LIKE '" & GID & "%' " & _ "AND SUBSTRING(" & db & "_ID,1) REGEXP '^[0-9]+$' " & _ "ORDER BY CAST(SUBSTRING(" & db & "_ID,1) AS DECIMAL) DESC" Call SQLCommand(conn, rs, query) If rs.EOF Then result = filter & "001" Else Dim value As String = IP(rs.Fields(0).Value).ToString.Substring(0) If Not IsNumeric(value) Then result = filter & "001" Else Dim nomor As Double = 0 If IsNumeric(value) Then nomor = CDbl(value) End If nomor += 1 Dim serial As String = CStr(nomor) While (Len(serial) < 3) serial = "0" + serial End While result = filter & serial End If End If Generate_ID = GID & result End Function. 12 Analisis dan Perancangan ..., Kristian, FTI UMN, 2013.

(15) Public Function Generate_Konsumen_ID(ByVal conn As ADODB.Connection, ByVal Nm As String) As String ' --- Konsumen_ID : CUS.001, CUS.002 ... --Dim query As String Dim result As String = "" Dim filter As String = Nm.Substring(0, 3) & "." Dim rs As New ADODB.Recordset query = "SELECT HIGH_PRIORITY CUSTOMER_ID FROM Customer " & _ "WHERE CUSTOMER_ID LIKE '" & filter & "%' " & _ "ORDER BY CAST(SUBSTRING(CUSTOMER_ID,5) AS DECIMAL) DESC " Call SQLCommand(conn, rs, query) If rs.EOF Then result = filter & "001" Else Dim value As String = IP(rs.Fields(0).Value).ToString.Substring(5) If Not IsNumeric(value) Then result = filter & "001" Else Dim nomor As Double = CDbl(value) nomor += 1 Dim serial As String = CStr(nomor) While (Len(serial) < 3) serial = "0" + serial End While result = filter & serial End If End If Generate_Konsumen_ID = result End Function Public Function Generate_Pegawai_ID(ByVal conn As ADODB.Connection, ByVal Nm As String) As String ' --- Pegawai_ID : KAR.001, KAR.002 ... --Dim query As String Dim result As String = "" Dim filter As String = Nm.Substring(0, 3) & "." Dim rs As New ADODB.Recordset query = "SELECT HIGH_PRIORITY Pegawai_ID FROM Pegawai " & _ "WHERE PEGAWAI_ID LIKE '" & filter & "%' " & _ "ORDER BY CAST(SUBSTRING(Pegawai_ID,5) AS DECIMAL) DESC " Call SQLCommand(conn, rs, query) If rs.EOF Then result = filter & "001" Else Dim value As String = IP(rs.Fields(0).Value).ToString.Substring(5). 13 Analisis dan Perancangan ..., Kristian, FTI UMN, 2013.

(16) If Not IsNumeric(value) Then result = filter & "001" Else Dim nomor As Double = CDbl(value) nomor += 1 Dim serial As String = CStr(nomor) While (Len(serial) < 3) serial = "0" + serial End While result = filter & serial End If End If result = GID & result Generate_Pegawai_ID = result End Function Public Function Generate_Supplier_ID(ByVal conn As ADODB.Connection, ByVal Nm As String) As String ' --- Supplier_ID : SUP.001, SUP.002 ... --Dim query As String Dim result As String = "" Dim filter As String = Nm.Substring(0, 3) & "." Dim rs As New ADODB.Recordset query = "SELECT HIGH_PRIORITY SUPPLIER_ID FROM Supplier " & _ "WHERE SUPPLIER_ID LIKE '" & filter & "%' " & _ "ORDER BY CAST(SUBSTRING(SUPPLIER_ID,5) AS DECIMAL) DESC " Call SQLCommand(conn, rs, query) If rs.EOF Then result = filter & "001" Else Dim value As String = IP(rs.Fields(0).Value).ToString.Substring(5) If Not IsNumeric(value) Then result = filter & "001" Else Dim nomor As Double = CDbl(value) nomor += 1 Dim serial As String = CStr(nomor) While (Len(serial) < 3) serial = "0" + serial End While result = filter & serial End If End If Generate_Supplier_ID = result. 14 Analisis dan Perancangan ..., Kristian, FTI UMN, 2013.

(17) End Function Public Function Generate_Barang_ID(ByVal conn As ADODB.Connection, ByVal Txt As String) As String ' --- Barang_ID : ABC.001, ABD.002 ... --Dim query As String Dim result As String = "" Dim filter As String = Txt.Substring(0, 3) & "." Dim rs As New ADODB.Recordset query = "SELECT HIGH_PRIORITY BARANG_ID FROM BARANG " & _ "WHERE BARANG_ID LIKE '" & filter & "%' " & _ "ORDER BY CAST(SUBSTRING(BARANG_ID,5) AS DECIMAL) DESC " Call SQLCommand(conn, rs, query) If rs.EOF Then result = filter & "001" Else Dim value As String = IP(rs.Fields(0).Value).ToString.Substring(5) If Not IsNumeric(value) Then result = filter & "001" Else Dim nomor As Double = CDbl(value) nomor += 1 Dim serial As String = CStr(nomor) While (Len(serial) < 3) serial = "0" + serial End While result = filter & serial End If End If Generate_Barang_ID = result End Function Sub Format_Number(ByRef xx As TextBox) If xx.Text <> "" And IsNumeric(xx.Text) Then Dim i As Double = xx.Text.IndexOf(".") If i < 0 Then xx.Text = FormatNumber(xx.Text, 0, , , vbTrue) xx.SelectionStart = Len(xx.Text) End If ElseIf xx.Text <> "" And Not IsNumeric(xx.Text) Then WarningMsgBox("Ada angka yang salah.") Call Highlight_Text(xx) End If End Sub Function Generate_Nomor(ByVal conn As ADODB.Connection, ByVal Tanggal As Date, _ ByVal Modul As String, ByVal Awalan As String) As String. 15 Analisis dan Perancangan ..., Kristian, FTI UMN, 2013.

(18) Dim rs As New ADODB.Recordset Dim query As String Dim year As Integer Dim month As Integer Dim filter As String Dim result As String ' --- ID example = P/0901/00001 --year = Tanggal.Year month = Tanggal.Month If month < 10 Then filter = Awalan & "/" & year.ToString.Substring(2) & "0" & month Else filter = Awalan & "/" & year.ToString.Substring(2) & month End If filter &= "/" query = "SELECT HIGH_PRIORITY " & Modul & "_ID FROM " & Modul & " WHERE " & Modul & "_ID Like '" & filter & _ "%' ORDER BY CAST(SUBSTRING(" & Modul & "_ID,8,5) AS DECIMAL) DESC LIMIT 1 " Call SQLCommand(conn, rs, query) If rs.EOF Then result = filter & "00001" Else Dim value As String = rs.Fields(0).Value Dim nomor As Double = IA(value.Substring(7)) nomor += 1 Dim serial As String = CStr(nomor) While (Len(serial) < 5) serial = "0" + serial End While result = filter & serial End If Return result End Function Sub Cari_Perbedaan3(ByVal conn As ADODB.Connection, ByVal rsA As ADODB.Recordset, ByVal rsB As ADODB.Recordset, ByRef perubahan As String) Dim query As String = "" Dim i As Integer = 0 While i < rsA.Fields.Count If Not IsDBNull(rsA.Fields(i).Value) Then If Not IsDBNull(rsB.Fields(i).Value) Then If (rsA.Fields(i).Value <> rsB.Fields(i).Value) Then If perubahan <> "" Then perubahan &= vbNewLine Dim fn As String = rsA.Fields(i).Name perubahan &= fn & " [" & rsA.Fields(i).Value & "] ==> [" & rsB.Fields(i).Value & "] " End If End If End If. 16 Analisis dan Perancangan ..., Kristian, FTI UMN, 2013.

(19) i += 1 End While End Sub Sub Cari_Perbedaan4(ByVal conn As ADODB.Connection, ByVal rsA As ADODB.Recordset, ByVal rsB As ADODB.Recordset, ByRef perubahan As String) Dim query As String = "" Dim n As Integer = 0 Dim i As Integer = 0 ' --- Edit --While Not rsA.EOF And Not rsB.EOF i=0 While i < rsA.Fields.Count If Not IsDBNull(rsA.Fields(i).Value) Then If Not IsDBNull(rsB.Fields(i).Value) Then If (rsA.Fields(i).Value <> rsB.Fields(i).Value) Then If perubahan <> "" Then perubahan &= vbNewLine Dim fn As String = rsA.Fields(i).Name perubahan &= rsA.Fields(0).Value & " | " & fn & " [" & rsA.Fields(i).Value & "] ==> [" & rsB.Fields(i).Value & "] " End If End If End If i += 1 End While rsA.Move(1) rsB.Move(1) End While ' --- Hapus --While Not rsA.EOF If perubahan <> "" Then perubahan &= vbNewLine Dim fn As String = rsA.Fields(0).Name perubahan &= "Hapus data " & fn & " " & rsA.Fields(0).Value rsA.Move(1) End While ' --- Tambah --While Not rsB.EOF If perubahan <> "" Then perubahan &= vbNewLine Dim fn As String = rsB.Fields(0).Name perubahan &= "Tambah data " & fn & " " & rsB.Fields(0).Value rsB.Move(1) End While End Sub. 17 Analisis dan Perancangan ..., Kristian, FTI UMN, 2013.

(20) Function Give_Space_Before(ByVal txt As String, ByVal n As Integer) While Len(txt) < n txt = " " & txt End While Give_Space_Before = txt End Function Function Give_Space_After(ByVal txt As String, ByVal n As Integer) While Len(txt) < n txt = txt & " " End While Give_Space_After = txt End Function End Module. 18 Analisis dan Perancangan ..., Kristian, FTI UMN, 2013.

(21) 2. BARANG.VB Public Class Barang Public BarangID As String = "" Public Kode As String = "" Public Deskripsi As String = "" Public Qty As Double = 0 Public HrgModal As Double = 0 Public HrgJual As Double = 0 Public ReOrderLevel As Double = 0 Private conn As ADODB.Connection Private rs As ADODB.Recordset Private rs1 As ADODB.Recordset Private rs2 As ADODB.Recordset Private query As String Public Sub New(ByVal cn As ADODB.Connection, ByVal ID As String) conn = cn query = "SELECT DISTINCT * FROM BARANG AS B " & _ "WHERE B.BARANG_ID='" & ID & "' AND STATUSAKTIF = 1 LIMIT 1 " Call SQLCommand(conn, rs, query) If Not rs.EOF Then BarangID = rs.Fields("BARANG_ID").Value Kode = IP(rs.Fields("KODE").Value) Deskripsi = IP(rs.Fields("DESKRIPSI").Value) Qty = IA(rs.Fields("QTY").Value) HrgModal = IA(rs.Fields("HRGMODAL").Value) HrgJual = IA(rs.Fields("HRGJUAL").Value) ReOrderLevel = IA(rs.Fields("REORDERLEVEL").Value) End If End Sub Public Sub New(ByVal cn As ADODB.Connection, ByVal Cd As String, _ ByVal Descp As String) conn = cn query = "SELECT DISTINCT * FROM BARANG AS B " & _ "WHERE STATUSAKTIF = 1 " & _ "AND B.KODE='" & Cd & "' " & _ "AND B.DESKRIPSI='" & Descp & "' " & _ "AND Qty > 0 ORDER BY QTY DESC LIMIT 1" Call SQLCommand(conn, rs, query) If rs.EOF Then query = "SELECT DISTINCT * FROM BARANG AS B " & _. 19 Analisis dan Perancangan ..., Kristian, FTI UMN, 2013.

(22) "WHERE STATUSAKTIF = 1 " & _ "AND B.KODE='" & Cd & "' " & _ "AND B.DESKRIPSI='" & Descp & "' " & _ " ORDER BY QTY DESC LIMIT 1" Call SQLCommand(conn, rs, query) End If If Not rs.EOF Then BarangID = rs.Fields("BARANG_ID").Value Kode = IP(rs.Fields("KODE").Value) Deskripsi = IP(rs.Fields("DESKRIPSI").Value) Qty = IA(rs.Fields("QTY").Value) HrgModal = IA(rs.Fields("HRGMODAL").Value) HrgJual = IA(rs.Fields("HRGJUAL").Value) ReOrderLevel = IA(rs.Fields("REORDERLEVEL").Value) Else Kode = Cd Deskripsi = Descp Qty = 0 HrgModal = 0 HrgJual = 0 ReOrderLevel = 0 BarangID = Generate_Barang_ID(conn, Descp) query = "INSERT INTO BARANG VALUES('" & BarangID & "','" & Cd & _ "','" & Descp & "'," & IA(Qty) & "," & IA(HrgModal) & "," & IA(HrgJual) & "," & IA(ReOrderLevel) & ",1)" conn.Execute(query) Call Update_Harga_Jual() Call Update_Harga_COGS() End If End Sub Public Sub New(ByVal cn As ADODB.Connection, ByVal Cd As String, _ ByVal Descp As String, ByVal BsPrc As Double, ByVal RtlPrice As Double) conn = cn query = "SELECT DISTINCT * FROM BARANG AS B " & _ "WHERE STATUSAKTIF = 1 " & _ "AND B.KODE = '" & Cd & "' " & _ "AND B.DESKRIPSI= '" & Descp & "' " & _ "AND B.HRGMODAL = " & IA(BsPrc) & " " & _ "AND B.HRGJUAL = " & IA(RtlPrice) & " " & _ "AND QTY > 0 ORDER BY QTY DESC LIMIT 1" Call SQLCommand(conn, rs, query) If rs.EOF Then query = "SELECT DISTINCT * FROM BARANG AS B " & _ "WHERE STATUSAKTIF = 1 " & _ "AND B.KODE = '" & Cd & "' " & _. 20 Analisis dan Perancangan ..., Kristian, FTI UMN, 2013.

(23) "AND B.DESKRIPSI = '" & Descp & "' " & _ "AND B.HRGMODAL = " & IA(BsPrc) & " " & _ "AND B.HRGJUAL = " & IA(RtlPrice) & " " & _ " ORDER BY QTY DESC LIMIT 1" Call SQLCommand(conn, rs, query) If rs.EOF Then query = "SELECT DISTINCT * FROM BARANG AS B " & _ "WHERE STATUSAKTIF = 1 " & _ "AND B.KODE = '" & Cd & "' " & _ "AND B.DESKRIPSI = '" & Descp & "' " & _ "AND B.HRGMODAL = " & IA(BsPrc) & " " & _ "AND B.HRGJUAL = " & IA(RtlPrice) & " " & _ " ORDER BY BARANG_ID DESC LIMIT 1" Call SQLCommand(conn, rs, query) End If End If If Not rs.EOF Then BarangID = rs.Fields("BARANG_ID").Value Kode = IP(rs.Fields("KODE").Value) Deskripsi = IP(rs.Fields("DESKRIPSI").Value) Qty = IA(rs.Fields("QTY").Value) HrgModal = IA(rs.Fields("HRGMODAL").Value) HrgJual = IA(rs.Fields("HRGJUAL").Value) ReOrderLevel = IA(rs.Fields("REORDERLEVEL").Value) Else Kode = Cd Deskripsi = Descp Qty = 0 HrgModal = BsPrc HrgJual = RtlPrice ReOrderLevel = 0 BarangID = Generate_Barang_ID(conn, Descp) query = "INSERT INTO BARANG VALUES('" & BarangID & "','" & Kode & _ "','" & Descp & "'," & IA(Qty) & "," & IA(HrgModal) & "," & IA(HrgJual) & "," & _ IA(ReOrderLevel) & ",1)" conn.Execute(query) Call Update_Harga_Jual() Call Update_Harga_COGS() End If End Sub Sub Update_Harga_Jual() query = "SELECT HRGJUAL FROM BARANG WHERE DESKRIPSI = '" & IP(Deskripsi) & "' " & _ "AND KODE = '" & IP(Kode) & "' " & _ "AND HRGJUAL <> 0 ORDER BY BARANG_ID DESC LIMIT 1 " Call SQLCommand(conn, rs1, query). 21 Analisis dan Perancangan ..., Kristian, FTI UMN, 2013.

(24) If Not rs1.EOF Then query = "UPDATE BARANG SET HRGJUAL = " & IA(rs1.Fields(0).Value) & " " & _ "WHERE BARANG_ID = '" & BarangID & "' " conn.Execute(query) End If End Sub Sub Update_Harga_COGS() query = "SELECT HRGMODAL FROM BARANG WHERE DESKRIPSI = '" & IP(Deskripsi) & "' " & _ "AND KODE = '" & IP(Kode) & "' " & _ "AND HRGMODAL <> 0 ORDER BY BARANG_ID DESC LIMIT 1 " Call SQLCommand(conn, rs1, query) If Not rs1.EOF Then query = "UPDATE BARANG SET HRGMODAL = " & IA(rs1.Fields(0).Value) & " " & _ "WHERE BARANG_ID = '" & BarangID & "' " conn.Execute(query) End If End Sub Public Sub AddPembelian(ByVal total As Double, ByVal tanggal As Date) Dim referensi As String ' --- Set Referensi --referensi = tanggal.Year.ToString.Substring(2) If tanggal.Month < 10 Then referensi &= "0" referensi &= tanggal.Month query = "SELECT * FROM SaldoBARANG WHERE BARANG_ID='" & BarangID & _ "' AND TahunBulan='" & referensi & "' LIMIT 1" Call SQLCommand(conn, rs, query) If Not rs.EOF Then query = "UPDATE SaldoBARANG SET Pembelian=Pembelian + " & total & _ " WHERE BARANG_ID='" & BarangID & "' AND TahunBulan='" & referensi & "'" Else ' --- Add Data SaldoProduct --query = "INSERT INTO SaldoBARANG(BARANG_ID, TahunBulan, Pembelian) " & _ " VALUES('" & BarangID & "','" & referensi & "'," & total & ")" End If conn.Execute(query) ' --- Update Database Product --query = "UPDATE BARANG SET Qty=Qty + " & total & _ " WHERE BARANG_ID='" & BarangID & "'" conn.Execute(query) Qty += total End Sub. 22 Analisis dan Perancangan ..., Kristian, FTI UMN, 2013.

(25) Public Sub AddRetur(ByVal total As Double, ByVal tanggal As Date) Dim referensi As String ' --- Set Referensi --referensi = tanggal.Year.ToString.Substring(2) If tanggal.Month < 10 Then referensi &= "0" referensi &= tanggal.Month query = "SELECT * FROM SaldoBARANG WHERE BARANG_ID='" & BarangID & _ "' AND TahunBulan='" & referensi & "' LIMIT 1" Call SQLCommand(conn, rs, query) If Not rs.EOF Then query = "UPDATE SaldoBARANG SET Retur=Retur + " & total & _ " WHERE BARANG_ID='" & BarangID & "' AND TahunBulan='" & referensi & "'" Else query = "INSERT INTO SaldoBARANG(BARANG_ID, TahunBulan, Retur) " & _ " VALUES('" & BarangID & "','" & referensi & "'," & total & ")" End If conn.Execute(query) ' --- Update Database Product --query = "UPDATE BARANG SET Qty=Qty - " & total & _ " WHERE BARANG_ID='" & BarangID & "'" conn.Execute(query) Qty -= total End Sub Public Sub AddPenjualan(ByVal total As Double, ByVal tanggal As Date) Dim referensi As String ' --- Set Referensi --referensi = tanggal.Year.ToString.Substring(2) If tanggal.Month < 10 Then referensi &= "0" referensi &= tanggal.Month query = "SELECT * FROM SaldoBARANG WHERE BARANG_ID='" & BarangID & _ "' AND TahunBulan='" & referensi & "' LIMIT 1" Call SQLCommand(conn, rs, query) If Not rs.EOF Then ' --- Update Data SaldoProduct --query = "UPDATE SaldoBARANG SET Penjualan=Penjualan + " & total & _ " WHERE BARANG_ID='" & BarangID & "' AND TahunBulan='" & referensi & "'" Else ' --- Add Data SaldoProduct --query = "INSERT INTO SaldoBARANG(BARANG_ID, TahunBulan, Penjualan) " & _ " VALUES('" & BarangID & "','" & referensi & "'," & total & ")" End If. 23 Analisis dan Perancangan ..., Kristian, FTI UMN, 2013.

(26) conn.Execute(query) ' --- Update Database Product --query = "UPDATE BARANG SET Qty=Qty - " & total & _ " WHERE BARANG_ID='" & BarangID & "'" conn.Execute(query) Qty -= total End Sub Public Sub AddRefund(ByVal total As Double, ByVal tanggal As Date) Dim referensi As String ' --- Set Referensi --referensi = tanggal.Year.ToString.Substring(2) If tanggal.Month < 10 Then referensi &= "0" referensi &= tanggal.Month query = "SELECT * FROM SaldoBARANG WHERE BARANG_ID='" & BarangID & _ "' AND TahunBulan='" & referensi & "' LIMIT 1" Call SQLCommand(conn, rs, query) If Not rs.EOF Then ' --- Update Data SaldoProduct --query = "UPDATE SaldoBARANG SET Refund=Refund + " & total & _ " WHERE BARANG_ID='" & BarangID & "' AND TahunBulan='" & referensi & "'" Else ' --- Add Data SaldoProduct --query = "INSERT INTO SaldoBARANG(BARANG_ID, TahunBulan, Refund) " & _ " VALUES('" & BarangID & "','" & referensi & "'," & total & ")" End If conn.Execute(query) ' --- Update Database Product --query = "UPDATE BARANG SET Qty=Qty + " & total & _ " WHERE BARANG_ID='" & BarangID & "'" conn.Execute(query) Qty += total End Sub. End Cl. 24 Analisis dan Perancangan ..., Kristian, FTI UMN, 2013.

(27) 3. FORM BARANG.VB Private Sub dGridBarang_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles dGridBarang.Click Try Dim cm As CurrencyManager = CType(Me.BindingContext(dGridBarang.DataSource, dGridBarang.DataMember), CurrencyManager) Dim dv As DataView = CType(cm.List, DataView) Dim dr As DataRow TextID.Text = IP(dv.Item(cm.Position).Row("BARANG_ID").ToString) TextKode.Text = IP(dv.Item(cm.Position).Row("KODE").ToString) TextDeskripsi.Text = IP(dv.Item(cm.Position).Row("DESKRIPSI").ToString) TextQty.Text = Angka(IA(dv.Item(cm.Position).Row("QTY").ToString)) TextHrgModal.Text = Angka(IA(dv.Item(cm.Position).Row("HRGMODAL").ToString)) TextHrgJual.Text = Angka(IA(dv.Item(cm.Position).Row("HRGJUAL").ToString)) TextReOrderLevel.Text = Angka(dv.Item(cm.Position).Row(dr("REORDERLEVEL").ToString)) If IA(dv.Item(cm.Position).Row("STATUSAKTIF").ToString) = 1 Then cbAktif.Checked = True Else cbAktif.Checked = False End If ds.Clear() DatagridHistory.TableStyles.Clear() Call cari_data_sejarah(IP(dr("BARANG_ID").ToString)) Catch err As Exception 'warningmsgbox("Data Tidak Dapat Ditemukan") End Try End Sub Sub cari_data_sejarah(ByVal ID As String) ' --- Set Value to Table --query = "SELECT DISTINCT GR.TANGGAL, SP.NAMA AS 'SUPPLIER', FORMAT(GRD.QTY,0) as QTY, FORMAT(GRD.HARGA,0) as HRGMODAL " & _ " FROM PENERIMAANDETAIL AS GRD " & _ " LEFT JOIN PENERIMAAN AS GR ON GRD.PENERIMAAN_ID=GR.PENERIMAAN_ID " & _ " LEFT JOIN SUPPLIER AS SP ON GR.Supplier_ID=SP.Supplier_ID" & _ " LEFT JOIN BARANG AS P ON GRD.BARANG_ID=P.BARANG_ID " & _ " WHERE GRD.QTY <> 0 and P.BARANG_ID = '" & IP(ID) & "' AND STATUS = 4 " & _ " ORDER by GR.TANGGAL DESC " & _ " LIMIT 20 " Call Enable_Grid(query) End Sub Sub Enable_Grid(ByVal query As String) ds.Clear() DatagridHistory.TableStyles.Clear() adap = New MySqlDataAdapter(query, myConn). 25 Analisis dan Perancangan ..., Kristian, FTI UMN, 2013.

(28) adap.Fill(ds, "Table_PO") DatagridHistory.DataSource = ds DatagridHistory.DataMember = "Table_PO" ' --- Set column length --Dim dgts As DataGridTableStyle dgts = New DataGridTableStyle dgts.MappingName = "Table_PO" DatagridHistory.TableStyles.Add(dgts) Call Set_Color_Grid(dgts) dgts.GridColumnStyles(0).Width = 70 dgts.GridColumnStyles(1).Width = 120 dgts.GridColumnStyles(2).Width = 45 dgts.GridColumnStyles(2).Alignment = HorizontalAlignment.Right dgts.GridColumnStyles(3).Width = 75 dgts.GridColumnStyles(3).Alignment = HorizontalAlignment.Right Call Set_Color_Grid(dgts) End Sub Private Sub TextQty_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextQty.TextChanged If IsNumeric(TextQty.Text) And TextQty.Text <> "" Then Dim i As Double = TextQty.Text.IndexOf(".") If i < 0 Then TextQty.Text = FormatNumber(TextQty.Text, 0, , , vbTrue) TextQty.SelectionStart = Len(TextQty.Text) End If End If End Sub Private Sub TextRetailPrice_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextHrgJual.TextChanged If IsNumeric(TextHrgJual.Text) And TextHrgJual.Text <> "" Then Dim i As Double = TextHrgJual.Text.IndexOf(".") If i < 0 Then TextHrgJual.Text = FormatNumber(TextHrgJual.Text, 0, , , vbTrue) TextHrgJual.SelectionStart = Len(TextHrgJual.Text) End If End If End Sub Private Sub TextBasePrice_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles TextHrgModal.TextChanged If IsNumeric(TextHrgModal.Text) And TextHrgModal.Text <> "" Then Dim i As Double = TextHrgModal.Text.IndexOf(".") If i < 0 Then TextHrgModal.Text = FormatNumber(TextHrgModal.Text, 0, , , vbTrue) TextHrgModal.SelectionStart = Len(TextHrgModal.Text) End If End If End Sub. 26 Analisis dan Perancangan ..., Kristian, FTI UMN, 2013.

(29) Private Sub TextReOrderLevel_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles TextReOrderLevel.TextChanged If IsNumeric(TextReOrderLevel.Text) And TextReOrderLevel.Text <> "" Then Dim i As Double = TextReOrderLevel.Text.IndexOf(".") If i < 0 Then TextReOrderLevel.Text = FormatNumber(TextReOrderLevel.Text, 0, , , vbTrue) TextReOrderLevel.SelectionStart = Len(TextReOrderLevel.Text) End If End If End Sub Private Sub ButtonUbahInfo_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonUbahInfo.Click If Check_Value() Then Try conn.Execute("BEGIN") Dim cm As CurrencyManager = Me.BindingContext(dGridBarang.DataSource, dGridBarang.DataMember) Dim dv As DataView = CType(cm.List, DataView) Dim original_position As Integer = cm.Position Dim status As Double If cbAktif.Checked = True Then status = 1 Else status = 0 End If Dim rsA As New ADODB.Recordset Dim rsB As New ADODB.Recordset query = "SELECT KODE, DESKRIPSI, FORMAT(QTY,0) QTY, " & _ "FORMAT(HRGMODAL,0) 'HARGA MODAL, FORMAT(HRGJUAL,0) 'HARGA JUAL', " & _ "REORDERLEVEL, STATUSAKTIF FROM BARANG " & _ "WHERE BARANG_ID = '" & IP(TextID.Text) & "' " Call SQLCommand(conn, rsA, query) query = "UPDATE BARANG SET KODE = '" & IP(TextKode.Text) & "', " & _ "DESKRIPSI = '" & IP(TextDeskripsi.Text) & "', " & _ "HRGMODAL = " & IA(TextHrgModal.Text) & ", " & _ "HRGJUAL = " & IA(TextHrgJual.Text) & ", " & _ "REORDERLEVEL = " & IA(TextReOrderLevel.Text) & ", " & _ "STATUSAKTIF = " & IA(status) & " " & _ "WHERE BARANG_ID = '" & IP(TextID.Text) & "' " conn.Execute(query) query = "SELECT KODE, DESKRIPSI, FORMAT(QTY,0) QTY, " & _ "FORMAT(HRGMODAL,0) 'HARGA MODAL, FORMAT(HRGJUAL,0) 'HARGA JUAL', " & _ "REORDERLEVEL, STATUSAKTIF FROM BARANG " & _ "WHERE BARANG_ID = '" & IP(TextID.Text) & "' " Call SQLCommand(conn, rsB, query) Dim Perubahan As String = "" Call Cari_Perbedaan3(conn, rsA, rsB, Perubahan) If Perubahan <> "" Then Call Insert_Log(conn, Perubahan.ToUpper, formMain.userLevel.nama, "BARANG", TextID.Text) End If. 27 Analisis dan Perancangan ..., Kristian, FTI UMN, 2013.

(30) conn.Execute("COMMIT") ShowMsgBox("Barang " & IP(TextDeskripsi.Text) & " berhasil diubah") Call Find_DataGrid() dGridBarang.ScrollToRow(original_position) Call Clear_Data() Catch ex As Exception conn.Execute("ROLLBACK") WarningMsgBox("Data Eror. " & ex.Message) End Try End If End Sub Function Check_Value() As Boolean If TextID.Text = "" Then WarningMsgBox("Harap Pilih Data") dGridBarang.Select() Return False ElseIf IP(TextDeskripsi.Text) = "" Then WarningMsgBox("Deskripsi Tidak Boleh Kosong") Call Highlight_Text(TextDeskripsi) Return False ElseIf Not IsNumeric(TextHrgModal.Text) Then WarningMsgBox("Hrg Modal Harus Dalam Angka!") Call Highlight_Text(TextHrgModal) Return False ElseIf Not IsNumeric(TextHrgJual.Text) Then WarningMsgBox("Hrg Jual Harus Dalam Angka!") Call Highlight_Text(TextHrgModal) Return False End If Return True End Function Sub Clear_Data() TextKode.Text = "" TextDeskripsi.Text = "" TextQty.Text = "" TextReOrderLevel.Text = "" TextHrgJual.Text = "" TextHrgModal.Text = "" TextID.Text = "" cbAktif.Checked = True Call Highlight_Text(TextCariKode) End Sub Private Sub DatagridHistory_MouseWheel(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles DatagridHistory.MouseWheel DatagridHistory.Select() End Sub Private Sub ButtonHapus_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonHapus.Click. 28 Analisis dan Perancangan ..., Kristian, FTI UMN, 2013.

(31) If AskMsgBox("Yakin ingin hapus data Barang " & IP(TextDeskripsi.Text) & " ?") Then If IA(TextQty.Text) <> 0 Then WarningMsgBox("QTY Harus Dalam Kondisi Nol (0).") dGridBarang.Select() Exit Sub End If Try conn.Execute("BEGIN") Dim ID_Baru As String = "" query = "SELECT BARANG_ID FROM BARANG " & _ "WHERE BARANG_ID = '" & IP(TextID.Text) & "' " & _ "ORDER BY BARANG_ID LIMIT 1 " Call SQLCommand(conn, rs2, query) If Not rs2.EOF Then ID_Baru = rs2.Fields("BARANG_ID").Value End If query = "(SELECT BARANG_ID FROM PENERIMAANDETAIL WHERE BARANG_ID = '" & ID_Baru & "') " & _ "UNION " & _ "(SELECT BARANG_ID FROM RETURPENERIMANDETAIL WHERE BARANG_ID = '" & ID_Baru & "') " Call SQLCommand(conn, rs3, query) If Not rs3.EOF Then WarningMsgBox("Barang " & IP(TextDeskripsi.Text) & " memiliki data transaksi PENGADAAN. " & _ "Anda hanya dapat mengatur material tersebut sebagai material non-aktif.") dGridBarang.Select() Exit Sub End If query = "(SELECT BARANG_ID FROM PENJUALANDETAIL WHERE BARANG_ID = '" & ID_Baru & "') " & _ "UNION " & _ "(SELECT BARANG_ID FROM RETURPENJUALANDETAIL WHERE BARANG_ID = '" & ID_Baru & "') " Call SQLCommand(conn, rs3, query) If Not rs3.EOF Then WarningMsgBox("Barang " & IP(TextDeskripsi.Text) & " memiliki data transaksi SALES. " & _ "Anda hanya dapat mengatur material tersebut sebagai material non-aktif.") dGridBarang.Select() Exit Sub End If query = "DELETE FROM BARANG WHERE BARANG_ID = '" & ID_Baru & "' " conn.Execute(query) query = "DELETE FROM SALDOBARANG WHERE BARANG_ID = '" & ID_Baru & "' " conn.Execute(query) conn.Execute("COMMIT") ShowMsgBox("Barang " & IP(TextDeskripsi.Text) & " berhasil dihapus.") Call Clear_Data() Call Find_DataGrid() Catch ex As Exception conn.Execute("ROLLBACK"). 29 Analisis dan Perancangan ..., Kristian, FTI UMN, 2013.

(32) WarningMsgBox("Error Data." & ex.Message) End Try End If End Sub Private Sub ButtonLog_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonLog.Click If TextID.Text = "" Then WarningMsgBox("Harap Pilih Data") Exit Sub End If Dim fLog As FormLog = New FormLog(TextID.Text, "BARANG") fLog.ShowDialog() End Sub Private Sub PanelDB_Paint(ByVal sender As System.Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles PanelDB.Paint End Sub Private Sub dGridBarang_Navigate(ByVal sender As System.Object, ByVal ne As System.Windows.Forms.NavigateEventArgs) Handles dGridBarang.Navigate End Sub End Class. 30 Analisis dan Perancangan ..., Kristian, FTI UMN, 2013.

(33) 4. FORM CARI BARANG.VB Sub Fill_Data() Dim TableK As DataTable = New DataTable("Table_K") Dim DataTableBarang As New DataGridTableStyle Dim newRow As DataRow Dim i As Integer = 0 Dim rs As New ADODB.Recordset Dim rs1 As New ADODB.Recordset ' ---- Set Initial Table --Dim dsBarang As New DataSet DataGridBarang.TableStyles.Clear() Dim ColumnKode As DataColumn = New DataColumn("KODE") Dim ColumnDeskripsi As DataColumn = New DataColumn("DESKRIPSI") Dim ColumnQty As DataColumn = New DataColumn("QTY") Dim ColumnHrgModal As DataColumn = New DataColumn("HRGMODAL") Dim ColumnHrgJual As DataColumn = New DataColumn("HRGJUAL") TableK.Columns.Add(ColumnKode) TableK.Columns.Add(ColumnDeskripsi) TableK.Columns.Add(ColumnQty) TableK.Columns.Add(ColumnHrgModal) TableK.Columns.Add(ColumnHrgJual) dsBarang.Tables.Clear() dsBarang.Tables.Add(TableK) query = "SELECT KODE, DESKRIPSI, FORMAT(SUM(QTY),0) AS QTY, " & _ "FORMAT(HRGMODAL,0) AS 'HRGMODAL', FORMAT(HRGJUAL,0) AS 'HRGJUAL' " & _ "FROM BARANG " & _ "WHERE STATUSAKTIF = 1 " If TextKode.Text <> "" Then query &= "AND (KODE LIKE '%" & IP(TextKode.Text) & "%' " & _ "OR DESKRIPSI LIKE '%" & IP(TextKode.Text) & "%') " End If query &= "GROUP BY KODE, DESKRIPSI " If CBQtyLebihDari0.Checked = False Then query &= "HAVING SUM(QTY) > 0 " End If query &= "ORDER BY KODE, DESKRIPSI " Call SQLCommand(conn, rs, query) While Not rs.EOF newRow = TableK.NewRow() newRow("KODE") = IP(rs.Fields("KODE").Value) TableK.Rows.Add(newRow) TableK.Rows(i)("DESKRIPSI") = IP(rs.Fields("DESKRIPSI").Value) TableK.Rows(i)("QTY") = Angka(IA(rs.Fields("QTY").Value)) TableK.Rows(i)("HRGMODAL") = Angka(IA(rs.Fields("HRGMODAL").Value)) TableK.Rows(i)("HRGJUAL") = Angka(IA(rs.Fields("HRGJUAL").Value)). 31 Analisis dan Perancangan ..., Kristian, FTI UMN, 2013.

(34) i += 1 rs.Move(1) End While DataGridBarang.SetDataBinding(dsBarang, "Table_K") DataTableBarang.MappingName = "Table_K" DataGridBarang.TableStyles.Add(DataTableBarang) DataTableBarang.GridColumnStyles(0).Width = 110 DataTableBarang.GridColumnStyles(1).Width = 260 DataTableBarang.GridColumnStyles(2).Width = 60 DataTableBarang.GridColumnStyles(2).Alignment = HorizontalAlignment.Right If formMain.userLevel.Pengadaan = 1 Then If formMain.userLevel.EditPengadaan = 0 Then DataTableBarang.GridColumnStyles(3).Width = 0 DataTableBarang.GridColumnStyles(3).HeaderText = "" Else DataTableBarang.GridColumnStyles(3).Width = 90 End If End If DataTableBarang.GridColumnStyles(3).Alignment = HorizontalAlignment.Right If formMain.userLevel.Pengeluaran = 1 Then If formMain.userLevel.EditPengeluaran = 0 Then DataTableBarang.GridColumnStyles(4).Width = 0 DataTableBarang.GridColumnStyles(4).HeaderText = "" Else DataTableBarang.GridColumnStyles(4).Width = 100 End If End If DataTableBarang.GridColumnStyles(4).Alignment = HorizontalAlignment.Right Call Set_Color_Grid(DataTableBarang) End Sub Private Sub DataGridBarang_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles DataGridBarang.MouseUp Dim pt = New Point(e.X, e.Y) Dim hti As DataGrid.HitTestInfo = DataGridBarang.HitTest(pt) If hti.Type = DataGrid.HitTestType.Cell Then DataGridBarang.CurrentCell = New DataGridCell(hti.Row, hti.Column) DataGridBarang.Select(hti.Row) End If End Sub Private Sub DataGridBarang_MouseWheel(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles DataGridBarang.MouseWheel DataGridBarang.Select() End Sub Private Sub DataGridBarang_DoubleClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles DataGridBarang.DoubleClick Try Dim cm As CurrencyManager = Me.BindingContext(DataGridBarang.DataSource, DataGridBarang.DataMember). 32 Analisis dan Perancangan ..., Kristian, FTI UMN, 2013.

(35) Dim dv As DataView = CType(cm.List, DataView) returnKode = IP(dv.Item(cm.Position).Row(0)) returnDeskripsi = IP(dv.Item(cm.Position).Row(1)) returnHarga = Angka(IA(dv.Item(cm.Position).Row(3))) returnHargaJual = Angka(IA(dv.Item(cm.Position).Row(4))) Me.Close() Catch err As Exception WarningMsgBox("Data Tidak Dapat Ditemukan") End Try End Sub End Class. 33 Analisis dan Perancangan ..., Kristian, FTI UMN, 2013.

(36) 5. FROM PESANAN.VB Imports MySql.Data.MySqlClient Public Class FormPesanan Inherits System.Windows.Forms.Form Public FormMain As FormMain Public conn As New ADODB.Connection Public conn_temp As New ADODB.Connection Dim query As String Dim keyChange As Integer Public tCust As New DataTable Public DataSet As New DataSet Dim DataTable As New DataGridTableStyle 'Dim cc As New ReportPO Dim DataSetPO As New DataSet Dim DataTablePO As New DataGridTableStyle Dim adap As New MySqlDataAdapter Dim adapDetail As New MySqlDataAdapter Dim ds As New DataSet Dim dsDetail As New DataSet Dim dtDetail As New DataGridTableStyle Dim tCustDetail As New DataTable Dim rs As New ADODB.Recordset Dim rs1 As New ADODB.Recordset Dim rs2 As New ADODB.Recordset Dim rs3 As New ADODB.Recordset Dim rs4 As New ADODB.Recordset Dim rs5 As New ADODB.Recordset Dim StatusLoad As Integer = 0 Dim StatusBuka As Integer = 0 #Region " Windows Form Designer generated code " Public Sub New(ByVal frmMain As FormMain) MyBase.New() FormMain = frmMain conn = FormMain.conn conn_temp = FormMain.conn_temp 'This call is required by the Windows Form Designer. InitializeComponent() 'Add any initialization after the InitializeComponent() call End Sub. 34 Analisis dan Perancangan ..., Kristian, FTI UMN, 2013.

(37) #End Region Private Sub FormPesanan_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Try If FormMain.userLevel.Pengadaan = 1 Then If FormMain.userLevel.EditPengadaan = 0 Then ButtonEdit.Visible = False ButtonBatalPesanan.Visible = False ButtonTutupPesanan.Visible = False PanelModal1.Visible = False PanelModal2.Visible = False End If Call Fill_DataGrid() LabelEdit.Visible = False LabelID.Text = Generate_Nomor(conn, DateTanggal.Value, "Pesanan", "P") Call Buat_Panel() StatusLoad = 1 Else WarningMsgBox("Mohon Maaf " & vbNewLine & _ "Anda, " & FormMain.userLevel.nama & " Tidak Memiliki Akses ke Menu PESANAN") Me.Close() End If Catch ex As Exception WarningMsgBox(Err.Description) Me.Close() End Try End Sub Protected Overrides Function ProcessCmdKey(ByRef msg As Message, ByVal keyData As Keys) As Boolean Const WM_KEYDOWN As Integer = &H100 Const WM_SYSKEYDOWN As Integer = &H104 If ((msg.Msg = WM_KEYDOWN) Or (msg.Msg = WM_SYSKEYDOWN)) Then ' --- Ctrl+V -> keyData = System.Windows.Forms.Shortcut.CtrlV --If keyData = Keys.F1 Then Call Buat_Panel() ElseIf keyData = Keys.F2 Then If LabelEdit.Visible = False Then If PanelBuat.Visible = True Then Call Lihat_Panel() End If End If End If End If Return MyBase.ProcessCmdKey(msg, keyData) End Function. 35 Analisis dan Perancangan ..., Kristian, FTI UMN, 2013.

(38) Sub Buat_Panel() DateTanggal.Select() PanelBuat.Visible = True PanelLihat.Visible = False 'PanelCetak.Visible = False ButtonBuat.BackColor = Color.White ButtonBuat.ForeColor = Color.Black ButtonLihat.BackColor = Color.Black ButtonLihat.ForeColor = Color.White 'ButtonCetak.BackColor = Color.Black 'ButtonCetak.ForeColor = Color.White End Sub Sub Lihat_Panel() Call Cari_PO() DateTanggalDari.Select() PanelBuat.Visible = False PanelLihat.Visible = True 'PanelCetak.Visible = False ButtonBuat.BackColor = Color.Black ButtonBuat.ForeColor = Color.White ButtonLihat.BackColor = Color.White ButtonLihat.ForeColor = Color.Black 'ButtonCetak.BackColor = Color.Black 'ButtonCetak.ForeColor = Color.White End Sub Sub Cetak_Panel() PanelBuat.Visible = False PanelLihat.Visible = False 'PanelCetak.Visible = True ButtonBuat.BackColor = Color.Black ButtonBuat.ForeColor = Color.White ButtonLihat.BackColor = Color.Black ButtonLihat.ForeColor = Color.White 'ButtonCetak.BackColor = Color.White 'ButtonCetak.ForeColor = Color.Black End Sub Private Sub ButtonBuat_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonBuat.Click Call Buat_Panel() End Sub Private Sub ButtonLihat_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonLihat.Click If LabelEdit.Visible = False Then Call Lihat_Panel() End If End Sub. 36 Analisis dan Perancangan ..., Kristian, FTI UMN, 2013.

(39) 'Private Sub ButtonCetak_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonCetak.Click ' Call Cetak_Panel() 'End Sub #Region "Masuk Pembelian" Private Sub TextSupplier_DoubleClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles TextSupplier.DoubleClick Call Cari_Supplier() End Sub Sub Cari_Supplier() Dim frmSupplier As FormSupplier = New FormSupplier(FormMain, 1) frmSupplier.ShowDialog() If IP(frmSupplier.returnNama) <> "" Then TextSupplier.Text = frmSupplier.returnNama LabelAlamat.Text = frmSupplier.returnAlamat End If DataGrid1.Select() End Sub Sub Fill_DataGrid() Dim rs As New ADODB.Recordset DataSet = New DataSet("myDataSet") tCust = New DataTable("PESANAN") Dim cKode As DataColumn cKode = New DataColumn("KODE") tCust.Columns.Add(cKode). '0. Dim cDeskripsi As DataColumn cDeskripsi = New DataColumn("DESKRIPSI") '1 tCust.Columns.Add(cDeskripsi) Dim cQty As DataColumn cQty = New DataColumn("QTY") tCust.Columns.Add(cQty) Dim cHarga As DataColumn cHarga = New DataColumn("HARGA") tCust.Columns.Add(cHarga). '2. '4. Dim cSubTotal As DataColumn cSubTotal = New DataColumn("SUBTOTAL") '5 tCust.Columns.Add(cSubTotal) ' --- Add the tables to the DataSet --DataSet.Tables.Add(tCust) Me.DataGrid1.SetDataBinding(DataSet, "PESANAN"). 37 Analisis dan Perancangan ..., Kristian, FTI UMN, 2013.

(40) Dim ts1 As DataGridTableStyle ts1 = New DataGridTableStyle ts1.MappingName = "PESANAN" Call Set_Color_Grid(ts1) ts1.PreferredRowHeight = 22 Dim TextCol As DataGridTextBoxColumn TextCol = New DataGridTextBoxColumn Call Set_TextCol(TextCol, "KODE", "KODE", 150, 1) ts1.GridColumnStyles.Add(TextCol) ' --- Set Nama Combobox --Dim ComboTextCol_Product As DataGridComboBoxColumn ComboTextCol_Product = New DataGridComboBoxColumn(conn, "BARANG") Call Set_TextCol(ComboTextCol_Product, "DESKRIPSI", "DESKRIPSI", 370, 1) ts1.GridColumnStyles.Add(ComboTextCol_Product) ComboTextCol_Product.ColumnComboBox.Items.Clear() query = "SELECT DISTINCT DESKRIPSI FROM BARANG ORDER BY DESKRIPSI " Call SQLCommand(conn, rs, query) While Not rs.EOF ComboTextCol_Product.ColumnComboBox.Items.Add(rs.Fields(0).Value) rs.Move(1) End While ComboTextCol_Product.ColumnComboBox.DropDownStyle = ComboBoxStyle.DropDown TextCol = New DataGridTextBoxColumn Call Set_TextCol(TextCol, "QTY", "QTY", 100, 0) ts1.GridColumnStyles.Add(TextCol) TextCol = New DataGridTextBoxColumn If FormMain.userLevel.Pengadaan = 1 Then If FormMain.userLevel.EditPengadaan = 0 Then Call Set_TextCol(TextCol, "HARGA", "", 0, 0) Else Call Set_TextCol(TextCol, "HARGA", "HARGA", 100, 0) End If End If ts1.GridColumnStyles.Add(TextCol) TextCol = New DataGridTextBoxColumn If FormMain.userLevel.Pengadaan = 1 Then If FormMain.userLevel.EditPengadaan = 0 Then Call Set_TextCol(TextCol, "SUBTOTAL", "", 0, 0) Else Call Set_TextCol(TextCol, "SUBTOTAL", "SUBTOTAL", 120, 0) End If End If TextCol.ReadOnly = True ts1.GridColumnStyles.Add(TextCol) ts1.AllowSorting = False Me.DataGrid1.TableStyles.Add(ts1) End Sub. 38 Analisis dan Perancangan ..., Kristian, FTI UMN, 2013.

(41) Sub Set_TextCol(ByRef dgtc As DataGridTextBoxColumn, _ ByVal mappingname As String, _ ByVal headertext As String, _ ByVal width As Integer, _ ByVal nulltext As Integer) dgtc.MappingName = mappingname dgtc.HeaderText = headertext dgtc.Width = width If nulltext = 0 Then dgtc.NullText = nulltext dgtc.Alignment = HorizontalAlignment.Right Else dgtc.NullText = "" End If End Sub Private Sub DataGrid1_Leave(ByVal sender As Object, ByVal e As System.EventArgs) Handles DataGrid1.Leave Call Hitung_Total() End Sub Private Sub DataGrid1_Enter(ByVal sender As Object, ByVal e As System.EventArgs) Handles DataGrid1.Enter DataGrid1.CurrentCell = New DataGridCell(DataGrid1.CurrentCell.RowNumber, 0) End Sub Private Sub DataGrid1_MouseWheel(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles DataGrid1.MouseWheel DataGrid1.Select() End Sub Private Sub DataGrid1_CurrentCellChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DataGrid1.CurrentCellChanged Dim rs As New ADODB.Recordset Dim cm As CurrencyManager = Me.BindingContext(DataGrid1.DataSource, DataGrid1.DataMember) Dim dv As DataView = CType(cm.List, DataView) If cm.Position = -1 Then Exit Sub End If Dim dr As DataRow = dv.Item(cm.Position).Row ' --- Skip --If DataGrid1.CurrentCell.ColumnNumber > 0 Then StatusBuka = 0 End If If IP(TextSupplier.Text) = "" Then WarningMsgBox("Supplier Tidak Boleh Kosong") Call Cari_Supplier() If IP(TextSupplier.Text) <> "" Then DataGrid1.CurrentCell = New DataGridCell(DataGrid1.CurrentCell.RowNumber, 0). 39 Analisis dan Perancangan ..., Kristian, FTI UMN, 2013.

(42) End If Exit Sub End If If DataGrid1.CurrentCell.ColumnNumber = 4 Then DataGrid1.CurrentCell = New DataGridCell(DataGrid1.CurrentCell.RowNumber + 1, 0) End If If DataGrid1.CurrentCell.ColumnNumber = 1 Then If StatusBuka = 0 Then If IP(dr("KODE").ToString) = "=" Then Dim frmCariBarang As FormCariBarang = New FormCariBarang(FormMain, 0) frmCariBarang.CBQtyLebihDari0.Checked = False frmCariBarang.ShowDialog() StatusBuka = 1 If IP(frmCariBarang.returnDeskripsi) <> "" Then dv.Item(cm.Position).Row("KODE") = frmCariBarang.returnKode dv.Item(cm.Position).Row("DESKRIPSI") = frmCariBarang.returnDeskripsi If IA(dv.Item(cm.Position).Row("HARGA").ToString) = 0 Then dv.Item(cm.Position).Row("HARGA") = Angka(IA(frmCariBarang.returnHarga)) End If DataGrid1.CurrentCell = New DataGridCell(DataGrid1.CurrentCell.RowNumber, 2) Else StatusBuka = 0 dv.Item(cm.Position).Row("KODE") = "" DataGrid1.CurrentCell = New DataGridCell(DataGrid1.CurrentCell.RowNumber, 0) End If Else ' --- cari data barang --If IP(dv.Item(cm.Position).Row("KODE")) <> "" _ And IP(dv.Item(cm.Position).Row("DESKRIPSI")) = "" Then '--- Pencarian Data Product berdasarkan Pesanan terdahulu atas supplier yang dipilih --query = "SELECT B.KODE, B.DESKRIPSI, FORMAT(POD.HARGA,0) AS HARGA FROM PENERIMAANDETAIL POD " & _ "LEFT JOIN PENERIMAAN PO ON POD.PENERIMAAN_ID = PO.PENERIMAAN_ID " & _ "LEFT JOIN SUPPLIER S ON PO.SUPPLIER_ID = S.SUPPLIER_ID " & _ "LEFT JOIN BARANG B ON POD.BARANG_ID = B.BARANG_ID " & _ "WHERE B.KODE = '" & IP(dv.Item(cm.Position).Row("KODE")) & "' " & _ "AND S.NAMA = '" & IP(TextSupplier.Text) & "' " & _ "ORDER BY PO.TANGGAL DESC LIMIT 1 " Call SQLCommand(conn, rs, query) If Not rs.EOF Then dv.Item(cm.Position).Row("DESKRIPSI") = IP(rs.Fields("DESKRIPSI").Value) If IA(dv.Item(cm.Position).Row("HARGA").ToString) = 0 Then dv.Item(cm.Position).Row("HARGA") = Angka(IA(rs.Fields("HARGA").Value)) End If DataGrid1.CurrentCell = New DataGridCell(DataGrid1.CurrentCell.RowNumber, 2) Else '--- Pencarian Data Product berdasarkan PO tertentu tanpa melihat supplier yang dipilih --query = "SELECT B.KODE, B.DESKRIPSI, FORMAT(POD.HARGA,0) AS HARGA FROM PENERIMAANDETAIL POD " & _ "LEFT JOIN PENERIMAAN PO ON POD.PENERIMAAN_ID = PO.PENERIMAAN_ID " &_ "LEFT JOIN BARANG B ON POD.BARANG_ID = B.BARANG_ID " & _. 40 Analisis dan Perancangan ..., Kristian, FTI UMN, 2013.

(43) "WHERE KODE = '" & IP(dv.Item(cm.Position).Row("KODE")) & "' " Call SQLCommand(conn, rs, query) If Not rs.EOF Then dv.Item(cm.Position).Row("DESKRIPSI") = IP(rs.Fields("DESKRIPSI").Value) If IA(dv.Item(cm.Position).Row("HARGA").ToString) = 0 Then dv.Item(cm.Position).Row("HARGA") = Angka(IA(rs.Fields("HARGA").Value)) End If DataGrid1.CurrentCell = New DataGridCell(DataGrid1.CurrentCell.RowNumber, 2) Else If IP(dv.Item(cm.Position).Row("KODE")) <> "" Then ' --- cari data barang --query = "SELECT DISTINCT KODE, DESKRIPSI, HRGMODAL AS HARGA FROM BARANG " & _ "WHERE KODE = '" & IP(dv.Item(cm.Position).Row("KODE")) & "' " & _ "AND STATUSAKTIF = 1 LIMIT 1 " Call SQLCommand(conn, rs, query) If Not rs.EOF Then dv.Item(cm.Position).Row("DESKRIPSI") = rs.Fields("DESKRIPSI").Value dv.Item(cm.Position).Row("HARGA") = Angka(IA(rs.Fields("HARGA").Value)) DataGrid1.CurrentCell = New DataGridCell(DataGrid1.CurrentCell.RowNumber, 2) Else '--- Pencarian Data Product berdasarkan Pesanan terdahulu atas supplier yang dipilih --query = "SELECT POD.KODE, POD.DESKRIPSI, FORMAT(POD.HARGA,0) AS HARGA FROM PESANANDETAIL POD " & _ "LEFT JOIN PESANAN PO ON POD.PESANAN_ID = PO.PESANAN_ID " & _ "WHERE POD.KODE = '" & IP(dv.Item(cm.Position).Row("KODE")) & "' " & _ "ORDER BY PO.TANGGAL DESC LIMIT 1 " Call SQLCommand(conn, rs, query) If Not rs.EOF Then dv.Item(cm.Position).Row("DESKRIPSI") = IP(rs.Fields("DESKRIPSI").Value) If IA(dv.Item(cm.Position).Row("HARGA").ToString) = 0 Then dv.Item(cm.Position).Row("HARGA") = Angka(IA(rs.Fields("HARGA").Value)) End If DataGrid1.CurrentCell = New DataGridCell(DataGrid1.CurrentCell.RowNumber, 2) End If End If End If End If End If End If End If End If ElseIf DataGrid1.CurrentCell.ColumnNumber = 2 Then If IP(dv.Item(cm.Position).Row("KODE")) = "" _ And IP(dv.Item(cm.Position).Row("DESKRIPSI")) <> "" Then ' --- cari data barang --'--- Pencarian Data Product berdasarkan Pesanan terdahulu atas supplier yang dipilih --query = "SELECT B.KODE, B.DESKRIPSI, FORMAT(POD.HARGA,0) AS HARGA FROM PENERIMAANDETAIL POD " & _ "LEFT JOIN PENERIMAAN PO ON POD.PENERIMAAN_ID = PO.PENERIMAAN_ID " & _ "LEFT JOIN SUPPLIER S ON PO.SUPPLIER_ID = S.SUPPLIER_ID " & _ "LEFT JOIN BARANG B ON POD.BARANG_ID = B.BARANG_ID " & _ "WHERE B.DESKRIPSI = '" & IP(dv.Item(cm.Position).Row("DESKRIPSI")) & "' " & _ "AND S.NAMA = '" & IP(TextSupplier.Text) & "' " & _ "ORDER BY PO.TANGGAL DESC LIMIT 1 ". 41 Analisis dan Perancangan ..., Kristian, FTI UMN, 2013.

(44) Call SQLCommand(conn, rs, query) If Not rs.EOF Then dv.Item(cm.Position).Row("KODE") = IP(rs.Fields("KODE").Value) If IA(dv.Item(cm.Position).Row("HARGA").ToString) = 0 Then dv.Item(cm.Position).Row("HARGA") = Angka(IA(rs.Fields("HARGA").Value)) End If Else '--- Pencarian Data Product berdasarkan PO tertentu tanpa melihat supplier yang dipilih --query = "SELECT B.KODE, B.DESKRIPSI, FORMAT(POD.HARGA,0) AS HARGA FROM PENERIMAANDETAIL POD " & _ "LEFT JOIN PENERIMAAN PO ON POD.PENERIMAAN_ID = PO.PENERIMAAN_ID " & _ "LEFT JOIN BARANG B ON POD.BARANG_ID = B.BARANG_ID " & _ "WHERE B.DESKRIPSI = '" & IP(dv.Item(cm.Position).Row("DESKRIPSI")) & "' " Call SQLCommand(conn, rs, query) If Not rs.EOF Then dv.Item(cm.Position).Row("KODE") = IP(rs.Fields("KODE").Value) If IA(dv.Item(cm.Position).Row("HARGA").ToString) = 0 Then dv.Item(cm.Position).Row("HARGA") = Angka(IA(rs.Fields("HARGA").Value)) End If DataGrid1.CurrentCell = New DataGridCell(DataGrid1.CurrentCell.RowNumber, 2) Else If IP(dv.Item(cm.Position).Row("DESKRIPSI")) <> "" Then ' --- cari data barang --query = "SELECT DISTINCT KODE, DESKRIPSI, FORMAT(HRGMODAL,0) AS HARGA FROM BARANG " & _ "WHERE DESKRIPSI = '" & IP(dv.Item(cm.Position).Row("DESKRIPSI")) & "' " & _ "AND STATUSAKTIF = 1 LIMIT 1 " Call SQLCommand(conn, rs, query) If Not rs.EOF Then dv.Item(cm.Position).Row("KODE") = rs.Fields("KODE").Value dv.Item(cm.Position).Row("HARGA") = Angka(IA(rs.Fields("HARGA").Value)) DataGrid1.CurrentCell = New DataGridCell(DataGrid1.CurrentCell.RowNumber, 2) Else '--- Pencarian Data Product berdasarkan Pesanan terdahulu atas supplier yang dipilih --query = "SELECT POD.KODE, POD.DESKRIPSI, FORMAT(POD.HARGA,0) AS HARGA FROM PESANANDETAIL POD " & _ "LEFT JOIN PESANAN PO ON POD.PESANAN_ID = PO.PESANAN_ID " & _ "WHERE POD.DESKRIPSI = '" & IP(dv.Item(cm.Position).Row("DESKRIPSI")) & "' " & _ "ORDER BY PO.TANGGAL DESC LIMIT 1 " Call SQLCommand(conn, rs, query) If Not rs.EOF Then dv.Item(cm.Position).Row("KODE") = IP(rs.Fields("KODE").Value) If IA(dv.Item(cm.Position).Row("HARGA").ToString) = 0 Then dv.Item(cm.Position).Row("HARGA") = Angka(IA(rs.Fields("HARGA").Value)) End If DataGrid1.CurrentCell = New DataGridCell(DataGrid1.CurrentCell.RowNumber, 2) End If End If End If End If End If End If End If If IsNumeric(IA(dv.Item(cm.Position).Row("QTY").ToString)) Then. 42 Analisis dan Perancangan ..., Kristian, FTI UMN, 2013.

(45) dv.Item(cm.Position).Row("QTY") = Angka(IA(dv.Item(cm.Position).Row("QTY").ToString)) End If If IsNumeric(IA(dv.Item(cm.Position).Row("HARGA").ToString)) Then dv.Item(cm.Position).Row("HARGA") = Angka(IA(dv.Item(cm.Position).Row("HARGA").ToString)) End If If IsNumeric(IA(dv.Item(cm.Position).Row("SUBTOTAL").ToString)) Then dv.Item(cm.Position).Row("SUBTOTAL") = Angka(IA(dv.Item(cm.Position).Row("SUBTOTAL").ToString)) End If Call Hitung_Total() End Sub Public Function Hitung_Total() As Integer Dim rs As New ADODB.Recordset Dim cm As CurrencyManager = Me.BindingContext(DataGrid1.DataSource, DataGrid1.DataMember) Dim dv As DataView = CType(cm.List, DataView) Dim pos As Integer = 0 Dim total As Double = 0 Dim TotalQty As Double = 0 While pos < cm.Count If IP(dv.Item(pos).Row("DESKRIPSI").ToString) <> "" Then dv.Item(pos).Row("DESKRIPSI") = IP(dv.Item(pos).Row("DESKRIPSI").ToString.ToUpper) End If If Not IsNumeric(IA(dv.Item(pos).Row("QTY").ToString)) And _ dv.Item(pos).Row("QTY").ToString <> "" Then WarningMsgBox("QTY Harus Dalam Angka!") DataGrid1.Select(pos) Return -1 Else dv.Item(pos).Row("QTY") = Angka(IA(dv.Item(pos).Row("QTY").ToString)) End If If Not IsNumeric(IA(dv.Item(pos).Row("HARGA").ToString)) And _ dv.Item(pos).Row("HARGA").ToString <> "" Then WarningMsgBox("HARGA Harus Dalam Angka!") DataGrid1.Select(pos) Return -1 Else dv.Item(pos).Row("HARGA") = Angka(IA(dv.Item(pos).Row("HARGA").ToString)) End If total += IA(dv.Item(pos).Row("QTY").ToString) * IA(dv.Item(pos).Row("HARGA").ToString) dv.Item(pos).Row("SUBTOTAL") = Angka(IA(dv.Item(pos).Row("QTY").ToString) * IA(dv.Item(pos).Row("HARGA").ToString)) TotalQty += IA(dv.Item(pos).Row("QTY").ToString) pos += 1 End While. 43 Analisis dan Perancangan ..., Kristian, FTI UMN, 2013.

(46) TextTotalItem.Text = Angka(cm.Count) TextTotalQty.Text = Angka(TotalQty) TextTotal.Text = Angka(total) Return 1 End Function Sub Clear_Data() Dim cm As CurrencyManager = Me.BindingContext(DataGrid1.DataSource, DataGrid1.DataMember) Dim dv As DataView = CType(cm.List, DataView) Dim pos As Integer = cm.Count - 1 While (pos > -1) cm.RemoveAt(pos) pos -= 1 End While TextSupplier.Text = "" LabelAlamat.Text = "" DateTanggal.Text = Now.Date TextTotalItem.Text = 0 TextTotalQty.Text = 0 TextTotal.Text = 0 TextKeterangan.Text = "" LabelEdit.Visible = False DateTanggal.Select() End Sub Private Sub ButtonUlang_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonUlang.Click Dim question As String = "Ingin Diulang?" Dim answer As Boolean = AskMsgBox(question) If (answer = True) Then Call Clear_Data() End If End Sub Function Clean_Up(ByVal tipe As Integer) As Integer Dim cm As CurrencyManager = Me.BindingContext(DataGrid1.DataSource, DataGrid1.DataMember) Dim dv As DataView = CType(cm.List, DataView) Dim pos As Integer = 0 While pos < cm.Count Dim NamaStr As String = IP(dv.Item(pos).Row("DESKRIPSI").ToString) Dim jumlahStr As Double = IA(dv.Item(pos).Row("QTY").ToString) Dim hargaStr As Double = IA(dv.Item(pos).Row("HARGA").ToString) If NamaStr = "" Then WarningMsgBox("DESKRIPSI Tidak Boleh Kosong") DataGrid1.Select(pos). 44 Analisis dan Perancangan ..., Kristian, FTI UMN, 2013.

(47) Return -1 ElseIf Not IsNumeric(IA(jumlahStr)) Then WarningMsgBox("QTY Harus Dalam Angka!") DataGrid1.Select(pos) Return -1 ElseIf Not IsNumeric(IA(hargaStr)) Then WarningMsgBox("HARGA Harus Dalam Angka!") DataGrid1.Select(pos) Return -1 End If pos += 1 End While Return 1 End Function Function Check_Value() As Boolean If Hitung_Total() = -1 Then Return False If Clean_Up(0) = -1 Then Return False If PanelBuat.Visible = True Then If TextSupplier.Text = "" Then WarningMsgBox("Supplier Tidak Boleh Kosong") TextSupplier.Focus() Return False Else query = "SELECT * FROM SUPPLIER WHERE NAMA = '" & IP(TextSupplier.Text) & "' AND STATUSAKTIF = 1 " Call SQLCommand(conn, rs, query) If rs.EOF Then query = "SELECT * FROM SUPPLIER WHERE NAMA = '" & IP(TextSupplier.Text) & "' " Call SQLCommand(conn, rs, query) If rs.EOF Then WarningMsgBox("Supplier Belum Terdaftar Dalam Database") Call Highlight_Text(TextSupplier) Return False Else WarningMsgBox("Supplier Sudah Tidak Aktif." & vbNewLine & "Silahkan Ubah Master Supplier Terlebih Dahulu") Call Highlight_Text(TextSupplier) Return False End If End If End If End If Return True End Function Private Sub ButtonSimpan_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonSimpan.Click If Check_Value() Then. 45 Analisis dan Perancangan ..., Kristian, FTI UMN, 2013.

(48) Try conn.Execute("BEGIN") LabelID.Text = Generate_Nomor(conn, DateTanggal.Value, "PESANAN", "P") Call Input_Value(IP(LabelID.Text)) Call Insert_Log(conn, "MEMBUAT PESANAN", FormMain.userLevel.nama, "PESANAN", LabelID.Text) conn.Execute("COMMIT") ShowMsgBox("Pesanan " & LabelID.Text & " Berhasil Disimpan") Call Clear_Data() LabelID.Text = Generate_Nomor(conn, DateTanggal.Value, "PESANAN", "P") Catch ex As Exception conn.Execute("ROLLBACK") WarningMsgBox("Data Eror. " & ex.Message) End Try End If End Sub Private Sub Input_Value(ByVal IDPO As String) Dim rs As New ADODB.Recordset Dim rs3 As New ADODB.Recordset Dim tanggal As Date = DateTanggal.Value Dim Supplier_ID As String = "" query = "select supplier_id from supplier where nama = '" & IP(TextSupplier.Text) & "'" Call SQLCommand(conn, rs, query) If Not rs.EOF Then Supplier_ID = IP(rs.Fields(0).Value) Dim cm As CurrencyManager = Me.BindingContext(DataGrid1.DataSource, DataGrid1.DataMember) Dim dv As DataView = CType(cm.List, DataView) Dim pos As Integer = 0 While pos < cm.Count Dim Cd As String = IP(dv.Item(pos).Row("KODE").ToString.ToUpper) Dim Descp As String = IP(dv.Item(pos).Row("DESKRIPSI").ToString.ToUpper) Dim Qty As Double = IA(dv.Item(pos).Row("QTY").ToString) Dim Price As Double = IA(dv.Item(pos).Row("HARGA").ToString) query = "INSERT INTO PESANANDETAIL (" & AN(conn, "PESANANDETAIL") & ") VALUES ('" & _ Cd & "','" & Descp & "'," & Qty & ",0," & _ Price & ",0,'" & IDPO & "')" conn.Execute(query) pos += 1 End While query = "INSERT INTO PESANAN VALUES ('" & IDPO & _. 46 Analisis dan Perancangan ..., Kristian, FTI UMN, 2013.

Referensi

Dokumen terkait

Analisa menggunakan metode analisis isi ( content analysis ); Metode ini merupakan analisis ilmiah mengenai isi pesan sebuah pemikiran. Hasil penelitian ini

Hasil penelitian adalah (1) proses pembelajaran pendidikan agama Islam guru mengunakan membuat RPP, menggunakan model pembelajaran, mengelola kelas, dan

Beban kerja DLP ditentukan dari jumlah peserta JKN yang masuk dalam daftar pesertanya (komunitas binaan). Pemanfaatan DLP oleh komunitas binaan ini dipengaruhi

Further examples of controlling manual handling risks by redesigning the workplace are shown below under the three category headings: Modifying Workplace Layout and

Berdasarkan hasil pengamatan (observasi), agar variabel sifat dapat menjadi satu kesatuan yang terintegrasi dan bersinergi membentuk kinerja yang efektif dalam

Proses menghitung jarak serta ketinggian sebuah objek digunakan tiga buah sensor ultrasonik, setiap sensor ultrasonik ditempatkan pada sebuah Nylon PT pan / tilt

Lalu mereka menutup kaca helm secara bersamaan pertanda siap untuk melaju dan memberikan pelukan kepada sang suami ―Yamaha N -Max momen terbaik bersama yang

Pengaruh penerapan model pembelajaran tutor sebaya dengan multimedia terhadap hasil belajar siswa pada materi operasi himpunan dan diagram venn. 2 Subjek SMP Islam