2019/4/15 Homework 5
Homework 5
Submit Assignment
Due Friday by 11:59pm Points 100 Submitting a file upload File Types zip Available Apr 12 at 12am – Apr 20 at 11:59pm 9 days
For this assignment you are first going to create a Microsoft Access Database of 2014-15 Statistics for the Virginia Tech Hokies Basketball Team. Your application will read the data from the database and put it in a DataSet. Then using LINQ commands, you will first populate a combo box with player names. Then using other link commands you will display the statistics of a chosen player in text boxes and two different graphs.
The file Homework5.zip involves an Excel file named Stats.xlsx with a worksheet named Stats that has the same name as the file with the following fields: First, Last, MNT, FGM, FGA, FTM, FTA, P3M, P3A, PTS, OFFR, DEFR, REB, AST, TOV, STL, BLK. The glossary for the field names can be found on a worksheet named Glossary. There are a total of 11 records in this worksheet. The file Homework5.zip also includes the form frmStats, which has been designed for this application. It has a combo box named cboPlayer, which displays the last name of a player whose stats will be displayed on the form. The full name of the player, total number of minutes played and total points are displayed in text boxes txtName, txtMinutes and txtPoints, respectively. The first chart named chrStats1 is used for displaying field goals attempted (FGA) and field goals made (FGM), free throws attempted (FTA) and free throws made (FTM), and three-point field goals attempted (3PA) and three-point field goals made (3PM). The second chart named chrStats2 is used for displaying the remaining stats; namely, offensive rebounds (OFFR), defensive rebounds (DEFR), rebounds (REB), assists (AST), turnovers (TOV), steals (STL), blocks (BLK).
Remember that you can find LINQ and Chart examples in the completed InClass files on Canvas. The screenshot of the application is included at the end of the assignment for your reference. Please follow the instructions below in developing your application.
1. Create a blank access database called HokiesBasketball.accdb in your project folder. Import the contents of the Stats worksheet in the Excel file Stats.xlsx to your database as a table with the same name, Stats. Do not assign a primary key when asked during the import wizard. When importing is complete, open the Stats table in the design view. Choose First and Last fields together and click on the primary key button.
2. In file frmStats.vb, first import the libraries for the data connections and data visualization before the frmStats class code. Then, in the frmStats class, first create a Public property called MyDataSet as a new DataSet type. Write a Public Sub called GetData. This sub should connect to the database using a DataAdapter and fill MyDataSet with the entire contents of the table Stats from the database. GetData should be called when frmStats loads.
3. Write a Public Sub called GetPlayers. Using a LINQ query, this sub should return the players last names in ascending order in an output list called players. Then each item in players should be added to the combo box cboPlayer. Finally, the first item of cboPlayer should be selected. GetPlayers should be called when frmStats loads.
4. Write a Public Sub called GetPlayerStats, which should be called when the selected index of cboPlayers changes. Write the code in GetPlayerStats that does the following:
a. Using a LINQ query, return the record with all of the fields from MyDataSet in an output list called
https://canvas.vt.edu/courses/86444/assignments/582320
1/2
2019/4/15 Homework 5
pstats, where the field Last is equal to the text from cboPlayer. Use the same words as the different fields for the Select command of this query (e.g. first = stats(¡°First¡±), last = stats(¡°Last¡±), etc.). Note that since pstats will have only 1 item, you can refer to any field returned form the query as pstats(0).; (e.g. pstats(0).first or pstats(0).fgm, etc.). Note also that names 3PG and 3PM may not work due to the number at the beginning; use P3G and P3M instead, wherever appropriate.
b. Clear the Series collection of the chart chrStats1, add the series ¡°Made¡±, set the ChartType of these series to SeriesChartType.Column, set the series chart area to ¡°ChartArea1¡±, and add the points for properties fgm, ftm, and p3m to this series, using property values as Y values, and a string which is the same as the property name (e.g. ¡°FGM¡± for fgm) as the X values. Add the series ¡°Attempted¡± to chrStats1, set the ChartType of these series to SeriesChartType.Column, set the series chart area to ¡°ChartArea1¡±, and add the point for the properties fga, fta, and p3a to this series. Set MajorGrid.Enabled property of AxisX to False, set the Maximum property of AxisY to the value of pstats(0).fga, set the Title property of AxisX to ¡°Statistics¡± and the Title property of AxisY to ¡°Count¡±.
c. Clear the Series collection of the chart chrStats2, add the series ¡°Other Stats¡±, set the ChartType of these series to SeriesChartType.Column, set the series chart area to ¡°ChartArea1¡±, and add the points for offr, defr, reb, ast, tov, stl, and blk to this series. Set MajorGrid.Enabled property of AxisX to False, set the Maximum property of AxisY to the maxium of pstats(0).reb and pstats(0).ast (using function Math.Max), set the Title property of AxisX to ¡°Statistics¡± and the Title property of Axis Y to Count.
When you are done, please save all of your work and close the project, zip the project folder, and name the zip file using the format
https://canvas.vt.edu/courses/86444/assignments/582320
2/2