railway ticket systemby nakul verma

114
Railway Ticket System 1 ACKNOWLEDGEMENT We express our sincere gratitude to Prof. , (HOD) who granted the permission to do this project. We are also thankful to Ms. Sreelekshmi S. (our project guide) for her constant support in the Design, Implementation and Evaluation of this project. She helped a lot with her constructive criticism and invaluable suggestions, which benefited us a lot. We are also thankful to Prof. M R Sarathchandradas, the Principal, who provided us the infrastructure to carry out the project including the lab facilities, and to all the staff members who were directly and indirectly instrumental in enabling us to stay committed for the project.

Upload: nakul-verma

Post on 26-Mar-2015

273 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: Railway Ticket SystemBY NAKUL VERMA

Railway Ticket System 1

ACKNOWLEDGEMENT

We express our sincere gratitude to Prof. , (HOD) who granted the permission to

do this project.

We are also thankful to Ms. Sreelekshmi S. (our project guide) for her constant

support in the Design, Implementation and Evaluation of this project. She helped a lot

with her constructive criticism and invaluable suggestions, which benefited us a lot.

We are also thankful to Prof. M R Sarathchandradas, the Principal, who provided

us the infrastructure to carry out the project including the lab facilities, and to all the staff

members who were directly and indirectly instrumental in enabling us to stay committed

for the project.

Page 2: Railway Ticket SystemBY NAKUL VERMA

Railway Ticket System 2

ABSTRACT

INTRODUCTION

Railway Ticket System (RTS) is interactive software, which is developed for the

issuing of a railway ticket. It is developed while keeping in mind the need of an updated

ticket issuing software for the Southern Railways (Southern Zone of Indian Railways).

The project is designed for the Windows-based platform.

Microsoft Visual Basic 6.0 Enterprise Edition is used as the front-end software

and Microsoft Access 2003 as back-end for the development of the software.

The software includes options for checking the status of a railway ticket and

retrieves the information required, especially when the ticket is a RAC or in waiting list,

so that the passenger can know his ticket priority in the lists. The software provides easy

and faster searching options and generation of the ticket that increases the efficiency of

the Southern Wing of Indian Railways, if this software is implemented.

Page 3: Railway Ticket SystemBY NAKUL VERMA

Railway Ticket System 3

OBJECTIVES

The main objective of this project is to study the manual procedure carried out for

the issuing of a railway ticket to senior citizens and non-senior citizens by the Indian

Railways and to develop management software that would simplify the existing process.

Designing user-friendly GUI screens, being specific in generating the output to the user

of the system (operator), generating reports related to the specification of the user and

that would simplify the manual task, creation of new train routes, eventually creating

databases of new trains and so on, add to the list of objectives.

To achieve all these objectives effectively and efficiently, more care has been

given to the data collected, stored, retrieved, displayed, updated and manipulated within a

short time and a little effort. The proposed system is found to be efficient and accurate

and also it checks the reliability of data entered.

Page 4: Railway Ticket SystemBY NAKUL VERMA

Railway Ticket System 4

DESCRIPTION

RTS is fully customizable with a number of options. The software is capable of

searching the database for available seats, and then accordingly reserves the seat for the

passenger. The operator can then check for the status of the passenger seat, whether it is

reserved, in waiting list or in RAC (Reservation Against Cancellation). Also, if the

passenger wishes to cancel the ticket, he can do so. Using RTS, the operator can easily

cancel a ticket. According the date reserved and the date, on which the ticket is cancelled,

certain percentage of the ticket fare is refunded.

The railway ticket is issued with a unique number which is only valid for the

particular ticket. Its’ called PNR (Passenger Name Record). This code is used to track the

record of the passenger in the database.

The RTS also allow the passenger to use the Journey Planner. This is one of the

innovative ideas that are introduced in this project. It enables the easy selection of direct

and connection trains easily. This feature is big relief to the existing system as the

passenger can plan his journey according to his needs very easily.

Tool Used

Adobe PhotoShop Creative Suite 2

Macromedia Flash v8.0

GIMP v2.0

GIF 89a

http://www.myspacegens.com/handler.php?gen=animatedimage – Free animated GIF creator

Page 5: Railway Ticket SystemBY NAKUL VERMA

Railway Ticket System 5

SYSTEM SPECIFICATION

HARDWARE SPECIFICATION

The software requires IBM compatible machines with the following

recommended specification.

Processor : Pentium III / AMD Atlon or higher

RAM : 128 MB or higher

Hard Disk Drive : 20 GB or higher

Monitor : 15” SVGA Colour

Mouse : Standard 3 button scroll mouse

Keyboard : Standard 101/102-Key keyboard

Optical Drive : 52X CD-ROM Drive

Removable Device (Optional) : 512 MB USB 2.0 Pen Drive

SOFTWARE REQUIREMENT

Operating System : Microsoft Windows XP SP2

Page 6: Railway Ticket SystemBY NAKUL VERMA

Railway Ticket System 6

SOFTWARE DESCRIPTION

Microsoft Windows: -

Microsoft Windows is a graphical user interface. It uses graphics to organize the

user’s workplace. Users can select and execute programs with the help of a mouse. The

program that runs from within Windows also has a graphical user interface; for example,

MS Excel, MS Word etc.

Windows provides a broad range of graphical functions for drawing lines and

geometric shapes and changing colour. It also provides library functions for accessing

screen, printers, keyboard, mouse and functions for working with various other types of

objects like menus, bitmaps, icons etc. These libraries are a part of operating system.

The system-defined functions that an application can call are provided by an

interface known as the Application Programming Interface, or API. It is the interface

between an application and Windows environment.

Every Windows environment has its unique API. The API that supports Windows

95, 98, 2000, XP are 32 bits API that is, all the functions supported by the API can work

with 32 bits of information. The API of Windows 2000, XP has some special features for

file security and support for multiple processors. This collection of working functions is

maintained in files stored in the SYSTEM32 directory in the hard disk drive. This is

created when the Windows is installed.

Page 7: Railway Ticket SystemBY NAKUL VERMA

Railway Ticket System 7

The three primary files are:

GDI.DLL – It is a Windows 32-bit graphics driver interface API library and is a core

Windows component. It contains functions for drawing graphics, accessing hardware,

displaying output etc.

USER32.DLL – It is a Windows user library used to provide support for user interface

routines. It contains functions that deal with the user interface, like creating and

managing Windows.

KERNEL32.DLL – It provides Windows 32-bit API support and is the core Windows

component. It contains functions, which deal with critical system resources, like

functions for allocating memory, accessing files etc.

Windows applications are, very often large in size, larger than the amount of

physical memory installed in the system. To get around this problem, Windows only

loads those modules of an application, which are needed. Using this technique, Windows

also greatly reduces memory consumption.

Page 8: Railway Ticket SystemBY NAKUL VERMA

Railway Ticket System 8

Microsoft Visual Basic: -

The newer programming languages like C++ and Visual Basic follow a different

programming approach: Object-Oriented Programming (OOPs) and Event driven

programming. Microsoft refers Visual Basic as an event-driven programming language.

Visual Basic has many elements of an object-oriented language such as Java. Each

release of Visual Basic moves it a little closer to a true object-oriented language.

In event driven model each user action can cause an event to occur, which triggers a basic

procedure.

The Object Model

Programming in Visual Basic deals working with objects, which have properties

and methods. Object is a thing or noun while properties represents data about an object

and method represents actions an object can take.

Editions of Visual Basic

Microsoft Visual Basic for Windows is marketed as a Working Model, Learning

edition, Professional edition and an Enterprise edition. To develop professional

applications that include the advanced features of database management, the Professional

or Enterprise edition should be used.

The Visual Basic Environment

The Visual Basic Environment, generally known as Integrated Development

Environment (IDE), consists of various customizable Windows like:

Form Window

Project Explorer Window

Properties Window

Form Layout Windows

Toolbox

A standard application in Visual Basic consists of the following objects:

Page 9: Railway Ticket SystemBY NAKUL VERMA

Railway Ticket System 9

Forms

Forms are individual Windows used in the application. Normally forms are the

interface of the application. In forms we can place data, graphics and controls. Visual

Basic supports to create two types of interfaces – Single Document Interface (SDI) and

Multiple Document Interface (MDI).

Controls

Controls are objects that are put into the form, to display information or get a

response from the user. All of the usual Windows features are classes as controls. There

are three broad categories of controls in Visual Basic:

Intrinsic Control

These are the controls that are included in the Toolbox of Visual Basic.

