Public Class frmMain
    Inherits System.Windows.Forms.Form

    Private m_intQuantity As Integer

#Region " Windows Form Designer generated code "

    Public Sub New()
        MyBase.New()

        'This call is required by the Windows Form Designer.
        InitializeComponent()

        'Add any initialization after the InitializeComponent() call

    End Sub

    'Form overrides dispose to clean up the component list.
    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
        If disposing Then
            If Not (components Is Nothing) Then
                components.Dispose()
            End If
        End If
        MyBase.Dispose(disposing)
    End Sub

    'Required by the Windows Form Designer
    Private components As System.ComponentModel.IContainer

    'NOTE: The following procedure is required by the Windows Form Designer
    'It can be modified using the Windows Form Designer.  
    'Do not modify it using the code editor.
    Friend WithEvents chkCompletePlaceSetting As System.Windows.Forms.CheckBox
    Friend WithEvents chkPlate As System.Windows.Forms.CheckBox
    Friend WithEvents chkButterPlate As System.Windows.Forms.CheckBox
    Friend WithEvents chkSoupBowl As System.Windows.Forms.CheckBox
    Friend WithEvents chkCup As System.Windows.Forms.CheckBox
    Friend WithEvents chkSaucer As System.Windows.Forms.CheckBox
    Friend WithEvents chkPlatter As System.Windows.Forms.CheckBox
    Friend WithEvents btnCalculate As System.Windows.Forms.Button
    Friend WithEvents btnReset As System.Windows.Forms.Button
    Friend WithEvents grpItems As System.Windows.Forms.GroupBox
    Friend WithEvents grpQuantity As System.Windows.Forms.GroupBox
    Friend WithEvents grpCompletePlaceSetting As System.Windows.Forms.GroupBox
    Friend WithEvents dlgChina As System.Windows.Forms.ColorDialog
    Friend WithEvents lblDateAndTime As System.Windows.Forms.Label
    Friend WithEvents lblPrice As System.Windows.Forms.Label
    Friend WithEvents picChina As System.Windows.Forms.PictureBox
    Friend WithEvents lstBrands As System.Windows.Forms.ListBox
    Friend WithEvents rad8 As System.Windows.Forms.RadioButton
    Friend WithEvents rad4 As System.Windows.Forms.RadioButton
    Friend WithEvents rad2 As System.Windows.Forms.RadioButton
    Friend WithEvents rad1 As System.Windows.Forms.RadioButton
    Friend WithEvents tmrChina As System.Windows.Forms.Timer
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        Me.components = New System.ComponentModel.Container()
        Me.grpItems = New System.Windows.Forms.GroupBox()
        Me.chkPlatter = New System.Windows.Forms.CheckBox()
        Me.chkSaucer = New System.Windows.Forms.CheckBox()
        Me.chkCup = New System.Windows.Forms.CheckBox()
        Me.chkSoupBowl = New System.Windows.Forms.CheckBox()
        Me.chkButterPlate = New System.Windows.Forms.CheckBox()
        Me.chkPlate = New System.Windows.Forms.CheckBox()
        Me.grpQuantity = New System.Windows.Forms.GroupBox()
        Me.rad1 = New System.Windows.Forms.RadioButton()
        Me.rad2 = New System.Windows.Forms.RadioButton()
        Me.rad4 = New System.Windows.Forms.RadioButton()
        Me.rad8 = New System.Windows.Forms.RadioButton()
        Me.grpCompletePlaceSetting = New System.Windows.Forms.GroupBox()
        Me.chkCompletePlaceSetting = New System.Windows.Forms.CheckBox()
        Me.lstBrands = New System.Windows.Forms.ListBox()
        Me.lblDateAndTime = New System.Windows.Forms.Label()
        Me.lblPrice = New System.Windows.Forms.Label()
        Me.btnCalculate = New System.Windows.Forms.Button()
        Me.btnReset = New System.Windows.Forms.Button()
        Me.picChina = New System.Windows.Forms.PictureBox()
        Me.dlgChina = New System.Windows.Forms.ColorDialog()
        Me.tmrChina = New System.Windows.Forms.Timer(Me.components)
        Me.grpItems.SuspendLayout()
        Me.grpQuantity.SuspendLayout()
        Me.grpCompletePlaceSetting.SuspendLayout()
        Me.SuspendLayout()
        '
        'grpItems
        '
        Me.grpItems.Controls.AddRange(New System.Windows.Forms.Control() {Me.chkPlatter, Me.chkSaucer, Me.chkCup, Me.chkSoupBowl, Me.chkButterPlate, Me.chkPlate})
        Me.grpItems.Location = New System.Drawing.Point(176, 40)
        Me.grpItems.Name = "grpItems"
        Me.grpItems.Size = New System.Drawing.Size(136, 240)
        Me.grpItems.TabIndex = 1
        Me.grpItems.TabStop = False
        Me.grpItems.Text = "China Items"
        '
        'chkPlatter
        '
        Me.chkPlatter.Location = New System.Drawing.Point(11, 203)
        Me.chkPlatter.Name = "chkPlatter"
        Me.chkPlatter.Size = New System.Drawing.Size(96, 16)
        Me.chkPlatter.TabIndex = 5
        Me.chkPlatter.Text = "Platter"
        '
        'chkSaucer
        '
        Me.chkSaucer.Location = New System.Drawing.Point(11, 163)
        Me.chkSaucer.Name = "chkSaucer"
        Me.chkSaucer.Size = New System.Drawing.Size(96, 16)
        Me.chkSaucer.TabIndex = 4
        Me.chkSaucer.Text = "Saucer"
        '
        'chkCup
        '
        Me.chkCup.Location = New System.Drawing.Point(11, 131)
        Me.chkCup.Name = "chkCup"
        Me.chkCup.Size = New System.Drawing.Size(96, 16)
        Me.chkCup.TabIndex = 3
        Me.chkCup.Text = "Cup"
        '
        'chkSoupBowl
        '
        Me.chkSoupBowl.Location = New System.Drawing.Point(11, 99)
        Me.chkSoupBowl.Name = "chkSoupBowl"
        Me.chkSoupBowl.Size = New System.Drawing.Size(96, 16)
        Me.chkSoupBowl.TabIndex = 2
        Me.chkSoupBowl.Text = "Soup Bowl"
        '
        'chkButterPlate
        '
        Me.chkButterPlate.Location = New System.Drawing.Point(11, 67)
        Me.chkButterPlate.Name = "chkButterPlate"
        Me.chkButterPlate.Size = New System.Drawing.Size(96, 16)
        Me.chkButterPlate.TabIndex = 1
        Me.chkButterPlate.Text = "Butter Plate"
        '
        'chkPlate
        '
        Me.chkPlate.Location = New System.Drawing.Point(11, 27)
        Me.chkPlate.Name = "chkPlate"
        Me.chkPlate.Size = New System.Drawing.Size(96, 16)
        Me.chkPlate.TabIndex = 0
        Me.chkPlate.Text = "Plate"
        '
        'grpQuantity
        '
        Me.grpQuantity.Controls.AddRange(New System.Windows.Forms.Control() {Me.rad1, Me.rad2, Me.rad4, Me.rad8})
        Me.grpQuantity.Location = New System.Drawing.Point(320, 40)
        Me.grpQuantity.Name = "grpQuantity"
        Me.grpQuantity.Size = New System.Drawing.Size(232, 152)
        Me.grpQuantity.TabIndex = 3
        Me.grpQuantity.TabStop = False
        Me.grpQuantity.Text = "Quantity"
        '
        'rad1
        '
        Me.rad1.Location = New System.Drawing.Point(21, 117)
        Me.rad1.Name = "rad1"
        Me.rad1.Size = New System.Drawing.Size(104, 18)
        Me.rad1.TabIndex = 3
        Me.rad1.Text = "1"
        '
        'rad2
        '
        Me.rad2.Location = New System.Drawing.Point(21, 84)
        Me.rad2.Name = "rad2"
        Me.rad2.Size = New System.Drawing.Size(104, 20)
        Me.rad2.TabIndex = 2
        Me.rad2.Text = "2"
        '
        'rad4
        '
        Me.rad4.Location = New System.Drawing.Point(21, 58)
        Me.rad4.Name = "rad4"
        Me.rad4.Size = New System.Drawing.Size(104, 14)
        Me.rad4.TabIndex = 1
        Me.rad4.Text = "4"
        '
        'rad8
        '
        Me.rad8.Location = New System.Drawing.Point(21, 24)
        Me.rad8.Name = "rad8"
        Me.rad8.Size = New System.Drawing.Size(104, 16)
        Me.rad8.TabIndex = 0
        Me.rad8.Text = "8"
        '
        'grpCompletePlaceSetting
        '
        Me.grpCompletePlaceSetting.Controls.AddRange(New System.Windows.Forms.Control() {Me.chkCompletePlaceSetting})
        Me.grpCompletePlaceSetting.Location = New System.Drawing.Point(320, 216)
        Me.grpCompletePlaceSetting.Name = "grpCompletePlaceSetting"
        Me.grpCompletePlaceSetting.Size = New System.Drawing.Size(232, 64)
        Me.grpCompletePlaceSetting.TabIndex = 2
        Me.grpCompletePlaceSetting.TabStop = False
        Me.grpCompletePlaceSetting.Text = "Complete Place Setting?"
        '
        'chkCompletePlaceSetting
        '
        Me.chkCompletePlaceSetting.Location = New System.Drawing.Point(16, 24)
        Me.chkCompletePlaceSetting.Name = "chkCompletePlaceSetting"
        Me.chkCompletePlaceSetting.Size = New System.Drawing.Size(152, 24)
        Me.chkCompletePlaceSetting.TabIndex = 0
        Me.chkCompletePlaceSetting.Text = "Complete Place Setting"
        '
        'lstBrands
        '
        Me.lstBrands.ItemHeight = 14
        Me.lstBrands.Location = New System.Drawing.Point(8, 48)
        Me.lstBrands.Name = "lstBrands"
        Me.lstBrands.Size = New System.Drawing.Size(120, 88)
        Me.lstBrands.TabIndex = 0
        '
        'lblDateAndTime
        '
        Me.lblDateAndTime.AutoSize = True
        Me.lblDateAndTime.Location = New System.Drawing.Point(312, 8)
        Me.lblDateAndTime.Name = "lblDateAndTime"
        Me.lblDateAndTime.Size = New System.Drawing.Size(0, 13)
        Me.lblDateAndTime.TabIndex = 6
        '
        'lblPrice
        '
        Me.lblPrice.AutoSize = True
        Me.lblPrice.Location = New System.Drawing.Point(16, 376)
        Me.lblPrice.Name = "lblPrice"
        Me.lblPrice.Size = New System.Drawing.Size(0, 13)
        Me.lblPrice.TabIndex = 7
        '
        'btnCalculate
        '
        Me.btnCalculate.Location = New System.Drawing.Point(360, 304)
        Me.btnCalculate.Name = "btnCalculate"
        Me.btnCalculate.TabIndex = 4
        Me.btnCalculate.Text = "Calculate"
        '
        'btnReset
        '
        Me.btnReset.DialogResult = System.Windows.Forms.DialogResult.Cancel
        Me.btnReset.Location = New System.Drawing.Point(360, 344)
        Me.btnReset.Name = "btnReset"
        Me.btnReset.TabIndex = 5
        Me.btnReset.Text = "Reset"
        '
        'picChina
        '
        Me.picChina.Location = New System.Drawing.Point(8, 160)
        Me.picChina.Name = "picChina"
        Me.picChina.Size = New System.Drawing.Size(100, 96)
        Me.picChina.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage
        Me.picChina.TabIndex = 4
        Me.picChina.TabStop = False
        '
        'tmrChina
        '
        Me.tmrChina.Interval = 1000
        '
        'frmMain
        '
        Me.AcceptButton = Me.btnCalculate
        Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
        Me.CancelButton = Me.btnReset
        Me.ClientSize = New System.Drawing.Size(594, 425)
        Me.ControlBox = False
        Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.btnReset, Me.btnCalculate, Me.lblPrice, Me.lblDateAndTime, Me.grpItems, Me.grpQuantity, Me.grpCompletePlaceSetting, Me.lstBrands, Me.picChina})
        Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle
        Me.Name = "frmMain"
        Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen
        Me.Text = "The Bullina China Shop"
        Me.grpItems.ResumeLayout(False)
        Me.grpQuantity.ResumeLayout(False)
        Me.grpCompletePlaceSetting.ResumeLayout(False)
        Me.ResumeLayout(False)

    End Sub

