Contohh kode Print Preview Nota Pada vb.net

Sub ViewReport()
objDataTable.Clear()
strSQL = "Select * from Q_Invoice Where Invoice " & _
" = '" & Trim(txtInvoice.Text) & "' Order by ID_Penjualan asc"
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

-----------------------------------------------------------------------------------------------------------

eksekusi kode untuk mengirim data ke cristalreport dari hasil pencarian diatas

Dim rdInvoice As New CrNota
Dim c As New FR_Report
' call ViewReport()
rdInvoice.SetDataSource(objDataTable)
c.CrystalReportViewer1.ReportSource = rdInvoice
'Melakukan print nota
rdInvoice.PrintToPrinter(1, True, 1, 2)
rdInvoice.Refresh()
MsgBox("Transaksi telah disimpan", MsgBoxStyle.Information, "")

Catch When Err.Number <> 0
MsgBox("Program error" _
& vbCrLf & Err.Description)
MyConnection.close()
End Try

---------------------------------------------------------------------------------------

contoh II:

Try
Dim i, Sisa, DisPersen As Integer
Dim DisRp As Double
'jika pada ListView = 0
If LstTransaksi.Items.Count = 0 Then
MsgBox("Lakukan transaksi penjualan", _
MsgBoxStyle.Exclamation, "")
Exit Sub
End If
'mencari Invoice No berdasarkan Invoice No
CekInvoice2()
'Jika Invoice No >=1
If objDataTable.Rows.Count >= 1 Then
MsgBox("Nomor Invoice sudah ada pada table", _
MsgBoxStyle.Exclamation, "")
Exit Sub
End If
'Menyimpan seluruhdata pembelian yang ada pada ListView
'Dengan melakukan pengulangan
For i = 0 To (LstTransaksi.Items.Count - 1)
MyConnectionPenjualan.AccessPenjualanInsert(Trim(txtInvoice.Text), _
dtTgl_Invoice.Text, _
LstTransaksi.Items(i).Text, _
LstTransaksi.Items(i).SubItems(2).Text, _
LstTransaksi.Items(i).SubItems(4).Text, _
LstTransaksi.Items(i).SubItems(5).Text, _
LstTransaksi.Items(i).SubItems(6).Text)

'menampilkan stok brang berdasarkan Kode Brg
objCommand = MyConnection.open.CreateCommand
objCommand.CommandText = "select Stok from Barang Where Kode_Brg " & _
" = '" & Trim(LstTransaksi.Items(i).Text) & "';"
objdatareader = objCommand.ExecuteReader
objdatareader.Read()
Stok = objdatareader.Item("Stok").ToString
MyConnection.close()
'Mengurangi Stok brg dengan jlh pembelian
Sisa = Stok - Val(LstTransaksi.Items(i).SubItems(2).Text)
'Mengupdate stok brg
'dengan hasil pengurangan diatas
MyConnectionBarang.AccessBarangUpdateStok _
(Trim(LstTransaksi.Items(i).Text), Sisa)
Sisa = Nothing
Stok = Nothing
Next i

If txtTotDisPersen.Text = "" Then
DisPersen = 0
Else
DisPersen = txtTotDisPersen.Text
End If
If txtTotDisRp.Text = "" Then
DisRp = 0
Else
DisRp = txtTotDisRp.Text
End If
'Menyimpan Total penjualan
MyConnectionTotalPenjualan.AccessTotalPenjualanInsert _
(Trim(txtInvoice.Text), _
DisPersen, DisRp, txtTotalHarga.Text, Username, Now)

Dim rdInvoice As New CrNota
Dim c As New FR_Report
'Menampilkan data pada Q_Invoice
'berdasarkan Invoice No
ViewReport()
rdInvoice.SetDataSource(objDataTable)
c.CrystalReportViewer1.ReportSource = rdInvoice
'Melakukan print nota
rdInvoice.PrintToPrinter(1, True, 1, 2)
rdInvoice.Refresh()
MsgBox("Transaksi telah disimpan", MsgBoxStyle.Information, "")

Catch When Err.Number <> 0
MsgBox("Program error" _
& vbCrLf & Err.Description)
MyConnection.close()
End Try

Comments
0 Comments

0 komentar:

Posting Komentar

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