- •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
298 Project 2 CREATING THE EMPLOYEE RECORDS SYSTEM PROJECT
This project describes the procedure to access XML data from a Windows application. It also illustrates the use of important Windows controls, such as
the TreeView and ListView controls.
Case Study |
|
Y |
|
|
|
You need to develop an application that enables you to pick up the details of |
||
|
L |
|
employees from an XML file and display the employee codes in the TreeView |
||
|
F |
|
control. On clicking an employee code, the details of the employee must be dis- |
||
played in the ListView control. |
|
|
|
M |
|
|
A |
|
|
E |
|
This chapter will startTdeveloping the ERS project.This project will introduce you to various controls, such as reeView, ListView, StatusBar, and ListLabel, and their properties and methods. The project will also discuss how to read records from a XML data store. This chapter covers the design of the project.
Project Life Cycle
You looked at the phases of a DLC (development life cycle) of a project in Chapter 7, “Project Case Study,” in the section “Case Study.” Because we have already discussed the entire life cycle of the project, here I will discuss the design of the application created by the development team for the ERS project. You, as a part of the development team, will analyze the requirements and create a design for the application.
Analyzing Requirements
To find a solution to a problem faced by a customer, you first need to analyze the customer’s requirements in detail. This is done in the analyzing requirements phase of the project life cycle. After analyzing the customer’s problems in detail, you create a plan for developing the application. This analysis of the customer’s
Team-Fly®
PROJECT CASE STUDY AND DESIGN |
Chapter 13 |
299 |
|
|
|
|
|
problem is based on the problem statement stated by senior management and the information gathered by the development team.
In this case, the problem statement, as stated by the HR Manager, is, “The details of each employee must be accessible in an easy and simple manner.”
Upon analyzing the problem statement, the development team defined the following list of tasks that they need to do:
The HR department needs to maintain the records of its employee in a data store.
The HR department needs an application that will enable it to obtain its employee records in a quick and efficient manner.
This application can be extended to add new employee records, modify existing records, and delete records.
High-Level Design
Based on the plan of the Windows application, the development team created a design of the Windows application in the high-level design phase. The design of the ERS application includes creating the user interface for the Windows form used in the application.
The ERS application consists of a Windows form, as shown in Figure 13-1.
FIGURE 13-1 Layout of the ERS form
300 Project 2 CREATING THE EMPLOYEE RECORDS SYSTEM PROJECT
To create the layout of the ERS application, as shown in Figure 13-1, you need to include TreeView, ListView, and StatusBar controls. The following section discusses the different controls in detail. The ERS application consists of a main Windows form, called EmployeeRecordsForm.
Press F4 to view the properties of the EmployeeRecordsForm form. Change the following property values in the Properties window:
Name: EmployeeRecordsForm
Auto Scroll: True
MinimizeBox: False
MaximizeBox: False
Size: 728, 408
Text: Employee Records Monitoring System
The properties of the EmployeeRecordsForm form are as shown in Figure 13-2.
FIGURE 13-2 Properties of the EmployeeRecordsForm form
Changing the Name property changes the name of the form. By setting the MinimizeBox and the MaximizeBox properties to False, you can ensure that the form cannot be maximized or minimized.
PROJECT CASE STUDY AND DESIGN |
Chapter 13 |
301 |
|
|
|
|
|
TreeView Control
A TreeView control is a Windows Forms control that you can use to display a hierarchy of nodes. These nodes are called root or parent nodes. Each root node in the hierarchy can contain one or more nodes, called child nodes.The root and parent nodes can be collapsed or expanded.
To add a TreeView control in Visual Studio .NET, you can drag the TreeView control from the Windows Forms toolbox to the EmployeeRecordsForm form. Figure 13-3 shows the TreeView control in the Windows Forms toolbox.
FIGURE 13-3 A TreeView control in the Windows Forms toolbox
You can create a TreeView control by dragging a TreeView control from the Windows Forms toolbox to the form.The appearance of the TreeView control can be changed from the properties window. Table 13-1 lists and explains some of the important TreeView control properties.
302 |
Project 2 |
CREATING THE EMPLOYEE RECORDS SYSTEM PROJECT |
|||
|
|
|
|
||
|
|
Table 13-1 TreeView Control Properties |
|||
|
|
|
|
|
|
|
|
Property |
Description |
||
|
|
|
|
|
|
|
|
Name |
|
Sets the name of the control. |
|
|
|
AllowDrop |
Indicates whether the control can accept data that user drags onto it. |
||
|
|
BorderStyle |
Sets the border st yle of the control.The default style is Fixed3D, |
||
|
|
|
|
|
wherein the control has a sunken three-dimensional appearance. |
|
|
CheckBoxes |
Displays check boxes next to the tree nodes in the control when set to |
||
|
|
|
|
|
true. |
|
|
FullRowSelect |
Highlights the entire width of the control when a node is selected. |
||
|
|
HideSelection |
When set to true, the selected tree node remains highlighted even |
||
|
|
|
|
|
after the control has lost the focus. |
|
|
HotTracking |
When set to true, the tree node labels appear as a hyperlink when the |
||
|
|
|
|
|
mouse pointer moves over it. |
|
|
ImageIndex |
Sets the image-list index value of the default image that is displayed |
||
|
|
|
|
|
by the tree nodes. |
|
|
ImageList |
Specifies the ImageList that contains the images. |
||
|
|
LabelEdit |
The tree node labels can be edited when this property is set to true. |
||
|
|
Nodes |
|
Gets the collection of nodes that are assigned to the TreeView control. |
|
|
|
Scrollable |
The TreeView control displa ys scroll bars when it is set to true. |
||
|
|
SelectedImageIndex |
Gets or sets the image list index value of the image that is displayed |
||
|
|
|
|
|
when a tree node is selected. |
|
|
ShowLines |
Displays lines connecting the nodes in the control,when set to true. |
||
|
|
ShowPlusMinus |
Displays plus sign (+) and minus sign (-) when a node contains child |
||
|
|
|
|
|
nodes. |
|
|
ShowRootLines |
Displays lines connecting root nodes in the control when set to true. |
||
|
|
Size |
|
Sets the height and width of the control. |
|
|
|
Sorted |
|
When set to true, the nodes in the control are displayed in a sorted |
|
|
|
|
|
|
order. |
|
|
Visible |
When set to true, the control is not displayed. |
||
|
|
|
|
|
|
PROJECT CASE STUDY AND DESIGN |
Chapter 13 |
303 |
|
|
|
|
|
You will now create a TreeView control for the application. To create a TreeView control, perform the following steps:
1.Drag a TreeView control from the Windows Forms toolbox to the form. A blank TreeView control is added to the form.
2.Press the F4 key to display the properties of the TreeView control.
3.In the Properties window, change the following properties:
Name: treeView1
ShowLines: True
ShowPlusMinus: True
ShowRootLines: True
Size: 240, 352
The control does not contain any nodes. You can add both parent and child nodes to the TreeView control by using the Nodes property. You can also add nodes programmatically, which will be discussed in the next chapter.
ListView Control
A ListView control is a Windows Form control that displays a collection of items by using one of the four different possible views. A ListView control enables you to display a list of items with text and images to identify the type of item. You can display the items in a ListView control as large icons, small icons, or a vertical list. The items can also be displayed with column headers identifying the information being displayed in a subitem.
You can create a ListView control by dragging a ListView control from the Windows Forms toolbox to the form.The appearance of the ListView control can be changed from the Properties window. Table 13-2 lists and explains some of the important ListView control properties.
304 |
Project 2 |
CREATING THE EMPLOYEE RECORDS SYSTEM PROJECT |
|||
|
|
|
|
||
|
|
Table 13-2 ListView Control Properties |
|||
|
|
|
|
|
|
|
|
Property |
Description |
||
|
|
|
|
|
|
|
|
Name |
|
Sets the name of the control. |
|
|
|
Activation |
Specifies the type of action the user must take to activate an item. |
||
|
|
Alignment |
Sets the alignment of items in the control. |
||
|
|
AllowDrop |
Indicates whether the control will accept data the user drags onto it or |
||
|
|
|
|
|
not. |
|
|
AllowColumnReorder |
Indicates whether the user can drag column headers to reorder |
||
|
|
|
|
|
columns in the control. |
|
|
AutoArrange |
Indicates whether items are automatically arranged. |
||
|
|
BorderStyle |
Sets the border st yle of the control. |
||
|
|
Columns |
Gets the collection of all column headers that appear in the control. |
||
|
|
Dock |
|
Sets the edge of the parent container to which a control is docked. |
|
|
|
FullRowSelect |
Indicates whether clicking an item selects all its subitems. |
||
|
|
HeaderStyle |
Sets whether the column header is clickable or not. |
||
|
|
Items |
|
Specifies the collection of items in the control. |
|
|
|
LabelWrap |
Indicates whether the item label wraps or not. |
||
|
|
LargeImageList |
Specifies the ImageList to use when displaying the items as large |
||
|
|
|
|
|
icons. |
|
|
MultiSelect |
Indicates whether multiple items can be selected. |
||
|
|
Scrollable |
Indicates whether scroll bars will be displayed. |
||
|
|
SmallImageList |
Specifies the ImageList to use when displaying the items. |
||
|
|
Sorting |
Sets the sort order for items in the control. |
||
|
|
View |
|
Specifies the manner in which items are displayed in the control.The |
|
|
|
|
|
|
items can be displayed either as large icons, small icons,in a list man- |
|
|
|
|
|
ner, or in a details manner. |
|
|
Visible |
When set to true, the control is not displayed. |
||
|
|
|
|
|
|
PROJECT CASE STUDY AND DESIGN |
Chapter 13 |
|
305 |
|
|
||||
|
|
|
|
|
You will now create a ListView control for the application. To create a ListView control, perform the following steps:
1.Drag a ListView control from the Windows Forms toolbox to the form.
A blank ListView control is added to the form. Similar to the TreeView control, the appearance of the ListView control can be modified by changing its properties.
2.Press the F4 key to display the properties of the ListView control.
3.In the Properties window, change the following properties:
Name: listView1
Activation: TwoClick
MultiSelect: False
View: Details
StatusBar Control
A StatusBar control is a Windows Forms control that typically appears at the bottom of the form and is used to display different types of status information. A StatusBar control can have status bar panels on them that display text or icons to indicate the state. The StatusBar panels can be used to display information about page numbers, spelling and grammar status, and editing modes on the status bar.
Perform the following steps to create a status bar for the application:
1.Drag a StatusBar control from the Windows Forms toolbox to the form.
2.Press F4 and change the following properties:
Name: statusBar1
ShowPanels: True
Panels can be added to a StatusBar control either at design time through
StatusBarPanel Collection Editor or at run time through the Status-
BarPanelCollection class.
3.In the Properties window, click on the Panels property, and then click on the ellipsis (…) button to open StatusBarPanel Collection Editor.
4.Add a panel by clicking the Add button.
306 Project 2 CREATING THE EMPLOYEE RECORDS SYSTEM PROJECT
5. Change the following values:
Name: statusBarPanel1
Text: Click the employee code to view details
Width: 240
The StatusBarPanel Collection Editor is shown in Figure 13-4.
FIGURE 13-4 The StatusBarPanel Collection Editor
The XML File Schema
The development team decides to store the records of the employees in an XML file.This would facilitate accessing the data store from any system.The schema of this XML file is as follows:
<?xml version=”1.0”?>
<EmpRecordsData>
<Ecode Id=”E0001” EmployeeName=”Michael Perry”>
<EmpDetails DateofJoin=”02-02-1999” Grade=”A” salary=”1750”/>
</Ecode>
PROJECT CASE STUDY AND DESIGN |
Chapter 13 |
307 |
|
|
|
|
|
<Ecode Id=”E0002” EmployeeName=”Jenifer Carell”>
<EmpDetails DateofJoin=”03-22-1999” Grade=”B” salary=”2500”/> </Ecode>
<Ecode Id=”E0003” EmployeeName=”George Rice”>
<EmpDetails DateofJoin=”04-18-1999” Grade=”A” salary=”1800”/> </Ecode>
<Ecode Id=”E0004” EmployeeName=”Pamela Griffin”>
<EmpDetails DateofJoin=”04-27-1999” Grade=”E” salary=”7000”/> </Ecode>
<Ecode Id=”E0005” EmployeeName=”Simon Watson”>
<EmpDetails DateofJoin=”05-03-1999” Grade=”A” salary=”1650”/> </Ecode>
<Ecode Id=”E0006” EmployeeName=”Daniel Allison”>
<EmpDetails DateofJoin=”05-13-1999” Grade=”D” salary=”5700”/> </Ecode>
<Ecode Id=”E0007” EmployeeName=”Laura Hansen”>
<EmpDetails DateofJoin=”06-02-1999” Grade=”C” salary=”4150”/> </Ecode>
<Ecode Id=”E0008” EmployeeName=”Sarah Judd”>
<EmpDetails DateofJoin=”09-11-1999” Grade=”B” salary=”2600”/> </Ecode>
<Ecode Id=”E0009” EmployeeName=”Joshua Johnson”>
<EmpDetails DateofJoin=”09-23-1999” Grade=”E” salary=”7725”/> </Ecode>
<Ecode Id=”E0010” EmployeeName=”Larry Gates”>
<EmpDetails DateofJoin=”10-20-1999” Grade=”C” salary=”4350”/> </Ecode>
<Ecode Id=”E0011” EmployeeName=”Nicholas Harvey”>
<EmpDetails DateofJoin=”10-20-1999” Grade=”B” salary=”2720”/> </Ecode>
<Ecode Id=”E0012” EmployeeName=”Michael Brown”>
<EmpDetails DateofJoin=”11-11-1999” Grade=”A” salary=”1665”/> </Ecode>
<Ecode Id=”E0013” EmployeeName=”George Lewis”>
<EmpDetails DateofJoin=”12-07-1999” Grade=”B” salary=”3150”/> </Ecode>