Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
<strong>BIS</strong> <strong>311</strong> <strong>DeVry</strong> <strong>Week</strong> 7 I <strong>Lab</strong><br />
Downloading is very simple, you can download this Course here:<br />
http://wiseamerican.us/product/bis-<strong>311</strong>-devry-week-7-ilab/<br />
Or<br />
Contact us at:<br />
SUPPORT@WISEAMERICAN.US<br />
Question Description<br />
<strong>BIS</strong> <strong>311</strong> <strong>DeVry</strong> <strong>Week</strong> 7 i<strong>Lab</strong><br />
<strong>BIS</strong><strong>311</strong><br />
<strong>BIS</strong> <strong>311</strong> <strong>DeVry</strong> <strong>Week</strong> 7 i<strong>Lab</strong><br />
iLAB OVERVIEW<br />
Scenario/Summary<br />
In this lab, you will create a two-tier application that retrieves the name and price of a product from a Microsoft Access<br />
database.<br />
Product Lookup Business Requirements<br />
The user enters the product ID for a product. The application searches the Products table of a Microsoft Access<br />
database named Inventory.accdb for the specified product. If a matching product is found, its name and price are<br />
displayed. If the product is not found, the message "Product ID not found" is displayed.<br />
TOE Chart for Product Lookup User Interface<br />
Task Object Event<br />
Get the following inputs from the user:<br />
Product ID<br />
txtProductID<br />
Perform the following processing:<br />
Retrieve product data from database using product ID<br />
Display the following output to the user:<br />
If the product ID was found: Product name and price<br />
If the product ID was not found: "Product ID not found"<br />
btnFindProduct<br />
dataSvc<br />
lblProductName,<br />
lblProductPrice<br />
lblMessage<br />
Click<br />
Pseudocode for Product Lookup User Interface<br />
Start button-click event handler<br />
Instantiate dataSvc object from DataService class<br />
Declare Boolean variable ProductFound<br />
Get ProductID property of dataSvc from user
ProductFound= result of GetProduct() method of dataSvc<br />
if ProductFound is True<br />
Display Product name and Product price<br />
Else Display "Product ID not found"<br />
Stop button-click event handler<br />
Class Diagram for DataService Class<br />
DataService<br />
+numeric ProductID<br />
+string ProductName<br />
+string ProductPrice<br />
GetProduct()<br />
Pseudocode for GetProduct() Method of DataService Class<br />
Boolean GetProduct()<br />
Instantiate DataSet object for the Inventory database<br />
Instantiate TableAdapter object for the Products table in the Inventory database<br />
Declare Boolean variable Found<br />
Use the Products TableAdapter object to retrieve the Products record matching ProductID into the Inventory DataSet<br />
object<br />
If the count of Products records in the Inventory DataSet > 0<br />
Set ProductName=ProductName field of the first retrieved record<br />
Set ProductPrice=ProductPrice field of the first retrieved record<br />
Set Found=True<br />
Else<br />
Set Found = False<br />
Return Found<br />
End GetProduct()<br />
Remember This<br />
In a true client-server application running on a network, the code in the DataService class would be executed on the<br />
server (the data-services tier), and the form would be executed on the client (the user-interface tier). In this lab, both<br />
the DataService class and the form will be executed on the same computer.<br />
Deliverables<br />
Submit a Word document named <strong>Lab</strong>7YourFirstLastName.docx (where YourFirstLastName = your first and last name;<br />
e.g., <strong>Lab</strong>7JohnSmith.docx) containing the following.<br />
<br />
<br />
<br />
<br />
Screenshot of form showing the application running, with a valid product ID entered and the corresponding<br />
product name and price displayed<br />
Screenshot of form showing the application running, with an invalid product ID entered and the message<br />
"Product ID not found" displayed<br />
Copy of code for button-click event<br />
Copy of code for DataService class
Category Points % Description<br />
Create and rename form,<br />
add controls, and set 15 30%<br />
properties<br />
Create<br />
database<br />
connection, dataset, and 10 20%<br />
query function<br />
Code data service class 5 10%<br />
Windows form was created and named ProductLookup.vb. Form text<br />
property was set to <strong>Lab</strong> 7 Your Name (where Your Name = your full<br />
name). The following controls were added to the form: Identifying<br />
label and text box for entry of product ID; button to perform product<br />
lookup; and labels for display of product name, product price, and<br />
error message. Name and text properties of all controls were set<br />
appropriately, with no typos or spelling errors.<br />
A connection to the Inventory database and an associated dataset<br />
containing the Products table were created. A FillByProductID()<br />
method using an SQL query to retrieve a product record with a<br />
specified product ID has been added to the Products table adapter.<br />
A DataService class was created with code that corresponds to the<br />
given class diagram and pseudocode, with no errors. Class includes<br />
public properties for the product ID, product name, and product price,<br />
and a GetProduct() method that retrieves the product name and price<br />
for a specified product ID and returns a Boolean value indicating<br />
success or failure. Code button-click event 5 10% Button-click event<br />
code was entered that corresponds to the given pseudocode, with no<br />
syntax errors. An object of the DataService class is instantiated and<br />
used to retrieve the product name and price for the product ID entered<br />
by the user. The name and price are displayed if the product record<br />
was found, or the "Product ID not found" message otherwise.<br />
Test-run<br />
successfully<br />
application<br />
15 30%<br />
Application is shown running successfully with screenshots for each<br />
of the 4 cases: cases 1–3 each show a valid product ID entered with<br />
correct name and price displayed; case 4 shows an invalid product ID<br />
entered with "Product ID not found" message displayed.<br />
Total 50 100%<br />
Required Software<br />
Visual Studio 2012<br />
Access the software at.devry.edu/">https://lab.devry.edu.<br />
Steps: all<br />
iLAB STEPS Step 1: Create Project and Form<br />
.equella.ecollege.com/file/ffda06da-93d2-4c2b-8bea-5ff3d0e58d3e/76/<strong>BIS</strong><strong>311</strong>_W7_i<strong>Lab</strong>.html#top">Back to Top<br />
(a) Important: Before beginning this lab, download the Microsoft Access database file Inventory.accdb from Doc Sharing<br />
and save it to your Downloads folder or on your computer desktop. Don't open the file from Doc Sharing, just save it<br />
and make a note of where it is located. If it downloads automatically when you click on it in Doc Sharing, it is most likely<br />
saved in your Downloads folder, but check to make sure. You will need to be able to locate this file to create a data<br />
connection to it in Step 2.<br />
(b) Log in to the Citrix i<strong>Lab</strong> site as you did in the previous labs. Click the Microsoft Visual Studio 2012 icon to launch<br />
Visual Studio.<br />
(c) Pull down the File menu and select New Project . . .<br />
(d) In the New Project dialog, ensure that under Templates in the left column, Visual Basic is selected, and that in the<br />
center column, Windows Form Application is selected. In the Name field at the bottom of the dialog, enter<br />
ProductLookup. Click OK.
(e) In the Solution Explorer pane on the right side of the screen, right-click on Form1.vb, select Rename, and change<br />
the name to ProductLookup.vb. Press Enter after entering the new form name.<br />
(f) Change the Text property of the form to <strong>Lab</strong> 7 Your Name (where Your Name = your full name), as you have done<br />
in previous labs.<br />
(g) Drag the following controls from the ToolBox onto the form, arrange them in a logical fashion, and set their properties<br />
as indicated in the table below.<br />
Control Name Property Text Property<br />
<strong>Lab</strong>el <strong>Lab</strong>el1 Product ID:<br />
TextBox<br />
txtProductID<br />
Button btnFindProduct Find Product<br />
<strong>Lab</strong>el <strong>Lab</strong>el2 Product name:<br />
<strong>Lab</strong>el lblProductName ????????<br />
<strong>Lab</strong>el <strong>Lab</strong>el3 Product price:<br />
<strong>Lab</strong>el lblProductPrice ????????<br />
<strong>Lab</strong>el lblMessage Ready<br />
(h) Ensure that the controls are positioned and sized so that the form has a neat, professional appearance and none<br />
of the text is cut off. Your completed form should look like the following.<br />
Step 2: Create Database Connection and Dataset<br />
.equella.ecollege.com/file/ffda06da-93d2-4c2b-8bea-5ff3d0e58d3e/76/<strong>BIS</strong><strong>311</strong>_W7_i<strong>Lab</strong>.html#top">Back to Top<br />
(a) Pull down the Project menu and select Add New Data Source.<br />
(b) The Data Source Configuration Wizard should appear. On the first screen, select Database and click Next.<br />
(c) On the next screen, select Dataset and click Next.<br />
Step 3: Create SQL Query Method<br />
.equella.ecollege.com/file/ffda06da-93d2-4c2b-8bea-5ff3d0e58d3e/76/<strong>BIS</strong><strong>311</strong>_W7_i<strong>Lab</strong>.html#top">Back to Top<br />
(a) In the Solution Explorer pane on the right, double-click the InventoryDataSet.xsd file to open it in the dataset design<br />
window. Right-click on ProductsTableAdapter, select Add, then select Query.<br />
(b) The TableAdapter Query Configuration Wizard appears. On the Choose a Command Type screen, ensure that the<br />
Use SQL Statements option is selected, and click Next.<br />
(c) On the Choose a Query Type screen, ensure that the option "SELECT which returns rows" is selected, and click<br />
Next.<br />
(d) On the Specify an SQL SELECT statement screen, add the clause WHERE ProductID=? at the end of the displayed<br />
SQL statement. This enables your query to retrieve a Product record with a specific ProductID, rather than returning all<br />
the records. Click Next.<br />
(e) On the Choose Methods to Generate screen, ensure that the checkbox next to Fill a DataTable is checked, and<br />
uncheck the checkbox next to Return a DataTable. Change the Method name under Fill a DataTable to FillByProductID.<br />
Click Next.<br />
(f) The Wizard Results screen should confirm that the SELECT statement and Fill method were generated with no<br />
errors. Click Finish.<br />
(g) Pull down the File menu and select Save All. If a Save Project dialog appears, ensure that the project is saved to<br />
the My DocumentsVisual Studio 2012Projects folder under your DSI number. Click Save.
(h) Click the X on the right of the InventoryDataSet.xsd tab to close the dataset design window.<br />
Step 4: Create DataService Class<br />
.equella.ecollege.com/file/ffda06da-93d2-4c2b-8bea-5ff3d0e58d3e/76/<strong>BIS</strong><strong>311</strong>_W7_i<strong>Lab</strong>.html#top">Back to Top<br />
(a) Pull down the Project menu, select Add Class, and add a new class file named DataService.vb to your project.<br />
(b) Starting where the cursor is positioned, in between the Public Class Order and the End Class statements, enter the<br />
following code.<br />
Code for DataService Class<br />
'Data access services class<br />
Public Property ProductID As Integer<br />
Public Property ProductName As String<br />
Public Property ProductPrice As Decimal<br />
Public Function GetProduct() As Boolean<br />
'Get product data from database for product matching ProductID<br />
Dim productsTA As New InventoryDataSetTableAdapters.ProductsTableAdapter<br />
Dim inventoryDS As New InventoryDataSet<br />
Dim blnFound As Boolean<br />
productsTA.FillByProductID(inventoryDS.Products,ProductID)<br />
If inventoryDS.Products.Count > 0 Then<br />
ProductName = inventoryDS.Products(0).ProductName<br />
ProductPrice = inventoryDS.Products(0).ProductPrice<br />
blnFound = True<br />
Else<br />
ProductName = ""<br />
ProductPrice = 0<br />
blnFound = False<br />
End If<br />
Return blnFound<br />
End Function<br />
(c) After entering the above code, your code editor window should look like this.<br />
Step 6: Test, Debug, and Submit<br />
.equella.ecollege.com/file/ffda06da-93d2-4c2b-8bea-5ff3d0e58d3e/76/<strong>BIS</strong><strong>311</strong>_W7_i<strong>Lab</strong>.html#top">Back to Top<br />
(a) Run the application by doing one of the following: click the Start button; pull down the Debug menu and select Start<br />
Debugging; or press the F5 key.<br />
(b) Your form should appear. Test your application by entering the following test cases. For each test case, enter the<br />
indicated value for Product ID; click the Find Product button; and check that the result displayed is correct. Capture a<br />
screenshot of each correct test case and paste it into a Word document. Remember, use CTRL+ALT+PrintScreen to<br />
capture a screenshot.<br />
Test case # Product ID Product name Product price Message
1 123 Road bike $499.95 Product ID found<br />
2 456 Mountain bike $359.95 Product ID found<br />
3 789 Town bike $579.95 Product ID found<br />
4 999 Product ID not found<br />
As an example, your screenshot for test case #1 should look like the following.<br />
(c) If your application does not work correctly, debug the application and try again. Post in the Q & A Forum or contact<br />
your professor for assistance, if needed.<br />
(d) When your application works correctly for all test cases, select and copy all the code for the button-click event<br />
handler and the DataService class and paste it into your Word document below the test case screenshots. Save the<br />
Word document as <strong>Lab</strong>7YourFirstLastName.docx (where YourFirstLastName = your first and last name; e.g.,<br />
JohnSmith) and submit it to the appropriate dropbox.