Examples: Textbox, Command button, Label box.

Objects that can be added to the Toolbox

The Microsoft Excel worksheet object, Microsoft Project calendar object, etc can

be added to the Toolbox. So they also can be considered as controls. Some of these

controls allow automation, which allows programming another application objects from

within a Visual Basic Application.

Modules

A module is like a normal basic program but it does not have the power to create

display or get input from the user; the forms control all this. Modules are stored in files

with .BAS extensions.

Microsoft Access: -

Microsoft Access is a relational database management system from Microsoft that

combines the relational Microsoft Jet Database Engine with a graphical user interface and

software development tools. It is a member of the 2007 Microsoft Office system.

Access can use data stored in Access/Jet, Microsoft SQL Server, Oracle, or any ODBC-

compliant data container (including MySQL and PostgreSQL).

Page 10: Railway Ticket SystemBY NAKUL VERMA

Railway Ticket System 10

Uses

Some professional application developers use Access for rapid application development,

especially for the creation of prototypes and standalone applications that serve as tools

for on-the-road salespeople. Access does not scale well if data access is via a network, so

applications that are used by more than a handful of people tend to rely on Client-Server

based solutions. However, an Access “front end” (the forms, reports, queries and VB

code) can be used against a host of database back-ends, including JET (file-based

database engine, used in Access by default), Microsoft SQL Server, Oracle, and all other

ODBC-compliant product.

In addition to traditional ODBC methods, Access also offers “Access Data Projects” for

accessing SQL Server data, which provides a number of advantages over linked tables.

Features

One of the benefits of Access from a programmer’s perspective is its relative

compatibility with SQL (structured query language) – queries may be viewed graphically

or edited as SQL statements, and SQL statements can be used directly in Macros and

VBA Modules to manipulate Access tables. Users may mix and use both VBA and

“Macros” for programming forms and logic and offers object-oriented possibilities.

MSDE 2000 (Microsoft SQL Server Desktop Engine), a scaled down version of

Microsoft SQL Server 2000, has been a free download for a decade and may be used with

Access as an alternative to the Jet Database Engine.

Unlike other RDBMS, Microsoft Access does not implement database triggers or stored

procedures.

Starting in Access 2000 (Jet 2.0), there is a new syntax for creating queries with

parameters, in a way that looks like creating stored procedures, but these procedures are

still limited to one statement per procedure.

Page 11: Railway Ticket SystemBY NAKUL VERMA

Railway Ticket System 11

In ADP files (supported in Access 2000 and later), the database-related features are

geared more towards a client-server architectures with MSDE or Microsoft SQL Server

serving as the Back-end instead of using the Jet Engine. Thus, it supports the creation of

nearly all objects in the underlying server (tables with constraints and triggers, views,

stored procedures and UDF-s). However, only forms, reports, macros and modules are

stored in the ADP file (the other objects are stored in the back-end database). This

centralization of queries and tables in the database server provide a more reliable

development environment for most businesses.

Microsoft Access can be applied to small projects (the Access 97 speed

characterization was done for 32-bit users) but scales poorly to larger projects with more

than several 10MB of data of many users because of the way indexing and locking are

handled. As a Microsoft Access database can be cached locally when used on network,

processing speed may be substantially better when there is only a single use. Because of

the effect of packet latency on the record locking system, Access databases are

effectively too slow to be used on a Virtual Private Network or a Wide Area Network.

Access Data Projects work great over VPN and WAN.

Access includes an Upsizing Wizard that allows users to upsize their database to

Microsoft SQL Server if they want to move to an ODBC client-server database.

One recommended technique is to migrate from SQL Server and utilize Access Data

Projects. This allows stored procedures, views, and constraints using standard SQL.

Additionally this full client-server significantly reduces maintenance and availability

problems.

Access allows no relative paths when linking, so the development environment

should have the same path as the production environment (though it is possible to write a

“dynamic-linker” routine in VBA). This technique also allows the developer to divide the

application among different files.

Page 12: Railway Ticket SystemBY NAKUL VERMA

Railway Ticket System 12

PROJECT DESCRIPTION

Rail transport is a commonly used mode of long-distance transportation in India. Almost

all rail operations in India are handled by a state-owned company, Indian Railways, under

the federal Ministry of Railways.

The Indian Railways issues railway tickets for the citizens, so that they can use the rail

transport facility. There are many categories of classes, for example, air-conditioned

class, first class, sleeper class and general class. Each has its own features. Sleeper class

is used for traveling more than a day.

Reservation

For long-distance travel, reservation of a berth can be done for comfortable travel up to

two months prior to the date of intended travel. Details such as the name, age and

concession (if eligible) are required and are recorded on the ticket. The ticket price

usually includes the base fare which depends on the classification of the train (example:

super-fast surcharge if the train is classified as a super-fast), the class in which one

wishes to travel and the reservation charge for overnight journeys.

Fare Calculation:-

The fare is calculated on the basis of the distance (in km) and the class

Fare in A.C. Class - Rs. (70% of the distance)

Fare in First Class - Rs. (60% of the distance)

Fare in Sleeper Class - Rs. (50% of the distance)

Fare in General Class - Rs. (40% of the distance)

The above is for persons less than 60 years of age. The senior citizens (persons of 60

years and above) can avail of a reduction of 15% in all the above classes.

Page 13: Railway Ticket SystemBY NAKUL VERMA

Railway Ticket System 13

Confirmed List

If a seat is not available, then the ticket is given a wait listed number; else the ticket is

confirmed, and a berth number is printed on the ticket.

RAC

Some of the tickets are assigned to the RAC or Reservation against Cancellation which is

between the waiting list and the confirmed list. These allow the ticket holder to board the

train and obtain an allotted seat decided by a ticket collector, after the ticket collector has

ascertained that there is a vacant (absentee) seat. It is a way of maximizing the number of

wait-listed passengers to be accommodated in case of a cancellation.

Wait-Listed Ticket

A person receiving a wait listed ticket will have to wait until there are enough

cancellations to enable him to move up the list and obtain a confirmed ticket. If his ticket

is not confirmed on the day of departure, he may not board the train.

Our project deals with the automation of the most of the processes involved in the issue

of a railway ticket. These procedures are done by a ticket issuing operator.

The main steps of reservation of a ticket are as follows: -

Checking for availability.

Inputting details.

Processing the data.

Allotting a seat along with a class.

A PNR is formulated.

Calculation of ticket fare and printing of the ticket.

Page 14: Railway Ticket SystemBY NAKUL VERMA

Railway Ticket System 14

Status

In this phase, a passenger can get to know his ticket details. Most of the time, the

passengers in the RAC list and the waiting list avail of this facility often, so that they can

understand their priority in these lists.

An additional feature is the “emergency tab” in the status page. Here any person can

request the operator to type in the PNR code of any passenger, who is under serious

medical condition. The emergency tab gives the contact number of this person (this is

input in the reservation phase) using which the relatives or other concerned persons can

be informed about the current condition of the passenger.

Cancellation

In this phase, a passenger can cancel his/her ticket before 24 hours of the travel time, so

as to get 85% refund. Thus, this available seat is now allotted to the passenger with the

priority number 1 on the RAC list. All other priority numbers are decremented by one.

Page 15: Railway Ticket SystemBY NAKUL VERMA

Railway Ticket System 15

Journey Planner

It is one of the innovative ideas in this project. The journey planner usually means

planning the journey. In Indian Railways, there is a journey planner entitled “Trains

between stations”. But our project is aimed for a better journey planner. The connection

trains provides an alternative solution, especially in the cases of festival seasons

Consider an example. A person wants to go from Thiruvananthapuram to New Delhi. He

can either travel in a direct train. But if there are no available seats, then he/she can opt

for connection trains.

That is, trains from Thiruvananthapuram to Mumbai, and then another train from

Mumbai to New Delhi.

Another possibility is to travel from Thiruvananthapuram to Kolkata and then Kolkata to

New Delhi.

Even though he/she might arrive at his/her destination some hours later, he/she will be

able to travel comfortably.

The passenger is asked for the starting and destination stations and the operator then

display the currently available routes and trains. The passenger can choose the routes and

the available trains accordingly.

In the intermediate station(s), the passenger will only have to wait for 30mins-60mins in

between from getting down from one train and boarding the next train. This feature can

be best utilized by the government diplomats, who have to use the rail transport to attend

the meetings and conferences where they have to meet on that day itself, with the

tolerance of some hours.

Thus, the Journey Planner is found to be very efficient.

