Assalamu'alaikum wr wb
Apakabar nii sobat sobat Programmer yang selalu digelutin Masalah hahahaa :D
Sekarang ane mauu berbagi cara untuk membuat :
Nomor Faktur, Kode Barang, Kode Petugas atau Kode Supplier Otomatis.
Oke deh langsung aja gan ngga usah banyak Cing Cong hahay :D
Private Sub NofakMatis()
Dim Conn As SqlConnection
Dim Da As SqlDataAdapter
Dim Ds As DataSet
Dim Rd As SqlDataReader
Dim Cmd As SqlCommand
Dim _Urutan As String
Dim _Hitung, _Cari As Long
Cmd = New SqlCommand("Select * from pembelian where faktur in " & _
"(select max (faktur)from pembelian)", Conn)
Rd = Cmd.ExecuteReader
Rd.Read()
If Not Rd.HasRows Then
_Urutan = "00000001"
Else
_Cari = Rd.GetString(0)
_Hitung = Rd.GetValue(0) + 1
_Urutan = Format(Hitung, "00000000")
End If
Rd.Close()
TxtNofak.Text = _Urutan
End Sub
NAH .. ini dia hasilnya gan,
Jika ingin menambahkan Karakter berupa String atau Sebagainya agan bisa menggunakan Source Code ini
Private Sub NofakMatis()
Dim Conn As SqlConnection
Dim Da As SqlDataAdapter
Dim Ds As DataSet
Dim Rd As SqlDataReader
Dim Cmd As SqlCommand
Dim _Urutan As String
Dim _Hitung, _Cari As Long
Cmd = New SqlCommand("Select * from pembelianNon where fakturNon in " & _
"(select max (fakturNon)from pembelianNon)", Conn)
Rd = Cmd.ExecuteReader
Rd.Read()
If Not Rd.HasRows Then
_Urutan = "SIJ/" & Date.Now.Year & "/" & "000001"
Else
_Cari = Microsoft.VisualBasic.Right(Rd.GetString(0), 6)
If Microsoft.VisualBasic.Left(Rd.GetString(0), 9) <> "SIJ/" & Date.Now.Year & "/" Then
_Urutan = "SIJ/" & Date.Now.Year & "/" & "000001"
Else
_Hitung = Microsoft.VisualBasic.Right(Rd.GetString(0), 6) + 1
_Urutan = "SIJ/" & Date.Now.Year & "/" & Microsoft.VisualBasic.Right("000000" & Hitung, 6)
End If
End If
Rd.Close()
TxtNofak.Text = _Urutan
End Sub
NAH .. ini dia hasilnya gan ada Format Tahunnya,
Jangan lupa dipanggil NofakMatisnya pada FormLoad()
Private Sub FrmPembelian_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) _
Handles MyBase.Load
BukaDB()
NofakMatis()
End Sub
Makasih gan udh mampir :D jangan lupa Komennya yooo,
kalo ada Error pada Programnya komen aja gan barang kali saya bisa bantu :D
kita Sharing barang.
Sama - sama masih Belajar ehehehe :D
Apakabar nii sobat sobat Programmer yang selalu digelutin Masalah hahahaa :D
Sekarang ane mauu berbagi cara untuk membuat :
Nomor Faktur, Kode Barang, Kode Petugas atau Kode Supplier Otomatis.
Oke deh langsung aja gan ngga usah banyak Cing Cong hahay :D
Private Sub NofakMatis()
Dim Conn As SqlConnection
Dim Da As SqlDataAdapter
Dim Ds As DataSet
Dim Rd As SqlDataReader
Dim Cmd As SqlCommand
Dim _Urutan As String
Dim _Hitung, _Cari As Long
Cmd = New SqlCommand("Select * from pembelian where faktur in " & _
"(select max (faktur)from pembelian)", Conn)
Rd = Cmd.ExecuteReader
Rd.Read()
If Not Rd.HasRows Then
_Urutan = "00000001"
Else
_Cari = Rd.GetString(0)
_Hitung = Rd.GetValue(0) + 1
_Urutan = Format(Hitung, "00000000")
End If
Rd.Close()
TxtNofak.Text = _Urutan
End Sub
NAH .. ini dia hasilnya gan,
Jika ingin menambahkan Karakter berupa String atau Sebagainya agan bisa menggunakan Source Code ini
Private Sub NofakMatis()
Dim Conn As SqlConnection
Dim Da As SqlDataAdapter
Dim Ds As DataSet
Dim Rd As SqlDataReader
Dim Cmd As SqlCommand
Dim _Urutan As String
Dim _Hitung, _Cari As Long
Cmd = New SqlCommand("Select * from pembelianNon where fakturNon in " & _
"(select max (fakturNon)from pembelianNon)", Conn)
Rd = Cmd.ExecuteReader
Rd.Read()
If Not Rd.HasRows Then
_Urutan = "SIJ/" & Date.Now.Year & "/" & "000001"
Else
_Cari = Microsoft.VisualBasic.Right(Rd.GetString(0), 6)
If Microsoft.VisualBasic.Left(Rd.GetString(0), 9) <> "SIJ/" & Date.Now.Year & "/" Then
_Urutan = "SIJ/" & Date.Now.Year & "/" & "000001"
Else
_Hitung = Microsoft.VisualBasic.Right(Rd.GetString(0), 6) + 1
_Urutan = "SIJ/" & Date.Now.Year & "/" & Microsoft.VisualBasic.Right("000000" & Hitung, 6)
End If
End If
Rd.Close()
TxtNofak.Text = _Urutan
End Sub
NAH .. ini dia hasilnya gan ada Format Tahunnya,
Jangan lupa dipanggil NofakMatisnya pada FormLoad()
Private Sub FrmPembelian_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) _
Handles MyBase.Load
BukaDB()
NofakMatis()
End Sub
Makasih gan udh mampir :D jangan lupa Komennya yooo,
kalo ada Error pada Programnya komen aja gan barang kali saya bisa bantu :D
kita Sharing barang.
Sama - sama masih Belajar ehehehe :D
Me Thai Lasho
BalasHapusgan, pas mau di save kog error ya...
BalasHapusString or binary data would be truncated.
mohon solusinya...
Tipe datanya itu gan, pake char atau varchar aja, disini ane pake char (15)
BalasHapusTipe datanya itu gan, pake char atau varchar aja, disini ane pake char (15)
BalasHapusgan kalau pengen kode barang itu tergantung jenis gimana? misal jenis A kode nya A001 apabila jenis B kodenya B001
BalasHapuskk,ku membuat from login admin errornya di conn.open sama rd=cmd executereader
BalasHapusImports System.Data.OleDb
Module Module1
Public conn As OleDbConnection
Public cmd As OleDbCommand
Public rd As OleDbDataReader
Public da As OleDbDataAdapter
Public ds As DataSet
Public Sub koneksi()
conn = New OleDbConnection("provider=microsoft.jet.oledb.4.0;datasource=dbpenjualan1.mdb")
conn.Open()
End Sub
End Module
Imports System.Data.OleDb
Public Class F1_LOGIN
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
End
End Sub
Private Sub TextBox1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress
If e.KeyChar = Chr(13) Then TextBox2.Focus()
End Sub
Private Sub TextBox2_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox2.KeyPress
If e.KeyChar = Chr(13) Then Button1.Focus()
End Sub
Private Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
If TextBox1.Text = "" Or TextBox2.Text = "" Then
MsgBox("Data login belum lengkap")
TextBox1.Focus()
Exit Sub
Else
cmd = New OleDbCommand("Select * from tb_Admin Where Nama_Admin="" & Textbox1.Text &"" Textbox2.Text & '", conn)
rd = cmd.ExecuteReader
rd.Read()
If rd.HasRows Then
MsgBox("anda berhasil melakukan login", MsgBoxStyle.Information)
Else
MsgBox("Nama atau password yang anda masukan salah", MsgBoxStyle.Critical)
TextBox1.Focus()
Exit Sub
End If
End If
End Sub
Private Sub F1_LOGIN_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
TextBox1.Text = ""
TextBox2.Text = ""
Call koneksi()
End Sub
End Class
tolong dong bantu aku kk
ku pusing nyri kesalahannya dimana
kak bisa posting source code biar bisa memunculkan data berulang di datagrid, dalam satu no faktur yang sama
BalasHapusBRO kalau nomor urut berdasarkan tanggal contoh pada tanggal 1 bulan january 0101001 terdapat data smpai nomor 50 maka 0101001-0101050 maka setelah ganti tanggal 2 january nomor urutnya harus berubah ke 0201001 or nourut kembali ke 1 lagi gmn bro?? ane lagi cari code nya nih . need help.
BalasHapusKenapa nomernya gx bertambah satu master, masa no invoicenya itu2 aja,
BalasHapusKenapa nomernya gx bertambah satu master, masa no invoicenya itu2 aja,
BalasHapuskalau mau buat nomor otomatis dengan format test/mkm2/X/2017/00001, tapi missal ganti bulan no urutnya terus berlanjut tidak dari awal lg gimana ya ?
BalasHapuskalau misalkan ingin membuat kode otomatis namun berdasarkan Tanggal aja Misalkan Sekarang Tanggal 16/04/18 nah tanggal itu jadi kode otomatisnya jadinya formatnya tanpa / itu,terus ngikutin tanggal di kalender komputer gimna ??
BalasHapusApa boleh minta sourcode aplikasinya untuk bahan pelajaran?
BalasHapusImports System.Data.SqlClient.SqlCommand
BalasHapusImports System.Data.SqlClient.SqlConnection
Imports System.Data.SqlClient
Public Class Form1
Dim Rd As SqlDataReader
Dim Cmd As SqlCommand
Dim Urutan As String
Dim Hitung, Cari As Long
Sub tampilkan()
da = New SqlDataAdapter("Select * from tadmintesnomor order by idadmin", Conn)
ds = New DataSet
ds.Clear()
da.Fill(ds, "tadmin")
DataGridView1.DataSource = (ds.Tables("tadmin"))
DataGridView1.ReadOnly = True
End Sub
Private Sub otomatisfak()
Koneksisql()
Cmd = New SqlCommand("Select * from tadmintesnomor where idadmin in " & _
"(select max (idadmin)from tadmintesnomor)", Conn)
Koneksisql()
Rd = Cmd.ExecuteReader
Rd.Read()
Koneksisql()
If Not Rd.HasRows Then
Urutan = "SIJ/" & Date.Now.Year & "/" & "000001"
Else
Cari = Microsoft.VisualBasic.Right(Rd.GetString(0), 6)
If Microsoft.VisualBasic.Left(Rd.GetString(0), 9) <> "SIJ/" & Date.Now.Year & "/" Then
Urutan = "SIJ/" & Date.Now.Year & "/" & "000001"
Else
Hitung = Microsoft.VisualBasic.Right(Rd.GetString(0), 6) + 1
Urutan = "SIJ/" & Date.Now.Year & "/" & Microsoft.VisualBasic.Right("000000" & Hitung, 6)
End If
End If
Rd.Close()
tid.Text = Urutan
End Sub
' Private Sub Form1_activated(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Me.Activated
' Koneksisql()
' otomatisfak()
' tampilkan()
'End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
Me.Close()
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If tid.Text = "" Or tnama.Text = "" Or tpass.Text = "" Or tstatus.Text = "" Then
MsgBox("Data Belum Lengkap")
Exit Sub
Else
Koneksisql()
Cmd = New SqlCommand("Select * from tadmintesnomor where idadmin='" & tid.Text & "'", Conn)
Rd = Cmd.ExecuteReader
Rd.Read()
If Not Rd.HasRows Then
Koneksisql()
Dim sqltambah As String = "Insert into tadmintesnomor(idadmin,usernameadmin,passwordadmin,statusadmin) values " & _
"('" & tid.Text & "','" & tnama.Text & "','" & tpass.Text & "','" & tstatus.Text & "')"
Cmd = New SqlCommand(sqltambah, Conn)
Cmd.ExecuteNonQuery()
tampilkan()
otomatisfak()
Else
Koneksisql()
Dim sqledit As String = "Update tadmintesnomor set " & _
"usernameadmin='" & tnama.Text & "', " & _
"passwordadmin='" & tpass.Text & "', " & _
"statusadmin='" & tstatus.Text & "' where idadmin='" & tid.Text & "'"
Cmd = New SqlCommand(sqledit, Conn)
Cmd.ExecuteNonQuery()
otomatisfak()
End If
End If
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
otomatisfak()
tampilkan()
End Sub
End Class
"Ini kode yang ane buat pakai sqlserver, dikombinasikan dengan yang ente buat gan. hasilnya no faktur muncul tapi ane mau pas ganti tanggal itu nomor fakturnya ganti ke 1 lagi , itu bisa bantu gan? caranya gmn ya ane pakai sql server"