Contoh kode Membuat nomor invoice pada vb.net

Kode di tulis didalam sebuah region

Sub CekInvoice()
objDataTable.Clear()
strSQL = "Select * from Penjualan Where Tgl_Invoice = #" & dtTgl_Invoice.Text & "# Order by Invoice Desc"
objCommand =
New OleDbCommand
objCommand.Connection = MyConnection.open
objCommand.CommandType = CommandType.Text
objCommand.CommandText = strSQL
objDataAdapter = New OleDbDataAdapter(objCommand)
objDataAdapter.Fill(objDataSet, "MDT_Penjualan")
MyConnection.close()
objDataTable = objDataSet.Tables("MDT_Penjualan")
End Sub
-----------------------------------------------------------------------------------------

Private Sub btnInvoice_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnInvoice.Click
Try
Dim Invoice As String
'Mengecek jumlah Invoice berdasarkan tanggal
call CekInvoice()
If objDataTable.Rows.Count = 0 Then
'jika jlh invoice = 0
'maka nomor invoice 1 dan dikuti dengan Tgl
txtInvoice.Text = "1-" & Trim(dtTgl_Invoice.Text)
Else
'jika lebih
'tampilkan no Invoice yang terkahir
With objDataTable.Rows(0)
Invoice = .Item("Invoice")
End With
'menammbahkan nomor invoice terakhir dengan 1
' dan diikuti dengan tgl invoice
txtInvoice.Text = Val(Microsoft.VisualBasic.Left _
(Invoice, (Len(Invoice) - 11))) + 1 & "-" & Trim(dtTgl_Invoice.Text)
End If
txtKode_Brg.Focus()
Catch When Err.Number <> 0
MsgBox("Program error" _
& vbCrLf & Err.Description)
MyConnection.close()
End Try
End Sub

------------------------------------------------------------------------------------------------
Comments
0 Comments

0 komentar:

Posting Komentar

Apabila ada Pertanyaan maka silakan tanggalkan komentar anda..
hal-hal yang melanggar hukum menjadi tanggung jawab komentator.