Page 16: Railway Ticket SystemBY NAKUL VERMA

Railway Ticket System 16

SYSTEM DESIGN

Data Flow Diagram

ER diagram

Database Design

Input Design

Output Design

Data Flow Design (DFD): -

As information move through software it is modifies by a series of transformations. A

data flow diagram (DFD) is a graphical technique that depicts information flow and

transformations that applied as data moves from input to output. The DFD is also called

Dataflow Graph or Bubble Chart.

The DFD may be used to represent a system or software at any level of abstraction. DFDs

may be portioned into levels that represent increasing information flow and functional

details. Therefore DFD provides a mechanism for functional modeling as well as

information flow modeling.

A Level 0 data flow diagram, also called a fundamental system model or a context model

represents the entire software as a single bubble with input and output data indicated by

incoming and outgoing arrows respectively. Additional process and information flow

path are represented on the level 0 data flow diagram is portioned to reveal more details.

Page 17: Railway Ticket SystemBY NAKUL VERMA

Railway Ticket System 17

Context Level DFD

Reservation

Option SelectEnter

internal forms

Choice entered by

user to login as an Operator / Admin

Logged in as

Admin

Edit structure of database

Reservation /Cancellation /

Status

Logged in as Operator

User Input Process Request

Check

Data Store

Add to data store

Reservation Done

If appropriate

Issu

e PN

R

Page 18: Railway Ticket SystemBY NAKUL VERMA

Railway Ticket System 18

Cancellation

Status

User Input Process Request

Check

Cancellation Done

Delete if appropriate, else

send ERROR message

User InputCheck

Display Status

Data StoreData Store

Page 19: Railway Ticket SystemBY NAKUL VERMA

Railway Ticket System 19

ENTITY RELATIONSHIP DIAGRAM (ERD)

Administrator Operator

train data

station data

new trains

new routes

Controlsadded to

status cancellation

i/p to

PNR

PNR

reservationjourney planner

data fed ticket + editing in database

stationsTrain no & routes

Page 20: Railway Ticket SystemBY NAKUL VERMA

Railway Ticket System 20

Database Design:-

A database is an integrated collection of data files/tables related to one another in support

of a common purpose. Each file in a database is made up of records, which in turn made

of data elements. A database provides a working environment where we store tables/files;

establish relationship between tables, set properties and data validation rules that control

how the related tables work together. The database files in this program provide effective

storage capacities and contribute to the overall efficiency of the program.

1. Database Name: - RTS-RESERVATION.mdb

Field Name Data Type

PNR Text

User_Name Text

Age Number

Sex Text

Starting_Station Text

Destination_Station Text

Fare Number

Phone_Number Text

Status AutoNumber

Page 21: Railway Ticket SystemBY NAKUL VERMA

Railway Ticket System 21

2. Database Name: - RTS-Station Details.mdb

Field Name Data Type

Station_Name Text

Time Date/Time

Kilometers Number

3. Database Name : - Station Index.mdb

Field Name Data Type

Index AutoNumber

Station Name Text

Station Code Text

Page 22: Railway Ticket SystemBY NAKUL VERMA

Railway Ticket System 22

Input Design:-

Proposed software uses user-friendly graphical user interface for input purpose. Data can

be easily input by the user through this screen. Repetition is avoided in data entry screen.

Whenever data, which is already input, is entered again, the system alerts you with error

messages.

The operator can easily enter the data flexibly, thus is the striking feature of the proposed

system. The beaming features of VB forms are used in the design and hence the design

stands one step forward of others. The following are the various input forms.

Reservation

Page 23: Railway Ticket SystemBY NAKUL VERMA

Railway Ticket System 23

Cancellation

Page 24: Railway Ticket SystemBY NAKUL VERMA

Railway Ticket System 24

Status

Page 25: Railway Ticket SystemBY NAKUL VERMA

Railway Ticket System 25

Journey planner

Page 26: Railway Ticket SystemBY NAKUL VERMA

Railway Ticket System 26

Output Design:-

The Computer output is the most important of information to the user. Efficient

intelligence output design would improve the system relationship with the user and help

in decision making. In online applications the information is displayed on the screen. A

major form of output is hard copy from the printer. Printout should be designed around

the output requirement of user.

TICKET

Page 27: Railway Ticket SystemBY NAKUL VERMA

Railway Ticket System 27

Journey planner

Page 28: Railway Ticket SystemBY NAKUL VERMA

Railway Ticket System 28

SYSTEM IMPLEMENTATION

Implementation means converting a new system into operation. The source code

that is actual program is developed in this phase. In the proposed system, the source code

is written in Visual Basic 6.0. The installation of the software is also done in this phase.

Testing and Modification

System testing is the stages of implementation, which is aimed at ensuring that the

system works accurately and efficiently before line operation commences. The following

types of tests were performed after developing a test plan. The approach was to test each

entity with successively large ones, up to the system level.

Program Testing

A program represents the logical elements of the system. With program testing,

the actual output was compared with the expected output. This test checks for syntax

errors and logical errors. When there was an error, the sequence of instructions was

traced and the problem was determined.

String Testing

The individual program modules that work perfectly when tested alone were

integrated with the related program modules to test how they interact with the total

system.

Page 29: Railway Ticket SystemBY NAKUL VERMA

Railway Ticket System 29

System Testing

System testing was designed to uncover weakness that was not found in the

earlier tests. The total system was validated, as the users in the operational environment

would implement it.

User Acceptance Testing

This testing was performed with the objective of testing the users on the validity

and reliability of the system. It was verified that the procedure operate to the

specifications and also that vital data integrity was maintained.

Page 30: Railway Ticket SystemBY NAKUL VERMA

Railway Ticket System 30

Administrator screenshots

Login

Page 31: Railway Ticket SystemBY NAKUL VERMA

Railway Ticket System 31

Add new train 1

Page 32: Railway Ticket SystemBY NAKUL VERMA

Railway Ticket System 32

Add new train 2

Page 33: Railway Ticket SystemBY NAKUL VERMA

Railway Ticket System 33

Add new station

Page 34: Railway Ticket SystemBY NAKUL VERMA

Railway Ticket System 34

View train data

Page 35: Railway Ticket SystemBY NAKUL VERMA

Railway Ticket System 35

View train data 2

Page 36: Railway Ticket SystemBY NAKUL VERMA

Railway Ticket System 36

Delete Train 1

Page 37: Railway Ticket SystemBY NAKUL VERMA

Railway Ticket System 37

Delete Train 2

Page 38: Railway Ticket SystemBY NAKUL VERMA

Railway Ticket System 38

View Stations

Page 39: Railway Ticket SystemBY NAKUL VERMA

Railway Ticket System 39

Edit Stations

Page 40: Railway Ticket SystemBY NAKUL VERMA

Railway Ticket System 40

SAMPLE CODE

Reservation

Private Sub search3() ' Checks whether source & destn are same

If (txtSource = txtDestn) Then

err = 1

End If

End Sub

Private Sub search1() ' Checks whether source is valid

TrainNo = cmbTrainno

Set rs1 = db1.OpenRecordset(TrainNo)

rs1.MoveFirst

Do Until rs1.EOF

If rs1.fields(0) = txtSource.Text Then

a1 = rs1.fields(2)

Exit Sub

Else

rs1.MoveNext

End If

Loop

err = 1

Exit Sub

End Sub

Private Sub search2() ' Checks whether destination is valid

TrainNo = cmbTrainno

Set rs2 = db1.OpenRecordset(TrainNo)

rs2.MoveFirst

Do Until rs2.EOF

Page 41: Railway Ticket SystemBY NAKUL VERMA

Railway Ticket System 41

If rs2.fields(0) = txtDestn.Text Then

a2 = rs2.fields(2)

Exit Sub

Else

rs2.MoveNext

End If

Loop

'MsgBox "Invalid Entry", vbOKOnly + vbCritical, "ERROR"

err = 1

Exit Sub

End Sub

Private Sub cmdHelp_Click()

TrainNo = cmbTrainno

Set db2 = OpenDatabase(App.Path + "\Station Index.mdb")

Set rs4 = db2.OpenRecordset("Station Index")

If (cmbTrainno = "") Then

MsgBox "Please Check Train Number !!!", vbOKOnly + vbCritical, "RETRY"

Else

frmOprOptions.Hide

frmHelpReservation1.Show

End If

End Sub

Private Sub cmdSubmit_Click()

err = 0

On Error GoTo Errorhandler1

