+ All Categories
Home > Documents > CHAPTER TWELVE

CHAPTER TWELVE

Date post: 12-Jan-2016
Category:
Upload: newton
View: 19 times
Download: 0 times
Share this document with a friend
Description:
CHAPTER TWELVE. Cell Phone Applications and Web Services. Objectives. Create a Smartphone application Use a cell phone keypad for input Enter input using a Smartphone Enter other characters using the keypad Add Smartphone Toolbox objects - PowerPoint PPT Presentation
48
Microsoft Visual Basic 2008 CHAPTER TWELVE Cell Phone Applications and Web Services
Transcript
Page 1: CHAPTER TWELVE

Microsoft Visual Basic 2008

CHAPTER TWELVE

Cell Phone Applications and Web Services

Page 2: CHAPTER TWELVE

12

Chapter 12: Cell Phone Applications and Web Services 2

Objectives

►Create a Smartphone application

►Use a cell phone keypad for input

►Enter input using a Smartphone

►Enter other characters using the keypad

►Add Smartphone Toolbox objects

►Display MsgBox objects in a Smartphone environment

►Code softkey “buttons” in a Smartphone application

Page 3: CHAPTER TWELVE

12

Chapter 12: Cell Phone Applications and Web Services 3

Objectives

►Find Web services

►Create a Web service connection

►Call a Web service method

►Create a Microsoft Report

►Display a Report in a Web application

►Microsoft Report vs Crystal Reports

Page 4: CHAPTER TWELVE

12

Chapter 12: Cell Phone Applications and Web Services 4

Introduction

Page 5: CHAPTER TWELVE

12

Chapter 12: Cell Phone Applications and Web Services 5

Creating a Smartphone Application

►With Visual Studio 2008 open:• New Project• New Smart Device

►In the Name text box:• Change from SmartDeviceProject1 to Tip. • Select Windows Mobile 5.0 Smartphone SDK

from the Target platform list button

►Select the Device Application Template and click the OK button

Page 6: CHAPTER TWELVE

12

Chapter 12: Cell Phone Applications and Web Services 6

Creating a Smartphone Application

Page 7: CHAPTER TWELVE

12

Chapter 12: Cell Phone Applications and Web Services 7

Entering Input Using a Smartphone

► Form Name Tip Calculator

► Label object lblBillAmount

• Text property Amount of Bill.

► TextBox object txtBill

► Run the Smartphone application by clicking the Start Debugging button on the Standard toolbar

► Make sure USA Windows Mobile 5.0 Smartphone R2 QVGA Emulator is selected, and then click the Deploy button

► To enter the bill amount of 75.22, press the 7 key on the keypad five times quickly. The letter “p” appears first, then the letter “q,” then the letter “r,” then the letter “s,” and lastly the number “7”. Next, press the 5 key on the keypad four times quickly to enter the number 5

Page 8: CHAPTER TWELVE

12

Chapter 12: Cell Phone Applications and Web Services 8

Entering Input Using a Smartphone

► To enter the decimal point: hold the # key in the lower-right corner of the keypad until the Symbols window opens

► To enter the decimal point, press the navigation keys, such as the right ARROW KEY and DOWN ARROW key, to move to the decimal point (period) in the Symbols window.

► To select the decimal point, press the Action key in the center of the navigation keys. Enter the digits 22 by first pressing the 2 key four times quickly. Wait a few seconds and press the 2 key four times quickly again to display the second 2.

You can also press the 1 key repeatedly…

► To close the application, click the Close button in the upper-right corner of the program window

Page 9: CHAPTER TWELVE

12

Chapter 12: Cell Phone Applications and Web Services 9

Entering Input Using a Smartphone

Page 10: CHAPTER TWELVE

12

Chapter 12: Cell Phone Applications and Web Services 10

Adding Smartphone Toolbox Objects

►Drag a second Label object named lblPercentage to the form below the TextBox object. Change the Text property to Tip Percentage.

