点击“选择媒体和预计资金”后,查看“所需机构数量”的结果。然后从左侧的代理列表框中选择代理的名称,然后单击“添加代理”。单击“添加机构:”按钮时,所选机构的名称应出现在机构列表旁边的列表框中。这是代理列表,应该在左侧的代理列表框中输入。
U-Ad ($350), Striker ($190), NewAd ($250), Samson ($530), J & R ($420), Victory ($120)。
单击“添加机构:”按钮时,计算的估计成本结果应显示在“总估计成本”旁边的文本框中。例如,如果您选择“U-Ad”和“Samson”,则总估计成本为 880.00 美元;当您单击“添加代理”时,结果应该会出现:当您添加更多代理时,应该更新这样计算的估计成本。
Public Class Form1
Private Sub btnMediaEstimatedFund_Click(sender As Object, e As EventArgs) Handles btnMediaEstimatedFund.Click
Dim interestRate, balance, initialBalance 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.05 * 0.07
End If
initialBalance = InputBox("Please Enter a balance between $500.00 and $3000.00")
If initialBalance > 3000 Then
InputBox("Please enter a number equal to or below $3000.00 and no less than $500.00")
ElseIf initialBalance < 500 Then
InputBox("Please enter a number equal to or above $500.00 and no more than $3000.00")
Else
balance = initialBalance * (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)
dict.Add("Striker", 190)
dict.Add("New Ad", 250)
dict.Add("Samson", 530)
dict.Add("J & R", 420)
dict.Add("Victory", 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)
total += dict(selectedItem)
Next
txtBoxEstimatedCost.Text = 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
结束类
修改后的代码!