Set rs = db.OpenRecordset(cmbTrainno + cmbClass)

On Error GoTo Errorhandler1

Page 42: Railway Ticket SystemBY NAKUL VERMA

Railway Ticket System 42

Call search1

If (err = 1) Then

MsgBox "Invalid Source", vbOKOnly + vbCritical, "RETRY"

Exit Sub

End If

Call search2

If (err = 1) Then

MsgBox "Invalid Destination Entry", vbOKOnly + vbCritical, "RETRY"

Exit Sub

End If

Call search3

If (err = 1) Then

MsgBox "Source & Destination can't be same", vbOKOnly + vbCritical, "RETRY"

Exit Sub

End If

If ((txtAge < 0) Or (txtAge > 105)) Then

GoTo Errorhandler1

End If

If (rs.RecordCount > -1 And rs.RecordCount < 12) Then

On Error GoTo Errorhandler1

rs.AddNew

PNRReserve = cmbTrainno.Text + cmbClass.Text + Format(Now, "hhmmss") +

Format(Now, "ddmm")

rs.fields(0) = PNRReserve

rs.fields(1) = txtName.Text

rs.fields(2) = txtAge.Text

rs.fields(3) = sx

rs.fields(4) = txtSource.Text

rs.fields(5) = txtDestn.Text

Page 43: Railway Ticket SystemBY NAKUL VERMA

Railway Ticket System 43

If (txtPhoneNumber.Text = "") Then

rs.fields(7) = "0"

Else

rs.fields(7) = txtPhoneNumber.Text

End If

Call search1

Call search2

If (cmbClass.Text = "GN") Then

If (txtAge.Text < 60) Then

rate = (a2 - a1) * (40 / 100)

Else

rate = (a2 - a1) * (40 / 100) * (85 / 100)

End If

If (rate < 0) Then

rate = -(rate)

End If

rs.fields(6) = rate

End If

If (cmbClass.Text = "SC") Then

If (txtAge.Text < 60) Then

rate = (a2 - a1) * (50 / 100)

Else

rate = (a2 - a1) * (50 / 100) * (85 / 100)

End If

If (rate < 0) Then

rate = -(rate)

End If

rs.fields(6) = rate

End If

If (cmbClass.Text = "FC") Then

If (txtAge.Text < 60) Then

Page 44: Railway Ticket SystemBY NAKUL VERMA

Railway Ticket System 44

rate = (a2 - a1) * (60 / 100)

Else

rate = (a2 - a1) * (60 / 100) * (85 / 100)

End If

If (rate < 0) Then

rate = -(rate)

End If

rs.fields(6) = rate

End If

If (cmbClass.Text = "AC") Then

If (txtAge.Text < 60) Then

rate = (a2 - a1) * (70 / 100)

Else

rate = (a2 - a1) * (70 / 100) * (85 / 100)

End If

If (rate < 0) Then

rate = -(rate)

End If

rs.fields(6) = rate

End If

rs.Update

NameReserve = txtName.Text

AgeReserve = txtAge.Text

SexReserve = sx

StReserve = txtSource.Text

DestReserve = txtDestn.Text

classReserve = cmbClass.Text

StatusReserve = "Confirmed"

iResponse = MsgBox(StatusReserve, vbOKOnly + vbInformation, "SUCCESS")

If (iResponse = vbOK) Then

frmRESERVATION.Hide

Page 45: Railway Ticket SystemBY NAKUL VERMA

Railway Ticket System 45

frmTicket.Show

End If

Exit Sub

ElseIf (rs.RecordCount > 11 And rs.RecordCount < 17) Then

On Error GoTo Errorhandler1

rs.AddNew

PNRReserve = cmbTrainno.Text + cmbClass.Text + Format(Now, "hhmmss") +

Format(Now, "ddmm")

rs.fields(0) = PNRReserve

rs.fields(1) = txtName.Text

rs.fields(2) = txtAge.Text

rs.fields(3) = sx

rs.fields(4) = txtSource.Text

rs.fields(5) = txtDestn.Text

If (txtPhoneNumber.Text = "") Then

rs.fields(7) = "0"

Else

rs.fields(7) = txtPhoneNumber.Text

End If

Call search1

Call search2

If (cmbClass.Text = "GN") Then

If (txtAge.Text < 60) Then

rate = (a2 - a1) * (40 / 100)

Else

rate = (a2 - a1) * (40 / 100) * (85 / 100)

End If

If (rate < 0) Then

rate = -(rate)

End If

Page 46: Railway Ticket SystemBY NAKUL VERMA

Railway Ticket System 46

rs.fields(6) = rate

ElseIf (cmbClass.Text = "SC") Then

If (txtAge.Text < 60) Then

rate = (a2 - a1) * (50 / 100)

Else

rate = (a2 - a1) * (50 / 100) * (85 / 100)

End If

If (rate < 0) Then

rate = -(rate)

End If

rs.fields(6) = rate

ElseIf (cmbClass.Text = "FC") Then

If (txtAge.Text < 60) Then

rate = (a2 - a1) * (60 / 100)

Else

rate = (a2 - a1) * (60 / 100) * (85 / 100)

End If

If (rate < 0) Then

rate = -(rate)

End If

rs.fields(6) = rate

ElseIf (cmbClass.Text = "AC") Then

If (txtAge.Text < 60) Then

rate = (a2 - a1) * (70 / 100)

Else

rate = (a2 - a1) * (70 / 100) * (85 / 100)

End If

If (rate < 0) Then

rate = -(rate)

End If

rs.fields(6) = rate

Page 47: Railway Ticket SystemBY NAKUL VERMA

Railway Ticket System 47

Else

MsgBox "Wrong Entry", vbOKOnly + vbCritical, "RETRY"

End If

rs.Update

NameReserve = txtName.Text

AgeReserve = txtAge.Text

SexReserve = sx

StReserve = txtSource.Text

DestReserve = txtDestn.Text

classReserve = cmbClass.Text

StatusReserve = "RAC"

iResponse = MsgBox(StatusReserve, vbOKOnly + vbInformation, "SUCCESS")

If (iResponse = vbOK) Then

frmRESERVATION.Hide

frmTicket.Show

End If

Exit Sub

ElseIf (rs.RecordCount > 16 And rs.RecordCount < 25) Then

On Error GoTo Errorhandler1

rs.AddNew

PNRReserve = cmbTrainno.Text + cmbClass.Text + Format(Now, "hhmmss") +

Format(Now, "ddmm")

rs.fields(0) = PNRReserve

rs.fields(1) = txtName.Text

rs.fields(2) = txtAge.Text

rs.fields(3) = sx

rs.fields(4) = txtSource.Text

rs.fields(5) = txtDestn.Text

rs.fields(6) = "20"

If (txtPhoneNumber.Text = "") Then

Page 48: Railway Ticket SystemBY NAKUL VERMA

Railway Ticket System 48

rs.fields(7) = "0"

Else

rs.fields(7) = txtPhoneNumber.Text

End If

Call search1

Call search2

If (cmbClass.Text = "GN") Then

If (txtAge.Text < 60) Then

rate = (a2 - a1) * (40 / 100)

Else

rate = (a2 - a1) * (40 / 100) * (85 / 100)

End If

If (rate < 0) Then

rate = -(rate)

End If

rs.fields(6) = rate

End If

If (cmbClass.Text = "SC") Then

If (txtAge.Text < 60) Then

rate = (a2 - a1) * (50 / 100)

Else

rate = (a2 - a1) * (50 / 100) * (85 / 100)

End If

If (rate < 0) Then

rate = -(rate)

End If

rs.fields(6) = rate

End If

If (cmbClass.Text = "FC") Then

If (txtAge.Text < 60) Then

rate = (a2 - a1) * (60 / 100)

Page 49: Railway Ticket SystemBY NAKUL VERMA

Railway Ticket System 49

Else

rate = (a2 - a1) * (60 / 100) * (85 / 100)

End If

If (rate < 0) Then

rate = -(rate)

End If

rs.fields(6) = rate

End If

If (cmbClass.Text = "AC") Then

If (txtAge.Text < 60) Then

rate = (a2 - a1) * (70 / 100)

Else

rate = (a2 - a1) * (70 / 100) * (85 / 100)

End If

If (rate < 0) Then

rate = -(rate)

End If

rs.fields(6) = rate

End If

rs.Update

NameReserve = txtName.Text

AgeReserve = txtAge.Text

SexReserve = sx

StReserve = txtSource.Text

DestReserve = txtDestn.Text