►Drag a ComboBox object to the Form object below the second label. Name the ComboBox object cboTipPercent. Click the ellipsis button to the right of the Items property.

►Enter the three tip percentage amounts into the String Collection Editor: 10% (press ENTER), 15% (press ENTER), and 20%. Resize the objects to the exact size of the text. Center both the Label and ComboBox objects on the center of the form

Page 11: CHAPTER TWELVE

12

Chapter 12: Cell Phone Applications and Web Services 11

Adding Smartphone Toolbox Objects

► Run the Smartphone application by clicking the Start Debugging button on the Standard toolbar. In the Deploy TipCalculator window, make sure the USA Windows Mobile 5.0 Smartphone R2 QVGA Emulator option is selected, and then click the Deploy button. When the Smartphone emulator opens and loads the application, enter 75.22 in the first TextBox object using the keypad.

► To move to the ComboBox object for input, click the down arrow key on the navigation keypad.

► To view the ComboBox items, click the right arrow on the navigation keypad; 10% is displayed in the ComboBox object. Click the right arrow again to view 15%. Select the 15% tip percentage by clicking the Action button in the center of the navigation keypad.

► Close the Smartphone emulator without saving the emulator state

Page 12: CHAPTER TWELVE

12

Chapter 12: Cell Phone Applications and Web Services 12

Adding Smartphone Toolbox Objects

Left softkey

Page 13: CHAPTER TWELVE

12

Chapter 12: Cell Phone Applications and Web Services 13

Creating a Softkey Menu

►On the frmTip Form object of the Tip application, click the left side of the Command control area

► Type Compute Tip in the Command control area. Press ENTER.

►Use the (Name) property to name the Command control area mnuComputeTip

Page 14: CHAPTER TWELVE

12

Chapter 12: Cell Phone Applications and Web Services 14

Coding the Smartphone Application

►In the TipCalculator application, double-click the mnuComputeTip Command control area in the lower-left corner of the Smartphone Form object

►Enter the code to compute the tip for the restaurant bill amount ( see next slide )

Page 15: CHAPTER TWELVE

12

Chapter 12: Cell Phone Applications and Web Services 15

Coding the Smartphone Application

Page 16: CHAPTER TWELVE

12

Chapter 12: Cell Phone Applications and Web Services 16

Program Design

Page 17: CHAPTER TWELVE

12

Chapter 12: Cell Phone Applications and Web Services 17

Program Design

Page 18: CHAPTER TWELVE

12

Chapter 12: Cell Phone Applications and Web Services 18

Designing the Program Processing Objects

Page 19: CHAPTER TWELVE

12 Web Services [page 906]

► A web service is a collection of protocols and standards used for exchanging data between applications or systems.

► UDDI Project

• Universal Description, Discovery, and Integration

►A directory of services over the web

► WSDL

• Web services us a special language called Web Services Description Language which is an XML format.

• WSDL provides a simple way for servuce providers to describe the basic format of requests to their systems regardless of the underlying protocol (such as SOAP [simple object access protocol] or XML)

Chapter 12: Cell Phone Applications and Web Services 19

Page 20: CHAPTER TWELVE

12 Finding Web Services

►The next slide shows the process described in the book to add a web service.

►This was the correct process in VisualStudio 2005 but NOT in VisualStudio 2008!!

►The slides following the VisualStudio 2005 method show how to do this correctly in VisualStudio 2008.

Chapter 12: Cell Phone Applications and Web Services 20

Page 21: CHAPTER TWELVE

12 Finding Web Services [VisualStudio 2005]

► New Windows Form object CurrencyConverter

► Select Add Web Reference on the shortcut menu

► Enter the following Web service URL in the URL text box:

http://www.webservicex.net/CurrencyConvertor.asmx?wsdl

► Then click the Go button to connect to the Web service.

You must be connected to the Internet to find the Web service.

