Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Microsoft C# Professional Projects - Premier Press.pdf
Скачиваний:
177
Добавлен:
24.05.2014
Размер:
14.65 Mб
Скачать

PROJECT CASE STUDY AND DESIGN

Chapter 15

335

 

 

 

 

An operator at the head office makes an entry of each cash memo into an XML document. At the end of the day, the data in the XML document is analyzed to determine the sales from each bookstore. This data would then be analyzed at the end of the month to decide the performance of the bookstores.

The development team at Creative Learning has decided to automate the entire process. When a salesperson issues a cash memo to a customer, the salesperson makes a copy of the cash memo in the specified directory on the main server. Then, on the main server, the format of the cash memo is checked for accuracy. Once the format is validated, the entry of the cash memo will be made into the XML document.The data in the document can then be easily analyzed to see the performance of each of the bookstores.

To carry out the entire process, the development team plans to create a Windows application and name it the Creative Learning project.The following section discusses the stages in the life cycle of the Creative Learning 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.” Therefore, in this chapter, I will not discuss the entire life cycle of the project. However, I will discuss the analysis of the organization’s requirements from the development team at Creative Learning. In addition, I will discuss the design of the application created by the development team based on the analysis of the organization’s requirements. You, as a part of the development team, will analyze the requirements of Creative Learning and will create a design for the application based on the analysis.

Analyzing Requirements

To find a solution to a customer’s problem, it is essential that you analyze the requirements of the customer in detail.This is done in the analyzing requirements phase of the project life cycle. After analyzing the customer’s problem in detail, you create a plan for developing the application. This analysis of the customer’s problem is based on the problem statement stated by senior managers and the information gathered by the development team.

336 Project 3 CREATING A CREATIVE LEARNING PROJECT

In the case of Creative Learning, the problem statement, as stated by senior managers, is, “Creative Learning needs to automate the process of analyzing sales data of each bookstore.”

Upon analyzing the problem statement, the development team defined the following list of tasks that Creative Learning needs to do:

The organization needs to analyze the sales data of each bookstore.

The organization needs to automate the data analysis process.

Based on the analysis results, the organization will determine the performance of each bookstore.

Based on the performance of bookstores, the organization plans to move ahead with its growth plans.

To provide a solution to the aforementioned problems of Creative Learning, the development team plans to create a Windows application with the following features:

The application will receive a copy of the cash memo from a directory on the main ser ver at the head office of Creative Learning.

The application will validate the format of the cash memo.

If the format of the cash memo is incorrect, the application will create an event log.

Alternatively, if the format of the cash memo is correct, an entry for the cash memo will be created in an XML document.

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 Creative Learning application includes creating the interface for the Windows form used in the application.

The Creative Learning application consists of a Windows form called Creative Learning. Figure 15-1 shows the layout of the Creative Learning form.

PROJECT CASE STUDY AND DESIGN

Chapter 15

337

 

 

 

 

FIGURE 15-1 Layout of the Creative Learning form

To create the layout of the Creative Learning application, as shown in Figure 15-1, you need to include a tab control and two button controls.You have learned about button controls in Chapter 8, “Windows Forms and Controls” in the section “Types of Windows Forms Controls.”The following section discusses a TabControl control in detail.

The TabControl Control

A TabControl control is a Windows forms control that you can use to create multiple tabbed pages in a window or a dialog box. For example, a tab control can be used to display multiple-options pages in a wizard. You can use the arrow keys to shift from one tabbed page to another. A TabControl control has a TabPages property that you can modify to add tabbed pages to the tab control. You will learn about adding tabbed pages to a tab control later in this chapter.

To create a tab control in Visual Studio .NET, you can drag the control from the Windows Forms toolbox to the form. Figure 15-2 shows the TabControl control in the Windows Forms toolbox.

338 Project 3 CREATING A CREATIVE LEARNING PROJECT

 

 

Y

 

L

 

F

 

M

 

A

 

E

 

FIGURE 15-2 A TabControl control in the Windows Forms toolbox

T

 

 

You can now create a tab control for your application. To create a tab control, perform the following steps:

1. Drag a TabControl control from the Windows Forms toolbox to the Creative Learning form.

A blank TabControl control is added to the form. To add pages to the tab control, you need to change the properties of the tab control.

2. Press the F4 key to display the properties of the tab control.

3. In the Properties window, click on the ellipsis button of the TabPages property.

The TabPage Collection Editor page is displayed. This page allows you to add tabbed pages to the control as a Collection object.

4. To add a tabbed page, click on the Add button.

A tabbed page with an index 0 is added to the Members: text box. The properties of the tabbed page are displayed in the tabPage1 Properties: window.

5. In the tabPage1 Properties: window, change the following properties of the tabbed page.

Text: Source Options

Name: tabSource

Team-Fly®

PROJECT CASE STUDY AND DESIGN

Chapter 15

339

 

 

 

 

When you change the name of the tabbed page to tabSource, the name of the tabPage1 Properties: window changes to tabSource Properties: window.