classReserve = cmbClass.Text

StatusReserve = "Waiting List"

iResponse = MsgBox(StatusReserve, vbOKOnly + vbInformation, "WAIT")

If (iResponse = vbOK) Then

frmRESERVATION.Hide

frmTicket.Show

Page 50: Railway Ticket SystemBY NAKUL VERMA

Railway Ticket System 50

End If

Exit Sub

Else

MsgBox "Sorry ! ! ! No Reservation Available ", vbOKOnly + vbCritical, "TRY

LATER"

Exit Sub

End If

Exit Sub

Exit Sub

Exit Sub

Exit Sub

Exit Sub

Errorhandler1:

MsgBox "Enter Proper Data", vbOKOnly + vbCritical, "IMPROPER DATA"

End Sub

Page 51: Railway Ticket SystemBY NAKUL VERMA

Railway Ticket System 51

Cancellation

Private Sub approve1() 'Checks first 4 characters

leftpnr1 = Left(txtPNR1.Text, 4)

Set rs1 = db1.OpenRecordset("TrainDetails")

rs1.MoveFirst

Do Until rs1.EOF

If rs1.fields(0) = leftpnr1 Then

x = 1

Exit Sub

Else

rs1.MoveNext

End If

Loop

End Sub

Private Sub approve2() 'Checks 5th & 6th characters

rightpnr1 = Right(txtPNR1.Text, 2)

If ((rightpnr1 = "AC") Or (rightpnr1 = "FC") Or (rightpnr1 = "SC") Or (rightpnr1 =

"GN")) Then

x1 = 1

End If

End Sub

Private Sub approve3() 'Entire PNR Check

Set rs = db.OpenRecordset(txtPNR1)

On Error GoTo z ' newly added

rs.MoveFirst

Do Until rs.EOF

If rs.fields(0) = (txtPNR1.Text + txtPNR2.Text) Then

x2 = 1

Page 52: Railway Ticket SystemBY NAKUL VERMA

Railway Ticket System 52

fine = (85 / 100) * (rs.fields(6))

Exit Sub

Else

rs.MoveNext

End If

Loop

Exit Sub ' newly added

z: MsgBox "Enter proper data", vbOKOnly + vbCritical, "RETRY"

End Sub

Private Sub cmdSubmit_Click()

x2 = 0

x1 = 0

x = 0

If (txtPNR1.Text = "" Or txtPNR2.Text = "") Then

MsgBox "Enter Complete PNR ", vbOKOnly + vbCritical, "RETRY"

Exit Sub

Else

Call approve1

If (x = 1) Then

Call approve2

Else

MsgBox "Enter valid PNR - Check first 4 chars or afterwards", vbOKOnly + vbCritical,

"RETRY"

Exit Sub

End If

If (x1 = 1) Then

Call approve3

Else

MsgBox "Enter valid PNR - Check characters 5 & 6 or afterwards", vbOKOnly +

vbCritical, "RETRY"

Page 53: Railway Ticket SystemBY NAKUL VERMA

Railway Ticket System 53

Exit Sub

End If

If (x2 = 1) Then

Response = MsgBox("Valid PNR - Are you sure to Cancel Ticket ?", vbYesNo +

vbInformation + vbDefaultButton1, "SUCCESS")

Else

MsgBox "Enter valid PNR - Check characters 7 to 12 ", vbOKOnly + vbCritical,

"RETRY"

Exit Sub

End If

If (Response = vbYes) Then

finestring = fine

finestring = "Cash Refund = " + finestring

Response = MsgBox((finestring), vbOKOnly + vbInformation, "REFUND")

End If

If (Response = vbOK) Then

rs.Delete

rs.MoveNext

Response = MsgBox("TICKET CANCELLED SUCCESSFULLY !!!", vbOKOnly +

vbInformation + vbDefaultButton1, "SUCCESS")

End If

If (Response = vbOK) Then

txtPNR1.Text = ""

txtPNR2.Text = ""

txtPNR1.SetFocus

End If

End If

End Sub

Page 54: Railway Ticket SystemBY NAKUL VERMA

Railway Ticket System 54

Status

Private Sub approve1() 'Checks first 4 characters

leftpnr1 = Left(txtPNR1.Text, 4)

Set rs1 = db1.OpenRecordset("TrainDetails")

rs1.MoveFirst

Do Until rs1.EOF

If rs1.fields(0) = leftpnr1 Then

x = 1

Exit Sub

Else

rs1.MoveNext

End If

Loop

End Sub

Private Sub approve2() 'Checks 5th & 6th characters

rightpnr1 = Right(txtPNR1.Text, 2)

If ((rightpnr1 = "AC") Or (rightpnr1 = "FC") Or (rightpnr1 = "SC") Or (rightpnr1 =

"GN")) Then

x1 = 1

End If

End Sub

Private Sub approve3()

Set rs2 = db.OpenRecordset(txtPNR1)

On Error GoTo z ' newly added

rs2.MoveFirst

Do Until rs2.EOF

If rs2.fields(0) = (txtPNR1.Text + txtPNR2.Text) Then

flag = 1

status = status + 1

Page 55: Railway Ticket SystemBY NAKUL VERMA

Railway Ticket System 55

statname = rs2.fields(1)

statage = rs2.fields(2)

statsex = rs2.fields(3)

statstart = rs2.fields(4)

statdestn = rs2.fields(5)

stattrainno = Left(txtPNR1, 4)

statPNR = rs2.fields(0)

Exit Sub

Else

flag = 0

status = status + 1

rs2.MoveNext

End If

Loop

Exit Sub

z: MsgBox "Enter proper data", vbOKOnly + vbCritical, "RETRY"

End Sub

Private Sub cmdEmergency_Click()

inp = InputBox("Enter Your PNR", "RTS", "", 512, 350)

a = Left(inp, 6)

b = Right(a, 2)

a = Left(a, 4)

On Error GoTo z

Set rs3 = db1.OpenRecordset("TrainDetails")

rs3.MoveFirst

Do Until (rs3.EOF)

If (rs3.fields(0) = a) Then

On Error GoTo z

If ((b = "AC") Or (b = "FC") Or (b = "SC") Or (b = "GN")) Then

Set rs4 = db.OpenRecordset(a + b)

Page 56: Railway Ticket SystemBY NAKUL VERMA

Railway Ticket System 56

rs4.MoveFirst

Do Until (rs4.EOF)

If (rs4.fields(0) = inp) Then

c = rs4.fields(7)

Exit Do

Else

rs4.MoveNext

End If

Loop

End If

Else

rs3.MoveNext

End If

Loop

If (c = "0") Then

MsgBox "Sorry No Phone-number entered", vbOKOnly + vbCritical, "NOT FOUND"

Else

MsgBox c

c = "Phone Number is " + c

MsgBox c, vbOKOnly, vbInformation, "FOUND"

End If

Exit Sub

Exit Sub

z: MsgBox "Invalid PNR", vbOKOnly + vbCritical, "ERROR"

End Sub

Private Sub cmdSubmit_Click()

flag = 0

status = 0

x = 0

x1 = 0

Page 57: Railway Ticket SystemBY NAKUL VERMA

Railway Ticket System 57

If (txtPNR1.Text = "" Or txtPNR2.Text = "") Then

MsgBox "Enter Complete PNR ", vbOKOnly + vbCritical, "RETRY"

Exit Sub

Else

Call approve1

If (x = 1) Then

Call approve2

Else

MsgBox "Enter valid PNR - Check first 4 chars or afterwards", vbOKOnly + vbCritical,

"RETRY"

Exit Sub

End If

If (x1 = 1) Then

Call approve3

Else

MsgBox "Enter valid PNR - Check characters 5 & 6 or afterwards", vbOKOnly +

vbCritical, "RETRY"

Exit Sub

End If

If (flag = 0) Then

MsgBox "Enter proper data - Check characters 7 to 16", vbOKOnly + vbCritical,

"ERROR"

Exit Sub

End If

If ((status > 0) And (status < 13)) Then

statpass = "CONFIRMED"

Response = MsgBox("CONFIRMED - Do You Want to see more Details?", vbYesNo +

vbInformation, "SUCCESS")

ElseIf ((status > 12) And (status < 18)) Then

statpass = "RAC"

Page 58: Railway Ticket SystemBY NAKUL VERMA

Railway Ticket System 58

Response = MsgBox("RAC - Do You Want to see more Details?", vbYesNo +

vbInformation, "SUCCESS")

ElseIf ((status > 17) And (status < 26)) Then

