1 / 48

CHAPTER TWELVE

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

newton
Download Presentation

CHAPTER TWELVE

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. CHAPTER TWELVE 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 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 Chapter 12: Cell Phone Applications and Web Services

  4. Introduction 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 Nametext 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 Chapter 12: Cell Phone Applications and Web Services

  6. Creating a Smartphone Application 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 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 theAction 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 Chapter 12: Cell Phone Applications and Web Services

  9. Entering Input Using a Smartphone 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 objectcboTipPercent. 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 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 Chapter 12: Cell Phone Applications and Web Services

  12. Adding Smartphone Toolbox Objects Left softkey 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 Tipin the Command control area. Press ENTER. • Use the (Name) property to name the Command control area mnuComputeTip 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 ) Chapter 12: Cell Phone Applications and Web Services

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

  16. Program Design Chapter 12: Cell Phone Applications and Web Services

  17. Program Design Chapter 12: Cell Phone Applications and Web Services

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

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

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

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

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

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

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

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

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

  27. CurrencyConverter Web Reference On the Add Web Reference dialog box, click the Add Reference button for the CurrencyConverter web service. 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 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 Chapter 12: Cell Phone Applications and Web Services

  30. Creating a Web Services Connection 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. Chapter 12: Cell Phone Applications and Web Services

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

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

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

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

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

  37. Program Design Chapter 12: Cell Phone Applications and Web Services

  38. Program Design Chapter 12: Cell Phone Applications and Web Services

  39. Designing the Program Processing Objects 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 Chapter 12: Cell Phone Applications and Web Services

  41. Microsoft Reports: Creating a Report • Click the Next button. • Download the database named physicians.accdbfrom 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. Chapter 12: Cell Phone Applications and Web Services

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

  43. Microsoft Reports: Creating a Report You may need to resize the fields… 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 Chapter 12: Cell Phone Applications and Web Services

  45. Displaying the Report 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 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 Chapter 12: Cell Phone Applications and Web Services

  48. CHAPTER TWELVE COMPLETE Cell Phone Applicationsand Web Services

More Related