我正在开发一个包含三个事件过程的程序(换句话说,三个不同的任务按钮:“选择媒体和估计基金”、“添加机构”和“生成报告”)。
当点击“选择媒体和预计资金”按钮时,会弹出输入框,要求用户输入余额,余额将通过公式(余额=余额*(1+利率)。余额用户输入不能少于 $500.00 或超过 $3000.00。
(预计预算应根据您选择的资金资源计算(资金资源是他们选择的账户类型,储蓄(7% 利率)和公司(5% 利率))计算结果应显示在旁边的禁用文本框中到“Estimated Budget”文本框。如果选择了两个资源,每个估计的预算应该汇总在一起。计算过程应该称为事件过程中定义为“FundingResource(Balance)”的子过程。
请注意当前年份,2013 年。现在,报告是在 2013 年准备的,但应根据您选择的年份(例如,2015、2016、2017)计算余额。考虑重复的主题以确定您所选年份的期末余额。
我已经完成了我相信的代码,但不知道如何将其放入子过程中。上述问题的代码在“btnMediaEstimatedFund”中。
Public Class Form1
Private Sub btnMediaEstimatedFund_Click(sender As Object, e As EventArgs) Handles btnMediaEstimatedFund.Click
Dim interestRate, balance, initialBalanceSavings, initialBalanceCorporate, finalBalance As Double
txtBoxEstimatedBudget.Enabled = False
txtBoxAgenciesNeeded.Enabled = False
If radButtonTraditional.Checked Then
txtBoxAgenciesNeeded.Text = 3
ElseIf radButtonEMedia.Checked Then
txtBoxAgenciesNeeded.Text = 2
End If
If checkBoxSavings.Checked Then
interestRate = 0.07
ElseIf checkBoxCorporate.Checked Then
interestRate = 0.05
ElseIf checkBoxCorporate.Checked And checkBoxSavings.Checked Then
interestRate = 0.12
End If
initialBalanceSavings = InputBox("Please Enter a balance for SAVINGS account between $500.00 and $3000.00")
If initialBalanceSavings > 3000 Then
InputBox("Please enter a balance for SAVINGS account equal to or below $3000.00 and no less than $500.00")
ElseIf initialBalanceSavings < 500 Then
InputBox("Please enter a balance for SAVINGS account equal to or above $500.00 and no more than $3000.00")
End If
initialBalanceCorporate = InputBox("Please Enter a balance for CORPORATE account between $500.00 and $3000.00")
If initialBalanceCorporate > 3000 Then
InputBox("Please enter a balance for CORPORATE account equal to or below $3000.000 and no less than $500.00")
ElseIf initialBalanceCorporate < 500 Then
InputBox("Please enter a balance for CORPORATE account equal to or above $500.00 and no more than $3000.00")
Else
finalBalance = initialBalanceCorporate + initialBalanceSavings
balance = finalBalance * (1 + interestRate)
txtBoxEstimatedBudget.Text = balance
End If
End Sub
Private Sub btnAddAgencies_Click(sender As Object, e As EventArgs) Handles btnAddAgencies.Click
Dim dict As Dictionary(Of String, Integer) = New Dictionary(Of String, Integer)()
dict.Add("U-Ad ($350)", 350)
dict.Add("Striker ($190)", 190)
dict.Add("New Ad ($250)", 250)
dict.Add("Samson ($530)", 530)
dict.Add("J & R ($420)", 420)
dict.Add("Victory ($120)", 120)
Dim selectedItems = (From i In lstBoxAgenciesList.SelectedItems).ToArray()
Dim total As Integer = 0
For Each selectedItem In selectedItems
lstBoxSelectedList.Items.Add(selectedItem)
lstBoxAgenciesList.Items.Remove(selectedItem)
Next
For Each item In lstBoxSelectedList.Items
total += dict(item)
Next
txtBoxEstimatedCost.Text = FormatCurrency(total.ToString())
End Sub
Private Sub btnGenerateReport_Click(sender As Object, e As EventArgs) Handles btnGenerateReport.Click
Dim employeeLevel, year, selectedMedia, numberOfAgencies As String
Dim today As Date
today = CStr(dtpToday.Text)
Name = CStr(txtBoxCreator.Text)
employeeLevel = CStr(lstBoxResults.Text)
year = CStr(lstBoxResults.Text)
selectedMedia = CStr(lstBoxResults.Text)
numberOfAgencies = CStr(txtBoxAgenciesNeeded.Text)
dtpToday.Text = FormatDateTime(today, DateFormat.ShortDate)
If radButtonManager.Checked Then
employeeLevel = "Manager"
ElseIf radButtonStaff.Checked Then
employeeLevel = "Staff"
End If
If radButton2015.Checked Then
year = "2015"
ElseIf radButton2016.Checked Then
year = "2016"
ElseIf radButton2017.Checked Then
year = "2017"
End If
If radButtonTraditional.Checked Then
selectedMedia = "Traditional Media (TV, Radio)"
ElseIf radButtonEMedia.Checked Then
selectedMedia = "New e-Media (SNS, e-Mail)"
End If
lstBoxResults.Items.Add("=======================================")
lstBoxResults.Items.Add(" ")
lstBoxResults.Items.Add("Date : " & today)
lstBoxResults.Items.Add(" ")
lstBoxResults.Items.Add("Reporting Entity : " & Name)
lstBoxResults.Items.Add(" ")
lstBoxResults.Items.Add("Level of Employee : " & employeeLevel)
lstBoxResults.Items.Add(" ")
lstBoxResults.Items.Add("=======================================")
lstBoxResults.Items.Add(" ")
lstBoxResults.Items.Add("Year" & " " & year & " " & "Budget of Advertising Report")
lstBoxResults.Items.Add(" ")
lstBoxResults.Items.Add("=======================================")
lstBoxResults.Items.Add(" ")
lstBoxResults.Items.Add("Total Estimated Cost : " & FormatCurrency(txtBoxEstimatedCost.Text))
lstBoxResults.Items.Add(" ")
lstBoxResults.Items.Add("Total Estimated Budget : " & FormatCurrency(txtBoxEstimatedBudget.Text))
lstBoxResults.Items.Add(" ")
lstBoxResults.Items.Add("Selected Media : " & selectedMedia)
lstBoxResults.Items.Add(" ")
lstBoxResults.Items.Add("Number of Agencies Involved : " & numberOfAgencies)
lstBoxResults.Items.Add(" ")
lstBoxResults.Items.Add("=======================================")
End Sub
End Class