statpass = "WAITING LIST"

Response = MsgBox("WAITING LIST - Do You Want to see more Details?", vbYesNo

+ vbInformation, "SUCCESS")

Else

MsgBox "Improper Data", vbOKOnly + vbCritical, "RETRY"

Exit Sub

End If

If (Response = vbYes) Then

Unload frmSTATUS

Load frmSTATUS1

frmSTATUS1.Show

End If

If (Response = vbNo) Then

Unload frmSTATUS

frmOprOptions.Show

End If

End If

End Sub

Page 59: Railway Ticket SystemBY NAKUL VERMA

Railway Ticket System 59

Administrator Coding

Add Train

Private Sub cmdCheck_Click()

flag = 0

flag1 = 0

Set rs = db.OpenRecordset("TrainDetails")

If (txtTrainno = "") Then

MsgBox "Enter Train number ", vbOKOnly + vbCritical, "RETRY"

Exit Sub

End If

If (txttrainname = "") Then

MsgBox "Enter Train name ", vbOKOnly + vbCritical, "RETRY"

Exit Sub

End If

k = txtTrainno

k1 = txttrainname

rs.MoveFirst

Do Until rs.EOF

If (txtTrainno = rs.fields(0)) Then

flag = 1

End If

If (txttrainname = rs.fields(1)) Then

flag1 = 1

End If

Page 60: Railway Ticket SystemBY NAKUL VERMA

Railway Ticket System 60

rs.MoveNext

Loop

If (flag = 1) Then

MsgBox "The Train Number already exists ! Please specify another ", vbOKOnly +

vbCritical, "RETRY"

Exit Sub

ElseIf (flag1 = 1) Then

MsgBox "The Train Name already exists ! Please specify another ", vbOKOnly +

vbCritical, "RETRY"

Exit Sub

Else

p = MsgBox("Availability Check Successful - Want to create table ", vbYesNo +

vbInformation, "SUCCESS")

End If

Set rs = Nothing

If (p = vbYes) Then

cmdEnter1.Visible = True

lblStstn.Visible = True

txtststn.Visible = True

txtsttime.Visible = True

cmdHelp.Visible = True

txttrainname.Locked = True

txtTrainno.Locked = True

txtststn.SetFocus

Page 61: Railway Ticket SystemBY NAKUL VERMA

Railway Ticket System 61

Else

MsgBox "No table will be created", vbOKOnly + vbCritical, "RETRY"

Exit Sub

End If

If (Len(txtTrainno) < 5) Then ' Code for combining zeros start here

zeros = Len(txtTrainno)

End If

If (zeros = 1) Then

k2 = "000" + txtTrainno

End If

If (zeros = 2) Then

k2 = "00" + txtTrainno

End If

If (zeros = 3) Then

k2 = "0" + txtTrainno

End If

If (zeros = 4) Then

k2 = txtTrainno

End If ' Code for combining zeros ends here

Call addtraindetails

Set rs = Nothing

Set td = db.CreateTableDef(k2)

Set fields(0) = td.CreateField("Station_Name", dbText)

Page 62: Railway Ticket SystemBY NAKUL VERMA

Railway Ticket System 62

Set fields(1) = td.CreateField("Time", dbDate)

Set fields(2) = td.CreateField("Kilometres", dbInteger)

td.fields.Append fields(0)

td.fields.Append fields(1)

td.fields.Append fields(2)

Set oindex = td.CreateIndex

With oindex

.Name = "KilometresIndex"

.fields.Append .CreateField("Kilometres")

.Primary = True

End With

td.Indexes.Append oindex

Set rs = Nothing

Set td = Nothing

Set oindex = Nothing

Set dbindex = Nothing

Call adduserdata

End Sub

Private Sub addtraindetails() ' Add data in a row to TrainDetails (No+Name)

Set rs = db.OpenRecordset("TrainDetails")

Page 63: Railway Ticket SystemBY NAKUL VERMA

Railway Ticket System 63

On Error GoTo z1

rs.AddNew

rs.fields(0) = k2

rs.fields(1) = k1

rs.Update

Exit Sub

z1: MsgBox "Enter proper data ", vbOKOnly + vbCritical, "RETRY"

End Sub

Private Sub cmdEnter1_Click()

Set rs = db.OpenRecordset(nw)

If (Len(txtststn) < 3) Then

GoTo z2

End If

On Error GoTo z2

rs.AddNew

rs.fields(0) = txtststn

rs.fields(1) = txtsttime

rs.fields(2) = 0

rs.Update

cmdEnter1.Visible = False

lblStstn.Visible = False

txtststn.Visible = False

txtsttime.Visible = False

lblEnterStation.Visible = True

lblEnterTime.Visible = True

lblEnterDistance.Visible = True

txtStnname.Visible = True

Page 64: Railway Ticket SystemBY NAKUL VERMA

Railway Ticket System 64

txtTime.Visible = True

txtDistance.Visible = True

cmdviewdata.Visible = True

cmdNext.Visible = True

txttrainname.Locked = True

txtTrainno.Locked = True

txtStnname.SetFocus

Set rs = Nothing

Exit Sub

z2: MsgBox "Enter proper data ", vbOKOnly + vbCritical, "RETRY"

End Sub

Private Sub adduserdata()

nw = k2

k2 = k2 + "AC" 'Train's AC table construction starts

Set td = db1.CreateTableDef(k2)

Set fields(0) = td.CreateField("PNR", dbText)

td.fields.Append fields(0)

Set fields(1) = td.CreateField("User_Name", dbText)

td.fields.Append fields(1)

Set fields(2) = td.CreateField("Age", dbInteger)

td.fields.Append fields(2)

Set fields(3) = td.CreateField("Sex", dbText)

td.fields.Append fields(3)

Set fields(4) = td.CreateField("Starting_Station", dbText)

td.fields.Append fields(4)

Set fields(5) = td.CreateField("Destination_Station", dbText)

td.fields.Append fields(5)

Set fields(6) = td.CreateField("Fare", dbInteger)

Page 65: Railway Ticket SystemBY NAKUL VERMA

Railway Ticket System 65

td.fields.Append fields(6)

Set fields(7) = td.CreateField("Phone_Number", dbText)

td.fields.Append fields(7)

Set fields(8) = td.CreateField("Status", dbLong)

With fields(8)

.Attributes = .Attributes Or dbAutoIncrField

End With

td.fields.Append fields(8)

Set oindex = td.CreateIndex

With oindex

.Name = "StatusIndex"

.fields.Append .CreateField("Status")

.Primary = True

End With

td.Indexes.Append oindex

db1.TableDefs.Append td

Set td = Nothing

Set oindex = Nothing

Set dbindex = Nothing 'Train's AC table construction ends

k2 = nw 'restore value of k2

Page 66: Railway Ticket SystemBY NAKUL VERMA

Railway Ticket System 66

k2 = k2 + "FC" 'Train's FC table construction starts

Set td = db1.CreateTableDef(k2)

Set fields(0) = td.CreateField("PNR", dbText)

td.fields.Append fields(0)

Set fields(1) = td.CreateField("User_Name", dbText)

td.fields.Append fields(1)

Set fields(2) = td.CreateField("Age", dbInteger)

td.fields.Append fields(2)

Set fields(3) = td.CreateField("Sex", dbText)

td.fields.Append fields(3)

Set fields(4) = td.CreateField("Starting_Station", dbText)

td.fields.Append fields(4)

Set fields(5) = td.CreateField("Destination_Station", dbText)

td.fields.Append fields(5)

Set fields(6) = td.CreateField("Fare", dbInteger)

td.fields.Append fields(6)

Set fields(7) = td.CreateField("Phone_Number", dbText)

td.fields.Append fields(7)

Set fields(8) = td.CreateField("Status", dbLong)

With fields(8)

.Attributes = .Attributes Or dbAutoIncrField

End With

td.fields.Append fields(8)

Set oindex = td.CreateIndex

Page 67: Railway Ticket SystemBY NAKUL VERMA

Railway Ticket System 67

With oindex

.Name = "StatusIndex"

.fields.Append .CreateField("Status")

.Primary = True

End With

td.Indexes.Append oindex

db1.TableDefs.Append td

Set td = Nothing

Set oindex = Nothing

Set dbindex = Nothing 'Train's FC table construction ends

k2 = nw 'restore value of k2

k2 = k2 + "SC" 'Train's SC table construction starts

Set td = db1.CreateTableDef(k2)

Set fields(0) = td.CreateField("PNR", dbText)

