C# ПІДРУЧНИКИ / c# / Premier Press - C# Professional Projects
.pdfxx Contents
Chapter 20
Exploring ASP.NET Web Applications. . . . . . . . . . . . . . . . . . |
. 434 |
||||
Introducing Web Forms |
. . . |
. . . . . . . . . . . . . . . . . . . . . . . . |
. 434 |
||
Web Form Server Controls. |
. . . . . . . . . . . . . . . . . . . . . . . . |
. 436 |
|||
Configuring ASP.NET Applications . . . . . . . . . . . . . . . . . . . . |
. 442 |
||||
Configuring Security for ASP.NET Applications . . . . . . . . |
. 442 |
||||
Deploying ASP.NET Applications . . . . . . . . . . . . . . . . . . . |
. 443 |
||||
Creating a Sample ASP.NET Application . . . . . . . . . . . . . . . . |
. 443 |
||||
Creating a New Project |
. . . |
. . . . . . . . . . . . . . . . . . . . . . . . |
. 444 |
||
|
|
F |
|
||
Adding Controls to the Project. . . . . . . . . . . . . . . . . . . . . . |
. 444 |
||||
Coding the Application |
. . . |
Y. . . . . . . . . . . . . . . . . . . . . . . . |
. 446 |
||
|
|
M |
|
|
|
Summary |
. . . . . . . |
. . . . . . . |
L. . . . . . . . . . . . . . . . . . . . . . . . . . . |
. 452 |
|
|
A |
|
|
|
|
|
E |
|
|
|
|
Designing the pplication . . . . . . . . . . . . . . |
453 |
||||
T |
|
|
|
|
|
Creating the Database Schema |
. . . . . . . . . . . . . . . . . . . . . . . . |
. 454 |
|||
Creating Database Tables . . |
. . . . . . . . . . . . . . . . . . . . . . . . |
. 455 |
|||
Managing Primary Keys and Relationships. . . . . . . . . . . . . |
. 460 |
||||
Viewing the Database Schema . . . . . . . . . . . . . . . . . . . . . . |
. 464 |
||||
Designing Application Forms . |
. . . . . . . . . . . . . . . . . . . . . . . . |
. 465 |
|||
Standardizing the Interface of the Application . . . . . . . . . . |
. 465 |
||||
Common Forms in the Application . . . . . . . . . . . . . . . . . . |
. 465 |
||||
Forms for Network Administrators. . . . . . . . . . . . . . . . . . . |
. 470 |
||||
Forms for Business Managers . . . . . . . . . . . . . . . . . . . . . . . |
. 473 |
||||
Forms for Line-of-Business Executives. . . . . . . . . . . . . . . . |
. 478 |
||||
Summary. |
. . . . . . . |
. . . . . . |
. . . |
. . . . . . . . . . . . . . . . . . . . . . . . |
. 481 |
Chapter 21 Implementing the Business Logic. . . . . . . . . 483
Coding the Logon and Logoff Functionality . . . . . . . . . . . . . . . 484
The Default.aspx Form. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 484
The Logoff.aspx Form . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 489
Team-Fly®
Contents xxi
Coding the Forms for Network Administrators . . . . . . . . . . . . . 490
The ManageUsers.aspx Form . . . . . . . . . . . . . . . . . . . . . . . . 490
The ManageDatabases.aspx Form. . . . . . . . . . . . . . . . . . . . . 495
The ChangePassword.aspx Form . . . . . . . . . . . . . . . . . . . . . 498
Restricting Access to Web Forms . . . . . . . . . . . . . . . . . . . . . 498
Coding the Forms for Business Managers . . . . . . . . . . . . . . . . . 500
The AddFl.aspx Form . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 500
The RequestID.aspx Form . . . . . . . . . . . . . . . . . . . . . . . . . . 503
The Reports.aspx Form . . . . . . . . . . . . . . . . . . . . . . . . . . . . 504
The FreqFl.aspx Form . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 506
Coding the Forms for LOB Executives . . . . . . . . . . . . . . . . . . . 508
The CreateRes.aspx Form. . . . . . . . . . . . . . . . . . . . . . . . . . . 508
The CancelRes.aspx Form . . . . . . . . . . . . . . . . . . . . . . . . . . 514
The QueryStat.aspx Form . . . . . . . . . . . . . . . . . . . . . . . . . . 516
The ConfirmRes.aspx Form . . . . . . . . . . . . . . . . . . . . . . . . . 518
Summary. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 519
Chapter 22 Creating the Customer Transaction Portal . . 521
Designing the Form . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 522
The View New Flights Option . . . . . . . . . . . . . . . . . . . . . . . 525
The View Ticket Status Option . . . . . . . . . . . . . . . . . . . . . . 526
The View Flight Status Option . . . . . . . . . . . . . . . . . . . . . . 528
The Confirm Reservation Option. . . . . . . . . . . . . . . . . . . . . 529
Testing the Application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 533
Summary. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 536
xxii Contents
Chapter 23 Debugging and Testing the Application. . . . . 537
Locating Errors in Programs . . . . . . . . . . . . . . . . . . . . . . . . . . . 538
Watch Window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 540
Locals Window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 540
Call Stack Window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 540
Autos Window. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 541
Command Window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 541
Testing the Application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 542
Summary. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 549
Chapter 24 Administering the Application . . . . . . . . . . . 551
Managing the Databases . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 552
Backing Up the SkyShark Airlines Databases . . . . . . . . . . . . 553
Exporting Data from Databases . . . . . . . . . . . . . . . . . . . . . . 555
Examining Database Logs . . . . . . . . . . . . . . . . . . . . . . . . . . 557
Scheduling Database Maintenance Tasks . . . . . . . . . . . . . . . 558
Managing Internet Information Server . . . . . . . . . . . . . . . . . . . 560
Configuring IIS Error Pages. . . . . . . . . . . . . . . . . . . . . . . . . 560
Managing Web Server Log Files . . . . . . . . . . . . . . . . . . . . . 563
Summary. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 565
Chapter 25 Securing the Application . . . . . . . . . . . . . . . 567
Security in ASP.NET Applications . . . . . . . . . . . . . . . . . . . . . . 568
Authentication Mechanisms. . . . . . . . . . . . . . . . . . . . . . . . . 568
Securing a Web Site with IIS and ASP.NET . . . . . . . . . . . . 570
Enabling Authentication in SkyShark Airlines. . . . . . . . . . . . . . 571
Configuring IIS Authentication . . . . . . . . . . . . . . . . . . . . . . 571
Configuring Authentication in ASP.NET. . . . . . . . . . . . . . . 573
Securing SQL Ser ver . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 576
Summary. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 578
Contents xxiii
Chapter 26 Deploying the Application . . . . . . . . . . . . . . 581
Deployment Scenarios. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 582 Deployment Editors. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 584 Deploying the SkyShark Airlines Application . . . . . . . . . . . . . . 586 Creating a Deployment Project. . . . . . . . . . . . . . . . . . . . . . . 587
Adding the Output of SkySharkDeploy
to the Deployment Project . . . . . . . . . . . . . . . . . . . . . . . . . . 589 Deploying the Project to a Web Server
on Another Computer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 591 Summary. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 591
PART VII PROFESSIONAL PROJECT 5 . . . . . . . |
. . . . 593 |
Project 5 Creating a Web Portal for a Bookstore |
. . . . 595 |
Project 5 Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 596
Chapter 27 Project Case Study and Design . . . . . . . . . . 597
Organization Profile . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 598
Project Requirements. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 599
Querying for Information about All Books. . . . . . . . . . . . . . 600
Querying for Information about Books Based on Criteria. . . 601
Ordering a Book on the Web Site. . . . . . . . . . . . . . . . . . . . . 602
Project Design. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 602
Database Design . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 603
Database Schema . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 608
Web Forms Design. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 611
Flowcharts for the Web Forms Modules. . . . . . . . . . . . . . . . 616
Summary. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 618
xxiv Contents
Chapter 28 Exploring ASP.NET Web Services . . . . . . . . . 619
Introduction to ASP.NET Web Services . . . . . . . . . . . . . . . . . . 621 Web Service Architecture . . . . . . . . . . . . . . . . . . . . . . . . . . . 623 Working of a Web Service . . . . . . . . . . . . . . . . . . . . . . . . . . 624 Technologies Used in Web Services . . . . . . . . . . . . . . . . . . . . . . 625 XML in a Web Service. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 626 WSDL in a Web Service . . . . . . . . . . . . . . . . . . . . . . . . . . . 626 SOAP in a Web Service . . . . . . . . . . . . . . . . . . . . . . . . . . . . 627 UDDI in a Web Service. . . . . . . . . . . . . . . . . . . . . . . . . . . . 628 Web Services in the .NET Framework . . . . . . . . . . . . . . . . . . . 628 Creating a Simple Web Service in the .NET Framework . . . . . . 632 The Default Code Generated for a Web Service. . . . . . . . . . 633
Creating a Web Method
in the SampleWebService Web Service. . . . . . . . . . . . . . . . . 635 Testing the SampleWebService Web Service. . . . . . . . . . . . . 638 Summary. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 640
Chapter 29 Developing Web Services. . . . . . . . . . . . . . . 641
Creating a Web Service for Deepthoughts Publications . . . . . . . 642
Creating the SearchAll() Web Method . . . . . . . . . . . . . . . . 645
Creating the SrchISBN() Web Method . . . . . . . . . . . . . . . . . 647
Creating the AcceptDetails() Web Method . . . . . . . . . . . . . 650
Creating the GenerateOrder() Web Method . . . . . . . . . . . . . 653
Testing the Web Service. . . . . . . . . . . . . . . . . . . . . . . . . . . . 662
Securing a Web Service . . . . . . . . . . . . . . . . . . . . . . . . . . . . 664
Summary. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 665
Contents xxv
Chapter 30 Developing Web Service Clients. . . . . . . . . . 667
Creating a Web Service Client Application
for Bookers Paradise . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 668 Creating the Web Forms
for the Bookers Paradise Web Site . . . . . . . . . . . . . . . . . . . . 668 Adding Code to the Web Forms. . . . . . . . . . . . . . . . . . . . . . 680 Summary. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 711
PART VIII PROFESSIONAL PROJECT 6 . . . . . . . . . . . |
713 |
Project 6 Creating a Mobile Application . . . . . . . . . . . 715
Project 6 Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 716
Chapter 31 Project Case Study and Design . . . . . . . . . . 717
Case Study . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 718
Project Life Cycle . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 719
Analyzing Requirements. . . . . . . . . . . . . . . . . . . . . . . . . . . . 719
High-Level Design . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 720
Low-Level Design . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 723
Summary. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 726
Chapter 32 Basics of Mobile Applications . . . . . . . . . . . 727
Overview of Mobile Applications . . . . . . . . . . . . . . . . . . . . . . . 728
The Microsoft Mobile Internet Toolkit. . . . . . . . . . . . . . . . . 729
Overview of WAP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 732
The WAP Architecture . . . . . . . . . . . . . . . . . . . . . . . . . . . . 733
Overview of WML . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 735
xxvi Contents
Creating a Simple Mobile Web Application
by Using the Mobile Internet Toolkit. . . . . . . . . . . . . . . . . . . . . 736 The Mobile Web Form . . . . . . . . . . . . . . . . . . . . . . . . . . . . 737 The Design of the MobileTimeRetriever Application . . . . . . 739 Creating the Interface for the Mobile Web Forms. . . . . . . . . 751 Adding Code to the MobileTimeRetriever Application . . . . 754
Summary. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 761
Chapter 33 Implementing the Business Logic. . . . . . . . . 763
Creating the Forms Required
for the MobileCallStatus Application . . . . . . . . . . . . . . . . . . . . 764 The Default Code Generated by Visual Studio .NET
for a Mobile Application . . . . . . . . . . . . . . . . . . . . . . . . . . . 765 Creating the frmLogon Form . . . . . . . . . . . . . . . . . . . . . . . . 767 Creating the frmSelectOption Form . . . . . . . . . . . . . . . . . . . 769 Creating the frmPending Form. . . . . . . . . . . . . . . . . . . . . . . 771 Creating the frmUnattended Form . . . . . . . . . . . . . . . . . . . . 772
Adding the Business Logic
to the MobileCallStatus Application . . . . . . . . . . . . . . . . . . . . . 774 Adding Code to the Submit Button
in the frmLogon Form . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 775 Adding Code to the Query Button
in the frmSelectOption Form . . . . . . . . . . . . . . . . . . . . . . . . 779 Adding Code to the Mark checked as complete
Button in the frmPending Form . . . . . . . . . . . . . . . . . . . . . . 782 Adding Code to the Back Button
in the frmPending Form . . . . . . . . . . . . . . . . . . . . . . . . . . . . 785 Adding Code to the Accept checked call(s) Button
in the frmUnattended Form . . . . . . . . . . . . . . . . . . . . . . . . . 786 Adding Code to the Back Button
in the frmUnattended Form . . . . . . . . . . . . . . . . . . . . . . . . . 788 Testing the MobileCallStatus Application in an Emulator . . . . . 788 Summary. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 791
Contents xxvii
PART IX BEYOND THE LABS . . . . . . . . . . . . . . . . . |
793 |
Chapter 34 Advanced C# Concepts . . . . . . . . . . . . . . . . 795
COM+ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 796
What Is COM? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 796
Windows DNA . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 802
Microsoft Transaction Server (MTS) . . . . . . . . . . . . . . . . . . 804
COM+. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 805
.NET Interoperability . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 809
COM Interoperability . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 810
Messaging. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 818
Benefits of Message Queues. . . . . . . . . . . . . . . . . . . . . . . . . 819
Limitations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 819
Key Messaging Terms. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 820
System.Messaging Namespace . . . . . . . . . . . . . . . . . . . . . . . . 822
Summary. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 826
PART X APPENDIXES . . . . . . . . . . . . . . . . . . . . . 829
Appendix A Unsafe Code . . . . . . . . . . . . . . . . . . . . . . . . 831
Pointers. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 832
Declaring Pointers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 834
Types of Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 835
Implementing Pointers. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 836
Using Pointers with Managed Code . . . . . . . . . . . . . . . . . . . 837
Working with Pointers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 837
Compiling Unsafe Code. . . . . . . . . . . . . . . . . . . . . . . . . . . . 840
Summary. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 841
Appendix B Introduction to Visual Basic .NET. . . . . . . . . 843
Introduction to the Languages of Visual Studio .NET . . . . . . . . 844 Visual C# .NET. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 845
xxviii Contents
Visual Basic .NET . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 845
Visual C++ .NET. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 845
Overview of Visual Basic .NET. . . . . . . . . . . . . . . . . . . . . . . . . 846
Features of an Object-Oriented Programming Language . . . . . . 849
Abstraction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 849
Encapsulation. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 850
Inheritance. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 850
Polymorphism . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 851
Components of Visual Basic .NET . . . . . . . . . . . . . . . . . . . . . . 852
Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 852
Constants. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 857
Operators. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 857
Arrays . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 858
Collections. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 861
Procedures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 862
Arguments. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 864
Functions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 864
Creating a Simple Visual C# .NET Windows Application. . . . . 865
Creating a Simple Application in Visual Basic .NET . . . . . . . . . 868
Adding Code to the Submit Button . . . . . . . . . . . . . . . . . . . 872
Adding Code to the Exit Button . . . . . . . . . . . . . . . . . . . . . 873
Summary. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 875
Appendix C Visual Studio .NET Integrated |
|
Development Environment . . . . . . . . . . . . . . |
877 |
Introduction to Visual Studio .NET IDE . . . . . . . . . . . . . . . . |
. 878 |
Contents xxix
Menu Bar. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 879
Toolbars. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 880
Visual Studio .NET IDE Windows . . . . . . . . . . . . . . . . . . . 882
Toolbox . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 888
The Task List Window . . . . . . . . . . . . . . . . . . . . . . . . . . . . 890
Managing Windows. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 891
Customizing Visual Studio .NET IDE . . . . . . . . . . . . . . . . . . . 892
The Options Dialog Box . . . . . . . . . . . . . . . . . . . . . . . . . . . 892
The Customize Dialog Box . . . . . . . . . . . . . . . . . . . . . . . . . 894
Summary. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 895
Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 897