Visual Basic中的工资表

时间:2013-11-12 02:12:47

标签: vb.net visual-studio-2010

''我在'调用函数计算佣金线时遇到重大错误。如果我做了其他任何错误,请随时告诉我。我相信我的数学在编码中是正确的。 Erros是commision decimal没有声明,销售没有声明,所以就这样,Everythng错误的佣金线......

Private Sub SummaryToolStripMenuItem_Click(sender As System.Object, e As System.EventArgs) Handles SummaryToolStripMenuItem.Click
    Dim TotalSalesDecimal As Decimal
    Dim TotalBasePayDecimal As Decimal
    Dim TotalCommissionsDecimal As Decimal
    Dim TotalPayDecimal As Decimal
    Dim MessageString As String
    Const TempComRate As Decimal = 0.035D
    Const PermComRate As Decimal = 0.05D

    MessageString = "Total Sales:  " & TotalSalesDecimal.ToString("c") &
        Environment.NewLine & Environment.NewLine &
    "Total Base Pay:  " & TotalBasePayDecimal.ToString("C") &
        Environment.NewLine & Environment.NewLine &
    "Total Commission:  " & TotalCommissionsDecimal.ToString("C") &
        Environment.NewLine & Environment.NewLine &
    "Total Pay:  " & TotalPayDecimal.ToString("C")
    MessageBox.Show(MessageString, "Summary Menu", MessageBoxButtons.OK)





End Sub

Private Sub ClearFormToolStripMenuItem_Click(sender As System.Object, e As System.EventArgs) Handles ClearFormToolStripMenuItem.Click
    ' Clear the stuff
    nameTextBox.Clear()
    salesTextBox.Clear()
    hoursWorkedTextBox.Clear()
    payRateTextBox.Clear()
    Basepaylabel.Text = ""
    commissionLabel.Text = ""
    employeePayLabel.Text = ""
End Sub

Private Sub ColorToolStripMenuItem_Click(sender As System.Object, e As System.EventArgs) Handles ColorToolStripMenuItem.Click
    basePayLabel.ForeColor = ColorDialog1.Color
    commissionLabel.ForeColor = ColorDialog1.Color
    employeePayLabel.ForeColor = ColorDialog1.Color
    With ColorDialog1
        .ShowDialog()
        basePayLabel.ForeColor = .Color
        commissionLabel.ForeColor = .Color
        employeePayLabel.ForeColor = .Color

    End With

End Sub

Private Sub FontToolStripMenuItem_Click(sender As System.Object, e As System.EventArgs) Handles FontToolStripMenuItem.Click
    With FontDialog1
        .ShowDialog()
        basePayLabel.Font = .Font
        commissionLabel.Font = .Font
        employeePayLabel.Font = .Font

    End With
End Sub

Private Sub logoPictureBox_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles logoPictureBox.Click
    If LogoToolStripMenuItem.Checked = True Then
        logoPictureBox.Image = My.Resources.Train
    Else
        LogoToolStripMenuItem.Checked = False



    End If
End Sub

Private Sub AboutToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AboutToolStripMenuItem.Click
    MsgBox("Program Name: Vintage Tours" + vbCrLf + "Programmer Name: Ryan Harvell")





End Sub

Private Sub basePayLabel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)

End Sub

Private Sub CalcPayToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CalcPayToolStripMenuItem.Click
    ' Define Local Variables
    Dim DollarValueDecimal As Decimal
    Dim HoursWorkedDecimal As Decimal
    Dim PayRateDecimal As Decimal
    Dim GoodDataBoolean = True
    Dim Basepaydecimal As Decimal
    Dim commissiondecimal As Decimal
    Dim employeepaydecimal As Decimal


    'Validate Text Fields
    If nameTextBox.Text = "" Then
        MessageBox.Show(" Please Enter A Name", " Data Is Missing",
                        MessageBoxButtons.OK, MessageBoxIcon.Error)
        nameTextBox.Focus()
        nameTextBox.SelectAll()
        GoodDataBoolean = False

    Else

        'Validate Numeric Fields
        Try

            DollarValueDecimal = Decimal.Parse(salesTextBox.Text)
            If DollarValueDecimal <= 0 Then
                MessageBox.Show("Please Enter A Positive Dollar Value", "Data Is Missing",
                                MessageBoxButtons.OK, MessageBoxIcon.Error)
                salesTextBox.Focus()
                salesTextBox.SelectAll()
                GoodDataBoolean = False

            Else
                Try
                    HoursWorkedDecimal = Decimal.Parse(hoursWorkedTextBox.Text)
                    If HoursWorkedDecimal <= 0 Then
                        MessageBox.Show(" Please Enter A Positive Amount Of Hours Worked ", "Data Is Missing",
                                        MessageBoxButtons.OK, MessageBoxIcon.Error)
                        hoursWorkedTextBox.Focus()
                        hoursWorkedTextBox.SelectAll()
                        GoodDataBoolean = False

                    Else
                        Try
                            PayRateDecimal = Decimal.Parse(payRateTextBox.Text)
                            If PayRateDecimal <= 0 Then


                                MessageBox.Show(" Please Enter A Positive Pay Rate", "Data Is Missing",
                                                 MessageBoxButtons.OK, MessageBoxIcon.Error)
                                payRateTextBox.Focus()
                                payRateTextBox.SelectAll()
                                GoodDataBoolean = False

                            End If




                        Catch payrateerr As FormatException
                            MessageBox.Show("Please Enter A Numeric Payrate", "Data Is Missing",
                                             MessageBoxButtons.OK, MessageBoxIcon.Error)
                            payRateTextBox.Focus()
                            payRateTextBox.SelectAll()
                            GoodDataBoolean = False
                        End Try

                    End If
        Catch hoursworkederr As FormatException
                    MessageBox.Show(" Please Enter Numeric Amount Of Hours Worked", "Data Is Missing",
                             MessageBoxButtons.OK, MessageBoxIcon.Error)
                    hoursWorkedTextBox.Focus()
                    hoursWorkedTextBox.SelectAll()
                    GoodDataBoolean = False
        End Try

            End If

        Catch dollarvalueerr As FormatException
            MessageBox.Show("Please Enter A Numeric Dollar Amount", "Data Is Missing",
                           MessageBoxButtons.OK, MessageBoxIcon.Error)
            salesTextBox.Focus()
            salesTextBox.SelectAll()
            GoodDataBoolean = False
        End Try


    End If
    'process good data
    If GoodDataBoolean = True Then

    End If
    'Call a function to calculate the base pay.
End Sub
Private Function calcbasepay(ByVal Hrsworked As Decimal,
    ByVal PayRate As Decimal) As Decimal
    If Hrsworked <= 40 Then
        Return Hrsworked * PayRate
    Else
        Return 40 * PayRate + (Hrsworked - 40) * (PayRate / 2 + PayRate)

    End If
End Function


'Call a function to calculate the commission.
Private Function calccommision(ByVal Commissionsales As Decimal) As Decimal
    If commissiondecimal >= 500 Then
        If permanentEmployeeRadioButton.Checked Then
            Commissionsales = (sales * 0.05) + sales
        Else
            Commissionsales = (sales * 0.035) + sales

            'Calculate the employee pay as the sum of base pay and commission.
            Employeepaydecimal = Basepaydecimal + Commissiondecimal
            'Accumulate the totals for the Summary box.
            totalbasepaydecimal += basepaydecimal
            totaLcommissiondecimal = commissiondecimal
            totalpaydecimal = basepaydecimal


            'display output

        End If




End Function

0 个答案:

没有答案