td.fields.Append fields(0)

Set fields(1) = td.CreateField("User_Name", dbText)

td.fields.Append fields(1)

Set fields(2) = td.CreateField("Age", dbInteger)

td.fields.Append fields(2)

Set fields(3) = td.CreateField("Sex", dbText)

td.fields.Append fields(3)

Set fields(4) = td.CreateField("Starting_Station", dbText)

td.fields.Append fields(4)

Page 68: Railway Ticket SystemBY NAKUL VERMA

Railway Ticket System 68

Set fields(5) = td.CreateField("Destination_Station", dbText)

td.fields.Append fields(5)

Set fields(6) = td.CreateField("Fare", dbInteger)

td.fields.Append fields(6)

Set fields(7) = td.CreateField("Phone_Number", dbText)

td.fields.Append fields(7)

Set fields(8) = td.CreateField("Status", dbLong)

With fields(8)

.Attributes = .Attributes Or dbAutoIncrField

End With

td.fields.Append fields(8)

Set oindex = td.CreateIndex

With oindex

.Name = "StatusIndex"

.fields.Append .CreateField("Status")

.Primary = True

End With

td.Indexes.Append oindex

db1.TableDefs.Append td

Set td = Nothing

Set oindex = Nothing

Page 69: Railway Ticket SystemBY NAKUL VERMA

Railway Ticket System 69

Set dbindex = Nothing 'Train's SC table construction ends

k2 = nw 'restore value of k2

k2 = k2 + "GN" 'Train's GN table construction starts

Set td = db1.CreateTableDef(k2)

Set fields(0) = td.CreateField("PNR", dbText)

td.fields.Append fields(0)

Set fields(1) = td.CreateField("User_Name", dbText)

td.fields.Append fields(1)

Set fields(2) = td.CreateField("Age", dbInteger)

td.fields.Append fields(2)

Set fields(3) = td.CreateField("Sex", dbText)

td.fields.Append fields(3)

Set fields(4) = td.CreateField("Starting_Station", dbText)

td.fields.Append fields(4)

Set fields(5) = td.CreateField("Destination_Station", dbText)

td.fields.Append fields(5)

Set fields(6) = td.CreateField("Fare", dbInteger)

td.fields.Append fields(6)

Set fields(7) = td.CreateField("Phone_Number", dbText)

td.fields.Append fields(7)

Set fields(8) = td.CreateField("Status", dbLong)

With fields(8)

.Attributes = .Attributes Or dbAutoIncrField

End With

td.fields.Append fields(8)

Page 70: Railway Ticket SystemBY NAKUL VERMA

Railway Ticket System 70

Set oindex = td.CreateIndex

With oindex

.Name = "StatusIndex"

.fields.Append .CreateField("Status")

.Primary = True

End With

td.Indexes.Append oindex

db1.TableDefs.Append td

Set td = Nothing

Set oindex = Nothing

Set dbindex = Nothing 'Train's GN table construction ends

End Sub

Private Sub cmdHelp_Click()

Load frmHelpReservation2

frmHelpReservation2.Show

End Sub

Private Sub cmdNext_Click()

Set rs = db.OpenRecordset(nw)

If (Len(txtStnname) < 3) Then

GoTo z

End If

On Error GoTo z

rs.AddNew

rs.fields(0) = txtStnname

Page 71: Railway Ticket SystemBY NAKUL VERMA

Railway Ticket System 71

rs.fields(1) = txtTime

rs.fields(2) = txtDistance

rs.Update

txtStnname = ""

txtTime = ""

txtDistance = ""

txtStnname.SetFocus

Exit Sub

z: MsgBox "Enter proper data ", vbOKOnly + vbCritical, "RETRY"

End Sub

Page 72: Railway Ticket SystemBY NAKUL VERMA

Railway Ticket System 72

Delete Train

Private Sub check1()

Set rs = db.OpenRecordset("TrainDetails")

rs.MoveFirst

Do Until rs.EOF

If (p = rs.fields(0)) Then

flag = 1

Exit Sub

End If

rs.MoveNext

Loop

End Sub

Private Sub cmdCheck_Click()

flag = 0

If (Len(txttrainno) < 4) Then

MsgBox "Enter proper Train number ", vbOKOnly + vbCritical, "RETRY"

Exit Sub

End If

p = txttrainno

Set rs = db.OpenRecordset("TrainDetails")

Call check1

Page 73: Railway Ticket SystemBY NAKUL VERMA

Railway Ticket System 73

If (flag = 1) Then

b = MsgBox("Train number found ! Want to continue?", vbYesNo + vbInformation,

"FOUND")

Else

MsgBox "Enter proper Train number ", vbOKOnly + vbCritical, "RETRY"

Exit Sub

End If

If (b = vbYes) Then

rs.MoveFirst

Do Until rs.EOF

If (rs.fields(0) = p) Then

rs.Delete

rs.MoveNext

Else

rs.MoveNext

End If

Loop

db.TableDefs.Delete p

a = p + "AC"

db1.TableDefs.Delete a

a = p + "FC"

db1.TableDefs.Delete a

a = p + "SC"

db1.TableDefs.Delete a

a = p + "GN"

db1.TableDefs.Delete a

Page 74: Railway Ticket SystemBY NAKUL VERMA

Railway Ticket System 74

MsgBox "DELETED all related tables", vbOKOnly + vbInformation, "SUCCESS"

Else

MsgBox "No table will be deleted", vbOKOnly + vbCritical, "RETRY"

End If

End Sub

Page 75: Railway Ticket SystemBY NAKUL VERMA

Railway Ticket System 75

Edit Train

Private Sub cmdCheck_Click()

flag = 0

If (Len(txttrainno) < 4) Then

MsgBox "Enter proper Train number ", vbOKOnly + vbCritical, "RETRY"

Exit Sub

End If

p = txttrainno

Set rs = db.OpenRecordset("TrainDetails")

rs.MoveFirst

Do Until rs.EOF

If (p = rs.fields(0)) Then

flag = 1

End If

rs.MoveNext

Loop

If (flag = 1) Then

b = MsgBox("Train number found ! Want to continue?", vbYesNo + vbInformation,

"FOUND")

Else

MsgBox "Enter proper Train number ", vbOKOnly + vbCritical, "RETRY"

Exit Sub

End If

If (b = vbYes) Then

lblstncd.Visible = True

txtstncd.Visible = True

Page 76: Railway Ticket SystemBY NAKUL VERMA

Railway Ticket System 76

cmdEnter.Visible = True

txtstncd.SetFocus

txttrainno.Locked = True

End If

End Sub

Private Sub cmdEnter_Click()

z = txtstncd

flag = 0

If (Len(z) < 3) Then

MsgBox "Enter proper Station Code ", vbOKOnly + vbCritical, "RETRY"

Exit Sub

End If

Set rs = db.OpenRecordset(p)

rs.MoveFirst

Do Until rs.EOF

If (rs.fields(0) = z) Then

flag = 1

End If

rs.MoveNext

Loop

If (flag = 0) Then

MsgBox "Enter proper Station Code ", vbOKOnly + vbCritical, "RETRY"

Exit Sub

Else

b = MsgBox("Station Code Matches !!! - Want to continue ?", vbYesNo +

vbInformation, "SUCCESS")

End If

If (b = vbYes) Then

lbltimeupd.Visible = True

Page 77: Railway Ticket SystemBY NAKUL VERMA

Railway Ticket System 77

txtTimeupd.Visible = True

lblDistupd.Visible = True

txtDistupd.Visible = True

lblStnupd.Visible = True

txtstnupd.Visible = True

cmdGenerate.Visible = True

txtstnupd.SetFocus

txtstncd.Locked = True

End If

End Sub

Private Sub cmdGenerate_Click()

If (Len(txtstnupd) < 3) Then

GoTo z1

End If

On Error GoTo z1

Set rs1 = db.OpenRecordset(p)

rs1.MoveFirst

Do Until rs1.EOF

If (rs1.fields(0) = z) Then

rs1.Edit

rs1.fields(0) = txtstnupd

rs1.fields(1) = txtTimeupd

rs1.fields(2) = txtDistupd

rs1.Update

Else

rs1.MoveNext

End If

Loop

Page 78: Railway Ticket SystemBY NAKUL VERMA

Railway Ticket System 78

Set rs1 = Nothing

Set rs = Nothing

w = MsgBox("Train Time Table Updated!!! - Want to view Table ?", vbYesNo +

vbInformation, "SUCCESS")

