Sie sind auf Seite 1von 102

On

Airline Ticket Reservation

A Dissertation submitted in partial fulfillment of


the
Requirements for the award of the degree of

(B.Sc.IT)

By

Rajneesh
Roll No – ……….

SIKKIM MANIPAL UNIVERSITY (SMU)

Of Health, Medical & Technological Sciences

(2019 – 2020)

1
No task is a single man’s effort. Various factors, situations and persons

Integrate to provide the background for accomplishment of


a task. Several persons, with whom I interacted, have
contributed significantly to the successful completion of
the project study.

I am immensely thankful to Miss. Archana Lal my best


teacher, SIKKIM MANIPAL UNIVERSITY (SMU) Of Health,
Medical & Technological Sciences, for her incessant and
perpetual cooperation and encouragement.

I would also like to convey my thanks to my seniors &


friends for their productive co-operation.

Rajneesh

2
]

This is to certify that the project work “Airline Ticket Reservation system”
Being submitted by Mr. Rajneesh in the partial fulfillment of the requirements for the
award of the degree B.Sc.(IT), SIKKIM MANIPAL UNIVERSITY (SMU) Of Health,
Medical & Technological Sciences, is a record of the student’s own work carried out
under the My Best Teacher MISS. ARCHNA LAL.

Miss. ARCHNA LAL

INTRODUCTION

3
This project aims at automating all the work being done manually in airline

ticket reservaion at present. The project is taken in hand for developing the enhanced

database management system because the current method of maintaining the daily

record and maintaining all the data is done on a paper sheet which is quite not reliable

for large amount of data. Because as the time passes the records on paper can spoiled

by the many more causes.

The traditional method is such as take data from large volume of files

and process on them step by step. This takes large amount of time and large man power.

So, if the software is developed, it is easy to maintain the database. On completion this

project would expedite the work in all regards. Some of the features of this software

would be:

 The features includes:-

Storing, editing and reporting sector details.

Storing, editing and reporting flight details.

Managing flights details for passengers.

Generating flight for sector.

4
Objective of the project:-

As the title of the project suggests, the objective of this software is to automate

all the data storage and manipulation procedure for a airline ticket reservation

department. The objective of this project is proposed to develop for automation of data

keeping unit which have all the details regarding to employees, passengers, sectors, fare

etc.

If this shell is automated then all work will be run fast because all the entities in

any airline reservations directly and indirectly related to the database. So, if data is

keeping and retrival is fast, then all work will be fast. This project is developed to

reduce a lot of time for manual work. In other words we can say that the maintaining of

large amount of database of that department. And if this system is developed then it

helps to maintain better control over the data of that department. And it also helps to

develop a better management over the employees and passengers.

5
System Analysis: -
System analysis refers to the process of examining a situation with the intent
of improving it through better procedures and methods. System Design is the process of
planning a new system to either replace or complement an existing system. But before
any planning is done, the old system must be thoroughly understood and the
requirements determined. System analysis is therefore, the process of gathering and
interpreting facts, diagnosis problems and using the information to re-comment
improvements in the system. Or in the other words, system analysis means a detailed
explanation or description. Before computerizing a system under consideration, it has
to be analyzed. We need to study how it functions currently, what are the problems, and
what are the requirements that the proposed system should meet.

The main components of making software are: -


 System and software requirements analysis
 Design and implementation of software
 Ensuring, verifying and maintaining software integrity.

System analysis is an activity that encompasses most of the tasks that are collectively
called Computer System Engineering. Confusing sometimes occurs because the term
often used in context that includes it only to software requirement analysis activities,
but system analysis focuses on all the system elements not just software.

System analysis is conducted with the following objectives in the mind: -


 Identify the customer’s need.
 Evaluate the system concept for feasibility
 Perform economic and technical analysis
 Allocate functions to hardware, software, people, database and other system
elements
 Establish cost and schedule constraints
 Create a system definition that forms the foundation for all the subsequent
engineering work.

6
Identification of need: -
The first strep of system analysis process involves the identification of need. The
analyst meets with the customer and the user. Identification of need is the starting point
in the evolution of a computer based system. The system analyst assists the customer
on defining the goals of the system.
 What information will be produced?
 What information is to be provided?
 What functions and performance are required?

The analyst makes sure to distinguish between customer “needs” and customer
“wants”. Information gathered during the need identification step is specified in a
System Concept Documents. The customer before meeting sometimes prepares the
original concept documents with the analyst. Invariably, customer analyst
communication results in his modifications to the documents.

Preliminary Investigation: -
The First Step in the System Development Life Cycle is the Preliminary Investigation
to determine the feasibility of the system. The purpose of the preliminary investigation
is to evaluate project requests. It is not a design study nor does it include the collection
of details to describe the business system in all respect. Rather, it is the collecting of the
information that helps committee members to evaluate the merits of the project request
and make an informed judgment about the feasibility of the proposed project.

The Preliminary investigation should accomplish the following Objectives.


1. Clarify and understand the project request.
 Determine the size of the project
 Assess costs and benefits of alternative approaches

7
 Determine the technical and operational feasibility of alternative approaches.
 Report the findings to management; with recommendations outlining the
acceptance or rejection of the proposal.

Conducting the investigation: -

The data that the analysts collect during preliminary investigations are gathered through
three primary methods: reviewing organization documents, on-site observations and
conducting interviews.

Reviewing organization documents:

The analyst conducting the investigation first learns about the organization involved in,
or affected by the project. In AIRLINE management system, it is necessary to know
how the department works and who are the persons directly associated with inventory
system.

Onsite observation: -

Another important technique to collect data is on-site observation. The purpose of the
On-site observation is to get as close as possible to the real system being studied.
During On-site Observation, office environment can be seen, work load, method of
work and facilities provided by the organization to the users can be studied.

Conducting interview: -

Interviews allows learning more about the nature of the Project request and reasons for
submitting it. Interviews should provide details that further explain the project and
show whether assistance is merited economically, operationally and technically.

8
Cost Benefit Analysis: -

Since cost plays an important role deciding the new system, it must be identified and
estimated properly. Benefits are also of different types and can be grouped on the basis
of advantages they provide the managements.

Cost-saving benefit leads to reduction in administrative and operational costs.


Cost-avoidance benefit eliminates future administrative and operational costs.
Direct Costs are those which are directly associated with a system. They are applied
directly to the operator.
Direct Benefits also can be specifically attributed to a given project.
Indirect Costs are not directly associated with a specific activity in the system. They
are often referred to as overhead expenses.
Indirect Benefits are realized as by-products on another system.

We can define cost-benefit analysis as: -


That method by which we can find and estimate the value of the gross benefits
of a new system specification.
That method by which we find and determine the increased operating costs
associated with the gross benefits.
The subtraction of these operating costs from the associated gross benefits to
arrive at net benefits.
The method by which we find and estimate the monetary value of the
development costs that produce the benefits.

9
Software requirement specification: -
The Software Requirements Specification is produced at the culmination of the analysis
task. The function and performance allocated to software as part of system engineering
are refined by establishing a complete information description, a detailed functional
description, a representation of system behavior, an indication of performance
requirement and design constraints, appropriate validation criteria, and other
information pertinent to requirement.

The Introduction to software requirements specification states the goals and objectives
of the software, describing it in the context of the computer based system.
The Information Description provides a detailed description of the problem that the
software must solve. Information content, flow, and structure are documented.
A Description of each function required to solve the problem is presented in the
Functional Description.
Validation Criteria is probably the most important and, ironically, the most often
neglected section of the Software requirement Specification.
Software Specifications can be used for different purposes. Here are there major uses.

Statement of user needs:


A main purpose of the product specification is to define the need of the product’s user.
Some times, the specification may be a part of a contract sign between the producer and
the user. It could also form part of the user manuals. A user’s needs are sometimes not
clearly understood by the developer. If this is the case, a careful analysis – involving
much interaction with the user should be devoted to reaching a clear statement of
requirements, in order to avoid possible misunderstandings.
Sometimes, at the beginning of a project, even the user has no clear idea of what
exactly the desired product is. Think, for instance, of user interfaces. A user with no
previous experience with computer products may not appreciate the difference
between, say, menu driven interaction and a command line interface. Even an exact
formulation of system functions and performance may be missing an initial description
produced by an inexperienced user.

10
A statement of the requirements for the implementation:
Specifications are also used as a reference point during product implementation. In fact,
the ultimate goal of the implementation is to build a product that needs specification.
Thus the implementers use specifications during design to make design decisions and
during the verification activity to check that the implementation compiles with the
specifications.

SOFTWARE AND HARDWARE


REQUIREMENTs:-

SOFTWARE REQUIREMENT: -

 OPERATING SYSTEM: - Window98/Window2000

 RDBMS: - MS Access

HARDWARE REQUIREMENT: -

 PROCESSOR: - PIV

 RAM: - 256MB

 STORAGE CAPACITY: - 40GB

 DRIVES: - 52X CD, 1.44MB FDD

11
System Design:-
Software Design is the first of three technical activities – design, Code generation, and
test – that are required to build and verify the software. Each activity transforms
information in a manner that ultimately results in validated computer software.

The Design task produces a data design, an architectural design, an interface design and
component design.The Design of an information system produces the details that
clearly describe how a system will meet the requirements identified during system
analysis. The system design process is not a step by step adherence of clear procedures
and guidelines. When I started working on system design, I face different types of
problems; many of these are due to constraints imposed by the user or limitation of
hardware and software available. Some time it was quite difficult to enumerate the
complexity of the problems and solutions thereof since the variety of likely problems is
so great and no solutions are exactly similar however the following consideration I kept
in mind during Design phase.

Design Objectives: -The primary objective of the design is


to deliver the requirements as specified in the feasibility
report. These are the some of the objective, which I kept in
mind.
 Practicality: The system is quite stable and can be operated by the people with
average intelligence.
 Efficiency: I tried to involve accuracy, timeliness and comprehensiveness of the
system output.
 Cost: It is desirable to aim for the system with a minimum cost subject to the
condition that it must satisfy the entire requirement.
 Flexibility: I have tried that the system should be modifiable depending on the
changing needs of the user. Such modifications should not entail extensive
reconstructing or recreation of software. It should also be portable to different
computer systems.

12
 Security: This is very important aspect which I followed in this designing phase
and tried to covers the areas of hardware reliability, fallback procedures, and
physical security of data.

Logical and physical design:-

System design goes through two phases of development: -


Logical and physical design covers these: -

Constraints: -
These are the following constraints:

 Hardware
 Software
 Budget
 Time Scale
 Interface with other System

Operations:-
Throughout the design process I considered and specify the requirement of each of
these operational areas.

 User raising Input


 Data preparation
 Data Validation
 Processing
 Output Handling
 Action on Output

13
Data flow Diagram: -

Start

Enter Login ID and Password

Is
No
Authorized?
No
If Administrator
Yes

Administrator Priviledge User Priviledge

Enter Details Enter Details

Manage Details, No Reservation and


Reservation, No Cancelation
Cancelation

Yes Yes
Data Store in
Database

Logou
t

Stop

14
Data Structure:-

Login Table

Sector Details Table

15
Flight Details Table

ScheduledFlight Details
Table

16
Passenger Details Table

Daily Collection Table

17
START UP FORM

LOGIN FORM

18
CHANGE PASSWORD FORM

MAIN FORM

19
ADD SECTOR DETAILS FORM

FLIGHT DETAILS FORM

20
SCHEDULED FLIGHT FORM

CONFIRM PASSENGER DETAILS

21
OVERBOOKING/WAITING LIST PASSENGER DETAILS

DAILYCOLLECTION FORM

22
ADD NEW ID FORM

UPDATE/DELETE ID FORM

23
RESERVATION FORM

PRINT TICKET FORM

24
CANCEL RESERVATION FORM

PRINT REFUND RECEIPT FORM

***

25
CODING

