Tuesday, 24 October 2017

Contoh Program Kasir

Contoh Source Code:

Form 1

Public Class Form1

    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        CMBPRODUCT.Items.Add("Buku")
        CMBPRODUCT.Items.Add("Tas")
        CMBPRODUCT.Items.Add("Dompet")
        CMBPRODUCT.Items.Add("Alat Tulis")
        TBHARGA.Text = "0"
        TBQTY.Text = "1"
        TBTOTAL.Text = "0"
        TBTOTAL2.Text = "0"
        TBTOTAL2.Visible = False
    End Sub

    Private Sub CMBPRODUCT_SelectedIndexChanged(sender As Object, e As EventArgs) Handles CMBPRODUCT.SelectedIndexChanged
        If CMBPRODUCT.Text = "Buku" Then
            TBHARGA.Text = "2000"
            TBTOTAL.Text = "2000"
        ElseIf CMBPRODUCT.Text = "Tas" Then
            TBHARGA.Text = "100000"
            TBTOTAL.Text = "100000"
        ElseIf CMBPRODUCT.Text = "Dompet" Then
            TBHARGA.Text = "50000"
            TBTOTAL.Text = "50000"
        ElseIf CMBPRODUCT.Text = "Alat Tulis" Then
            TBHARGA.Text = "10000"
            TBTOTAL.Text = "10000"
        End If
    End Sub

    Private Sub TBQTY_TextChanged(sender As Object, e As EventArgs) Handles TBQTY.TextChanged
        Dim harga, qty As Integer
        harga = Convert.ToInt32(TBHARGA.Text)
        If TBQTY.Text <> "" Then
            qty = Convert.ToInt32(TBQTY.Text)
        Else
            qty = 1
        End If
        TBTOTAL.Text = harga * qty
    End Sub

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        Dim total, total2 As Integer
        LBBELANJA.Items.Add(CMBPRODUCT.Text)
        LBBELANJA.Items.Add(TBHARGA.Text)
        LBBELANJA.Items.Add(TBQTY.Text)
        LBBELANJA.Items.Add(TBTOTAL.Text)
        LBBELANJA.Items.Add("")
        If TBTOTAL2.Text = "" Then
            TBTOTAL2.Text = TBTOTAL.Text
        Else
            total2 = Convert.ToInt32(TBTOTAL.Text)
            total = Convert.ToInt32(TBTOTAL2.Text)
            TBTOTAL2.Text = total2 + total
        End If
    End Sub

    Private Sub BTNEXIT_Click(sender As Object, e As EventArgs) Handles BTNEXIT.Click
        Close()
    End Sub

    Private Sub BTNBAYAR_Click(sender As Object, e As EventArgs) Handles BTNBAYAR.Click
        Form2.TextBox1.Text = TBTOTAL2.Text
        Form2.Show()
    End Sub
End Class

Form 2

Public Class Form2

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        Dim total, bayar, kembali As Integer
        total = Convert.ToInt32(TextBox1.Text)
        bayar = Convert.ToInt32(TextBox2.Text)
        If bayar < total Then
            MessageBox.Show("Maaf, Pembayaran Anda Kurang")
        ElseIf bayar > total Then
            kembali = bayar - total
            MessageBox.Show("Terimakasih, anda mendapat kembalian sebanyak " & Convert.ToString(kembali))
        Else
            MessageBox.Show("Terimakasih")
        End If
    End Sub
End Class

No comments:

Post a Comment

Odoo 11 - Create a new sample module

How To Create or Develop a Custom Module in Odoo 11 In this blog, we‘ll be focusing on how we can create or develop a custom mo...