6.Repeat Steps 4 and 5 to add another tabbed page to the form.

7.Name the new tabbed page tabDest, and change the Text property to Destination Options.

You can change the order in which the tabbed pages are displayed by clicking on either the Up or Down Arrow buttons.

Figure 15-3 shows the TabPage Collection Editor page.

8.Click on the OK button to add tabbed pages.

FIGURE 15-3 The TabPage Collection Editor page

The tabbed pages are added, as shown in Figure 15-4. You can resize the tab control to display the tabbed pages.

340 Project 3 CREATING A CREATIVE LEARNING PROJECT

FIGURE 15-4 The TabControl control added to the Creative Learning form

The tabs in the tab control do not contain an image yet. You can add images to the tabs in the tab control by changing the ImageIndex property in the TabPage Collection Editor page. However, to do this, you first need to add an ImageList control to the Creative Learning form.

The ImageList Control

Visual Studio .NET provides you with an ImageList control that you can use to add images to the controls in a Windows form. These include various controls, such as TabControl, Button, ToolBar, TreeView control, and so on. An ImageList control is a collection of images. You can add images to the ImageList control by using the Images property.

However, to associate an ImageList control to a Windows Forms control, you can change the ImageList property of the Windows Forms control. The ImageList control is present in the Windows Forms toolbox, and to add the control to the form, you must drag the control to the form.

To add an ImageList control to the Creative Learning form, perform the following steps:

1.Drag an ImageList control from the Windows Forms toolbox to the form.

PROJECT CASE STUDY AND DESIGN

Chapter 15

 

341

 

 

 

 

 

 

An ImageList control with the name ImageList1 is added to the component tray. Figure 15-5 shows the ImageList control added to the component tray of the Creative Learning form.

FIGURE 15-5 The ImageList control added to the component tray of the Creative Learning form

Until now, the ImageList control does not contain any image. To add images to the ImageList control, you need to change the Images property of the ImageList control. When you add images to the ImageList control, the images are added to a Collection object of the control. To add images to a ImageList control in Visual Studio .NET, perform the following steps:

2.Click on the ellipsis button of the Images property. The Image Collection Editor dialog box is displayed.

3.Click on the Add button to add an image to the Members: textbox.

You can browse for the image to add it to the ImageList control. The image that you add is included in the System.Drawing namespace. The index value of the first image that is added is 0. As you add more images to the ImageList control, the index value increases. However, in the case of Creative Learning form, you will add only one image.

4.Click on the OK button to close the Image Collection Editor dialog box.

Figure 15-6 shows the Bitmap image added to the Image Collection Editor dialog box.

342 Project 3 CREATING A CREATIVE LEARNING PROJECT

FIGURE 15-6 The Bitmap image added to the Image Collection Editor dialog box

To add the image in the ImageList control to the TabControl control, perform the following steps:

5.Click on the drop-down button of the ImageList property of the TabControl control.

6.From the drop-down list, select the imageList1 option. imageList1 is associated with the TabControl control.

However, the Bitmap image is not presently visible on the tabbed pages. To display the image on the tabbed pages, you need to modify the properties of the tabbed pages on the TabPage Collection Editor page.

7.Click on the ellipsis button of the TabPages property of the tab control to display the properties of the tabbed pages.

The tabSource tabbed page is selected by default.

8.Click on the drop-down button of the ImageIndex property.

9.From the drop-down list, select the 0 option.

10.Repeat Steps 8 and 9 to add an image to the tabDest tabbed page. The images get added to the tabbed pages.

PROJECT CASE STUDY AND DESIGN

Chapter 15

343

 

 

 

 

TIP

You can add the same image to all tabbed pages or different images to different tabbed pages in a tab control.

Having created the tabbed pages in the tab control, you can add label controls and text boxes to be displayed on the tabbed pages.

Adding Controls to Tabbed Pages

The tab control that you created contains two tabbed pages, Source Options and Destination Options. You can first add controls to the Source Options page.

The Source Options page consists of a check box control, two label controls, and two text box controls. You can add these controls to the tabSource tabbed page by dragging the controls from the Windows Forms toolbox. Then, change the following properties of the controls.

Label1

Name: label1

Text: Source Directory

Label2

Name: label3

Text: After processing, move source file to:

TextBox1

Name: txtSource

TextBox2

Name: txtProcessedFile

344 Project 3 CREATING A CREATIVE LEARNING PROJECT

CheckBox

Name: optGenerateLog

Text: Generate event log for bad file format

After adding controls to the tabSource tabbed page, the page looks as shown in Figure 15-7.

FIGURE 15-7 The tabSource page with the cont rols added

Similarly, you can add controls to the tabDest page. The tabDest page contains a label, a text box, a list box, a group box, and two button controls. Change the following properties of the controls after adding them to the tabbed page.

Label

Name: label2

Text: Destination Directory

TextBox

Name: txtDest

ListBox

Name: lstEvents