If (w = vbYes) Then

Set rs = db.OpenRecordset("TrainDetails")

rs.MoveFirst

Do Until rs.EOF

If (rs.fields(0) = p) Then

x = rs.fields(1)

Exit Do

Else

rs.MoveNext

End If

Loop

lblTrainname.Caption = x

lblStncode.Visible = True

lblTime.Visible = True

lblDistance.Visible = True

cmdGenerate.Visible = False

Set rs = Nothing

Set rs = db.OpenRecordset(p)

rs.MoveFirst

Do Until rs.EOF

LstStationIndex.AddItem (((rs.fields(0) & " --------> ")) & (rs.fields(1) & "

---------> ")) & (rs.fields(2))

rs.MoveNext

Loop

LstStationIndex.Visible = True

lblTrainname.Visible = True

Page 79: Railway Ticket SystemBY NAKUL VERMA

Railway Ticket System 79

lblStnDetails.Visible = True

lblTrainnumber.Visible = True

lblTrainnumber.Caption = p

Else

MsgBox "Train Time Table Updated", vbOKOnly + vbInformation, "RTS"

cmdGenerate.Visible = False

End If

Exit Sub

z1: MsgBox "Enter proper data ", vbOKOnly + vbCritical, "RETRY"

End Sub

Page 80: Railway Ticket SystemBY NAKUL VERMA

Railway Ticket System 80

Edit Station

Private Sub cmdCheck_Click()

flag = 0

If (Len(txtstncd) < 3) Then

MsgBox "Enter proper Station Code ", vbOKOnly + vbCritical, "RETRY"

Exit Sub

End If

p = txtstncd

rs.MoveFirst

Do Until rs.EOF

If (rs.fields(2) = p) Then

flag = 1

Exit Do

Else

rs.MoveNext

End If

Loop

If (flag = 1) Then

b = MsgBox("Station Code found ! Want to continue?", vbYesNo + vbInformation,

"FOUND")

Else

MsgBox "Enter proper Station Code ", vbOKOnly + vbCritical, "RETRY"

Exit Sub

End If

If (b = vbYes) Then

txtstncd.Locked = True

lblstncode.Visible = True

lblstnname.Visible = True

Page 81: Railway Ticket SystemBY NAKUL VERMA

Railway Ticket System 81

txtstnname.Visible = True

txtstncode.Visible = True

cmdEnter.Visible = True

txtstncode.SetFocus

End If

End Sub

Private Sub cmdEnter_Click()

If (Len(txtstncode) < 3) Then

GoTo z1

End If

On Error GoTo z1

rs.MoveFirst

Do Until rs.EOF

If (rs.fields(2) = p) Then

rs.Edit

rs.fields(2) = txtstncode

rs.fields(1) = txtstnname

rs.Update

Exit Do

Else

rs.MoveNext

End If

Loop

b = MsgBox("Station Data Updated!!! - Want to view ", vbYesNo + vbInformation,

"SUCCESS")

If (b = vbYes) Then

txtstncode.Locked = True

txtstnname.Locked = True

Page 82: Railway Ticket SystemBY NAKUL VERMA

Railway Ticket System 82

cmdEnter.Visible = False

lblstncde.Visible = True

lblstnnme.Visible = True

LstEditStations.Visible = True

rs.MoveFirst

Do Until rs.EOF

LstEditStations.AddItem (((rs.fields(1) & " -----> ")) & rs.fields(2))

rs.MoveNext

Loop

Else

MsgBox "No View will be displayed ", vbOKOnly + vbCritical, "RTS"

txtstncode.Locked = True

txtstnname.Locked = True

cmdEnter.Visible = False

End If

Exit Sub

z1: MsgBox "Enter proper Data ", vbOKOnly + vbCritical, "RETRY"

End Sub

Page 83: Railway Ticket SystemBY NAKUL VERMA

Railway Ticket System 83

View Stations

Private Sub Form_Load()

Set db = OpenDatabase(App.Path + "\Station Index.mdb")

Set rs = db.OpenRecordset("Station Index")

rs.MoveFirst

Do Until rs.EOF

LstViewStations.AddItem (((rs.fields(1) & " -----> ")) & rs.fields(2))

rs.MoveNext

Loop

End Sub

Page 84: Railway Ticket SystemBY NAKUL VERMA

Railway Ticket System 84

View Train

Private Sub cmdCheck_Click()

flag = 0

If (Len(txttrainno) < 4) Then

MsgBox "Enter proper Train number ", vbOKOnly + vbCritical, "RETRY"

Exit Sub

End If

p = txttrainno

Set rs = db.OpenRecordset("TrainDetails")

Do Until rs.EOF

If (p = rs.fields(0)) Then

flag = 1

x = rs.fields(0)

y = rs.fields(1)

End If

rs.MoveNext

Loop

If (flag = 1) Then

b = MsgBox("Train number found ! Want to continue?", vbYesNo + vbInformation,

"FOUND")

Else

MsgBox "Enter proper Train number ", vbOKOnly + vbCritical, "RETRY"

Exit Sub

End If

Page 85: Railway Ticket SystemBY NAKUL VERMA

Railway Ticket System 85

If (b = vbYes) Then

LstStationIndex.Visible = True

lblTrainname.Visible = True

lblStnDetails.Visible = True

lblTrainnumber.Visible = True

txttrainno.Locked = True

lblStncode.Visible = True

lblTime.Visible = True

lblDistance.Visible = True

cmdEdit.Visible = True

cmdCheck.Visible = False

lblTrainnumber.Caption = x

lblTrainname.Caption = y

Set rs1 = db.OpenRecordset(p)

rs1.MoveFirst

Do Until rs1.EOF

LstStationIndex.AddItem (((rs1.fields(0) & " --------> ")) & (rs1.fields(1) & "

---------> ")) & (rs1.fields(2))

rs1.MoveNext

Loop

Else

MsgBox "No View will be displayed ", vbOKOnly + vbCritical, "RETRY"

End If

rs.Close

Set rs = Nothing

End Sub

Account Status

Private Sub cmdCheck_Click()

Page 86: Railway Ticket SystemBY NAKUL VERMA

Railway Ticket System 86

t = txtpass

If (Len(txtpass) < 4) Then

MsgBox "Enter proper password ", vbOKOnly + vbCritical, "RETRY"

Exit Sub

Else

z = MsgBox("Are you sure ,you want to edit operator password? ", vbOKCancel +

vbInformation, "RTS")

End If

If (z = vbOK) Then

s = ((Len(t) / 2))

pk = CInt(s)

pk1 = Len(t) - pk

t1 = Left(t, pk)

t2 = Right(t, pk1)

rs.MoveFirst

rs.Edit

rs.fields(0) = t2

rs.fields(1) = t1

rs.Update

MsgBox "Operator Password Successfully Edited ", vbOKOnly + vbInformation,

"SUCCESS"

Else

MsgBox "Operator Password Not Edited ", vbOKOnly + vbCritical, "RETRY"

End If

End Sub

Page 87: Railway Ticket SystemBY NAKUL VERMA

Railway Ticket System 87

DFD SYMBOLS

External Entity

A procedure or information that resides outsides the boundary of system to be modified

ProcessA transformer of information that resides within the bounds of system to be modified

A data object, the arrowhead indicates the direction of dataflow

A repository of data that’s to be stored for use by one or more processor ; may be as simple as a buffer or queue or as sophisticated as a relational database .

Output Symbol to denote output state

Data StoreData Store

Page 88: Railway Ticket SystemBY NAKUL VERMA

Railway Ticket System 88

REFERENCES

Microsoft Developer Network

Visual Basic 6 Black Book

http://www.wikipedia.com – Free Online Encyclopedia

http://www.southernrailway.org

http://www.indianrailways.gov.in

http://www.irctc.com

Southern Railway Time-Tables

Page 89: Railway Ticket SystemBY NAKUL VERMA

Railway Ticket System 89

CONCLUSION

The project entitled “Railway Ticket System” has been developed to maintain and

manage all the reservation procedures include in the generation of a railway ticket for

senior and non-senior citizens. We believe that, this project will help the computer

operator of Indian Railways (South Zone) to carry out the railway ticket reservation, to

cancel tickets and to implement the newly proposed journey planner without any

difficulties, if this project is implemented in Indian Railways (South Zone). We had tried

our level best to produce the project in its present form.

During the course of the project work, it was found to be very user interactive and

effective than the existing system. The flexible attitude of Visual Basic helps to maintain

the “Railway Ticket System” more effectively.