► If the Web service is available online, a message appears stating the name of the method that will be used in the code window to call the existing Web service

► Click the Add Reference button in the Add Web Reference window

Chapter 12: Cell Phone Applications and Web Services 21

Page 22: CHAPTER TWELVE

12

Chapter 12: Cell Phone Applications and Web Services 22

Finding Web Services [VisualStudio 2008]

►With a new Windows Form object open • right-click the project name• Select Add Service Reference on the shortcut menu

Page 23: CHAPTER TWELVE

12 Add Service Reference

Chapter 12: Cell Phone Applications and Web Services 23

Right-click the project name

Page 24: CHAPTER TWELVE

12 Add Service Reference – Advanced Button

Chapter 12: Cell Phone Applications and Web Services 24

On the Add Service Reference dialog box, click the Advanced button

Page 25: CHAPTER TWELVE

12 Service Reference Settings – Add Web Reference

Chapter 12: Cell Phone Applications and Web Services 25

On the Service Reference Settings dialog box, click the Add Web Reference… button

Page 26: CHAPTER TWELVE

12 Add Web Reference - URL

Chapter 12: Cell Phone Applications and Web Services 26

http://www.webservicex.net/CurrencyConvertor.asmx?wsdl

Enter the URL and click Go

Page 27: CHAPTER TWELVE

12 CurrencyConverter Web Reference

Chapter 12: Cell Phone Applications and Web Services 27

On the Add Web Reference dialog box, click the Add Reference button for the CurrencyConverter web service.

Page 28: CHAPTER TWELVE

12

Chapter 12: Cell Phone Applications and Web Services 28

Finding Web Services

► A reference to the Web Service is added to your project in a folder called Web References

Page 29: CHAPTER TWELVE

12

Chapter 12: Cell Phone Applications and Web Services 29

Creating a Web Services Connection

► After creating the Web reference, open the code window to create an instance of the Web service class.

► create an instance named wsMoney (where ws stands for Web service)

► type Dim wsMoney as New net. • You include the word net because the Web reference listed in the

Solution Explorer begins with the name net

► Select the Web service named CurrencyConvertor in the IntelliSense window

Page 30: CHAPTER TWELVE

12

Chapter 12: Cell Phone Applications and Web Services 30

Creating a Web Services Connection

Page 31: CHAPTER TWELVE

12

Chapter 12: Cell Phone Applications and Web Services 31

Calling a Web Service Method

► The object you need is the wsMoney object

► The method you need to call is named ConversionRate.

• ConversionRate takes two arguments. The argument types are constants provided by the Web Service.

• The first argument is the FROM currency• The second argument is the TO currency

• The method returns a conversion rate.

Page 32: CHAPTER TWELVE

12 Simple Conversion Example

Chapter 12: Cell Phone Applications and Web Services 32

Page 33: CHAPTER TWELVE

12 ConversionRate Method Arguments

Chapter 12: Cell Phone Applications and Web Services 33

Page 34: CHAPTER TWELVE

12 Currency Converter Constants

►http://www.webservicex.com/CurrencyConvertor.asmx

Chapter 12: Cell Phone Applications and Web Services 34

Page 35: CHAPTER TWELVE

12

Chapter 12: Cell Phone Applications and Web Services 35

Calling a Web Service Method

Option Strict OnOption Explicit OnPublic Class Form1

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

Dim wsMoney As New net.webservicex.www.CurrencyConvertor Dim decAmount As Decimal Dim dblRate As Double

dblRate = wsMoney.ConversionRate( net.webservicex.www.Currency.USD,

net.webservicex.www.Currency.EUR )

decAmount = 100D * Convert.ToDecimal(dblRate)

