7:22 AM |
Category:
MULTIMEDIA
|
0
comments
Ini merupakan pembelajaran saya mengenai pembuatan software mesin kasir menggunakan software visual studio 2008.
Coding Pada Menu Form 1 :
Imports
System.Drawing.Bitmap
Public Class Form1
Inherits
System.Windows.Forms.Form
Public
gambar As String
Dim
objekhitung As New
Hitung
Private Sub tampil()
objekhitung.buka()
objekhitung.cmd = New OleDb.OleDbCommand
objekhitung.cmd.Connection =
objekhitung.cn
objekhitung.cmd.CommandText = " Select*from baju"
objekhitung.da = New OleDb.OleDbDataAdapter
objekhitung.da.SelectCommand =
objekhitung.cmd
objekhitung.ds = New DataSet
objekhitung.da.Fill(objekhitung.ds, "baju")
DataGridView1.DataSource =
objekhitung.ds
DataGridView1.DataMember = "baju"
DataGridView1.ReadOnly = True
objekhitung.tutup()
End Sub
Private Sub Form1_Load(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
gambar = "C:\Users\Acer\Google
Drive\visual 1\pertemuan 10 (lanjutan pertemuan 9)\picture\"
jenis_baju.Items.Add("Kaos")
jenis_baju.Items.Add("Tshirt")
jenis_baju.Items.Add("Gaun")
jenis_baju.Items.Add("Kemeja")
jenis_baju.Items.Add("Blouse")
ukuran.Items.Add("S")
ukuran.Items.Add("M")
ukuran.Items.Add("L")
ukuran.Items.Add("XL")
ukuran.Items.Add("XXL")
'deklarasi
tampil'
objekhitung.tampung_harga =
Val(harga.Text)
objekhitung.tampung_jumlah =
Val(jumlah_beli.Text)
objekhitung.tampung_diskon =
Val(diskon.Text)
tampil()
End Sub
Private Sub jenis_baju_SelectedIndexChanged(ByVal sender As
System.Object, ByVal e As
System.EventArgs) Handles
jenis_baju.SelectedIndexChanged
If
jenis_baju.Text = "Kaos" Then
PictureBox1.SizeMode =
PictureBoxSizeMode.StretchImage
PictureBox1.Image = FromFile(gambar
+ "kaos.jpg")
ElseIf
jenis_baju.Text = "Tshirt" Then
PictureBox1.SizeMode =
PictureBoxSizeMode.StretchImage
PictureBox1.Image = FromFile(gambar
+ "tshirt.jpg")
ElseIf
jenis_baju.Text = "Gaun" Then
PictureBox1.SizeMode =
PictureBoxSizeMode.StretchImage
PictureBox1.Image = FromFile(gambar
+ "gaun.jpg")
ElseIf
jenis_baju.Text = "Kemeja" Then
PictureBox1.SizeMode =
PictureBoxSizeMode.StretchImage
PictureBox1.Image = FromFile(gambar
+ "kemeja.jpg")
Else
PictureBox1.SizeMode =
PictureBoxSizeMode.StretchImage
PictureBox1.Image = FromFile(gambar
+ "blouse.jpg")
End If
ukuran.Focus()
End Sub
Private Sub ID_KeyPress(ByVal
sender As Object,
ByVal e As
System.Windows.Forms.KeyPressEventArgs) Handles
ID.KeyPress
If
e.KeyChar = Chr(13) Then
nama.Focus()
End If
End Sub
Private Sub nama_KeyPress(ByVal
sender As Object,
ByVal e As
System.Windows.Forms.KeyPressEventArgs) Handles
nama.KeyPress
If
e.KeyChar = Chr(13) Then
no_tlp.Focus()
End If
End Sub
Private Sub no_tlp_KeyPress(ByVal
sender As Object,
ByVal e As
System.Windows.Forms.KeyPressEventArgs) Handles
no_tlp.KeyPress
If
e.KeyChar = Chr(13) Then
jenis_baju.Focus()
End If
End Sub
Private Sub diskon_KeyPress(ByVal
sender As Object,
ByVal e As
System.Windows.Forms.KeyPressEventArgs) Handles
diskon.KeyPress
If
e.KeyChar = Chr(13) Then
objekhitung.tampung_harga =
Val(harga.Text)
objekhitung.tampung_jumlah =
Val(jumlah_beli.Text)
objekhitung.tampung_diskon =
Val(diskon.Text)
total.Text = objekhitung.hitungan
End If
End Sub
Private Sub tutup_aplikasi_Click(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles tutup_aplikasi.Click
Me.Close()
End Sub
Private Sub simpan_Click(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles simpan.Click
' proses
simpan data'
objekhitung.cmd = New OleDb.OleDbCommand
objekhitung.buka()
objekhitung.cmd.CommandType =
CommandType.Text
objekhitung.cmd.CommandText = " insert into baju
(IDPEL,nama,jbaju,ukuran,harga,jumlah,tgl_beli) values (' " &
ID.Text & " ',' " &
nama.Text & " ',' " &
jenis_baju.Text & " ',' "
& ukuran.Text & " ',' "
& harga.Text & " ',' "
& jumlah_beli.Text & " ',' "
& DateTimePicker1.Text & " ')"
objekhitung.cmd.ExecuteNonQuery()
objekhitung.tutup()
objekhitung.ds.Clear()
tampil()
MsgBox("
Data Telah Tersimpan !", 64, "Informasi")
End Sub
End Class
CODING PADA MENU CLASS :
Option Explicit On
Option Strict On
Public Class Hitung
Public cn As New
OleDb.OleDbConnection
Public cmd As New
OleDb.OleDbCommand
Public dr As OleDb.OleDbDataReader
Public da As OleDb.OleDbDataAdapter
Public ds As New DataSet
Public Sub buka()
cn = New
OleDb.OleDbConnection
cn.ConnectionString = "provider=microsoft.ace.oledb.12.0;data source=
C:\Users\Acer\Google Drive\visual 1\pertemuan 10 (lanjutan pertemuan
9)\database.accdb"
cn.Open()
cmd.Connection = cn
End Sub
Public Sub tutup()
If Not cn Is Nothing Then
cn.Close()
cn = Nothing
End If
End Sub
'variabelnya
Private
diskon, harga As Single
Private
jumlah As Integer
Private
ttlbayar As Single
'pemesanan
property
Public Property tampung_harga() As
Single
Get
Return
harga
End Get
Set(ByVal value As Single)
harga = value
End Set
End Property
Public Property tampung_diskon() As
Single
Get
Return
diskon
End Get
Set(ByVal value As Single)
diskon = value
End Set
End Property
Public Property tampung_jumlah() As
Integer
Get
Return
jumlah
End Get
Set(ByVal value As Integer)
jumlah = value
End Set
End Property
'procedure
Public Function hitungan() As
Single
Return
(harga - (harga * diskon / 100)) * jumlah
End Function
End Class
8:57 PM |
Category:
Pemrograman Visual 1
|
0
comments