Contoh Aplikasi — Program Penjualan Dengan Vb.net 2008

' Load customer ke ComboBox Koneksi() da = New OleDbDataAdapter("SELECT id_customer, nama FROM customer", conn) dt = New DataTable() da.Fill(dt) cmbCustomer.DataSource = dt cmbCustomer.DisplayMember = "nama" cmbCustomer.ValueMember = "id_customer" TutupKoneksi() End Sub

Public Sub Koneksi() conn = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|\db_penjualan.mdb") If conn.State = ConnectionState.Closed Then conn.Open() End If End Sub contoh aplikasi program penjualan dengan vb.net 2008

' Kurangi stok cmd = New OleDbCommand("UPDATE barang SET stok = stok - @qty WHERE kode_barang = @kode", conn, trans) cmd.Parameters.AddWithValue("@qty", row("qty")) cmd.Parameters.AddWithValue("@kode", row("kode_barang")) cmd.ExecuteNonQuery() Next trans.Commit() MsgBox("Transaksi berhasil disimpan") dtDetail.Clear() total = 0 lblTotal.Text = "0" Catch ex As Exception trans.Rollback() MsgBox("Error: " & ex.Message) End Try TutupKoneksi() End Sub End Class Gunakan PrintDocument dan PrintPreviewDialog . Contoh sederhana untuk mencetak teks nota: ' Load customer ke ComboBox Koneksi() da =

Private Sub txtKodeBarang_KeyPress(sender As Object, e As KeyPressEventArgs) Handles txtKodeBarang.KeyPress If e.KeyChar = Chr(13) Then Koneksi() cmd = New OleDbCommand("SELECT nama_barang, harga FROM barang WHERE kode_barang=@kode", conn) cmd.Parameters.AddWithValue("@kode", txtKodeBarang.Text) rd = cmd.ExecuteReader() If rd.Read() Then txtNamaBarang.Text = rd("nama_barang").ToString() txtHarga.Text = rd("harga").ToString() Else MsgBox("Barang tidak ditemukan") End If rd.Close() TutupKoneksi() txtQty.Focus() End If End Sub nama FROM customer"

Imports System.Drawing.Printing Public Class frmNota Private WithEvents pd As New PrintDocument() Private teksNota As String