MsgBox("$100.00 dollars (USD) is equivalent to " & decAmount.ToString("C") & " euros (EUR).", , "USD to EUR

Conversion") End SubEnd Class

Page 36: CHAPTER TWELVE

12 Simple Example Execution

Chapter 12: Cell Phone Applications and Web Services 36

Page 37: CHAPTER TWELVE

12

Chapter 12: Cell Phone Applications and Web Services 37

Program Design

Page 38: CHAPTER TWELVE

12

Chapter 12: Cell Phone Applications and Web Services 38

Program Design

Page 39: CHAPTER TWELVE

12

Chapter 12: Cell Phone Applications and Web Services 39

Designing the Program Processing Objects

Page 40: CHAPTER TWELVE

12

Chapter 12: Cell Phone Applications and Web Services 40

Microsoft Reports: Creating a Report

►Click the New Web Site button on the Standard toolbar.

► In the list of Visual Studio installed templates, click ASP.NET Reports Web Site.

►Name the sample report PhysicianReferral.

► In the Toolbox, open the Reporting category by clicking the plus sign to expand the Reporting category.

► Drag the MicrosoftReportViewer object onto the Default.aspx page in the div control

► If necessary, click the action button on the MicrosoftReportViewer object, and then click the text Design a new report

Page 41: CHAPTER TWELVE

12

Chapter 12: Cell Phone Applications and Web Services 41

Microsoft Reports: Creating a Report

► Click the Next button. ► Download the database named physicians.accdb from scsite.com/vb2008/ch12 ► Click the plus sign in front of Create New Connection to expand the options. ► Click the New Connection button. Browse to the physicians.accdb database and select

the file. ► Click the Open button► Click the OK button. ► Click the Next button.

When asked if you want to copy the file to your current project, click the No button.

► Click the Next button to save the connection string. ► On the Choose Your Database Objects window, expand the Tables list by clicking the

plus sign. ► Click PhysicianList to select the table► Click the Finish button. ► Click the Next button to select the data source. ► Select the Tabular report type and click the Next button. ► On the Design the Table window, display the first six fields of the table in the Group

Section.

Page 42: CHAPTER TWELVE

12 Microsoft Reports: Creating a Report

►Click the Next button.

►Select a Block layout for the report and click the Next button again.

►Select the Ocean table style and click Next

►Name the report Texas HMO Physicians and click the Finish button.

►The fields can be resized to display the entire field value in the finished Web page

Chapter 12: Cell Phone Applications and Web Services 42

Page 43: CHAPTER TWELVE

12

Chapter 12: Cell Phone Applications and Web Services 43

Microsoft Reports: Creating a Report

You may need to resize the fields…

Page 44: CHAPTER TWELVE

12

Chapter 12: Cell Phone Applications and Web Services 44

Displaying the Report

►Click the Default.aspx tab to open the Web form.

►Click the Smart tag to the right of the MicrosoftReportViewer object

►Click the Choose Report list arrow.

►Select Texas HMO Physicians.rdlc

►Select the MicrosoftReportViewer object and change the Height property to 500px and the Width property to 700px.

►Click the Start Debugging button on the Standard toolbar to execute the Web page.

►On the Script Debugging Displayed window, click the Yes button

Page 45: CHAPTER TWELVE

12

Chapter 12: Cell Phone Applications and Web Services 45

Displaying the Report

Page 46: CHAPTER TWELVE

12

Chapter 12: Cell Phone Applications and Web Services 46

Summary

►Create a Smartphone application

►Use a cell phone keypad for input

►Enter input using a Smartphone

►Enter other characters using the keypad

►Add Smartphone Toolbox objects

►Create a softkey menu

►Code the Smartphone application

Page 47: CHAPTER TWELVE

12

Chapter 12: Cell Phone Applications and Web Services 47

Summary

►Display MessageBox objects in a Smartphone environment

►Find Web services

►Create a Web service connection

►Call a Web service method

►Create a Microsoft Report

►Display a Report in a Web application

Page 48: CHAPTER TWELVE

Microsoft Visual Basic 2008

CHAPTER TWELVE COMPLETE

Cell Phone Applicationsand Web Services


Recommended