Presentation is loading. Please wait.

Presentation is loading. Please wait.

Microsoft Visual Basic 2008 CHAPTER TWELVE Cell Phone Applications and Web Services.

Similar presentations


Presentation on theme: "Microsoft Visual Basic 2008 CHAPTER TWELVE Cell Phone Applications and Web Services."— Presentation transcript:

1 Microsoft Visual Basic 2008 CHAPTER TWELVE Cell Phone Applications and Web Services

2 12 Chapter 12: Cell Phone Applications and Web Services2 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

3 12 Chapter 12: Cell Phone Applications and Web Services3 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

4 12 Chapter 12: Cell Phone Applications and Web Services4 Introduction

5 12 Chapter 12: Cell Phone Applications and Web Services5 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

6 12 Chapter 12: Cell Phone Applications and Web Services6 Creating a Smartphone Application

7 12 Chapter 12: Cell Phone Applications and Web Services7 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

8 12 Chapter 12: Cell Phone Applications and Web Services8 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

9 12 Chapter 12: Cell Phone Applications and Web Services9 Entering Input Using a Smartphone

10 12 Chapter 12: Cell Phone Applications and Web Services10 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

11 12 Chapter 12: Cell Phone Applications and Web Services11 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

12 12 Chapter 12: Cell Phone Applications and Web Services12 Adding Smartphone Toolbox Objects Left softkey

13 12 Chapter 12: Cell Phone Applications and Web Services13 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

14 12 Chapter 12: Cell Phone Applications and Web Services14 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 )

15 12 Chapter 12: Cell Phone Applications and Web Services15 Coding the Smartphone Application

16 12 Chapter 12: Cell Phone Applications and Web Services16 Program Design

17 12 Chapter 12: Cell Phone Applications and Web Services17 Program Design

18 12 Chapter 12: Cell Phone Applications and Web Services18 Designing the Program Processing Objects

19 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 Services19

20 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 Services20

21 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 Services21

22 12 Chapter 12: Cell Phone Applications and Web Services22 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

23 12 Add Service Reference Chapter 12: Cell Phone Applications and Web Services23 Right-click the project name

24 12 Add Service Reference – Advanced Button Chapter 12: Cell Phone Applications and Web Services24 On the Add Service Reference dialog box, click the Advanced button

25 12 Service Reference Settings – Add Web Reference Chapter 12: Cell Phone Applications and Web Services25 On the Service Reference Settings dialog box, click the Add Web Reference… button

26 12 Add Web Reference - URL Chapter 12: Cell Phone Applications and Web Services26 http://www.webservicex.net/CurrencyConvertor.asmx?wsdl Enter the URL and click Go

27 12 CurrencyConverter Web Reference Chapter 12: Cell Phone Applications and Web Services27 On the Add Web Reference dialog box, click the Add Reference button for the CurrencyConverter web service.

28 12 Chapter 12: Cell Phone Applications and Web Services28 Finding Web Services ►A reference to the Web Service is added to your project in a folder called Web References

29 12 Chapter 12: Cell Phone Applications and Web Services29 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

30 12 Chapter 12: Cell Phone Applications and Web Services30 Creating a Web Services Connection

31 12 Chapter 12: Cell Phone Applications and Web Services31 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.

32 12 Simple Conversion Example Chapter 12: Cell Phone Applications and Web Services32

33 12 ConversionRate Method Arguments Chapter 12: Cell Phone Applications and Web Services33

34 12 Currency Converter Constants ►http://www.webservicex.com/CurrencyConvertor.asmxhttp://www.webservicex.com/CurrencyConvertor.asmx Chapter 12: Cell Phone Applications and Web Services34

35 12 Chapter 12: Cell Phone Applications and Web Services35 Calling a Web Service Method Option Strict On Option Explicit On Public 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 Sub End Class

36 12 Simple Example Execution Chapter 12: Cell Phone Applications and Web Services36

37 12 Chapter 12: Cell Phone Applications and Web Services37 Program Design

38 12 Chapter 12: Cell Phone Applications and Web Services38 Program Design

39 12 Chapter 12: Cell Phone Applications and Web Services39 Designing the Program Processing Objects

40 12 Chapter 12: Cell Phone Applications and Web Services40 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

41 12 Chapter 12: Cell Phone Applications and Web Services41 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.

42 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 Services42

43 12 Chapter 12: Cell Phone Applications and Web Services43 Microsoft Reports: Creating a Report You may need to resize the fields…

44 12 Chapter 12: Cell Phone Applications and Web Services44 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

45 12 Chapter 12: Cell Phone Applications and Web Services45 Displaying the Report

46 12 Chapter 12: Cell Phone Applications and Web Services46 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

47 12 Chapter 12: Cell Phone Applications and Web Services47 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

48 Microsoft Visual Basic 2008 CHAPTER TWELVE COMPLETE Cell Phone Applications and Web Services


Download ppt "Microsoft Visual Basic 2008 CHAPTER TWELVE Cell Phone Applications and Web Services."

Similar presentations


Ads by Google