'Program:
Shedd0503
'Programmer:
Brad Shedd
'Date
June 4, 2006
'Description: This project displays
commission and total pay for employees with a summary and an about box.
Option Strict On
Public Class
salesForm
Inherits System.Windows.Forms.Form
#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 MainMenu1 As
System.Windows.Forms.MainMenu
Friend
WithEvents MenuItem1 As
System.Windows.Forms.MenuItem
Friend
WithEvents MenuItem2 As
System.Windows.Forms.MenuItem
Friend
WithEvents MenuItem3 As
System.Windows.Forms.MenuItem
Friend
WithEvents payMenuItem As
System.Windows.Forms.MenuItem
Friend
WithEvents summaryMenuItem As
System.Windows.Forms.MenuItem
Friend
WithEvents exitMenuItem As
System.Windows.Forms.MenuItem
Friend
WithEvents clearMenuItem As
System.Windows.Forms.MenuItem
Friend
WithEvents fontMenuItem As
System.Windows.Forms.MenuItem
Friend
WithEvents colorMenuItem As
System.Windows.Forms.MenuItem
Friend
WithEvents aboutMenuItem As
System.Windows.Forms.MenuItem
Friend
WithEvents Label1 As
System.Windows.Forms.Label
Friend
WithEvents Label2 As
System.Windows.Forms.Label
Friend
WithEvents salesTextBox As
System.Windows.Forms.TextBox
Friend
WithEvents Label3 As
System.Windows.Forms.Label
Friend
WithEvents totalPayLabel As
System.Windows.Forms.Label
Friend
WithEvents Label5 As
System.Windows.Forms.Label
Friend
WithEvents commissionLabel As
System.Windows.Forms.Label
Friend
WithEvents FontDialog1 As
System.Windows.Forms.FontDialog
Friend
WithEvents ColorDialog1 As
System.Windows.Forms.ColorDialog
Friend
WithEvents nameTextBox As
System.Windows.Forms.TextBox
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Me.MainMenu1 =
New System.Windows.Forms.MainMenu
Me.MenuItem1 =
New System.Windows.Forms.MenuItem
Me.payMenuItem =
New System.Windows.Forms.MenuItem
Me.summaryMenuItem =
New System.Windows.Forms.MenuItem
Me.exitMenuItem =
New System.Windows.Forms.MenuItem
Me.MenuItem2 =
New System.Windows.Forms.MenuItem
Me.clearMenuItem =
New System.Windows.Forms.MenuItem
Me.fontMenuItem =
New System.Windows.Forms.MenuItem
Me.colorMenuItem =
New System.Windows.Forms.MenuItem
Me.MenuItem3 =
New System.Windows.Forms.MenuItem
Me.aboutMenuItem =
New System.Windows.Forms.MenuItem
Me.Label1 = New
System.Windows.Forms.Label
Me.nameTextBox =
New System.Windows.Forms.TextBox
Me.Label2 = New
System.Windows.Forms.Label
Me.salesTextBox =
New System.Windows.Forms.TextBox
Me.Label3 = New
System.Windows.Forms.Label
Me.totalPayLabel =
New System.Windows.Forms.Label
Me.Label5 = New
System.Windows.Forms.Label
Me.commissionLabel =
New System.Windows.Forms.Label
Me.FontDialog1 =
New System.Windows.Forms.FontDialog
Me.ColorDialog1 =
New System.Windows.Forms.ColorDialog
Me.SuspendLayout()
'
'MainMenu1
'
Me.MainMenu1.MenuItems.AddRange(New
System.Windows.Forms.MenuItem() {Me.MenuItem1,
Me.MenuItem2, Me.MenuItem3})
'
'MenuItem1
'
Me.MenuItem1.Index = 0
Me.MenuItem1.MenuItems.AddRange(New
System.Windows.Forms.MenuItem() {Me.payMenuItem,
Me.summaryMenuItem, Me.exitMenuItem})
Me.MenuItem1.Text =
"&File"
'
'payMenuItem
'
Me.payMenuItem.Index = 0
Me.payMenuItem.Text =
"&Pay"
'
'summaryMenuItem
'
Me.summaryMenuItem.Index = 1
Me.summaryMenuItem.Text =
"&Summary"
'
'exitMenuItem
'
Me.exitMenuItem.Index = 2
Me.exitMenuItem.Text =
"E&xit"
'
'MenuItem2
'
Me.MenuItem2.Index = 1
Me.MenuItem2.MenuItems.AddRange(New
System.Windows.Forms.MenuItem() {Me.clearMenuItem,
Me.fontMenuItem, Me.colorMenuItem})
Me.MenuItem2.Text =
"&Edit"
'
'clearMenuItem
'
Me.clearMenuItem.Index = 0
Me.clearMenuItem.Text =
"C&lear"
'
'fontMenuItem
'
Me.fontMenuItem.Index = 1
Me.fontMenuItem.Text =
"&Font"
'
'colorMenuItem
'
Me.colorMenuItem.Index
= 2
Me.colorMenuItem.Text =
"&Color"
'
'MenuItem3
'
Me.MenuItem3.Index = 2
Me.MenuItem3.MenuItems.AddRange(New
System.Windows.Forms.MenuItem() {Me.aboutMenuItem})
Me.MenuItem3.Text =
"&Help"
'
'aboutMenuItem
'
Me.aboutMenuItem.Index = 0
Me.aboutMenuItem.Text =
"&About"
'
'Label1
'
Me.Label1.Location =
New System.Drawing.Point(48, 32)
Me.Label1.Name =
"Label1"
Me.Label1.Size =
New System.Drawing.Size(96, 23)
Me.Label1.TabIndex = 0
Me.Label1.Text =
"Name"
'
'nameTextBox
'
Me.nameTextBox.Location =
New System.Drawing.Point(152, 32)
Me.nameTextBox.Name =
"nameTextBox"
Me.nameTextBox.Size =
New System.Drawing.Size(192, 20)
Me.nameTextBox.TabIndex = 1
Me.nameTextBox.Text =
""
'
'Label2
'
Me.Label2.Location =
New System.Drawing.Point(48, 72)
Me.Label2.Name =
"Label2"
Me.Label2.TabIndex = 2
Me.Label2.Text =
"Sales"
'
'salesTextBox
'
Me.salesTextBox.Location =
New System.Drawing.Point(160, 72)
Me.salesTextBox.Name =
"salesTextBox"
Me.salesTextBox.Size =
New System.Drawing.Size(184, 20)
Me.salesTextBox.TabIndex = 3
Me.salesTextBox.Text =
""
'
'Label3
'
Me.Label3.Location =
New System.Drawing.Point(40, 152)
Me.Label3.Name =
"Label3"
Me.Label3.Size =
New System.Drawing.Size(96, 24)
Me.Label3.TabIndex = 4
Me.Label3.Text =
"Total Pay"
'
'totalPayLabel
'
Me.totalPayLabel.BorderStyle =
System.Windows.Forms.BorderStyle.Fixed3D
Me.totalPayLabel.Location =
New System.Drawing.Point(144, 152)
Me.totalPayLabel.Name =
"totalPayLabel"
Me.totalPayLabel.Size =
New System.Drawing.Size(176, 24)
Me.totalPayLabel.TabIndex = 5
Me.totalPayLabel.TextAlign =
System.Drawing.ContentAlignment.TopRight
'
'Label5
'
Me.Label5.Location =
New System.Drawing.Point(40, 192)
Me.Label5.Name =
"Label5"
Me.Label5.TabIndex = 6
Me.Label5.Text =
"Commission"
'
'commissionLabel
'
Me.commissionLabel.BorderStyle =
System.Windows.Forms.BorderStyle.Fixed3D
Me.commissionLabel.Location =
New System.Drawing.Point(152, 192)
Me.commissionLabel.Name =
"commissionLabel"
Me.commissionLabel.Size =
New System.Drawing.Size(168, 23)
Me.commissionLabel.TabIndex = 7
Me.commissionLabel.TextAlign =
System.Drawing.ContentAlignment.TopRight
'
'salesForm
'
Me.AutoScaleBaseSize =
New System.Drawing.Size(5, 13)
Me.ClientSize =
New System.Drawing.Size(568, 437)
Me.Controls.Add(Me.commissionLabel)
Me.Controls.Add(Me.Label5)
Me.Controls.Add(Me.totalPayLabel)
Me.Controls.Add(Me.Label3)
Me.Controls.Add(Me.salesTextBox)
Me.Controls.Add(Me.Label2)
Me.Controls.Add(Me.nameTextBox)
Me.Controls.Add(Me.Label1)
Me.Menu = Me.MainMenu1
Me.Name =
"salesForm"
Me.Text =
"Sales, Commission, and Total pay for employees"
Me.ResumeLayout(False)
End Sub
#End Region
'Declare Constants
Const BASE_PAY_Decimal
As Decimal =
250D
Const COMMISSION_RATE_Decimal
As Decimal = 0.15D
Const QUOTA_Decimal
As Decimal =
1000D
'Declare Varibles
Dim totalSales, totalPay,
totalCommission, payDecimal, commissionDecimal, salesDecimal
As Decimal
Private Sub
payMenuItem_Click(ByVal sender
As System.Object, ByVal
e As System.EventArgs)
Handles payMenuItem.Click
'Declare Varibles
'Not blank
Dim salesInteger
As Integer
Dim messageString
As String
'Validate sales for blanks or non numeric.
If salesTextBox.Text <>
"" Then
Try
salesDecimal = Decimal.Parse(salesTextBox.Text)
Catch
'numeric Data
messageString = "Nonnumeric data entered for
sales."
MessageBox.Show(messageString, "Data Entry
Error")
End Try
Else
'Missing data
messageString = "Enter the Sales."
MessageBox.Show(messageString, "Data entry
error")
End If
'Validate name for blanks.
If nameTextBox.Text <>
"" Then
'Do Something.
Else
MessageBox.Show("Requrired Entry",
"Sales Summary", MessageBoxButtons.OK)
End If
'Call the commission function.
commissionDecimal = FindCommission(salesDecimal)
payDecimal = BASE_PAY_Decimal + commissionDecimal
'Display pay
totalPayLabel.Text = payDecimal.ToString("C")
'Display commission
commissionLabel.Text = commissionDecimal.ToString("C")
totalSales += salesDecimal
totalCommission += commissionDecimal
totalPay += payDecimal
End Sub
Private Function
FindCommission(ByVal salesDecimal
As Decimal)
As Decimal
'Calculate the commission.
If salesDecimal >= QUOTA_Decimal
Then
Return salesDecimal *
COMMISSION_RATE_Decimal
Else
Return 0
End If
End Function
Private Sub
summaryMenuItem_Click(ByVal sender
As System.Object, ByVal
e As System.EventArgs)
Handles summaryMenuItem.Click
Dim messageString
As String
'Calculate the Summary Values.
totalCommission += commissionDecimal
totalSales += salesDecimal
totalPay += payDecimal
If payDecimal > 0
Then
'Clear textBoxes and Labels.
clearMenuItem_Click(sender, e)
'Concatenate the message string.
messageString = "Total Pay: " &
totalPay.ToString("C") _
& ControlChars.NewLine & ControlChars.NewLine _
& "Total Commission: " &
totalCommission.ToString("C") _
& ControlChars.NewLine & ControlChars.NewLine
MessageBox.Show(messageString, "Pay Summary",
MessageBoxButtons.OK, MessageBoxIcon.Information)
Else
messageString = "No Data to Summarize."
MessageBox.Show(messageString, "Pay Summary",
MessageBoxButtons.OK, _
MessageBoxIcon.Information)
nameTextBox.Focus()
End If
End Sub
Private Sub
clearMenuItem_Click(ByVal sender
As System.Object, ByVal
e As System.EventArgs)
Handles clearMenuItem.Click
'Clear the Feilds
commissionLabel.Text = ""
totalPayLabel.Text = ""
salesTextBox.Clear()
With nameTextBox
.Clear()
.Focus()
End With
End Sub
Private Sub
fontMenuItem_Click(ByVal sender
As System.Object, ByVal
e As System.EventArgs)
Handles fontMenuItem.Click
' Allow user to select a new font for total pay
With FontDialog1
.Font = totalPayLabel.Font
.ShowDialog()
totalPayLabel.Font = .Font
End With
End Sub
Private Sub
colorMenuItem_Click(ByVal sender
As System.Object, ByVal
e As System.EventArgs)
Handles colorMenuItem.Click
'Allow user to select a new color for total pay
With ColorDialog1
.Color = totalPayLabel.ForeColor
.ShowDialog()
totalPayLabel.ForeColor = .Color
End With
End Sub
Private Sub
exitMenuItem_Click(ByVal sender
As System.Object, ByVal
e As System.EventArgs)
Handles exitMenuItem.Click
'Exit the Program
Me.Close()
End Sub
Private Sub
aboutMenuItem_Click(ByVal sender
As System.Object, ByVal
e As System.EventArgs)
Handles aboutMenuItem.Click
'Display About Message Box
Dim messageString
As String
messageString = "Shedd0503" &
ControlChars.NewLine _
& ControlChars.NewLine & "Programmed by Brad
Shedd"
MessageBox.Show(messageString, "About
Shedd0503", _
MessageBoxButtons.OK, MessageBoxIcon.Information)
End Sub
End Class