#End Region

    Private Sub frmMain_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim strBrand As String

        FileOpen(1, "C:\VBFILES\CHINA\BRANDS.TXT", _
                OpenMode.Input)

        Do While Not EOF(1)
            Input(1, strBrand)
            lstBrands.Items.Add(strBrand)
        Loop

        FileClose(1)
    End Sub

 

    Private Sub rad1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles rad1.Click
        m_intQuantity = 1
    End Sub

    Private Sub rad2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles rad2.Click
        m_intQuantity = 2
    End Sub

    Private Sub rad4_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles rad4.Click
        m_intQuantity = 4
    End Sub

    Private Sub rad8_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles rad8.Click
        m_intQuantity = 8
    End Sub

    Private Sub chkCompletePlaceSetting_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles chkCompletePlaceSetting.Click
        If chkCompletePlaceSetting.Checked = True Then
            chkPlate.Checked = True
            chkButterPlate.Checked = True
            chkSoupBowl.Checked = True
            chkCup.Checked = True
            chkSaucer.Checked = True
        Else
            chkPlate.Checked = False
            chkButterPlate.Checked = False
            chkSoupBowl.Checked = False
            chkCup.Checked = False
            chkSaucer.Checked = False
        End If
    End Sub

    Private Sub btnCalculate_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnCalculate.Click
        Dim sngTotalPrice As Single
        Dim sngButterPlatePrice As Single
        Dim sngCupPrice As Single
        Dim sngPlatePrice As Single
        Dim sngPlatterPrice As Single
        Dim sngSaucerPrice As Single
        Dim sngSoupBowlPrice As Single

        'Has the customer selected a brand of china?

        If lstBrands.Text = "" Then
            MsgBox("You must select a China Brand")
            Exit Sub
        End If

        'Has the customer selected one or more china items?

        If chkPlate.Checked = False And _
            chkButterPlate.Checked = False And _
            chkSoupBowl.Checked = False And _
            chkCup.Checked = False And _
            chkSaucer.Checked = False And _
            chkPlatter.Checked = False Then
            MsgBox("You must select one or more china items")
            Exit Sub
        End If

        'Has the customer selected a quantity?

        If rad8.Checked = False And _
            rad4.Checked = False And _
            rad2.Checked = False And _
            rad1.Checked = False Then
            MsgBox("You must select a quantity")
            Exit Sub
        End If

        'If the customer has selected a platter
        'warn them that there is only 1 permitted per sales
        'quotation

        If chkPlatter.Checked = True And m_intQuantity > 1 Then
            MsgBox("Customer is limited to 1 platter per " & _
            "order." & Chr(13) & _
            "Adjusting price acordingly")
        End If

        'All the pieces are here, let's calculate a price

        'Assign prices to each item

        Select Case lstBrands.Text
            Case "Mikasa"
                If chkPlate.Checked = True Then
                    sngPlatePrice = 25
                End If
                If chkButterPlate.Checked = True Then
                    sngbutterplateprice = 10
                End If
                If chkSoupBowl.Checked = True Then
                    sngSoupBowlPrice = 10
                End If
                If chkCup.Checked = True Then
                    sngCupPrice = 5
                End If
                If chkSaucer.Checked = True Then
                    sngSaucerPrice = 5
                End If
                If chkPlatter.Checked = True Then
                    sngPlatterPrice = 50
                End If

            Case "Farberware"
                If chkPlate.Checked = True Then
                    sngPlatePrice = 10
                End If
                If chkButterPlate.Checked = True Then
                    sngButterPlatePrice = 3
                End If
                If chkSoupBowl.Checked = True Then
                    sngSoupBowlPrice = 5
                End If
                If chkCup.Checked = True Then
                    sngCupPrice = 3
                End If
                If chkSaucer.Checked = True Then
                    sngSaucerPrice = 3
                End If
                If chkPlatter.Checked = True Then
                    sngPlatterPrice = 13
                End If

            Case "Corelle"
                If chkPlate.Checked = True Then
                    sngPlatePrice = 4
                End If
                If chkButterPlate.Checked = True Then
                    sngButterPlatePrice = 1
                End If
                If chkSoupBowl.Checked = True Then
                    sngSoupBowlPrice = 2
                End If
                If chkCup.Checked = True Then
                    sngCupPrice = 1
                End If
                If chkSaucer.Checked = True Then
                    sngSaucerPrice = 1
                End If
                If chkPlatter.Checked = True Then
                    sngPlatterPrice = 5
                End If
        End Select

        'Add the prices together and multiply by the quantity to
        'calculate a grand total

        sngTotalPrice = (((sngPlatePrice + sngButterPlatePrice + _
                            sngSoupBowlPrice + sngCupPrice + _
                            sngSaucerPrice) _
                        * m_intQuantity) + sngPlatterPrice)

        'If the price is greater than 0, display the price and
        'make the label visible
        If sngTotalPrice > 0 Then
            lblPrice.Text = "The price of your order is $" & _
                sngTotalPrice
            lblPrice.Visible = True
        End If
    End Sub

    Private Sub btnReset_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnReset.Click
        lstBrands.SelectedIndex = -1
        chkPlate.Checked = False
        chkButterPlate.Checked = False
        chkSoupBowl.Checked = False
        chkCup.Checked = False
        chkSaucer.Checked = False
        chkPlatter.Checked = False
        rad8.Checked = False
        rad4.Checked = False
        rad2.Checked = False
        rad1.Checked = False
        chkCompletePlaceSetting.Checked = False
        lblPrice.Visible = False
        picChina.Image = Nothing
    End Sub

    Private Sub lstBrands_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles lstBrands.SelectedIndexChanged
        If lstBrands.SelectedIndex = -1 Then Exit Sub
        picChina.Image = Image.FromFile("C:\VBFiles\China\" & _
            lstBrands.Text & ".gif")
    End Sub
End Class
