Friday, February 22, 2019

Groceries Store Software | vb.net

Groceries Store Software using vb.net

                   Watch the video available on YouTube:






More information about this video(coding):

Public Class Form1
    Const Price_MatchBox As Decimal = 1.0
    Const Price_Eggs As Decimal = 5.0
    Const Price_Milk As Decimal = 25
    Const Price_Cheese As Decimal = 20
    Const Price_Rice As Decimal = 26
    Const Price_Bread As Decimal = 12

    Dim itemcost(5) As Decimal
    Dim iTotal As Decimal


    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        txtTotal.Text = "₹0"
    End Sub

    Private Sub BtnExit_Click(sender As Object, e As EventArgs) Handles BtnExit.Click
        Dim iExit As DialogResult
        iExit = MessageBox.Show("Confirm if You want to Exit", "VS Programs", MessageBoxButtons.YesNo, MessageBoxIcon.Question)

        If iExit = DialogResult.Yes Then

            Application.Exit()
        End If
    End Sub

    Private Sub BtnClear_Click(sender As Object, e As EventArgs) Handles BtnClear.Click
        For Each chk In {ChkMatchBox, ChkEggs, ChkMilk, ChkCheese, ChkRice, ChkBread}
            chk.Checked = False
        Next
        txtTotal.Text = "₹0"
        txtReceipt.Clear()

    End Sub

    Private Sub ChkMatchBox_CheckedChanged(sender As Object, e As EventArgs) Handles ChkMatchBox.CheckedChanged
        PicMatchBox.BackColor = Color.GreenYellow
        ChkMatchBox.BackColor = Color.GreenYellow
        txtMatchBox.Enabled = True
        txtMatchBox.Text = "1"
        txtMatchBox.Focus()

        If ChkMatchBox.Checked = False Then
            PicMatchBox.BackColor = Color.WhiteSmoke
            ChkMatchBox.BackColor = Color.WhiteSmoke
            txtMatchBox.Enabled = False
            txtMatchBox.Text = "0"
        End If

    End Sub
    Private Sub ChkEggs_CheckedChanged(sender As Object, e As EventArgs) Handles ChkEggs.CheckedChanged
        PicEggs.BackColor = Color.GreenYellow
        ChkEggs.BackColor = Color.GreenYellow
        txtEggs.Enabled = True
        txtEggs.Text = "1"
        txtEggs.Focus()

        If ChkEggs.Checked = False Then
            PicEggs.BackColor = Color.WhiteSmoke
            ChkEggs.BackColor = Color.WhiteSmoke
            txtEggs.Enabled = False
            txtEggs.Text = "0"
        End If
    End Sub
    Private Sub ChkMilk_CheckedChanged(sender As Object, e As EventArgs) Handles ChkMilk.CheckedChanged
        PicMilk.BackColor = Color.GreenYellow
        ChkMilk.BackColor = Color.GreenYellow
        txtMilk.Enabled = True
        txtMilk.Text = "1"
        txtMilk.Focus()

        If ChkMilk.Checked = False Then
            PicMilk.BackColor = Color.WhiteSmoke
            ChkMilk.BackColor = Color.WhiteSmoke
            txtMilk.Enabled = False
            txtMilk.Text = "0"
        End If
    End Sub
    Private Sub ChkCheese_CheckedChanged(sender As Object, e As EventArgs) Handles ChkCheese.CheckedChanged
        PicCheese.BackColor = Color.GreenYellow
        ChkCheese.BackColor = Color.GreenYellow
        txtCheese.Enabled = True
        txtCheese.Text = "1"
        txtCheese.Focus()

        If ChkCheese.Checked = False Then
            PicCheese.BackColor = Color.WhiteSmoke
            ChkCheese.BackColor = Color.WhiteSmoke
            txtCheese.Enabled = False
            txtCheese.Text = "0"
        End If
    End Sub
    Private Sub ChkRice_CheckedChanged(sender As Object, e As EventArgs) Handles ChkRice.CheckedChanged
        PicRice.BackColor = Color.GreenYellow
        ChkRice.BackColor = Color.GreenYellow
        txtRice.Enabled = True
        txtRice.Text = "1"
        txtRice.Focus()

        If ChkRice.Checked = False Then
            PicRice.BackColor = Color.WhiteSmoke
            ChkRice.BackColor = Color.WhiteSmoke
            txtRice.Enabled = False
            txtRice.Text = "0"
        End If
    End Sub
    Private Sub ChkBread_CheckedChanged(sender As Object, e As EventArgs) Handles ChkBread.CheckedChanged
        PicBread.BackColor = Color.GreenYellow
        ChkBread.BackColor = Color.GreenYellow
        txtBread.Enabled = True
        txtBread.Text = "1"
        txtBread.Focus()

        If ChkBread.Checked = False Then
            PicBread.BackColor = Color.WhiteSmoke
            ChkBread.BackColor = Color.WhiteSmoke
            txtBread.Enabled = False
            txtBread.Text = "0"
        End If
    End Sub
    Private Sub Numbers_Only(sender As Object, e As KeyPressEventArgs) Handles txtMatchBox.KeyPress, txtEggs.KeyPress, txtMilk.KeyPress,
        txtCheese.KeyPress, txtRice.KeyPress, txtBread.KeyPress
        If Asc(e.KeyChar) <> 8 Then
            If Asc(e.KeyChar) < 48 Or Asc(e.KeyChar) > 57 Then
                e.Handled = True
            End If
        End If
    End Sub

    Private Sub BtnTotal_Click(sender As Object, e As EventArgs) Handles BtnTotal.Click
        itemcost(0) = Convert.ToDecimal(txtMatchBox.Text) * Price_MatchBox
        itemcost(1) = Convert.ToDecimal(txtEggs.Text) * Price_Eggs
        itemcost(2) = Convert.ToDecimal(txtMilk.Text) * Price_Milk
        itemcost(3) = Convert.ToDecimal(txtCheese.Text) * Price_Cheese
        itemcost(4) = Convert.ToDecimal(txtRice.Text) * Price_Rice
        itemcost(5) = Convert.ToDecimal(txtBread.Text) * Price_Bread

        iTotal = itemcost(0) + itemcost(1) + itemcost(2) + itemcost(3) + itemcost(4) + itemcost(5)
        txtTotal.Text = "₹" & iTotal

    End Sub

    Private Sub BtnPrint_Click(sender As Object, e As EventArgs) Handles BtnPrint.Click
        txtReceipt.Font = New Font("Courier New", 10)
        txtReceipt.AppendText(" ")
        txtReceipt.AppendText(" " + vbNewLine)
        txtReceipt.AppendText(vbTab & "Groceries Store Software Receipt" + vbNewLine)
        txtReceipt.AppendText("==================================================" + vbNewLine)
        txtReceipt.AppendText("Order No:" & " " & "001" & vbNewLine)
        txtReceipt.AppendText(vbNewLine & "Date: " + vbTab & Date.Today + vbTab + "Time: " + vbTab & TimeOfDay + vbNewLine)
        txtReceipt.AppendText(vbNewLine & "Item Name" + vbTab + "Price" + vbTab + "Qty" + vbNewLine)
        txtReceipt.AppendText("__________________________________________________" + vbNewLine)

        If txtMatchBox.Text > 0 Then
            txtReceipt.AppendText(vbNewLine & "Match Box" + vbTab & "₹" & Price_MatchBox & vbTab + txtMatchBox.Text + vbNewLine)
        End If
        If txtEggs.Text > 0 Then
            txtReceipt.AppendText(vbNewLine & "Eggs     " + vbTab & "₹" & Price_Eggs & vbTab + txtEggs.Text + vbNewLine)
        End If
        If txtMilk.Text > 0 Then
            txtReceipt.AppendText(vbNewLine & "Milk     " + vbTab & "₹" & Price_Milk & vbTab + txtMilk.Text + vbNewLine)
        End If
        If txtCheese.Text > 0 Then
            txtReceipt.AppendText(vbNewLine & "Cheese   " + vbTab & "₹" & Price_Cheese & vbTab + txtCheese.Text + vbNewLine)
        End If
        If txtRice.Text > 0 Then
            txtReceipt.AppendText(vbNewLine & "Rice     " + vbTab & "₹" & Price_Rice & vbTab + txtRice.Text + vbNewLine)
        End If
        If txtBread.Text > 0 Then
            txtReceipt.AppendText(vbNewLine & "Bread    " + vbTab & "₹" & Price_Bread & vbTab + txtBread.Text + vbNewLine)
        End If
        txtReceipt.AppendText("__________________________________________________" + vbNewLine)
        txtReceipt.AppendText(vbNewLine & "Total" + vbTab + vbTab & txtTotal.Text & vbNewLine)
        txtReceipt.AppendText("--------------------------------------------------" + vbNewLine)
        txtReceipt.AppendText(vbTab + " Thank You, Visit Again" & vbNewLine)

    End Sub

End Class

No comments:

Post a Comment