10 months ago

BIS 311 DeVry Week 7 iLab

(e) In the Solution

(e) In the Solution Explorer pane on the right side of the screen, right-click on Form1.vb, select Rename, and change the name to ProductLookup.vb. Press Enter after entering the new form name. (f) Change the Text property of the form to Lab 7 Your Name (where Your Name = your full name), as you have done in previous labs. (g) Drag the following controls from the ToolBox onto the form, arrange them in a logical fashion, and set their properties as indicated in the table below. Control Name Property Text Property Label Label1 Product ID: TextBox txtProductID Button btnFindProduct Find Product Label Label2 Product name: Label lblProductName ???????? Label Label3 Product price: Label lblProductPrice ???????? Label lblMessage Ready (h) Ensure that the controls are positioned and sized so that the form has a neat, professional appearance and none of the text is cut off. Your completed form should look like the following. Step 2: Create Database Connection and Dataset">Back to Top (a) Pull down the Project menu and select Add New Data Source. (b) The Data Source Configuration Wizard should appear. On the first screen, select Database and click Next. (c) On the next screen, select Dataset and click Next. Step 3: Create SQL Query Method">Back to Top (a) In the Solution Explorer pane on the right, double-click the InventoryDataSet.xsd file to open it in the dataset design window. Right-click on ProductsTableAdapter, select Add, then select Query. (b) The TableAdapter Query Configuration Wizard appears. On the Choose a Command Type screen, ensure that the Use SQL Statements option is selected, and click Next. (c) On the Choose a Query Type screen, ensure that the option "SELECT which returns rows" is selected, and click Next. (d) On the Specify an SQL SELECT statement screen, add the clause WHERE ProductID=? at the end of the displayed SQL statement. This enables your query to retrieve a Product record with a specific ProductID, rather than returning all the records. Click Next. (e) On the Choose Methods to Generate screen, ensure that the checkbox next to Fill a DataTable is checked, and uncheck the checkbox next to Return a DataTable. Change the Method name under Fill a DataTable to FillByProductID. Click Next. (f) The Wizard Results screen should confirm that the SELECT statement and Fill method were generated with no errors. Click Finish. (g) Pull down the File menu and select Save All. If a Save Project dialog appears, ensure that the project is saved to 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. Step 4: Create DataService Class">Back to Top (a) Pull down the Project menu, select Add Class, and add a new class file named DataService.vb to your project. (b) Starting where the cursor is positioned, in between the Public Class Order and the End Class statements, enter the following code. Code for DataService Class 'Data access services class Public Property ProductID As Integer Public Property ProductName As String Public Property ProductPrice As Decimal Public Function GetProduct() As Boolean 'Get product data from database for product matching ProductID Dim productsTA As New InventoryDataSetTableAdapters.ProductsTableAdapter Dim inventoryDS As New InventoryDataSet Dim blnFound As Boolean productsTA.FillByProductID(inventoryDS.Products,ProductID) If inventoryDS.Products.Count > 0 Then ProductName = inventoryDS.Products(0).ProductName ProductPrice = inventoryDS.Products(0).ProductPrice blnFound = True Else ProductName = "" ProductPrice = 0 blnFound = False End If Return blnFound End Function (c) After entering the above code, your code editor window should look like this. Step 6: Test, Debug, and Submit">Back to Top (a) Run the application by doing one of the following: click the Start button; pull down the Debug menu and select Start Debugging; or press the F5 key. (b) Your form should appear. Test your application by entering the following test cases. For each test case, enter the indicated value for Product ID; click the Find Product button; and check that the result displayed is correct. Capture a screenshot of each correct test case and paste it into a Word document. Remember, use CTRL+ALT+PrintScreen to capture a screenshot. Test case # Product ID Product name Product price Message

DEVRY CIS 336 Week 7 iLab 7