Client Analysis
- Create a new form named frmClientAnalysis with Text property as “Client Analysis”. Add a panel object to it and dock it at the top of the form using the Dock property in the Properties window. Adjust the height of the panel so that it does not take too much space on the form. Add two radio buttons on this panel and name them rdoCostRevenue and rdoProfitMargin with the Text properties “Cost and
Revenue” and “Profit Margin”, respectively. Add a Chart object to the form below the Panel object and
dock it in the parent container. Name the Chart object as chrClientAnalysis.
- In the code page for frmClientAnalysis, declare a public property called ClientList as a list of string values, a public property called CostList as a list of decimal values, a public property called RevenueList as a list of decimal values, and a public property called ProfitMarginList as a list of decimal. Refer to the code from the lecture W10B-Charts. Copy the AddSeries sub (from the frmChart class of to the project for W10B lecture) to the frmStaffAnalysis class of your final project.
- In the code page for frmStaffAnalysis, create a private sub called ShowSeries. In this sub, clear the series collection of chrStaffAnalysis. Then add an if-then-else structure, in which you check if the Checked property of rdoCostRevenue equals True. Under the if condition, call AddSeries with the 8 parameters as chrClientAnalysis, “Cost”, ClientList, CostList, SeriesChartType.Column, “Clients”, “Dollars” and “Cost and Revenue”. Set chrStaffAnalysis.Titles(0).Text equal to “Cost and Revenue”. Under the else condition, call AddSeries with the 8 parameters as chrClientAnalysis, “ProfitMargin”,
ClientList, ProfitMarginList, SeriesChartType.Column, “Clients”, “Percentage” and “Profit Margin”. Set chrStaffAnalysis.Titles(0).Text equal to “Profit Margin”. In the design view of frmStaffAnalysis, double-
click on rdoCostRevenue to create the CheckedChange event handler. In this event handler, call the sub Show Series. Repeat the same with rdoProfitMargin.
- In the code page for frmDashboard, create a public sub called ClientAnalysis. In this sub, declare a variable called ClientList as a new list of string, a variable called CostList as a new list of decimal, a variable called RevenueList as a new list of decimal, and a variable called ProfitMarginList as a new list of decimal. Create an integer variable called maxWeek and call GetMaxWeek to assign to this variable.
Create a For-each loop over the values collection of ClientSList property of frmDashboard. In this loop, create a LINQ query over the AssignmentList property of frmDashboard where the ClientID property of the Client property of the query variable euqals the ClientID property of the loop variable and the Assigned property of the query variable equals True. Declare a variable for total cost as decimal and initialize it to zero. Create an inner for-each loop over the output of the LINQ query. In this inner for- each loop, increment the total cost variable by the Rate property of the loop variable times a call to GetTotalHours function with the loop variable, 1, and maxWeek as its three parameters, respectively. After the inner for-each loop, add the Name property of the loop variable of the outer for-each loop to ClientList, add the total cost variable to CostList, and add the Revenue property of the loop variable of the outer for-each loop to RevenueList. Finally, and add the ratio of the difference between the Revenue property and the total cost to the Revenue property times 100 to ProfitMarginList before the end of the outer for-each loop. After the outer for-each loop, declare a variable called clientAnalysisForm as frmClietnAnalysis type and call the GetForm sub of the MainForm property of frmDashboard with the parameter”ClientAnalysis”. Assign ClientList, CostList, RevenueList and ProfitMarginList to the properties of clientAnalysisForm with the same name. Finally, call the subs Show and BringToFront of clientAnalysisForm, respectively.
- Create a button on frmDashboard called btnClientAnalysis with the Text property “Client Analysis”.
Double-click on this button to create its Click even handler. In this even handler, call the sub
ClientAnalysis. In the code page for frmMain, create a case called “ClientAnalysis” in the select-case structure inside UpdateFormSList, and under this case, assign a new instance of frmClientAnalysis to FormSList(formName). In the sub InitializeFormSList, include a line to add the key “ClientAnalysis” with value Nothing inside the With structure.
- In the design view of frmMain, under the top-level menu item called “Analysis” and below the sub- menu item “Staff Analysis”, create a menu item called “Client Analysis”. Double-click on this menu item to create its event handler. In this even handler, add an if-then structure to check if the call to DatabaseLoaded function equals true. Inside the if-then structure, create a variable of type frmDashboard and call GetForm with parameter “Dashboard” to assign to this variable. Call BringToFront sub of this variable followed by the ClientAnalysis sub of this variable.
This assignment has been answered 2 times in private sessions.
Or buy a ready solution below.
© 2024 Codify Tutor. All rights reserved