- •About the Authors
- •Contents at a Glance
- •Contents
- •Introduction
- •Goal of the Book
- •How to Use this Book
- •Introduction to the .NET Framework
- •Common Language Runtime (CLR)
- •Class Library
- •Assembly
- •Versioning
- •Exceptions
- •Threads
- •Delegates
- •Summary
- •Introduction to C#
- •Variables
- •Initializing Variables
- •Variable Modifiers
- •Variable Data Types
- •Types of Variables
- •Variable Scope
- •Types of Data Type Casting
- •Arrays
- •Strings
- •Initializing Strings
- •Working with Strings
- •Statements and Expressions
- •Types of Statements
- •Expressions
- •Summary
- •Classes
- •Declaring Classes
- •Inheritance
- •Constructors
- •Destructors
- •Methods
- •Declaring a Method
- •Calling a Method
- •Passing Parameters to Methods
- •Method Modifiers
- •Overloading a Method
- •Namespaces
- •Declaring Namespaces
- •Aliases
- •Structs
- •Enumerations
- •Interfaces
- •Writing, Compiling, and Executing
- •Writing a C# Program
- •Compiling a C# Program
- •Executing a C# Program
- •Summary
- •Arrays
- •Single-Dimensional Arrays
- •Multidimensional Arrays
- •Methods in Arrays
- •Collections
- •Creating Collections
- •Working with Collections
- •Indexers
- •Boxing and Unboxing
- •Preprocessor Directives
- •Summary
- •Attributes
- •Declaring Attributes
- •Attribute Class
- •Attribute Parameters
- •Default Attributes
- •Properties
- •Declaring Properties
- •Accessors
- •Types of Properties
- •Summary
- •Introduction to Threads
- •Creating Threads
- •Aborting Threads
- •Joining Threads
- •Suspending Threads
- •Making Threads Sleep
- •Thread States
- •Thread Priorities
- •Synchronization
- •Summary
- •Case Study
- •Project Life Cycle
- •Analyzing Requirements
- •High-Level Design
- •Primary and Foreign Keys
- •Referential Integrity
- •Normalization
- •Designing a Database
- •Low-Level Design
- •Construction
- •Integration and Testing
- •User Acceptance Testing
- •Implementation
- •Operations and Maintenance
- •Summary
- •Creating a New Project
- •Console Application
- •Windows Applications
- •Creating a Windows Application for the Customer Maintenance Project
- •Creating an Interface for Form1
- •Creating an Interface for WorkerForm
- •Creating an Interface for CustomerForm
- •Creating an Interface for ReportsForm
- •Creating an Interface for JobDetailsForm
- •Summary
- •Performing Validations
- •Identifying the Validation Mechanism
- •Using the ErrorProvider Control
- •Handling Exceptions
- •Using the try and catch Statements
- •Using the Debug and Trace Classes
- •Using the Debugging Features of Visual Studio .NET
- •Using the Task List
- •Summary
- •Creating Form1
- •Connecting WorkerForm to the Workers Table
- •Connecting CustomerForm to the tblCustomer Table
- •Connecting the JobDetails Form
- •to the tblJobDetails Table
- •Summary
- •Introduction to the Crystal Reports Designer Tool
- •Creating the Reports Form
- •Creating Crystal Reports
- •Creating the Windows Forms Viewer Control
- •Creating the Monthly Worker Report
- •Summary
- •Introduction to Deploying a Windows Application
- •Deployment Projects Available in Visual Studio .NET
- •Deployment Project Editors
- •Summary
- •Case Study
- •Project Life Cycle
- •Analyzing Requirements
- •High-Level Design
- •Low-Level Design
- •Summary
- •Populating the TreeView Control
- •Displaying Employee Codes in the TreeView Control
- •Event Handling
- •Displaying Employee Details in the ListView Control
- •Summary
- •Case Study
- •Project Life Cycle
- •Analyzing Requirements
- •High-Level Design
- •Low-Level Design
- •Summary
- •Adding the Programming Logic to the Application
- •Adding Code to the Form Load() Method
- •Adding Code to the OK Button
- •Adding Code to the Exit Button
- •Summary
- •The Created Event
- •Adding Code to the Created Event
- •Overview of XML
- •The XmlReader Class
- •The XmlWriter Class
- •Displaying Data in an XML Document
- •Displaying an Error Message in the Event Log
- •Displaying Event Entries from Event Viewer
- •Displaying Data from the Summary.xml Document in a Message Box
- •Summary
- •Airline Profile
- •Role of a Business Manager
- •Role of a Network Administrator
- •Role of a Line-of-Business Executive
- •Project Requirements
- •Creation and Deletion of User Accounts
- •Addition of Flight Details
- •Reservations
- •Cancellations
- •Query of Status
- •Confirmation of Tickets
- •Creation of Reports
- •Launch of Frequent Flier Programs
- •Summarizing the Tasks
- •Project Design
- •Database Design
- •Web Forms Design
- •Enabling Security with the Directory Structure
- •Summary
- •Getting Started with ASP.NET
- •Prerequisites for ASP.NET Applications
- •New Features in ASP.NET
- •Types of ASP.NET Applications
- •Exploring ASP.NET Web Applications
- •Introducing Web Forms
- •Web Form Server Controls
- •Configuring ASP.NET Applications
- •Configuring Security for ASP.NET Applications
- •Deploying ASP.NET Applications
- •Creating a Sample ASP.NET Application
- •Creating a New Project
- •Adding Controls to the Project
- •Coding the Application
- •Summary
- •Creating the Database Schema
- •Creating Database Tables
- •Managing Primary Keys and Relationships
- •Viewing the Database Schema
- •Designing Application Forms
- •Standardizing the Interface of the Application
- •Common Forms in the Application
- •Forms for Network Administrators
- •Forms for Business Managers
- •Forms for Line-of-Business Executives
- •Summary
- •The Default.aspx Form
- •The Logoff.aspx Form
- •The ManageUsers.aspx Form
- •The ManageDatabases.aspx Form
- •The ChangePassword.aspx Form
- •Restricting Access to Web Forms
- •The AddFl.aspx Form
- •The RequestID.aspx Form
- •The Reports.aspx Form
- •The FreqFl.aspx Form
- •Coding the Forms for LOB Executives
- •The CreateRes.aspx Form
- •The CancelRes.aspx Form
- •The QueryStat.aspx Form
- •The ConfirmRes.aspx Form
- •Summary
- •Designing the Form
- •The View New Flights Option
- •The View Ticket Status Option
- •The View Flight Status Option
- •The Confirm Reservation Option
- •Testing the Application
- •Summary
- •Locating Errors in Programs
- •Watch Window
- •Locals Window
- •Call Stack Window
- •Autos Window
- •Command Window
- •Testing the Application
- •Summary
- •Managing the Databases
- •Backing Up the SkyShark Airlines Databases
- •Exporting Data from Databases
- •Examining Database Logs
- •Scheduling Database Maintenance Tasks
- •Managing Internet Information Server
- •Configuring IIS Error Pages
- •Managing Web Server Log Files
- •Summary
- •Authentication Mechanisms
- •Securing a Web Site with IIS and ASP.NET
- •Configuring IIS Authentication
- •Configuring Authentication in ASP.NET
- •Securing SQL Server
- •Summary
- •Deployment Scenarios
- •Deployment Editors
- •Creating a Deployment Project
- •Adding the Output of SkySharkDeploy to the Deployment Project
- •Deploying the Project to a Web Server on Another Computer
- •Summary
- •Organization Profile
- •Project Requirements
- •Querying for Information about All Books
- •Querying for Information about Books Based on Criteria
- •Ordering a Book on the Web Site
- •Project Design
- •Database Design
- •Database Schema
- •Web Forms Design
- •Flowcharts for the Web Forms Modules
- •Summary
- •Introduction to ASP.NET Web Services
- •Web Service Architecture
- •Working of a Web Service
- •Technologies Used in Web Services
- •XML in a Web Service
- •WSDL in a Web Service
- •SOAP in a Web Service
- •UDDI in a Web Service
- •Web Services in the .NET Framework
- •The Default Code Generated for a Web Service
- •Testing the SampleWebService Web Service
- •Summary
- •Creating the SearchAll() Web Method
- •Creating the SrchISBN() Web Method
- •Creating the AcceptDetails() Web Method
- •Creating the GenerateOrder() Web Method
- •Testing the Web Service
- •Securing a Web Service
- •Summary
- •Creating the Web Forms for the Bookers Paradise Web Site
- •Adding Code to the Web Forms
- •Summary
- •Case Study
- •Project Life Cycle
- •Analyzing Requirements
- •High-Level Design
- •Low-Level Design
- •Summary
- •Overview of Mobile Applications
- •The Microsoft Mobile Internet Toolkit
- •Overview of WAP
- •The WAP Architecture
- •Overview of WML
- •The Mobile Web Form
- •The Design of the MobileTimeRetriever Application
- •Creating the Interface for the Mobile Web Forms
- •Adding Code to the MobileTimeRetriever Application
- •Summary
- •Creating the Forms Required for the MobileCallStatus Application
- •Creating the frmLogon Form
- •Creating the frmSelectOption Form
- •Creating the frmPending Form
- •Creating the frmUnattended Form
- •Adding Code to the Submit Button in the frmLogon Form
- •Adding Code to the Query Button in the frmSelectOption Form
- •Adding Code to the Mark checked as complete Button in the frmPending Form
- •Adding Code to the Back Button in the frmPending Form
- •Adding Code to the Accept checked call(s) Button in the frmUnattended Form
- •Adding Code to the Back Button in the frmUnattended Form
- •Summary
- •What Is COM?
- •Windows DNA
- •Microsoft Transaction Server (MTS)
- •.NET Interoperability
- •COM Interoperability
- •Messaging
- •Benefits of Message Queues
- •Limitations
- •Key Messaging Terms
- •Summary
- •Pointers
- •Declaring Pointers
- •Types of Code
- •Implementing Pointers
- •Using Pointers with Managed Code
- •Working with Pointers
- •Compiling Unsafe Code
- •Summary
- •Introduction to the Languages of Visual Studio .NET
- •Visual C# .NET
- •Visual Basic .NET
- •Visual C++ .NET
- •Overview of Visual Basic .NET
- •Abstraction
- •Encapsulation
- •Inheritance
- •Polymorphism
- •Components of Visual Basic .NET
- •Variables
- •Constants
- •Operators
- •Arrays
- •Collections
- •Procedures
- •Arguments
- •Functions
- •Adding Code to the Submit Button
- •Adding Code to the Exit Button
- •Summary
- •Introduction to Visual Studio .NET IDE
- •Menu Bar
- •Toolbars
- •Visual Studio .NET IDE Windows
- •Toolbox
- •The Task List Window
- •Managing Windows
- •Customizing Visual Studio .NET IDE
- •The Options Dialog Box
- •The Customize Dialog Box
- •Summary
- •Index
|
|
Y |
|
L |
|
|
F |
|
|
M |
|
A |
|
|
E |
|
|
T |
|
|
C#
Professional Projects
This page intentionally left blank
Geetanjali Arora
Balasubramaniam
Aiaswamy
Nitin Pandey
C#
Professional Projects
WITH
©2002 by Premier Press, Inc.All rights reserved. No part of this book may be reproduced or transmitted in any form or by any means, electronic or mechanical, including photocopying, recording, or by any information storage or retrieval system without written permission from Premier Press, except for the inclusion of brief quotations in a review.
The Premier Press logo, top edge printing, and related trade dress are trademarks of P remier Press, Inc. and may not be used without written permission. All other trademarks are the property of their respective owners.
Important: Premier Press cannot provide software support. Please contact the appropriate sof tware manufacturer ’s technical support line or Web site for assistance.
Premier Press and the author have attempted throughout this book to distinguish proprietary trademarks from descriptive terms by following the capitalization style used by the manufacturer.
Information contained in this book has been obtained by Premier Press from sources believed to be reliable.However, because of the possibility of human or mechanical error by our sources, Premier Press, or others, the Publisher does not guarantee the accuracy, adequacy, or completeness of any information and is not responsible for any errors or omissions or the results obtained from use of such information. Readers should be particularly aware of the fact that the Internet is an ever-changing entity. Some facts may have changed since this book went to press.
ISBN: 1-931841-30-6
Library of Congress Catalog Card Number: 2001096998
Printed in the United States of America
02 03 04 05 06 RI 10 9 8 7 6 5 4 3 2 1
Publisher:
Stacy L. Hiquet
Marketing Manager:
Heather Buzzingham
Managing Editor:
Sandy Doell
Editorial Assistant:
Margaret Bauer
Book Production Services:
Argosy
Cover Design:
Mike Tanamachi
About NIIT
NIIT is a global IT solutions corporation with a presence in 38 countries. With its unique business model and technology-creation capabilities, NIIT delivers software and learning solutions to more than 1,000 clients across the world.
The success of NIIT’s training solutions lies in its unique approach to education. NIIT’s Knowledge Solutions Business conceives, researches, and develops all of its course material. A rigorous instructional design methodology is followed to create engaging and compelling course content.
NIIT trains over 200,000 executives and learners each year in information technology areas using stand-up training, video-aided instruction, computer-based training (CBT), and Internet-based training (IBT). NIIT has been featured in the Guinness Book of World Records for the largest number of learners trained in one year!
NIIT has developed over 10,000 hours of instructor-led training (ILT) and over 3,000 hours of Internet-based training and computer-based training. IDC ranked NIIT among the Top 15 IT training providers globally for the year 2000. Through the innovative use of training methods and its commitment to research and development, NIIT has been in the forefront of computer education and training for the past 20 years.
Quality has been the prime focus at NIIT. Most of the processes are ISO-9001 certified. It was the 12th company in the world to be assessed at Level 5 of SEI-CMM. NIIT’s Content (Learning Material) Development facility is the first in the world to be assessed at this highest maturity level. NIIT has strategic partnerships with companies such as Computer Associates, IBM, Microsoft, Oracle, and Sun Microsystems.
This page intentionally left blank
About the Authors
Geetanjali Arora is an instructional designer who has worked with the NIIT for almost two years. She has done several projects with the NIIT that include instructorled training (ILT),computer-based training (CBT),and Web-based training (WBT). She has written on both technical and non-technical subjects. At the NIIT, Geentanjali’s responsibilities include scripting, construction, planning, and scheduling. She has also provided training on NexGen and Dreamweaver.
Balasubramaniam Aiaswamy is a technical trainer and writer, an instructional designer, a subject matter expert (SME), and an ID reviewer with NIIT’s Knowledge Solutions Business division, which develops and reviews instructor-led training (ILT) products for various software and technologies.These technologies include Microsof t Visual InterDev 6.0, Microsoft Site Server 3.0 Commerce Edition, Microsoft Windows CE, Java 2 Micro Edition (J2ME), networking concepts, the installation and administration of a Layer 3 network, and Web security. He is both an MCSD and an MCP in Windows NT. Balasubramaniam has experience in teaching career programs at NIIT’s Career Education Group division. He has taught various technical subject areas including networking essentials, SQL Server 7.0, Microsoft Windows NT Server 4.0, Microsoft Visual Basic 6.0, Microsoft Visual C++ 4.0, Windows 32 API programming, HTML, Java, Unix, C, and C++. He has also set up and managed labs for students and administered Novell 3.11 and UNIX (SCO)–based networks.
Nitin Pandey works with NIIT as a subject matter expert (SME) for learning content developed on Microsoft technologies. Nitin has been involved in the development of WBTs and seminars for NIIT Online Ltd. and Microsoft. Nitin provides technical support to the development teams, develops sample applications, and provides technical reviews of learning content.
This page intentionally left blank
Contents at a Glance
Introduction. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxxi
Part I |
Introduction to C# . . . . . . . . . . . . . . . . . . . . |
. . 1 |
|
|
1 |
Overview of the .NET Framework . . . . . . . . . . . . . . . . . |
. . 3 |
|
2 |
C# Basics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . |
. 17 |
Part II |
Handling Data . . . . . . . . . . . . . . . . . . . . . . . . |
41 |
|
|
3 |
Components of C# . . . . . . . . . . . . . . . . . . . . . . . . . . . . . |
. 43 |
|
4 |
More about Components . . . . . . . . . . . . . . . . . . . . . . . . |
. 67 |
|
5 |
Attributes and Properties. . . . . . . . . . . . . . . . . . . . . . . . . |
. 83 |
|
6 |
Threads . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . |
. 93 |
Part III |
Professional Project 1: |
|
|
|
Creating a Customer Maintenance Project. . |
109 |
|
|
7 |
Project Case Study . . . . . . . . . . . . . . . . . . . . . . . . . . . . . |
113 |
|
8 |
Windows Forms and Controls. . . . . . . . . . . . . . . . . . . . . |
141 |
|
9 |
Validations and Exception Handling . . . . . . . . . . . . . . . . |
175 |
|
10 |
Database Interaction Using ADO.NET . . . . . . . . . . . . . |
197 |
|
11 |
Crystal Reports. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . |
239 |
|
12 |
Deploying a Windows Application . . . . . . . . . . . . . . . . . |
259 |
Part IV |
Professional Project 2: Creating the |
|
|
|
Employee Records System (ERS) Project. . . 293 |
||
|
13 |
Project Case Study and Design . . . . . . . . . . . . . . . . . . . . |
297 |
|
14 |
Implementing the Business Logic . . . . . . . . . . . . . . . . . . |
311 |
Part V Professional Project 3:
Creating a Creative Learning Project . . . . . . 329
15 Project Case Study and Design . . . . . . . . . . . . . . . . . . . . 333 16 Implementing the Programming Logic . . . . . . . . . . . . . . 349 17 Interacting with a Microsoft Word
Document and Event Viewer . . . . . . . . . . . . . . . . . . . . . 365
xContents at a Glance
Part VI
Part VII
Part VIII
Part IX
Part X
Professional Project 4:
Creating an Airline Reservation Portal. . . . . 395
18 |
Project Case Study and Design . . . . . . . . . . . . . . . . . . . . |
399 |
19 |
Basics of ASP.NET Web Applications. . . . . . . . . . . . . . . |
429 |
20 |
Designing the Application. . . . . . . . . . . . . . . . . . . . . . . . |
453 |
21 |
Implementing the Business Logic . . . . . . . . . . . . . . . . . . |
483 |
|
Y |
|
22 |
Creating the Customer Transaction Portal. . . . . . . . . . . . |
521 |
|
L |
|
23 |
Debugging and Testing the Application. . . . . . . . . . . . . . |
537 |
|
F |
|
24 |
Administering the Application . . . . . . . . . . . . . . . . . . . . |
551 |
25 |
Securing the Application . . . . . . . . . . . . . . . . . . . . . . . . . |
567 |
26 |
Deploying the Application . . . . . . . . . . . . . . . . . . . . . . . |
581 |
Professional Project 5: |
|
|
Creating a WebMPortal for a Bookstore . . . . 593 |
||
27 |
Project CaseAStudy and Design . . . . . . . . . . . . . . . . . . . . |
597 |
28 |
ExploringEASP.NET Web Services . . . . . . . . . . . . . . . . . |
619 |
29 |
TDeveloping Web Services . . . . . . . . . . . . . . . . . . . . . . . . |
641 |
30 |
Developing Web Service Clients . . . . . . . . . . . . . . . . . . . |
667 |
Professional Project 6:
Creating a Mobile Application . . . . . . . . . . . 713
31 Project Case Study and Design . . . . . . . . . . . . . . . . . . . . 717 32 Basics of Mobile Applications . . . . . . . . . . . . . . . . . . . . . 727 33 Implementing the Business Logic . . . . . . . . . . . . . . . . . . 763
Beyond the Labs . . . . . . . . . . . . . . . . . . . . . 793
34 Advanced C# Concepts. . . . . . . . . . . . . . . . . . . . . . . . . . 795
Appendixes . . . . . . . . . . . . . . . . . . . . . . . . . 829
A Unsafe Code. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 831
B Introduction to Visual Basic .NET . . . . . . . . . . . . . . . . . 843
CVisual Studio.NET Integrated
Development Environment . . . . . . . . . . . . . . . . . . . . . . . 877
Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 897
Team-Fly®