File, Printing, and
Database Access in
In the graded project for Lesson 4, you added the
GroceryItemForm to the GroceryApp project. In this project,
you’ll add functionality to save and load saved grocery basket
files. You’ll display the contents of the basket using the databound
You’ll add a form to the project to display grocery items in
This will be the last graded project based on this scenario.
You’ll be graded on the end-user functionality, so variable
names and other aspects can differ, but the application must
work as intended.
1. In Visual Studio, load the GroceryApp project that you
completed in Lesson 4.
2. Add the options &Save and &Load to the Application
3. Add the OpenFileDialog and SaveFileDialog components
to the Windows form. Name them openDialog and
4. In the Click event for the Save option, prompt the user
for a file location and store the basket as a text file.
Recall that grocery items are stored in the basket variable.
Hint: You could use a CSV file similar to a flat-file
database. See Chapter 9 in your book for details on how
to format the text file.
5. In the Click event for the Load option, prompt the user
for a file location and load the contents of the text file
into the basket. Make sure you empty the basket first.
Hint: You could use the Split method in the String class
to break each line into individual array items. See the
MSDN Library Web page http://msdn.microsoft.com/
en-us/library/b873y76a.aspx for more information.
6. Save your work and test the program. Add some items to
the basket and save them. Then attempt to load them
again. Click on the View option in the Basket menu to
see the basket contents. You’ll modify how this menu
option works in the concluding steps.
7. Add a new form to the project named
BasketDisplayForm. Set the Text property to Basket
Contents. You should also set the Size property to 600,
8. Add a DataGridView control named viewBasket. Set the
Dock property to Fill.
9. In the Load event of the BasketDisplayForm, add the
following code to display the basket contents in the
viewBasket.DataSource = basket
Notice how simple it’s to perform data-binding with data
sources other than databases.
10. Go back to the code view of GroceryItemForm and
replace the content of the ViewToolStripMenuItem_Click
event handler. Load and display the BasketDisplayForm
modally instead. Remember you don’t have to worry
about the basket variable, because the BasketDisplayForm
handles data-binding in its Load event.
11. Save and run the application. Verify that all controls and
menus work correctly. You’ll submit the compiled application
for this project.
Note: If you close the Login form, you don’t need to perform
the login process. This is by design, so that you can
test the application without logging on.
To submit your project, you should build the project and
submit the following file:
To find this file, you should go to directory where you saved
the GroceryApp project. To determine this path, click on
GroceryApp in the Solution Explorer panel. Copy the
value for the Project Folder property in the Properties
panel. In Windows Explorer, paste the file path and hit the
Enter key. Then, go to the bin\Debug folder. Copy the
GroceryApp.exe file to your desktop or any other temporary
location. This EXE file is the compiled application and you
can double-click on it to run it without using Visual Studio.
Use the following procedure to submit your project online:
1. Log in to view your student homepage and go to the My
2. Click on Take Exam next to the lesson you’re working on.
3. Attach your files as follows:
a. Click on the Browse box.
b. Locate the file you wish to attach.
c. Double-click on the file.
d. Click Upload File.
e. If you have more than one file to attach, repeat
steps a–d for each file.
4. Enter your e-mail address in the box provided.
(Note: Your e-mail address is required for online
5. If you wish to include comments about this project to
your instructor, enter your comments in the Message
6. Click on Submit Files.
Remember to follow directions and follow good programming
principles as described in the study guide.
Your project will be graded using the following rubric:
■ The Save menu option performs
the correct behavior. 130 points
■ The Load menu option performs
the correct behavior. 130 points
■ The View menu option performs
the correct behavior. 115 points
■ The BasketDisplayForm is
laid out correctly. 115 points
■ The compiled application is
included and runs. 110 points
TOTAL 100 points
* You can also use 2CO option if you want to purchase through Credit Cards/Paypal but make sure you put the correct billing information otherwise you wont be able to receive any download link.
* Your paypal has to be pre-loaded in order to complete the purchase or otherwise please discuss it with us at [email protected].
* As soon as the payment is received, download link of the solution will automatically be sent to the address used in selected payment method.
* Please check your junk mails as the download link email might go there and please be patient for the download link email. Sometimes, due to server congestion, you may receive download link with a delay.
* All the contents are compressed in one zip folder.
* In case if you get stuck at any point during the payment process, please immediately contact us at [email protected] and we will fix it with you.
* We try our best to reach back to you on immediate basis. However, please wait for atleast 8 hours for a response from our side. Afterall, we are humans.
* Comments/Feedbacks are truely welcomed and there might be some incentives for you for the next lab/quiz/assignment.
* In case of any query, please donot hesitate to contact us at [email protected].
* MOST IMPORTANT Please use the tutorials as a guide and they need NOT to be used for any submission. Just take help from the material.
******************************************** Good Luck ***************************************************
Any personal information received will only be used to fill your order. We will not sell or redistribute your information to anyone.
We will try our best to resolve the issue and if still persists we can discuss for a refund in case its required.