Coding for Login Form

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace AIRLINE_RESERVATION
{
public partial class Login : Form
{
System.Data.OleDb.OleDbDataAdapter adp;
System.Data.OleDb.OleDbConnection con;
public Login()
{
InitializeComponent();
}
private void btnlogin_Click(object sender, EventArgs e)
{
adp = new System.Data.OleDb.OleDbDataAdapter("select*
from Login where login_ID=?", con);
System.Data.OleDb.OleDbParameter p;
p = new System.Data.OleDb.OleDbParameter("Login",
System.Data.OleDb.OleDbType.VarChar);
adp.SelectCommand.Parameters.Add(p);

26
if (txtusername.Text == "")
{
MessageBox.Show("Pleas Enter your User Name");
txtusername.Focus();
}
if (txtpassword.Text == "")
{
MessageBox.Show("Please Enetr your Password");
txtpassword.Focus();
}
else
{
adp.SelectCommand.Parameters[0].Value =
txtusername.Text;
DataSet ds = new DataSet();
adp.Fill(ds, "Login");
if (ds.Tables.Count > 0)
{
bool validuser1 = false;
foreach (DataRow dr in ds.Tables[0].Rows)
{
string id = dr[0].ToString();
id = id.Trim();
string pass = dr[1].ToString();
pass = pass.Trim();
if (id == txtusername.Text && pass == txtpassword.Text)
{
validuser1 = true;
MainForm mfrm = new MainForm();
this.Hide();
mfrm.textBox1.Text =
ds.Tables[0].Rows[0].ItemArray[0].ToString();
mfrm.Show();
}
}
if (validuser1 == false)

27
{
MessageBox.Show("Enter valid UserID and Password");
txtpassword.Text = "";
txtpassword.Focus();
}
}
}
}

private void btnchangepassword_Click(object sender,


EventArgs e)
{
ChangePassword chfrm = new ChangePassword();
this.Hide();
chfrm.Show();
}

private void Login_Load(object sender, EventArgs e)


{
con = new System.Data.OleDb.OleDbConnection();
con.ConnectionString = "provider=Microsoft.jet.oledb.4.0;data
source=Ticket_Reservation.mdb";
con.Open();
}

private void btnExit_Click(object sender, EventArgs e)


{
Application.Exit();
}
}
}

Coding for Change Password Form


using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;

28
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace AIRLINE_RESERVATION
{
public partial class ChangePassword : Form
{
System.Data.OleDb.OleDbConnection con;
System.Data.OleDb.OleDbDataAdapter adp;
public ChangePassword()
{
InitializeComponent();
}

private void btnChange_Click(object sender, EventArgs e)


{
con.Open();
if (txtoldpassword.Text == "")
{
MessageBox.Show("Please enter your old password");
txtoldpassword.Focus();
}
else if (!(txtoldpassword.Text == ""))
{
System.Data.OleDb.OleDbDataAdapter adp1;
adp1 = new System.Data.OleDb.OleDbDataAdapter("select *
from Login where login_id=?", con);
System.Data.OleDb.OleDbParameter s1;
s1 = new System.Data.OleDb.OleDbParameter("login_id",
System.Data.OleDb.OleDbType.VarChar);
adp1.SelectCommand.Parameters.Add(s1);
adp1.SelectCommand.Parameters[0].Value =
CBUsername.SelectedValue;
DataSet ds = new DataSet();
if(adp1.Fill(ds)==0)
{
MessageBox.Show("pasword is invalid");

29
return;
}

else if (txtPassword.Text == "")


{
MessageBox.Show("Enter new password");
txtPassword.Focus();
}
else if (txtConfirm.Text == "")
{
MessageBox.Show("Enter confirm password");
txtConfirm.Focus();
}
else if (!(txtPassword.Text == txtConfirm.Text))
{
MessageBox.Show("Password does not match");
txtConfirm.Focus();
}
else
{
System.Data.OleDb.OleDbCommand cu;
cu = new System.Data.OleDb.OleDbCommand("UPDATE
LOgin SET [password] =? WHERE login_ID = ?");
System.Data.OleDb.OleDbParameter p, p1;
p = new System.Data.OleDb.OleDbParameter("password",
System.Data.OleDb.OleDbType.VarChar);
p1 = new System.Data.OleDb.OleDbParameter("login_ID",
System.Data.OleDb.OleDbType.VarChar);
cu.Parameters.Add(p);
cu.Parameters.Add(p1);
cu.Parameters[0].Value = txtPassword.Text;
cu.Parameters[1].Value = CBUsername.Text;
cu.Connection = con;
int res;
res = cu.ExecuteNonQuery();
if (res > 0)
{
MessageBox.Show("your password has been successfully
changed");

30
}

else
{
MessageBox.Show("No matching record found");
}
}
}
con.Close();
}

private void Changepassword_Load(object sender,


EventArgs e)
{
con = new System.Data.OleDb.OleDbConnection();
con.ConnectionString = "provider=Microsoft.jet.oledb.4.0;
data source=Ticket_Reservation.mdb";
con.Open();
if (CBUsername.Text == CBUsername.Text &&
txtoldpassword.Text == txtoldpassword.Text)
{
adp = new System.Data.OleDb.OleDbDataAdapter("select *
from Login", con);
DataSet ds = new DataSet();
adp.Fill(ds);
CBUsername.DataSource = ds.Tables[0].DefaultView;
CBUsername.DisplayMember = "login_id";
CBUsername.ValueMember = "login_id";
con.Close();
}
}

private void btnBack_Click(object sender, EventArgs e)


{
Login lgin = new Login();
this.Close();
lgin.Show();
}

31
}
}

Coding for Main Form

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace AIRLINE_RESERVATION
{
public partial class MainForm : Form
{
System.Data.OleDb.OleDbConnection con;
System.Data.OleDb.OleDbDataAdapter adp;
public MainForm()
{
InitializeComponent();
}

private void btnLogout_Click(object sender, EventArgs e)


{
Login lgn = new Login();
lgn.Show();
this.Hide();
}

private void btnReservation_Click(object sender, EventArgs


e)
{
Reservation frm = new Reservation();

32
frm.textBox1.Text = textBox1.Text;
frm.Show();
this.Hide();
}

private void secterToolStripMenuItem_Click(object sender,


EventArgs e)
{
SecterDetails sectd = new SecterDetails();
sectd.Show();
this.Hide();
}

private void btnCancelReservation_Click(object sender,


EventArgs e)
{
CancelReservation Cfrm = new CancelReservation();
Cfrm.textBox1.Text = textBox1.Text;
Cfrm.Show();
this.Hide();
}

private void MainForm_Load(object sender, EventArgs e)


{
try
{
string id;
con = new System.Data.OleDb.OleDbConnection();
con.ConnectionString = "provider=Microsoft.jet.oledb.4.0;
data source= Ticket_Reservation.mdb";
con.Open();
adp = new System.Data.OleDb.OleDbDataAdapter("select
role from Login where login_ID=?", con);
System.Data.OleDb.OleDbParameter p;
p = new System.Data.OleDb.OleDbParameter("login_ID",
System.Data.OleDb.OleDbType.Char);
adp.SelectCommand.Parameters.Add(p);
adp.SelectCommand.Parameters[0].Value = textBox1.Text;
DataSet ds = new DataSet();

33
adp.Fill(ds, "Login");
id = ds.Tables[0].Rows[0][0].ToString().Trim();
if (!(id == "Administrator"))
{
menuStrip1.Enabled = false;
}
}
catch
{
}
}

private void flightToolStripMenuItem_Click(object sender,


EventArgs e)
{
FlightDetails frm = new FlightDetails();
frm.Show();
this.Hide();
}
private void
scheduledFlightsToolStripMenuItem_Click(object sender,
EventArgs e)
{
ScheduledFlight schfrm= new ScheduledFlight();
schfrm.Show();
this.Close();
}

private void
confirmedPassengerListToolStripMenuItem_Click(object
sender, EventArgs e)
{
ConfirmedPassengers frm = new ConfirmedPassengers();
frm.Show();
this.Hide();
}

34
private void
overbookingWaitingListToolStripMenuItem_Click(object
sender, EventArgs e)
{
Overooked_Waitlisted frm = new Overooked_Waitlisted();
frm.Show();
this.Hide();
}

private void
dailyCollectionListToolStripMenuItem_Click(object sender,
EventArgs e)
{
DailyCollection dfrm = new DailyCollection();
dfrm.Show();
this.Hide();
}

private void addNewIDToolStripMenuItem_Click(object


sender, EventArgs e)
{
NewLoginID nfrm = new NewLoginID();
nfrm.Show();
this.Hide();
}

private void updateDeleteIDToolStripMenuItem_Click(object


sender, EventArgs e)
{
UpdateorDeleteID frm = new UpdateorDeleteID();
frm.Show();
this.Hide();
}
}
}

35
Coding for Sector Details Form

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace AIRLINE_RESERVATION
{
public partial class SecterDetails : Form
{
System.Data.OleDb.OleDbConnection con;
System.Data.OleDb.OleDbDataAdapter adp;
System.Data.OleDb.OleDbCommand cmdel;
System.Data.OleDb.OleDbCommand cmedit;
DataSet ds = new DataSet();
public SecterDetails()
{
InitializeComponent();
con = new System.Data.OleDb.OleDbConnection();
con.ConnectionString = "provider=Microsoft.jet.oledb.4.0;data
source= Ticket_Reservation.mdb";
con.Open();
}
DataRow row = null;
DataTable table = null;
private void SecterDetails_Load(object sender, EventArgs e)
{
adp = new System.Data.OleDb.OleDbDataAdapter("select*
from Secter",con);
adp.Fill(ds,"Secter");
dgvSecterDetails.DataSource = ds.Tables[0].DefaultView;
}

36
private void btnAdd_Click(object sender, EventArgs e)
{
System.Data.OleDb.OleDbDataAdapter adp;
adp = new System.Data.OleDb.OleDbDataAdapter("select*
from Secter", con);
DataSet ds = new DataSet();
adp.Fill(ds,"Secter");
if (txtSecterID.Text == "")
{
MessageBox.Show("Please Enter Secter ID");
txtSecterID.Focus();
return;
}

if (txtDesc.Text == "")
{
MessageBox.Show("Please Enter Description");
txtDesc.Focus();
return;
}
else if(txtFCFares.Text=="")
{
MessageBox.Show("Please Enter First Class Fares");
txtFCFares.Focus();
return;
}
if(!(txtFCFares.Text==""))
{
string fstr;
string fstr1=null;
bool fcheck=false;
int fi=0;
int fasci=0;
fstr=txtFCFares.Text;
for(fi=1;fi<=fstr.Length;fi++)
{
fstr1=fstr.Substring(fi-1,1);
fasci=System.Convert.ToInt32(fstr1[0]);

37
if(fasci>=48&fasci<=57)
{
fcheck=true;
}
else
{
fcheck=false;
break;
}
}

if(fcheck==false)
{
MessageBox.Show("Enter Valid Fares");
txtFCFares.Text="";
txtFCFares.Focus();
return;
}
}
if(txtBCFares.Text=="")
{
MessageBox.Show("Enter Valid Fares");
txtBCFares.Text = "";
txtBCFares.Focus();
return;
}
if (!(txtBCFares.Text == ""))
{
string bstr;
string bstr1 = null;
bool bcheck = false;
int bi = 0;
int basci = 0;
bstr = txtBCFares.Text;
for (bi = 1; bi <= bstr.Length; bi++)
{
bstr1 = bstr.Substring(bi - 1, 1);
basci = System.Convert.ToInt32(bstr1[0]);

38
if (basci >= 48 & basci <= 57)
{
bcheck = true;
}
else
{
bcheck = false;
break;
}
}
if (bcheck == false)
{
MessageBox.Show("Enter Valid Fares");
txtBCFares.Text = "";
txtBCFares.Focus();
return;
}
}
if (txtECFares.Text == "")
{
MessageBox.Show("Enter Valid Fares");
txtECFares.Text = "";
txtECFares.Focus();
return;
}

if (!(txtECFares.Text == ""))
{
string estr;
string estr1 = null;
bool echeck = false;
int ei = 0;
int easci = 0;
estr = txtECFares.Text;
for (ei = 1; ei <= estr.Length; ei++)
{
estr1 = estr.Substring(ei - 1, 1);
easci = System.Convert.ToInt32(estr1[0]);

39
if (easci >= 48 & easci <= 57)
{
echeck = true;
}
else
{
echeck = false;
break;
}
}
if (echeck == false)
{
MessageBox.Show("Enter Valid Fares");
txtECFares.Text = "";
txtECFares.Focus();
return;
}
}
try
{
table = ds.Tables["Secter"];
row = table.NewRow();
row[0] = txtSecterID.Text;
row[1] = txtDesc.Text;
row[2] = txtFCFares.Text;
row[3] = txtBCFares.Text;
row[4] = txtECFares.Text;
table.Rows.Add(row);
System.Data.OleDb.OleDbCommandBuilder comm = new
System.Data.OleDb.OleDbCommandBuilder(adp);
adp.InsertCommand = comm.GetInsertCommand();
adp.Update(ds, "Secter");
adp.Fill(ds);
MessageBox.Show("New Entry saved");
System.Data.OleDb.OleDbDataAdapter adp2 = new
System.Data.OleDb.OleDbDataAdapter("select* from Secter",
con);
DataSet ds2 = new DataSet();

40
adp2.Fill(ds2, "Secter");
dgvSecterDetails.DataSource = ds2.Tables[0].DefaultView;
txtSecterID.Text = "";
txtDesc.Text = "";
txtFCFares.Text = "";
txtBCFares.Text = "";
txtECFares.Text = "";
}
catch
{
MessageBox.Show("Secter ID already Exist");
}
}

private void dgvSecterDetails_CellContentClick(object


sender, DataGridViewCellEventArgs e)
{
try
{
int index = 0;
index = e.ColumnIndex;
if (index == 0)
{
System.Data.OleDb.OleDbDataAdapter adp;
DataSet ds = new DataSet();
adp = new System.Data.OleDb.OleDbDataAdapter("select*
from Secter where secter_ID=?", con);
System.Data.OleDb.OleDbParameter p;
p = new System.Data.OleDb.OleDbParameter("secter_ID",
System.Data.OleDb.OleDbType.VarChar);
adp.SelectCommand.Parameters.Add(p);
adp.SelectCommand.Parameters[0].Value =
dgvSecterDetails.Rows[e.RowIndex].Cells[1].Value.
ToString();
adp.Fill(ds, "Secter");
txtSecterID.Text = ds.Tables["Secter"].Rows[0]
["secter_ID"].ToString();
txtDesc.Text = ds.Tables["Secter"].Rows[0]
["Description"].ToString();

41
txtFCFares.Text = ds.Tables["Secter"].Rows[0]
["FirstClassFare"].ToString();
txtBCFares.Text = ds.Tables["Secter"].Rows[0]
["BussinessClassFare"]. ToString();
txtECFares.Text = ds.Tables["Secter"].Rows[0]
["EconomyClassFare"]. ToString();
}
else
{
return;
}
}
catch
{

}
}

private void btnBack_Click(object sender, EventArgs e)


{
MainForm mfrm = new MainForm();
mfrm.Show();
this.Hide();
}

private void btnDelete_Click(object sender, EventArgs e)


{
if (txtFCFares.Text == "" || txtBCFares.Text == "" ||
txtECFares.Text == "")
{
MessageBox.Show("Please select Record first");
return;
}
try
{
DialogResult Result = new DialogResult();
Result = MessageBox.Show("Do you wanto to Delete this
Record ?", "Delete?",

42
System.Windows.Forms.MessageBoxButtons.YesNo,
System.Windows.Forms.MessageBoxIcon.Question);
if (Result == DialogResult.Yes)
{
cmdel = new System.Data.OleDb.OleDbCommand("delete*
from Secter where Secter_ID=?", con);
System.Data.OleDb.OleDbParameter p;
p = new System.Data.OleDb.OleDbParameter("Secter_ID",
System.Data.OleDb.OleDbType.VarChar);
cmdel.Parameters.Add(p);
cmdel.Parameters[0].Value = txtSecterID.Text;
int del = cmdel.ExecuteNonQuery();
if (del >= 1)
MessageBox.Show("Record Deleted");
else
MessageBox.Show("No matching record found");
}
}
catch
{

}
}
private void btnReset_Click(object sender, EventArgs e)
{
txtSecterID.Text = "";
txtDesc.Text = "";
txtFCFares.Text = "";
txtBCFares.Text = "";
txtECFares.Text = "";
}

private void btnEdit_Click(object sender, EventArgs e)


{
cmedit = new System.Data.OleDb.OleDbCommand("update
Secter set
Description=?,FirstClassFare=?,BussinessClassFare=?,Econo
myClassFare=?where Secter_ID=?",con);
System.Data.OleDb.OleDbParameter pe, pe1, pe2, pe3, pe4;

43
pe = new
System.Data.OleDb.OleDbParameter("Description",System.D
ata.OleDb.OleDbType.VarChar);
pe1 = new
System.Data.OleDb.OleDbParameter("FirstClassFare",
System.Data.OleDb.OleDbType.VarChar);
pe2 = new
System.Data.OleDb.OleDbParameter("BussinessClassFare",
System.Data.OleDb.OleDbType.VarChar);
pe3 = new
System.Data.OleDb.OleDbParameter("EconomyClassFare",
System.Data.OleDb.OleDbType.VarChar);
pe4 = new System.Data.OleDb.OleDbParameter("Secter_ID",
System.Data.OleDb.OleDbType.VarChar);
cmedit.Parameters.Add(pe);
cmedit.Parameters.Add(pe1);
cmedit.Parameters.Add(pe2);
cmedit.Parameters.Add(pe3);
cmedit.Parameters.Add(pe4);
cmedit.Parameters[0].Value = txtDesc.Text;
int ee;
try
{
cmedit.Parameters[1].Value = txtFCFares.Text;
cmedit.Parameters[2].Value = txtBCFares.Text;
cmedit.Parameters[3].Value = txtECFares.Text;
cmedit.Parameters[4].Value = txtSecterID.Text;
ee= cmedit.ExecuteNonQuery();
if (ee >= 1)
MessageBox.Show("Record Updated");
}
catch
{
MessageBox.Show("Enter only numeric value of fares");
}
}
}
}

44
Coding for Flight Details Form

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace AIRLINE_RESERVATION
{
public partial class FlightDetails : Form
{
public FlightDetails()
{
InitializeComponent();
}
System.Data.OleDb.OleDbConnection con;
DataRow row = null;
DataTable table = null;
private void FlightDetails_Load(object sender, EventArgs e)
{
con = new System.Data.OleDb.OleDbConnection();
con.ConnectionString = "provider=Microsoft.jet.oledb.4.0;data
source=Ticket_Reservation.mdb";
con.Open();
System.Data.OleDb.OleDbDataAdapter adp;
adp = new System.Data.OleDb.OleDbDataAdapter("select*
from Flight", con);
DataSet ds = new DataSet();
adp.Fill(ds, "Flight");
dgvFlightDetails.DataSource =
ds.Tables["Flight"].DefaultView;
}

private void btnBack_Click(object sender, EventArgs e)

45
{
MainForm mfrm = new MainForm();
mfrm.Show();
this.Hide();
}

private void dgvFlightDetails_CellContentClick(object


sender, DataGridViewCellEventArgs e)
{
try
{
int index = 0;
index = e.ColumnIndex;
if (index == 0)
{
System.Data.OleDb.OleDbDataAdapter adp;
DataSet ds = new DataSet();
adp = new System.Data.OleDb.OleDbDataAdapter("select*
from Flight where Flight_Number=?", con);
System.Data.OleDb.OleDbParameter p;
p = new
System.Data.OleDb.OleDbParameter("Flight_Number",
System.Data.OleDb.OleDbType.VarChar);
adp.SelectCommand.Parameters.Add(p);
adp.SelectCommand.Parameters[0].Value =
dgvFlightDetails.Rows[e.RowIndex].Cells[1].Value.
ToString();
adp.Fill(ds, "Flight");
txtFlightNo.Text = ds.Tables["Flight"].Rows[0]
["Flight_Number"].ToString();
txtDepTime.Text = ds.Tables["Flight"].Rows[0]
["Depart_Time"].ToString();
txtArrTime.Text = ds.Tables["Flight"].Rows[0]
["Arival_Time"].ToString();
txtAircraftID.Text = ds.Tables["Flight"].Rows[0]
["Aircraft_ID"].ToString();
txtAircraftDesc.Text = ds.Tables["Flight"].Rows[0]
["Aircraft_DesC"].ToString();
System.Data.OleDb.OleDbDataAdapter adp1;

46
adp1 = new System.Data.OleDb.OleDbDataAdapter("select*
from Flight where Flight_Number=?", con);
System.Data.OleDb.OleDbParameter p1;
p1 = new
System.Data.OleDb.OleDbParameter("Flight_Number",
System.Data.OleDb.OleDbType.VarChar);
adp1.SelectCommand.Parameters.Add(p1);
adp1.SelectCommand.Parameters[0].Value =
dgvFlightDetails.Rows[e.RowIndex].Cells[1].Value.
ToString();
DataSet ds1 = new DataSet();
adp1.Fill(ds1, "Flight");
cmbSecterID.DataSource =
ds1.Tables["Flight"].DefaultView;
cmbSecterID.DisplayMember = "Sector_ID";
cmbSecterID.ValueMember = "Sector_ID";
}
else
{
return;
}
}
catch
{

}
}
private void btnAdd_Click(object sender, EventArgs e)
{
if (txtFlightNo.Text == "")
{
MessageBox.Show("Please Enter Flight Number");
txtFlightNo.Focus();
return;
}
else if (txtDepTime.Text == "")
{
MessageBox.Show("Please enter Departure Time");
txtDepTime.Focus();

47
return;
}
else if (!(txtDepTime.Text == ""))
{
string dstr;
string dstr1 = null;
bool dcheck = false;
int di = 0;
int dasci = 0;
dstr = txtDepTime.Text;
for (di = 1; di <= dstr.Length; di++)
{
dstr1 = dstr.Substring(di - 1, 1);
dasci = System.Convert.ToInt32(dstr1[0]);
if (dasci >= 48 & dasci <= 57)
{
dcheck = true;
}
else
{
dcheck = false;
break;
}
}
if (dcheck == false)
{
MessageBox.Show("Enter Valid Number of Seats in First
Class");
txtDepTime.Focus();
return;
}
if (txtArrTime.Text == "")
{
MessageBox.Show("Please Enter Arrival Time");
txtArrTime.Focus();
return;
}
if (!(txtArrTime.Text == ""))
{

48
string str;
string str1 = null;
bool check = false;
int i = 0;
int asci = 0;
str = txtArrTime.Text;
for (i = 1; i <= str.Length; i++)
{
str1 = str.Substring(i - 1, 1);
asci = System.Convert.ToInt32(str1[0]);
if (asci >= 48 & asci <= 57)
{
check = true;
}
else
{
check = false;
break;
}
}
if (check == false)
{
MessageBox.Show("Enter Valid Number of Seats in First
Class");
txtArrTime.Focus();
return;
}
}
if (txtAircraftID.Text == "")
{
MessageBox.Show("Please Enter the Aircraft ID");
return;
}
if (txtAircraftDesc.Text == "")
{
MessageBox.Show("Please Enter the description of the
Aircraft");
return;
}

49
System.Data.OleDb.OleDbDataAdapter adp = new
System.Data.OleDb.OleDbDataAdapter("Select * from Flight",
con);
DataSet ds = new DataSet();
adp.Fill(ds, "Flight");

try
{
table = ds.Tables["Flight"];
row = table.NewRow();
row[0] = txtFlightNo.Text;
row[1] = txtDepTime.Text;
row[2] = txtArrTime.Text;
row[3] = txtAircraftID.Text;
row[4] = txtAircraftDesc.Text;
row[5] = cmbSecterID.Text;
table.Rows.Add(row);
System.Data.OleDb.OleDbCommandBuilder comm = new
System.Data.OleDb.OleDbCommandBuilder(adp);
adp.InsertCommand = comm.GetInsertCommand();
adp.Update(ds, "Flight");
adp.Fill(ds);
MessageBox.Show("New Record Saved");
System.Data.OleDb.OleDbDataAdapter adp2 = new
System.Data.OleDb.OleDbDataAdapter("Select * from Flight",
con);
DataSet ds2 = new DataSet();
adp.Fill(ds2, "Flight");
dgvFlightDetails.DataSource = ds2.Tables[0].DefaultView;
txtFlightNo.Text = "";
txtDepTime.Text = "";
txtArrTime.Text = "";
txtAircraftID.Text = "";
txtAircraftDesc.Text = "";
cmbSecterID.Text = "";
}
catch
{
MessageBox.Show("No new record saved","INPUT ERROR");

50
}
}
}

private void btnReset_Click(object sender, EventArgs e)


{
txtFlightNo.Text = "";
txtDepTime.Text = "";
txtArrTime.Text = "";
txtAircraftID.Text = "";
txtAircraftDesc.Text = "";
cmbSecterID.Text = "";
}

private void cmbSecterID_MouseUp(object sender,


MouseEventArgs e)
{
System.Data.OleDb.OleDbDataAdapter adp4;
adp4 = new System.Data.OleDb.OleDbDataAdapter("select*
from Secter", con);
DataSet ds4 = new DataSet();
adp4.Fill(ds4, "Secter");
cmbSecterID.DataSource =
ds4.Tables["Secter"].DefaultView;
cmbSecterID.DisplayMember = "Secter_ID";
cmbSecterID.ValueMember = "Secter_ID";
}

private void btnDelete_Click(object sender, EventArgs e)


{
System.Data.OleDb.OleDbCommand cmdel;
DialogResult result = new DialogResult();
if (txtFlightNo.Text == "")
{
MessageBox.Show("Please Select a record first");
return;
}
System.Data.OleDb.OleDbDataAdapter adp;
DataSet ds = new DataSet();

51
adp = new System.Data.OleDb.OleDbDataAdapter("Select *
from Flight", con);
adp.Fill(ds, "Flight");
try
{
result = MessageBox.Show("Do You Want to Delete this record
?", "Delete?",
System.Windows.Forms.MessageBoxButtons.YesNo,
System.Windows.Forms.MessageBoxIcon.Question);
if (result == DialogResult.Yes)
{
cmdel = new System.Data.OleDb.OleDbCommand("delete*
from Flight where Flight_Number=?", con);
System.Data.OleDb.OleDbParameter p;
p = new
System.Data.OleDb.OleDbParameter("Flight_Number",
System.Data.OleDb.OleDbType.VarChar);
cmdel.Parameters.Add(p);
cmdel.Parameters[0].Value = txtFlightNo.Text;
int del = cmdel.ExecuteNonQuery();
if (del >= 1)
MessageBox.Show("Record Deleted");
else
MessageBox.Show("No matching record found","INPUT
ERROR");
adp.Update(ds, "Flight");
adp.Fill(ds);
System.Data.OleDb.OleDbDataAdapter adp2 = new
System.Data.OleDb.OleDbDataAdapter("Select * from Flight",
con);
DataSet ds2 = new DataSet();
adp2.Fill(ds2, "Flight");
dgvFlightDetails.DataSource = ds2.Tables[0].DefaultView;
txtFlightNo.Text = "";
txtArrTime.Text = "";
txtDepTime.Text = "";
txtAircraftID.Text = "";
txtAircraftDesc.Text = "";
cmbSecterID.Text = "";

52
}
}
catch
{

}
}

private void btnEdit_Click(object sender, EventArgs e)


{
System.Data.OleDb.OleDbCommand com;
com = new System.Data.OleDb.OleDbCommand("update
Flight set
Sector_ID=?,Depart_Time=?,Arival_Time=?,Aircraft_ID=?,Aircr
aft_DesC=? where Flight_Number=?", con);
System.Data.OleDb.OleDbParameter p, p1,p2,p3,p4,p5;
p = new
System.Data.OleDb.OleDbParameter("Sector_ID",System.Da
ta.OleDb.OleDbType.Char);
p1 = new
System.Data.OleDb.OleDbParameter("Depart_Time",
System.Data.OleDb.OleDbType.Char);
p2 = new System.Data.OleDb.OleDbParameter("Arival_Time",
System.Data.OleDb.OleDbType.Char);
p3 = new
System.Data.OleDb.OleDbParameter("Aircraft_ID",System.Da
ta.OleDb.OleDbType.Char);
p4 = new
System.Data.OleDb.OleDbParameter("Aircraft_DesC",
System.Data.OleDb.OleDbType.Char);
p5 = new
System.Data.OleDb.OleDbParameter("Flight_Number",
System.Data.OleDb.OleDbType.Char);
com.Parameters.Add(p);
com.Parameters.Add(p1);
com.Parameters.Add(p2);
com.Parameters.Add(p3);
com.Parameters.Add(p4);
com.Parameters.Add(p5);

53
com.Parameters[0].Value =cmbSecterID.Text;
com.Parameters[1].Value = txtDepTime.Text;
com.Parameters[2].Value = txtArrTime.Text;
com.Parameters[3].Value = txtAircraftID.Text;
com.Parameters[4].Value = txtAircraftDesc.Text;
com.Parameters[5].Value =txtFlightNo.Text;
int res;
res=com.ExecuteNonQuery();
if (res >= 1)
{
MessageBox.Show("Record updated successfully");
}
else
MessageBox.Show("Record not updated ", "INUT ERROR");
}
}
}

Coding for Scheduled Flight Details Form

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace AIRLINE_RESERVATION
{
public partial class ScheduledFlight : Form
{

54
System.Data.OleDb.OleDbConnection con;
System.Data.OleDb.OleDbDataAdapter adp;
public ScheduledFlight()
{
InitializeComponent();
}

private void btnBack_Click(object sender, EventArgs e)


{
MainForm mfrm;
mfrm = new MainForm();
mfrm.Show();
this.Close();
}

private void
dgvScheduledFlightDetails_CellContentClick(object
sender, DataGridViewCellEventArgs e)
{
try
{
int index = 0;
index = e.ColumnIndex;
if (index == 0)
{
System.Data.OleDb.OleDbDataAdapter adp;
DataSet ds = new DataSet();
adp = new System.Data.OleDb.OleDbDataAdapter("select*
from ScheduledFlight where ScheduledID=?", con);
System.Data.OleDb.OleDbParameter p;
p = new System.Data.OleDb.OleDbParameter("ScheduledID",
System.Data.OleDb.OleDbType.VarChar);
adp.SelectCommand.Parameters.Add(p);
adp.SelectCommand.Parameters[0].Value =
dgvScheduledFlightDetails.Rows[e.RowIndex].Cells[1].Valu
e.ToString();
adp.Fill(ds, "ScheduledFlight");
txtScheduledID.Text = ds.Tables["ScheduledFlight"].Rows[0]
["ScheduledID"]. ToString();

55
lstFNumber.Text = ds.Tables["ScheduledFlight"].Rows[0]
["Flight_Number"]. ToString();
dtpFlightDate.Text = ds.Tables["ScheduledFlight"].Rows[0]
["Flight_Date"]. ToString();
txtFCSeats.Text = ds.Tables["ScheduledFlight"].Rows[0]
["FirstClassSeatAvailable"].ToString();
txtBCSeats.Text = ds.Tables["ScheduledFlight"].Rows[0]
["BussinessClassSeatAvailable"].ToString();
txtECSeats.Text = ds.Tables["ScheduledFlight"].Rows[0]
["EconomyClassSeatAvailable"].ToString();
}
else
{
return;
}
}

catch
{

}
}

private void ScheduledFlight_Load(object sender, EventArgs


e)
{
con = new System.Data.OleDb.OleDbConnection();
con.ConnectionString = "provider=Microsoft.jet.oledb.4.0;data
source=Ticket_Reservation.mdb";
con.Open();
adp = new System.Data.OleDb.OleDbDataAdapter("select*
from ScheduledFlight", con);
DataSet ds = new DataSet();
adp.Fill(ds, "ScheduledFlight");
dgvScheduledFlightDetails.DataSource =
ds.Tables["ScheduledFlight"].DefaultView;
System.Data.OleDb.OleDbDataAdapter adp1;
adp1 = new System.Data.OleDb.OleDbDataAdapter("select
Flight_Number from Flight",con);

56
DataSet ds1 = new DataSet();
adp1.Fill(ds1,"Flight");
lstFNumber.DataSource = ds1.Tables["Flight"].DefaultView;
lstFNumber.DisplayMember = "Flight_Number";
lstFNumber.ValueMember = "Flight_Number";
}

private void btnAdd_Click(object sender, EventArgs e)


{
System.Data.OleDb.OleDbCommand cmdAdd;
cmdAdd = new System.Data.OleDb.OleDbCommand("insert
into ScheduledFlight values (?,?,?,?,?,?)",con);
System.Data.OleDb.OleDbParameter p1, p2, p3, p4, p5, p6;
p1 = new
System.Data.OleDb.OleDbParameter("SchduledID",System.D
ata.OleDb.OleDbType.VarChar);
p2 = new
System.Data.OleDb.OleDbParameter("Flight_Number",
System.Data.OleDb.OleDbType.VarChar);
p3 = new System.Data.OleDb.OleDbParameter("Flight_Date",
System.Data.OleDb.OleDbType.VarChar);
p4 = new
System.Data.OleDb.OleDbParameter("FirstClassSeatAvailabl
e", System.Data.OleDb.OleDbType.VarChar);
p5 = new
System.Data.OleDb.OleDbParameter("BussinessClassSeatAv
ailable", System.Data.OleDb.OleDbType.VarChar);
p6 = new
System.Data.OleDb.OleDbParameter("EconomyClassSeatAva
ilable", System.Data.OleDb.OleDbType.VarChar);
cmdAdd.Parameters.Add(p1);
cmdAdd.Parameters.Add(p2);
cmdAdd.Parameters.Add(p3);
cmdAdd.Parameters.Add(p4);
cmdAdd.Parameters.Add(p5);
cmdAdd.Parameters.Add(p6);
cmdAdd.Parameters[0].Value = txtScheduledID.Text;
cmdAdd.Parameters[1].Value = lstFNumber.SelectedValue;
cmdAdd.Parameters[2].Value = dtpFlightDate.Text;

57
cmdAdd.Parameters[3].Value = txtFCSeats.Text;
cmdAdd.Parameters[4].Value = txtBCSeats.Text;
cmdAdd.Parameters[5].Value = txtECSeats.Text;
int res;
res = cmdAdd.ExecuteNonQuery();
if (res >= 1)
{
MessageBox.Show("Record Saved");
System.Data.OleDb.OleDbDataAdapter adp1;
adp1 = new System.Data.OleDb.OleDbDataAdapter("select*
from ScheduledFlight",con);
DataSet ds1 = new DataSet();
adp1.Fill(ds1,"ScheduledFlight");
dgvScheduledFlightDetails.DataSource =
ds1.Tables[0].DefaultView;
}

else
MessageBox.Show("Record Not Saved");
}

private void btnReset_Click(object sender, EventArgs e)


{
txtScheduledID.Text = "";
txtFCSeats.Text = "";
txtBCSeats.Text = "";
txtECSeats.Text = "";
dtpFlightDate.Text = "";
}

private void btnDelete_Click(object sender, EventArgs e)


{
try
{
DialogResult result = new DialogResult();
System.Data.OleDb.OleDbCommand cmDel;
cmDel = new System.Data.OleDb.OleDbCommand("delete
*from ScheduledFlight where ScheduledID=?",con);

58
System.Data.OleDb.OleDbParameter p;
p = new
System.Data.OleDb.OleDbParameter("ScheduledID",System.
Data.OleDb.OleDbType.VarChar);
cmDel.Parameters.Add(p);
cmDel.Parameters[0].Value = txtScheduledID.Text;
int res=0;
if (txtScheduledID.Text == "")
MessageBox.Show("Enter ScheduledID First");
else
{
result = MessageBox.Show("Do You Want to Delete this record
?", "Delete?",
System.Windows.Forms.MessageBoxButtons.YesNo,
System.Windows.Forms.MessageBoxIcon.Question);
if (result == DialogResult.Yes)
{
res = cmDel.ExecuteNonQuery();
if (res >= 1)
MessageBox.Show("Record Deleted");
}
}
System.Data.OleDb.OleDbDataAdapter adp1;
adp1 = new System.Data.OleDb.OleDbDataAdapter("select*
from ScheduledFlight", con);
DataSet ds1 = new DataSet();
adp1.Fill(ds1, "ScheduledFlight");
dgvScheduledFlightDetails.DataSource =
ds1.Tables[0].DefaultView;
}
catch
{
MessageBox.Show("Record Not Deleted", "INPUT ERROR");
}
}

private void btnEdit_Click(object sender, EventArgs e)


{
System.Data.OleDb.OleDbCommand cmdEdit;

59
cmdEdit = new System.Data.OleDb.OleDbCommand("update
ScheduledFlight set
Flight_Number=?,Flight_Date=?,FirstClassSeatAvailable=?,Bu
ssinessClassSeatAvailable=?,EconomyClassSeatAvailable=?
where ScheduledID=?",con);
System.Data.OleDb.OleDbParameter p1, p2, p3, p4,p5, p6;
p1 = new
System.Data.OleDb.OleDbParameter("Flight_Number",Syste
m.Data.OleDb.OleDbType.VarChar);
p2 = new System.Data.OleDb.OleDbParameter("Flight_Date",
System.Data.OleDb.OleDbType.VarChar);
p3 = new
System.Data.OleDb.OleDbParameter("FirstClassSeatAvailabl
e", System.Data.OleDb.OleDbType.VarChar);
p4 = new
System.Data.OleDb.OleDbParameter("BussinessClassSeatAv
ailable", System.Data.OleDb.OleDbType.VarChar);
p5 = new
System.Data.OleDb.OleDbParameter("EconomyClassSeatAva
ilable", System.Data.OleDb.OleDbType.VarChar);
p6 = new
System.Data.OleDb.OleDbParameter("ScheduledID",
System.Data.OleDb.OleDbType.VarChar);
cmdEdit.Parameters.Add(p1);
cmdEdit.Parameters.Add(p2);
cmdEdit.Parameters.Add(p3);
cmdEdit.Parameters.Add(p4);
cmdEdit.Parameters.Add(p5);
cmdEdit.Parameters.Add(p6);
cmdEdit.Parameters[0].Value = lstFNumber.SelectedValue;
cmdEdit.Parameters[1].Value = dtpFlightDate.Text;
cmdEdit.Parameters[2].Value = txtFCSeats.Text;
cmdEdit.Parameters[3].Value = txtBCSeats.Text;
cmdEdit.Parameters[4].Value = txtECSeats.Text;
cmdEdit.Parameters[5].Value = txtScheduledID.Text;
int res;
res = cmdEdit.ExecuteNonQuery();
if (res >= 1)
{

60
MessageBox.Show("Record Updated");
System.Data.OleDb.OleDbDataAdapter adp1;
adp1 = new System.Data.OleDb.OleDbDataAdapter("select*
from ScheduledFlight", con);
DataSet ds1 = new DataSet();
adp1.Fill(ds1, "ScheduledFlight");
dgvScheduledFlightDetails.DataSource =
ds1.Tables[0].DefaultView;
}

else
MessageBox.Show("Record Not Updated");
}
}
}

Coding for Confitmed Passengers’ Details Form

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace AIRLINE_RESERVATION
{
public partial class ConfirmedPassengers : Form
{
System.Data.OleDb.OleDbConnection con;
System.Data.OleDb.OleDbDataAdapter adp;
public ConfirmedPassengers()
{
InitializeComponent();
}

61
private void ConfirmedPassengers_Load(object sender,
EventArgs e)
{
con = new System.Data.OleDb.OleDbConnection();
con.ConnectionString = "provider=Microsoft.jet.oledb.4.0;data
source=Ticket_Reservation.mdb";
con.Open();
adp = new System.Data.OleDb.OleDbDataAdapter("select*
from Passenger",con);
DataSet ds = new DataSet();
adp.Fill(ds,"Passenger");
dgvCPDetails.DataSource = ds.Tables[0].DefaultView;
}

private void btnBack_Click(object sender, EventArgs e)


{
MainForm mfrm = new MainForm();
mfrm.Show();
this.Hide();
}
}
}

Coding for Overbooked/Waiting List Passenger Details


Form

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace AIRLINE_RESERVATION
{

62
public partial class Overooked_Waitlisted : Form
{
System.Data.OleDb.OleDbConnection con;
System.Data.OleDb.OleDbDataAdapter adp;
public Overooked_Waitlisted()
{
InitializeComponent();
}

private void Overooked_Waitlisted_Load(object sender,


EventArgs e)
{
con = new System.Data.OleDb.OleDbConnection();
con.ConnectionString = "provider=Microsoft.jet.oledb.4.0;data
source=Ticket_Reservation.mdb";
con.Open();
adp = new System.Data.OleDb.OleDbDataAdapter("select*
from Passenger",con);
DataSet ds = new DataSet();
adp.Fill(ds,"Passenger");
dgvOWPDetails.DataSource = ds.Tables[0].DefaultView;
}

private void btnBack_Click(object sender, EventArgs e)


{
MainForm mfrm = new MainForm();
mfrm.Show();
this.Hide();
}

private void dgvOWPDetails_CellContentClick(object


sender, DataGridViewCellEventArgs e)
{

}
}
}

Coding for Daily Collection Details Form

63
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace AIRLINE_RESERVATION
{
public partial class DailyCollection : Form
{
System.Data.OleDb.OleDbConnection con;
System.Data.OleDb.OleDbDataAdapter adp;
public DailyCollection()
{
InitializeComponent();
}

private void btnBack_Click(object sender, EventArgs e)


{
MainForm mfrm = new MainForm();
mfrm.Show();
this.Hide();
}

private void DailyCollection_Load(object sender, EventArgs


e)
{
con = new System.Data.OleDb.OleDbConnection();
con.ConnectionString = "provider=Microsoft.jet.oledb.4.0;data
source=Ticket_Reservation.mdb";
con.Open();
adp = new System.Data.OleDb.OleDbDataAdapter("select*
from DailyCollection",con);
DataSet ds = new DataSet();
adp.Fill(ds,"DailyCollection");

64
dgvDCDetails.DataSource = ds.Tables[0].DefaultView;
}
}
}

Coding for New Login ID Form

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace AIRLINE_RESERVATION
{
public partial class NewLoginID : Form
{
System.Data.OleDb.OleDbConnection con;

public NewLoginID()
{
InitializeComponent();
}
DataSet ds = new DataSet();

private void btnAdd_Click(object sender, EventArgs e)


{
if (txtLoginID.Text == "" || txtPassword.Text == "" ||
cmbRole.Text == "")
{
MessageBox.Show("Please Fill All the Fields ", "Error");
return;
}
else
{

65
System.Data.OleDb.OleDbCommand cmdAdd;
cmdAdd = new System.Data.OleDb.OleDbCommand("insert
into Login values(?,?,?)",con);
System.Data.OleDb.OleDbParameter p, p1, p2;
p = new
System.Data.OleDb.OleDbParameter("login_ID",System.Data
.OleDb.OleDbType.VarChar);
p1 = new System.Data.OleDb.OleDbParameter("password",
System.Data.OleDb.OleDbType.VarChar);
p2 = new System.Data.OleDb.OleDbParameter("role",
System.Data.OleDb.OleDbType.VarChar);
cmdAdd.Parameters.Add(p);
cmdAdd.Parameters.Add(p1);
cmdAdd.Parameters.Add(p2);
cmdAdd.Parameters[0].Value = txtLoginID.Text;
cmdAdd.Parameters[1].Value = txtPassword.Text;
cmdAdd.Parameters[2].Value = cmbRole.Text;
int res;
try
{
res = cmdAdd.ExecuteNonQuery();
if (res >= 1)
{
MessageBox.Show("New Lgoin ID Saved");
txtLoginID.Text = "";
txtPassword.Text = "";
cmbRole.Text = "";
}
}

catch
{
MessageBox.Show("This lginid already exist", "Error");
}
}
}
private void NewLoginID_Load(object sender, EventArgs e)
{

66
con = new System.Data.OleDb.OleDbConnection();
con.ConnectionString = "provider=Microsoft.jet.oledb.4.0;data
source=Ticket_Reservation.mdb";
con.Open();
}

private void btnCancel_Click(object sender, EventArgs e)


{
MainForm mfrm = new MainForm();
mfrm.Show();
this.Hide();
}
}
}

Coding for Update or Delete ID Form

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace AIRLINE_RESERVATION
{
public partial class UpdateorDeleteID : Form
{
System.Data.OleDb.OleDbConnection con;
System.Data.OleDb.OleDbDataAdapter adp;
System.Data.OleDb.OleDbDataAdapter adp1;
DataSet ds = new DataSet();
DataSet ds1 = new DataSet();
int index;
public UpdateorDeleteID()
{
InitializeComponent();

67
}

private void UpdateorDeleteID_Load(object sender,


EventArgs e)
{
con = new System.Data.OleDb.OleDbConnection();
con.ConnectionString = "provider=Microsoft.jet.oledb.4.0;data
source=Ticket_Reservation.mdb";
con.Open();
adp = new System.Data.OleDb.OleDbDataAdapter("Select
*from Login", con);
adp.Fill(ds, "Login");
for (index = 0; index < ds.Tables[0].Rows.Count; index++)
{
cmbLoginID.Items.Add(ds.Tables[0].Rows[index][0]);
}
}

private void btnDelete_Click(object sender, EventArgs e)


{
try
{
System.Data.OleDb.OleDbCommand cmdDelete;
cmdDelete = new
System.Data.OleDb.OleDbCommand("Delete *from Login
where login_ID=?", con);
System.Data.OleDb.OleDbParameter p;
p = new System.Data.OleDb.OleDbParameter("login_ID",
System.Data.OleDb.OleDbType.VarChar);
cmdDelete.Parameters.Add(p);
cmdDelete.Parameters[0].Value = cmbLoginID.Text;
int res;
res = cmdDelete.ExecuteNonQuery();
if (res >= 1)
MessageBox.Show("Account Deleted", "Deleted");
else
MessageBox.Show("Account Not Deleted", "Input Error");
}
catch

68
{

}
}

private void btnCancel_Click(object sender, EventArgs e)


{
MainForm mfrm = new MainForm();
mfrm.Show();
this.Hide();
}

private void btnEdit_Click(object sender, EventArgs e)


{
string strpass = null;
adp1 = new System.Data.OleDb.OleDbDataAdapter("Select
password from Login where login_ID=?", con);
System.Data.OleDb.OleDbParameter pp;
pp = new
System.Data.OleDb.OleDbParameter("login_ID",System.Data
.OleDb.OleDbType.VarChar);
adp1.SelectCommand.Parameters.Add(pp);
adp1.SelectCommand.Parameters[0].Value =
cmbLoginID.Text;
adp1.Fill(ds1, "Login");

strpass = ds1.Tables[0].Rows[0][0].ToString();
MessageBox.Show(strpass);
if (strpass == txtoldpassword.Text)
{
if (txtpassword.Text == txtRenterpassword.Text)
{
System.Data.OleDb.OleDbCommand cmdEdit;
cmdEdit = new System.Data.OleDb.OleDbCommand("update
Login set [password]=?,role=? where login_ID=?", con);
System.Data.OleDb.OleDbParameter p, p1, p2;
p = new System.Data.OleDb.OleDbParameter("password",
System.Data.OleDb.OleDbType.VarChar);

69
p1 = new System.Data.OleDb.OleDbParameter("role",
System.Data.OleDb.OleDbType.VarChar);
p2 = new System.Data.OleDb.OleDbParameter("login_ID",
System.Data.OleDb.OleDbType.VarChar);
cmdEdit.Parameters.Add(p);
cmdEdit.Parameters.Add(p1);
cmdEdit.Parameters.Add(p2);
cmdEdit.Parameters[0].Value = txtpassword.Text;
cmdEdit.Parameters[1].Value = cmbRole.Text;
cmdEdit.Parameters[2].Value = cmbLoginID.Text;
int res;
res = cmdEdit.ExecuteNonQuery();
if (res > 0)
MessageBox.Show("Password has been changed");
else
MessageBox.Show("Password has not been changed");
}
else
{
MessageBox.Show("Password does not match");
}
}
else
MessageBox.Show("Wrong password");
}
}
}

Coding for Reservation Form

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;

70
using System.Text;
using System.Windows.Forms;

namespace AIRLINE_RESERVATION
{
public partial class Reservation : Form
{
string strGender, strSeatPref, strMealPref, strSecter;
string strNewPnr = null;

public Reservation()
{
InitializeComponent();
}
System.Data.OleDb.OleDbConnection con;

private void btnBack_Click(object sender, EventArgs e)


{
MainForm mfrm = new MainForm();
mfrm.textBox1.Text = textBox1.Text;
mfrm.Show();
this.Hide();
}

public void initializecontrols()


{
lstFlightNo.SelectedIndex = 0;
dtpTravelDate.Value = System.DateTime.Today;
cmbClass.Text = "";
txtFareAmount.Text = "";
txtFName.Text = "";
txtLName.Text = "";
txtAge.Text = "";
rbMale.Checked = false;
rbFemale.Checked = false;
rbAisle.Checked = false;
rbWindow.Checked = false;
rbVeg.Checked = false;
rbNonVeg.Checked = false;

71
txtSSR.Text = "";
strGender = null;
strSeatPref = null;
strMealPref = null;
}

public string GeneratePNRNo()


{
string strMaxPnrNo = null;
string strNewPnrNo = null;
int intMaxPnrNo = 0;
int intNewPnrNo = 0;
System.Data.OleDb.OleDbDataAdapter adp;
adp = new System.Data.OleDb.OleDbDataAdapter("select
PnrNo from Passenger", con);
DataSet ds = new DataSet();
adp.Fill(ds);
if (ds.Tables[0].Rows.Count == 0)
{
strNewPnrNo = "1";
}
else
{
int index = ds.Tables[0].Rows.Count;
strMaxPnrNo = ds.Tables[0].Rows[index - 1][0].ToString();
intMaxPnrNo = System.Convert.ToInt32(strMaxPnrNo);
intNewPnrNo = intMaxPnrNo + 1;
int i = 0;
for (i = 0; i < 3 -
System.Convert.ToString(intNewPnrNo).Length; i++)
{
strNewPnrNo = "";
}
strNewPnrNo = intNewPnrNo.ToString();
}
return strNewPnrNo;
}

private void Reservation_Load(object sender, EventArgs e)

72
{
con = new System.Data.OleDb.OleDbConnection();
con.ConnectionString = "provider=Microsoft.jet.oledb.4.0;data
source=Ticket_Reservation.mdb";
con.Open();
System.Data.OleDb.OleDbDataAdapter adp = new
System.Data.OleDb.OleDbDataAdapter("select
Flight_Number,Description from Flight,Secter where
Flight.Sector_ID=Secter.Secter_ID ", con);
DataSet ds = new DataSet();
ds.Clear();
adp.Fill(ds);
lstFlightNo.DataSource = ds.Tables[0].DefaultView;
lstFlightNo.DisplayMember = "Fight_Number";
lstFlightNo.ValueMember = "Flight_Number";
lstDescription.DataSource = ds.Tables[0].DefaultView;
lstDescription.DisplayMember = "Description";
lstDescription.ValueMember = "Description";
System.Data.OleDb.OleDbDataAdapter adpdate;
adpdate = new
System.Data.OleDb.OleDbDataAdapter("select Flight_Date
from ScheduledFlight where Flight_Number=?", con);
System.Data.OleDb.OleDbParameter pdate;
pdate = new
System.Data.OleDb.OleDbParameter("Flight_Number",
System.Data.OleDb.OleDbType.VarChar);
adpdate.SelectCommand.Parameters.Add(pdate);
adpdate.SelectCommand.Parameters[0].Value =
lstFlightNo.Text;
DataSet dsDate = new DataSet();
adpdate.Fill(dsDate);
dtpTravelDate.Text = dsDate.Tables[0].Rows[0]
[0].ToString();
}

private void btnReset_Click(object sender, EventArgs e)


{
initializecontrols();
}

73
private void btnSave_Click(object sender, EventArgs e)
{
try
{
System.Data.OleDb.OleDbDataAdapter adpdate;
adpdate = new
System.Data.OleDb.OleDbDataAdapter("select Flight_Date
from ScheduledFlight where Flight_Number=?", con);
System.Data.OleDb.OleDbParameter pdate;
pdate = new
System.Data.OleDb.OleDbParameter("Flight_Number",
System.Data.OleDb.OleDbType.VarChar);
adpdate.SelectCommand.Parameters.Add(pdate);
adpdate.SelectCommand.Parameters[0].Value =
lstFlightNo.Text;
DataSet dsDate = new DataSet();
adpdate.Fill(dsDate);
string strdate = dsDate.Tables[0].Rows[0][0].ToString();
if (dtpTravelDate.Text == strdate)
{

}
else
{
MessageBox.Show("Sorry! No flight exist on this date");
dtpTravelDate.Focus();
return;
}
}

catch
{
}
if (cmbClass.Text.Trim(' ').Length == 0)
{
MessageBox.Show("Please specify the class of travel.","Input
Error",MessageBoxButtons.OK,MessageBoxIcon.Error);
cmbClass.Focus();

74
return;
}
if (txtFareAmount.Text.Trim(' ').Length == 0)
{
MessageBox.Show("Please Fill the Field Correctly.", "Input
Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
if (txtFName.Text.Trim(' ').Length == 0)
{
MessageBox.Show("Please enter full Name of the passenger.",
"Input Error", MessageBoxButtons.OK,
MessageBoxIcon.Error);
txtFName.Focus();
return;
}
string str = txtFName.Text.ToString();
foreach (char c in str)
{
if (char.IsDigit(c))
{
MessageBox.Show("You cannot enter Numbers in Name",
"Input Error", MessageBoxButtons.OK,
MessageBoxIcon.Error);
txtFName.Text = "";
return;
}
}
string str1 = txtLName.Text.ToString();
foreach (char c in str1)
{
if (char.IsDigit(c))
{
MessageBox.Show("You cannot enter Numbers in Name",
"Input Error", MessageBoxButtons.OK,
MessageBoxIcon.Error);
txtLName.Text = "";
return;
}

75
}
if (txtAge.Text.Trim(' ').Length == 0)
{
MessageBox.Show("Please enter age of the passenger.",
"Input Error", MessageBoxButtons.OK,
MessageBoxIcon.Error);
txtAge.Focus();
return;
}
string str2 = txtAge.Text.ToString();
foreach (char c in str2)
{
if (char.IsLetter(c))
{
MessageBox.Show("You cannot enter characters in Age.",
"Input Error", MessageBoxButtons.OK,
MessageBoxIcon.Error);
txtAge.Text = "";
return;
}
}

if (rbMale.Checked == false & rbFemale.Checked == false)


{
MessageBox.Show("Please specify the gender of the
passenger.", "Input Error", MessageBoxButtons.OK,
MessageBoxIcon.Error);
return;
}
if (rbAisle.Checked == false & rbWindow.Checked == false)
{
MessageBox.Show("Please specify the seat preference of the
passenger.", "Input Error", MessageBoxButtons.OK,
MessageBoxIcon.Error);
return;
}
if (rbVeg.Checked == false & rbNonVeg.Checked == false)

76
{
MessageBox.Show("Please specify the meal preference of the
passenger.", "Input Error", MessageBoxButtons.OK,
MessageBoxIcon.Error);
return;
}
try
{
System.Data.OleDb.OleDbCommand cmdSave;
cmdSave = new System.Data.OleDb.OleDbCommand("insert
into Passenger values(?,?,?,?,?,?,?,?,?,?,?,?)", con);
System.Data.OleDb.OleDbParameter p1, p2, p3, p4, p5, p6,
p7, p8, p9, p10, p11, p12;
p1 = new System.Data.OleDb.OleDbParameter("PnrNo",
System.Data.OleDb.OleDbType.VarChar);
p2 = new
System.Data.OleDb.OleDbParameter("Flight_Number",
System.Data.OleDb.OleDbType.VarChar);
p3 = new System.Data.OleDb.OleDbParameter("Travel_Date",
System.Data.OleDb.OleDbType.VarChar);
p4 = new System.Data.OleDb.OleDbParameter("FName",
System.Data.OleDb.OleDbType.VarChar);
p5 = new System.Data.OleDb.OleDbParameter("LName",
System.Data.OleDb.OleDbType.VarChar);
p6 = new System.Data.OleDb.OleDbParameter("Age",
System.Data.OleDb.OleDbType.VarChar);
p7 = new System.Data.OleDb.OleDbParameter("Gender",
System.Data.OleDb.OleDbType.VarChar);
p8 = new System.Data.OleDb.OleDbParameter("Class",
System.Data.OleDb.OleDbType.VarChar);
p9 = new System.Data.OleDb.OleDbParameter("SeatPref",
System.Data.OleDb.OleDbType.VarChar);
p10 = new System.Data.OleDb.OleDbParameter("MealPref",
System.Data.OleDb.OleDbType.VarChar);
p11 = new System.Data.OleDb.OleDbParameter("SSR",
System.Data.OleDb.OleDbType.VarChar);
p12 = new System.Data.OleDb.OleDbParameter("Status",
System.Data.OleDb.OleDbType.VarChar);
cmdSave.Parameters.Add(p1);

77
cmdSave.Parameters.Add(p2);
cmdSave.Parameters.Add(p3);
cmdSave.Parameters.Add(p4);
cmdSave.Parameters.Add(p5);
cmdSave.Parameters.Add(p6);
cmdSave.Parameters.Add(p7);
cmdSave.Parameters.Add(p8);
cmdSave.Parameters.Add(p9);
cmdSave.Parameters.Add(p10);
cmdSave.Parameters.Add(p11);
cmdSave.Parameters.Add(p12);
strNewPnr = null;
strNewPnr = GeneratePNRNo();
cmdSave.Parameters[0].Value = strNewPnr;
cmdSave.Parameters[1].Value = lstFlightNo.Text;
cmdSave.Parameters[2].Value = dtpTravelDate.Value;
cmdSave.Parameters[3].Value = txtFName.Text;
cmdSave.Parameters[4].Value = txtLName.Text;
cmdSave.Parameters[5].Value = txtAge.Text;
cmdSave.Parameters[6].Value = strGender;
cmdSave.Parameters[7].Value = cmbClass.Text;
cmdSave.Parameters[8].Value = strSeatPref;
cmdSave.Parameters[9].Value = strMealPref;
cmdSave.Parameters[10].Value = txtSSR.Text;
cmdSave.Parameters[11].Value = "Booked";
DialogResult intres;
intres = MessageBox.Show("Do you want to continue",
"Confirmation Required", MessageBoxButtons.YesNo,
MessageBoxIcon.Question);
if (intres == DialogResult.Yes)
{
if (cmbClass.Text == "First")
{
System.Data.OleDb.OleDbDataAdapter adp1;
adp1 = new System.Data.OleDb.OleDbDataAdapter("select
FirstClassSeatAvailable from ScheduledFlight where
Flight_number=?", con);
System.Data.OleDb.OleDbParameter p;

78
p = new
System.Data.OleDb.OleDbParameter("Flight_Number",
System.Data.OleDb.OleDbType.VarChar);
adp1.SelectCommand.Parameters.Add(p);
adp1.SelectCommand.Parameters[0].Value =
lstFlightNo.Text;
DataSet ds1 = new DataSet();
adp1.Fill(ds1);
string firstseat = ds1.Tables[0].Rows[0][0].ToString();
int fseat;
fseat = System.Convert.ToInt32(firstseat);
if (fseat > 0)
{
fseat = fseat - 1;
firstseat = System.Convert.ToString(fseat);
System.Data.OleDb.OleDbCommand cmdin;
cmdin = new System.Data.OleDb.OleDbCommand("update
ScheduledFlight set FirstClassSeatAvailable=? where
Flight_Number=?", con);
System.Data.OleDb.OleDbParameter p15, p16;
p15 = new
System.Data.OleDb.OleDbParameter("FirstClassSeatAvailabl
e", System.Data.OleDb.OleDbType.VarChar);
p16 = new
System.Data.OleDb.OleDbParameter("Flight_Number",
System.Data.OleDb.OleDbType.VarChar);
cmdin.Parameters.Add(p15);
cmdin.Parameters.Add(p16);
cmdin.Parameters[0].Value = firstseat;
cmdin.Parameters[1].Value = lstFlightNo.Text;
int result;
cmdSave.ExecuteNonQuery();
result = cmdin.ExecuteNonQuery();
if (result >= 1)
MessageBox.Show("Record inserted,PnrNo is" + strNewPnr);
else
MessageBox.Show("Record not inserted");
}
else

79
{
MessageBox.Show("Sorry! Seats are not Available for this flight
in the class.");
}
}
if (cmbClass.Text == "Bussiness")
{
System.Data.OleDb.OleDbDataAdapter adp2;
adp2 = new System.Data.OleDb.OleDbDataAdapter("select
BussinessClassSeatAvailable from ScheduledFlight where
Flight_number=?", con);
System.Data.OleDb.OleDbParameter pb;
pb = new
System.Data.OleDb.OleDbParameter("Flight_Number",
System.Data.OleDb.OleDbType.VarChar);
adp2.SelectCommand.Parameters.Add(pb);
adp2.SelectCommand.Parameters[0].Value =
lstFlightNo.Text;
DataSet ds2 = new DataSet();
adp2.Fill(ds2);
string firstseat = ds2.Tables[0].Rows[0][0].ToString();
int fseat;
fseat = System.Convert.ToInt32(firstseat);
if (fseat > 0)
{
fseat = fseat - 1;
firstseat = System.Convert.ToString(fseat);
System.Data.OleDb.OleDbCommand cmdup;
cmdup = new System.Data.OleDb.OleDbCommand("update
ScheduledFlight set BussinessClassSeatAvailable=? where
Flight_Number=?", con);
System.Data.OleDb.OleDbParameter p17, p18;
p17 = new
System.Data.OleDb.OleDbParameter("BussinessClassSeatAv
ailable", System.Data.OleDb.OleDbType.VarChar);
p18 = new
System.Data.OleDb.OleDbParameter("Flight_Number",
System.Data.OleDb.OleDbType.VarChar);
cmdup.Parameters.Add(p17);

80
cmdup.Parameters.Add(p18);
cmdup.Parameters[0].Value = firstseat;
cmdup.Parameters[1].Value = lstFlightNo.Text;
cmdSave.ExecuteNonQuery();
cmdup.ExecuteNonQuery();
MessageBox.Show("Record inserted,PnrNo:" + strNewPnr);
}

else
{
MessageBox.Show("Sorry! Seats are not Available for this flight
in the class.");
}
}
if (cmbClass.Text == "Economy")
{
System.Data.OleDb.OleDbDataAdapter adp3;
adp3 = new System.Data.OleDb.OleDbDataAdapter("select
EconomyClassSeatAvailable from ScheduledFlight where
Flight_number=?", con);
System.Data.OleDb.OleDbParameter pe;
pe = new
System.Data.OleDb.OleDbParameter("Flight_Number",
System.Data.OleDb.OleDbType.VarChar);
adp3.SelectCommand.Parameters.Add(pe);
adp3.SelectCommand.Parameters[0].Value =
lstFlightNo.Text;
DataSet ds3 = new DataSet();
adp3.Fill(ds3);
string firstseat = ds3.Tables[0].Rows[0][0].ToString();
int fseat;
fseat = System.Convert.ToInt32(firstseat);
if (fseat > 0)
{
fseat = fseat - 1;
firstseat = System.Convert.ToString(fseat);
System.Data.OleDb.OleDbCommand cmdeup;

81
cmdeup = new System.Data.OleDb.OleDbCommand("update
ScheduledFlight set EconomyClassSeatAvailable=? where
Flight_Number=?", con);
System.Data.OleDb.OleDbParameter p19, p20;
p19 = new
System.Data.OleDb.OleDbParameter("EconomyClassSeatAva
ilable", System.Data.OleDb.OleDbType.VarChar);
p20 = new
System.Data.OleDb.OleDbParameter("Flight_Number",
System.Data.OleDb.OleDbType.VarChar);
cmdeup.Parameters.Add(p19);
cmdeup.Parameters.Add(p20);
cmdeup.Parameters[0].Value = firstseat;
cmdeup.Parameters[1].Value = lstFlightNo.Text;
cmdSave.ExecuteNonQuery();
cmdeup.ExecuteNonQuery();
MessageBox.Show("Record inserted,PnrNo is:" + strNewPnr);
}
else
{
MessageBox.Show("Sorry! Seats are not Available for this flight
int the class.");
}
}
}
else
{
MessageBox.Show("Record not inserted");
}
System.Data.OleDb.OleDbCommand cmdDaily;
cmdDaily = new System.Data.OleDb.OleDbCommand("insert
into DailyCollection values(?,?,?,?)", con);
System.Data.OleDb.OleDbParameter pd1, pd2, pd3, pd4;
pd1 = new System.Data.OleDb.OleDbParameter("PnrNo",
System.Data.OleDb.OleDbType.VarChar);
pd2 = new System.Data.OleDb.OleDbParameter("TranDate",
System.Data.OleDb.OleDbType.VarChar);
pd3 = new System.Data.OleDb.OleDbParameter("TranType",
System.Data.OleDb.OleDbType.VarChar);

82
pd4 = new System.Data.OleDb.OleDbParameter("Amount",
System.Data.OleDb.OleDbType.VarChar);
cmdDaily.Parameters.Add(pd1);
cmdDaily.Parameters.Add(pd2);
cmdDaily.Parameters.Add(pd3);
cmdDaily.Parameters.Add(pd4);
cmdDaily.Parameters[0].Value = strNewPnr;
cmdDaily.Parameters[1].Value = System.DateTime.Today;
cmdDaily.Parameters[2].Value = "Collection";
cmdDaily.Parameters[3].Value = txtFareAmount.Text;
cmdDaily.ExecuteNonQuery();
PrintTicket frmPrintTicket = new PrintTicket();
frmPrintTicket.lblPnr.Text = strNewPnr;
frmPrintTicket.lblName.Text = txtFName.Text;
frmPrintTicket.lblLName.Text = txtLName.Text;
frmPrintTicket.lblFlightno.Text = lstFlightNo.Text + "(" +
lstDescription.Text + ")";
frmPrintTicket.lblDate.Text = dtpTravelDate.Text;
frmPrintTicket.lblclass.Text = cmbClass.Text;
frmPrintTicket.lblfare.Text = txtFareAmount.Text;
frmPrintTicket.ShowDialog();
}

catch
{
}
}
private void rbMale_CheckedChanged(object sender,
EventArgs e)
{
strGender = "M";
}

private void rbFemale_CheckedChanged(object sender,


EventArgs e)
{
strGender = "F";
}

83
private void rbAisle_CheckedChanged(object sender,
EventArgs e)
{
strSeatPref = "Aisle";
}

private void rbWindow_CheckedChanged(object sender,


EventArgs e)
{
strSeatPref = "Window";
}

private void rbVeg_CheckedChanged(object sender,


EventArgs e)
{
strMealPref = "Veg";
}

private void rbNonVeg_CheckedChanged(object sender,


EventArgs e)
{
strMealPref = "Non-Veg";
}

private void cmbClass_SelectedIndexChanged(object


sender, EventArgs e)
{
if (cmbClass.Text == "First")
{
System.Data.OleDb.OleDbDataAdapter sect;
sect = new System.Data.OleDb.OleDbDataAdapter("select
Sector_ID from Flight where Flight_Number=?", con);
System.Data.OleDb.OleDbParameter p;
p = new
System.Data.OleDb.OleDbParameter("Flight_Number",
System.Data.OleDb.OleDbType.VarChar);
sect.SelectCommand.Parameters.Add(p);
sect.SelectCommand.Parameters[0].Value =
lstFlightNo.SelectedValue.ToString();

84
DataSet dsSec = new DataSet();
sect.Fill(dsSec);
strSecter = dsSec.Tables[0].Rows[0][0].ToString();
System.Data.OleDb.OleDbDataAdapter adp1;
adp1 = new System.Data.OleDb.OleDbDataAdapter("select
FirstClassFare from Secter where Secter_ID=?", con);
System.Data.OleDb.OleDbParameter ps;
ps = new System.Data.OleDb.OleDbParameter("Secter_ID",
System.Data.OleDb.OleDbType.VarChar);
adp1.SelectCommand.Parameters.Add(ps);
adp1.SelectCommand.Parameters[0].Value = strSecter;
DataSet ds1 = new DataSet();
ds1.Clear();
adp1.Fill(ds1);
txtFareAmount.Text = ds1.Tables[0].Rows[0][0].ToString();
}
else if (cmbClass.Text == "Bussiness")
{
System.Data.OleDb.OleDbDataAdapter sect;
sect = new System.Data.OleDb.OleDbDataAdapter("select
Sector_ID from Flight where Flight_Number=?", con);
System.Data.OleDb.OleDbParameter p;
p = new
System.Data.OleDb.OleDbParameter("Flight_Number",
System.Data.OleDb.OleDbType.VarChar);
sect.SelectCommand.Parameters.Add(p);
sect.SelectCommand.Parameters[0].Value =
lstFlightNo.SelectedValue.ToString();
DataSet dsSec = new DataSet();
sect.Fill(dsSec);
strSecter = dsSec.Tables[0].Rows[0][0].ToString();
System.Data.OleDb.OleDbDataAdapter adp1;
adp1 = new System.Data.OleDb.OleDbDataAdapter("select
BussinessClassFare from Secter where Secter_ID=?", con);
System.Data.OleDb.OleDbParameter ps;
ps = new System.Data.OleDb.OleDbParameter("Secter_ID",
System.Data.OleDb.OleDbType.VarChar);
adp1.SelectCommand.Parameters.Add(ps);
adp1.SelectCommand.Parameters[0].Value = strSecter;

85
DataSet ds1 = new DataSet();
ds1.Clear();
adp1.Fill(ds1);
txtFareAmount.Text = ds1.Tables[0].Rows[0][0].ToString();
}
else if (cmbClass.Text == "Economy")
{
System.Data.OleDb.OleDbDataAdapter sect;
sect = new System.Data.OleDb.OleDbDataAdapter("select
Sector_ID from Flight where Flight_Number=?", con);
System.Data.OleDb.OleDbParameter p;
p = new
System.Data.OleDb.OleDbParameter("Flight_Number",
System.Data.OleDb.OleDbType.VarChar);
sect.SelectCommand.Parameters.Add(p);
sect.SelectCommand.Parameters[0].Value =
lstFlightNo.SelectedValue.ToString();
DataSet dsSec = new DataSet();
sect.Fill(dsSec);
strSecter = dsSec.Tables[0].Rows[0][0].ToString();
System.Data.OleDb.OleDbDataAdapter adp1;
adp1 = new System.Data.OleDb.OleDbDataAdapter("select
EconomyClassFare from Secter where Secter_ID=?", con);
System.Data.OleDb.OleDbParameter ps;
ps = new System.Data.OleDb.OleDbParameter("Secter_ID",
System.Data.OleDb.OleDbType.VarChar);
adp1.SelectCommand.Parameters.Add(ps);
adp1.SelectCommand.Parameters[0].Value = strSecter;
DataSet ds1 = new DataSet();
ds1.Clear();
adp1.Fill(ds1);
txtFareAmount.Text = ds1.Tables[0].Rows[0][0].ToString();
}
}

private void lstFlightNo_SelectedIndexChanged(object


sender, EventArgs e)
{
System.Data.OleDb.OleDbDataAdapter adpdate;

86
adpdate = new
System.Data.OleDb.OleDbDataAdapter("select Flight_Date
from ScheduledFlight where Flight_Number=?", con);
System.Data.OleDb.OleDbParameter pdate;
pdate = new
System.Data.OleDb.OleDbParameter("Flight_Number",
System.Data.OleDb.OleDbType.VarChar);
adpdate.SelectCommand.Parameters.Add(pdate);
adpdate.SelectCommand.Parameters[0].Value =
lstFlightNo.Text;
DataSet dsDate = new DataSet();
adpdate.Fill(dsDate);
dtpTravelDate.Text = dsDate.Tables[0].Rows[0]
[0].ToString();
txtFareAmount.Text = "";
}
}
}

Coding for Print Ticket Form

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Drawing.Printing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;
namespace AIRLINE_RESERVATION
{
public partial class PrintTicket : Form
{
public PrintTicket()
{

87
InitializeComponent();
}
StringReader myReader;
private void PrintTicket_Load(object sender, EventArgs e)
{
rbtTicket.BackColor = Color.White;
rbtTicket.Text = " HORIZON AIRWAYS
";
rbtTicket.Text += '\r' + " Passenger Ticket
";
rbtTicket.Text += '\r' +
"__________________________________________________
___";
rbtTicket.Text += '\r' +"
"+"Date of Issue:" +
System.DateTime.Today.ToShortDateString();
rbtTicket.Text += '\r' + "NOT TRANSFERABLE" + '\r' ;
rbtTicket.Text += '\r' + "PNR No. : "
+ lblPnr.Text + " Passenger Name:" + lblName.Text + " "
+ lblLName.Text + '\r' ;
rbtTicket.Text += '\r' + "Flight No. :" + lblFlightno.Text + '\r' ;
rbtTicket.Text += '\r' + "Class Travel
Date Fare";
rbtTicket.Text +='\r' +
"__________________________________________________
_____";
rbtTicket.Text += '\r' + lblclass.Text + " "
+ lblDate.Text+" " + lblfare.Text;
}

private void btnClose_Click(object sender, EventArgs e)


{
Close();
}
private void printDocument1_PrintPage(object sender,
PrintPageEventArgs e)
{
if (rbtTicket.Text != null)
{

88
float lineperpage = 0;
float yPosition = 0;
int count = 0;
float leftMargin = e.MarginBounds.Left;
float topMargin = e.MarginBounds.Top;
string line = null;
Font PrintFont = rbtTicket.Font;
SolidBrush myBrush = new SolidBrush(Color.Black);
lineperpage = e.MarginBounds.Height /
PrintFont.GetHeight(e.Graphics);
while (count < lineperpage && ((line =
myReader.ReadLine()) != null))
{
yPosition = topMargin + (count *
PrintFont.GetHeight(e.Graphics));
e.Graphics.DrawString(line, PrintFont, myBrush,
leftMargin, yPosition, new StringFormat());
count++;
}
if (line != null)
e.HasMorePages = true;
else
e.HasMorePages = false;
myBrush.Dispose();
}
}
private void btnPrint_Click(object sender, EventArgs e)
{
try
{
PrintDialog pntDialog = new PrintDialog();
PrintDocument pDocument = new PrintDocument();
pntDialog.Document = pDocument;
string strText = rbtTicket.Text;
myReader = new StringReader(strText);
DialogResult result = pntDialog.ShowDialog();
if (result == System.Windows.Forms.DialogResult.OK)
pDocument.Print();
}

89
catch
{
}
}

private void rbtTicket_TextChanged(object sender, EventArgs


e)
{
}
}
}

Coding for Cancel Reservation Form

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace AIRLINE_RESERVATION
{
public partial class CancelReservation : Form
{
System.Data.OleDb.OleDbConnection con;

public CancelReservation()
{
InitializeComponent();
}

private void initializeecontrols()


{
txtPnrNo.Text = "";
txtFlightNo.Text = "";

90
txtFName.Text = "";
txtLName.Text = "";
txtAge.Text = "";
txtGender.Text = "";
txtTravelDate.Text = "";
txtClass.Text = "";
txtStatus.Text = "";
txtAmountPaid.Text = "";
txtRefundAmt.Text = "";
btnGetDetails.Enabled = true;
btnCancel.Enabled = false;
}
private void CalculateRefundAmt()
{
if (txtStatus.Text.Trim(' ') == "Booked")
{
txtRefundAmt.Text = txtAmountPaid.Text;
}
else
{
System.DateTime dtDate = DateTime.MinValue;
dtDate = System.Convert.ToDateTime(txtTravelDate.Text);
System.DateTime dtTravelDate = new
DateTime(dtDate.Year,dtDate.Month,dtDate.Day);
int intNumDays = 0;
intNumDays =
dtTravelDate.Subtract(System.DateTime.Today.Date).Days;
if (intNumDays <= 1)
{
txtRefundAmt.Text =
System.Convert.ToString(System.Convert.ToDecimal(txtAmou
ntPaid.Text) * Convert.ToDecimal(0.9));
}
else
{
txtRefundAmt.Text = txtAmountPaid.Text;
}
}
}

91
private void btnBack_Click(object sender, EventArgs e)
{
MainForm mfrm = new MainForm();
mfrm.textBox1.Text = textBox1.Text;
mfrm.Show();
this.Hide();
}

private void btnCancel_Click(object sender, EventArgs e)


{
System.Data.OleDb.OleDbCommand cmdupdate;
cmdupdate = new
System.Data.OleDb.OleDbCommand("update Passenger set
Status='Cancelled' where PnrNo=?", con);
System.Data.OleDb.OleDbParameter pu;
pu = new System.Data.OleDb.OleDbParameter("PnrNo",
System.Data.OleDb.OleDbType.VarChar);
cmdupdate.Parameters.Add(pu);
cmdupdate.Parameters[0].Value = txtPnrNo.Text;
System.Data.OleDb.OleDbCommand cmdDC;
cmdDC = new System.Data.OleDb.OleDbCommand("update
DailyCollection set TranType='Refund' where PnrNo=?", con);
System.Data.OleDb.OleDbParameter pd;
pd = new System.Data.OleDb.OleDbParameter("PnrNo",
System.Data.OleDb.OleDbType.VarChar);
cmdDC.Parameters.Add(pd);
cmdDC.Parameters[0].Value = txtPnrNo.Text;
string strseat;
int seat,res;
res = cmdupdate.ExecuteNonQuery();
if (res > 0)
{
cmdDC.ExecuteNonQuery();
if (txtClass.Text == "First")
{
MessageBox.Show("Reservation has been cancelled",
"Application Message", MessageBoxButtons.OK);
System.Data.OleDb.OleDbDataAdapter adpfirst;

92
adpfirst = new
System.Data.OleDb.OleDbDataAdapter("select
FirstClassSeatAvailable from scheduledFlight where
Flight_Number=?", con);
System.Data.OleDb.OleDbParameter pf;
pf = new
System.Data.OleDb.OleDbParameter("Flight_Nmuber",
System.Data.OleDb.OleDbType.VarChar);
adpfirst.SelectCommand.Parameters.Add(pf);
adpfirst.SelectCommand.Parameters[0].Value =
txtFlightNo.Text;
DataSet dsfirst = new DataSet();
adpfirst.Fill(dsfirst);
strseat = dsfirst.Tables[0].Rows[0][0].ToString();
seat = System.Convert.ToInt32(strseat);
seat = seat + 1;
strseat = System.Convert.ToString(seat);
System.Data.OleDb.OleDbCommand cmdfseat;
cmdfseat = new
System.Data.OleDb.OleDbCommand("update ScheduledFlight
set FirstClassSeatAvailable=? where Flight_Number=?", con);
System.Data.OleDb.OleDbParameter fseat, fnum;
fseat = new
System.Data.OleDb.OleDbParameter("FirstClassSeatAvailabl
e", System.Data.OleDb.OleDbType.VarChar);
fnum = new
System.Data.OleDb.OleDbParameter("Flight_Number",
System.Data.OleDb.OleDbType.VarChar);
cmdfseat.Parameters.Add(fseat);
cmdfseat.Parameters.Add(fnum);
cmdfseat.Parameters[0].Value = strseat;
cmdfseat.Parameters[1].Value = txtFlightNo.Text;
cmdfseat.ExecuteNonQuery();
}
if (txtClass.Text == "Bussiness")
{
MessageBox.Show("Reservation has been cancelled",
"Application Message", MessageBoxButtons.OK);
System.Data.OleDb.OleDbDataAdapter adpfirst;

93
adpfirst = new
System.Data.OleDb.OleDbDataAdapter("select
BussinessClassSeatAvailable from scheduledFlight where
Flight_Number=?", con);
System.Data.OleDb.OleDbParameter pf;
pf = new
System.Data.OleDb.OleDbParameter("Flight_Nmuber",
System.Data.OleDb.OleDbType.VarChar);
adpfirst.SelectCommand.Parameters.Add(pf);
adpfirst.SelectCommand.Parameters[0].Value =
txtFlightNo.Text;
DataSet dsfirst = new DataSet();
adpfirst.Fill(dsfirst);
strseat = dsfirst.Tables[0].Rows[0][0].ToString();
seat = System.Convert.ToInt32(strseat);
seat = seat + 1;
strseat = System.Convert.ToString(seat);
System.Data.OleDb.OleDbCommand cmdfseat;
cmdfseat = new
System.Data.OleDb.OleDbCommand("update ScheduledFlight
set BussinessClassSeatAvailable=? where Flight_Number=?",
con);
System.Data.OleDb.OleDbParameter fseat, fnum;
fseat = new
System.Data.OleDb.OleDbParameter("BussinessClassSeatAv
ailable", System.Data.OleDb.OleDbType.VarChar);
fnum = new
System.Data.OleDb.OleDbParameter("Flight_Number",
System.Data.OleDb.OleDbType.VarChar);
cmdfseat.Parameters.Add(fseat);
cmdfseat.Parameters.Add(fnum);
cmdfseat.Parameters[0].Value = strseat;
cmdfseat.Parameters[1].Value = txtFlightNo.Text;
cmdfseat.ExecuteNonQuery();
}

if (txtClass.Text == "Economy")
{

94
MessageBox.Show("Reservation has been cancelled",
"Application Message", MessageBoxButtons.OK);
System.Data.OleDb.OleDbDataAdapter adpfirst;
adpfirst = new
System.Data.OleDb.OleDbDataAdapter("select
EconomyClassSeatAvailable from scheduledFlight where
Flight_Number=?", con);
System.Data.OleDb.OleDbParameter pf;
pf = new
System.Data.OleDb.OleDbParameter("Flight_Nmuber",
System.Data.OleDb.OleDbType.VarChar);
adpfirst.SelectCommand.Parameters.Add(pf);
adpfirst.SelectCommand.Parameters[0].Value =
txtFlightNo.Text;
DataSet dsfirst = new DataSet();
adpfirst.Fill(dsfirst);
strseat = dsfirst.Tables[0].Rows[0][0].ToString();
seat = System.Convert.ToInt32(strseat);
seat = seat + 1;
strseat = System.Convert.ToString(seat);
System.Data.OleDb.OleDbCommand cmdfseat;
cmdfseat = new
System.Data.OleDb.OleDbCommand("update ScheduledFlight
set EconomyClassSeatAvailable=? where Flight_Number=?",
con);
System.Data.OleDb.OleDbParameter fseat, fnum;
fseat = new
System.Data.OleDb.OleDbParameter("EconomyClassSeatAva
ilable", System.Data.OleDb.OleDbType.VarChar);
fnum = new
System.Data.OleDb.OleDbParameter("Flight_Number",
System.Data.OleDb.OleDbType.VarChar);
cmdfseat.Parameters.Add(fseat);
cmdfseat.Parameters.Add(fnum);
cmdfseat.Parameters[0].Value = strseat;
cmdfseat.Parameters[1].Value = txtFlightNo.Text;
cmdfseat.ExecuteNonQuery();
}
}

95
PrintRefundRefundReceipt frmPrint = new
PrintRefundRefundReceipt();
frmPrint.label1.Text = txtFName.Text.Trim(' ') + " " +
txtLName.Text.Trim(' ');
frmPrint.label2.Text = txtPnrNo.Text.Trim(' ');
frmPrint.label3.Text = txtRefundAmt.Text;
frmPrint.ShowDialog();
}

private void txtPnrNo_TextChanged(object sender, EventArgs


e)
{
string str = txtPnrNo.Text.ToString();
foreach (char c in str)
{
if (char.IsLetter(c))
{
MessageBox.Show("Please Enter valid PNR Number");
txtPnrNo.Text = "";
}
else
{
btnGetDetails.Enabled = true;
btnCancel.Enabled = false;
}
}
}

private void CancelReservation_Load(object sender,


EventArgs e)
{
con = new System.Data.OleDb.OleDbConnection();
con.ConnectionString = "provider=Microsoft.jet.oledb.4.0;data
source= Ticket_Reservation.mdb";
con.Open();
}

private void btnGetDetails_Click(object sender, EventArgs e)


{

96
if (txtPnrNo.Text.Trim(' ').Length == 0)
{
MessageBox.Show("Please enter PNR number","Input
Error",MessageBoxButtons.OK,MessageBoxIcon.Error);
return;
}
System.Data.OleDb.OleDbDataAdapter adp;
adp = new System.Data.OleDb.OleDbDataAdapter("select
Flight_Number,travelDate,FName,Lname,Age,Gender,Class,St
atus,Amount from Passenger,DailyCollection where
Passenger.PnrNo=?",con);
System.Data.OleDb.OleDbParameter p;
p = new
System.Data.OleDb.OleDbParameter("PnrNo",System.Data.
OleDb.OleDbType.VarChar);
adp.SelectCommand.Parameters.Add(p);
adp.SelectCommand.Parameters[0].Value = txtPnrNo.Text;
DataSet ds = new DataSet();
ds.Clear();
adp.Fill(ds);
if (ds.Tables[0].Rows.Count == 0)
{
MessageBox.Show("PNR number not found. Please re-
enter","Input
Error",MessageBoxButtons.OK,MessageBoxIcon.Error);
return;
}
string a = ds.Tables[0].Rows[0]["Status"].ToString();
if (a.Trim() == "Cancelled")
{
MessageBox.Show("The ticket is already cancelled","Input
Error",MessageBoxButtons.OK,MessageBoxIcon.Error);
return;
}

if(Convert.ToDateTime(ds.Tables[0].Rows[0]
["TravelDate"].ToString()) < System.DateTime.Today)
{

97
MessageBox.Show("Cannot cancel the ticket since the travel
date is less than the current date.","Input
Error",MessageBoxButtons.OK,MessageBoxIcon.Error);
return;
}
DataRow objDR = null;
objDR = ds.Tables[0].Rows[0];
txtFlightNo.Text= objDR["Flight_Number"].ToString();
txtFName.Text = objDR["FName"].ToString();
txtLName.Text = objDR["LName"].ToString();
txtTravelDate.Text = objDR["TravelDate"].ToString();
txtAge.Text = objDR["Age"].ToString();
txtGender.Text = objDR["Gender"].ToString();
txtClass.Text = objDR["Class"].ToString();
txtStatus.Text = objDR["Status"].ToString();
txtAmountPaid.Text = objDR["Amount"].ToString();
CalculateRefundAmt();
btnGetDetails.Enabled = false;
btnCancel.Enabled = true;
}
}
}

Coding for Print Refund Receipt Form

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Drawing.Printing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;

namespace AIRLINE_RESERVATION
{

98
public partial class PrintRefundRefundReceipt : Form
{
public PrintRefundRefundReceipt()
{
InitializeComponent();
}
StringReader myReader;

private void PrintRefundRefundReceipt_Load(object sender,


EventArgs e)
{
rtbRefundReciept.BackColor = Color.White;
rtbRefundReciept.Text = " HORIZON
AIRWAYS ";
rtbRefundReciept.Text += '\r' + " Refund
Receiept ";
rtbRefundReciept.Text += '\r' +
"_________________________________________________"
;
rtbRefundReciept.Text += '\r' + "
Date:" + System.DateTime.Today + '\r';
rtbRefundReciept.Text += '\r' + "PNR No. :" + label2.Text + '\r'
+ '\r' + "Passenger Name: " + label1.Text + '\r';
rtbRefundReciept.Text += '\r' + "Refund Amount : " +
label3.Text + '\r';
rtbRefundReciept.Text += '\r' + "
______________";
rtbRefundReciept.Text += '\r' + "
Signature";
}

private void btnClose_Click(object sender, EventArgs e)


{
Close();
}

private void printDocument1_PrintPage(object sender,


PrintPageEventArgs e)
{

99
if (rtbRefundReciept.Text != null)
{
float lineperpage = 0;
float yPosition = 0;
int count = 0;
float leftMargin = e.MarginBounds.Left;
float topMargin = e.MarginBounds.Top;
string line = null;
Font PrintFont = rtbRefundReciept.Font;
SolidBrush myBrush = new SolidBrush(Color.Black);
lineperpage = e.MarginBounds.Height /
PrintFont.GetHeight(e.Graphics);
while (count < lineperpage && ((line=myReader.ReadLine())
!= null))
{
yPosition = topMargin + (count *
PrintFont.GetHeight(e.Graphics));
e.Graphics.DrawString(line, PrintFont, myBrush,
leftMargin, yPosition, new StringFormat());
count++;
}
if (line != null)
e.HasMorePages = true;
else
e.HasMorePages = false;
myBrush.Dispose();
}
}

private void btnPrint_Click(object sender, EventArgs e)


{
try
{
PrintDialog pntDialog = new PrintDialog();
PrintDocument pDocument = new PrintDocument();
pntDialog.Document = pDocument;
string strText = rtbRefundReciept.Text;
myReader = new StringReader(strText);
DialogResult result = pntDialog.ShowDialog();

100
if (result == System.Windows.Forms.DialogResult.OK)
pDocument.Print();
}
catch
{

}
}

}
}
}
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace AIRLINE_RESERVATION
{
public partial class Flash : Form
{
public Flash()
{
InitializeComponent();
}

private void timer1_Tick(object sender, EventArgs e)


{
progressBar1.Value = progressBar1.Value + 1;
if (progressBar1.Value > 999)
{
timer1.Enabled = false;
this.Hide();
Login frmlogin = new Login();
frmlogin.Show();

101
}
}
}
}

***

102

Das könnte Ihnen auch gefallen