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

522 Project 4 CREATING AN AIRLINE RESERVATION PORTAL

In the last chapter, you implemented the business logic for running the application and fulfilling the business requirements of SkyShark Airlines. In this chapter, you will design and create the customer transaction portal for the airline, which will help customers to view details of new flights launched by the company,

the status of their tickets, and the status of flights.

Designing the Form

The customer transaction portal is developed to enhance the experience of customers. This portal provides the following four options to a customer:

View New Flights. This option enables customers to view the five most recently launched flights.

View Ticket Status. This option enables customers to view the status of their tickets.

View Flight Status. This option enables customers to view the booking status of a flight.

Confirm Reservation. This option enables customers to confirm their reservation.

To provide these functionalities, you’ll create an ASP.NET Web application.This application will contain only one Web form named wbFrmSkyShark.aspx. This form will display the data corresponding to all four options by using a different set of controls. The design of the wbFrmSkyShark.aspx Web form is displayed in Figure 22-1.

CREATING THE CUSTOMER TRANSACTION PORTAL

Chapter 22

523

 

 

 

 

FIGURE 22-1 The design of the wbFrmSkyShark.aspx Web form

The preceding figure does not show all the controls present on the Web form. This is because I’ve used only a single Web form for all the options. Controls corresponding to each option are organized in various Panels. Table 22-1 lists all these Panels and other controls present on the Web form.

Table 22-1 Controls in the wbFrmSkyShark.aspx Form

Controls

Function

Panel1

Contains controls to display all the options

Panel2

Contains controls used for the View Flight Status option

Panel3

Contains controls used for the View Ticket Status option

Panel4

Contains controls used for the Confirm Reservation option

DataGrid1

Displays the new flights

LblStatus

To display various messages to the user

 

 

524 Project 4 CREATING AN AIRLINE RESERVATION PORTAL

Of these panels, Table 22-2 lists all the controls present in Panel1.

Table 22-2 Controls in Panel1

Control Type

ID

Properties Changed

Hyperlink

Hyperlink1

Text=View New Flights

 

 

NavigateURL = wbFrmSkyShark.aspx?subform=VNF

Hyperlink

Hyperlink2

Text=View Ticket Status

 

 

NavigateURL = wbFrmSkyShark.aspx?subform=VTS

Hyperlink

Hyperlink3

Text=View Flight Status

 

 

NavigateURL = wbFrmSkyShark.aspx?subform=VFS

Hyperlink

Hyperlink4

Text=Confirm Reservation

 

 

NavigateURL = wbFrmSkyShark.aspx?subform=CR

Hyperlink

Hyperlink5

Text=Home

 

 

NavigateURL = wbFrmSkyShark.aspx?subform=H

 

 

 

If you notice, each panel is placed in different locations on the form. However, at run time, only one panel will appear on the screen, depending on the choice of the user. Therefore, you should align each panel at the same location before loading the form. You can do so by changing the Left and Top attributes of the panels in the Load event of the Web form, as given in the code that follows:

private void Page_Load(object sender, System.EventArgs e)

{

Panel2.Style[“left”]=”222px”;

Panel2.Style[“Top”]=”152px”;

Panel3.Style[“left”]=”222px”;

Panel3.Style[“Top”]=”152px”;

Panel4.Style[“left”]=”222px”;

Panel4.Style[“Top”]=”152px”;

}

The wbFrmSkyShark.aspx uses the dtFltDetails table to retrieve the flight details. Before you write the code for the wbFrmSkyShark.aspx form, drag the dtFltDetails table from Server Explorer to the design view of the form. Visual

CREATING THE CUSTOMER TRANSACTION PORTAL

Chapter 22

525

 

 

 

 

Studio .NET automatically configures SqlDataAdapter and SqlConnection controls for the form. You can read a description of these controls in Chapter 19, “Basics of ASP.NET Web Applications,” in the section “Coding the Application.”

After you add SqlDataAdapter and SqlConnection controls to the form, you can generate a dataset for the form. To generate the dataset, follow these steps:

1.Click anywhere on the form.

2.Click on the Data menu and select Generate Dataset.The Generate Dataset dialog box will appear.

3.In the Generate Dataset dialog box, click on the New option and in the corresponding box, enter dsFlight and click on OK.

4.A new DataSet control is added to your project.

All three data controls are visible in Component Designer in the Design view of the form, as you can see in Figure 22-1. I will now proceed with the implementation of the functionality that was discussed in the beginning of the chapter.

The View New Flights Option

This option displays the details of the five most recent flights launched by the SkyShark Airlines in a DataGrid control. To implement this functionality, create a procedure named Display_NewFlights(). The code for this procedure is given as follows.

public void Display_NewFlights()

{

string SelStr;

SelStr = “Select top 5 fltno, origin, destination, deptime, fareexec, farebn, launchdate from dtfltdetails order by launchdate”;

SqlCommand SelComm;

SelComm = new SqlCommand(SelStr, sqlConnection1); sqlDataAdapter1.SelectCommand = SelComm; sqlDataAdapter1.Fill(dsFlight1,”Details”);

DataView source= new DataView(dsFlight1.Tables[“Details”]);

DataGrid1.DataSource=source;

DataGrid1.DataBind();

DataGrid1.Visible = true;

}