MCA, Final Project for SMU

107
Railway Reservation System – eRail Krishan Kumar Pareek, MCA – 6 th Sem., Reg. No.: 571124530 Page: 1/107 Tirupati College of Distance Education, Centre Code – 03372 Jaipur (Raj)-302015 The Project Report On “Railway Reservation System – eRail” Submitted in partial fulfillment of the requirement of The Degree of “Master of Computer ApplicationIn Sikkim Manipal University, India Submitted By- Project Guide- Name : Krishan Kumar Pareek Dr. A. K. Tiwari Roll No : 571124530 Associate Professor Course : MCA 6 th Sem. Tirupati College, Pratap Nagar, Jaipur

description

Sikkim Manipal UniversityMCA - 6th Semester Final Project on “Railway Reservation System – eRail” Created on 14th April 2014 by Krishan Kumar Pareek

Transcript of MCA, Final Project for SMU

Page 1: MCA, Final Project for SMU

Railway Reservation System – eRail

Krishan Kumar Pareek, MCA – 6th Sem., Reg. No.: 571124530 Page: 1/107

Tirupati College of Distance Education, Centre Code – 03372

Jaipur (Raj)-302015

The Project Report

On

“Railway Reservation System – eRail”

Submitted in partial fulfillment of the requirement of

The Degree of “Master of Computer Application”

In Sikkim Manipal University, India

Submitted By - Project Guide-

Name : Krishan Kumar Pareek Dr. A. K. Tiwari

Roll No : 571124530 Associate Professor

Course : MCA – 6th

Sem. Tirupati College, Pratap Nagar, Jaipur

Page 2: MCA, Final Project for SMU

Railway Reservation System – eRail

Krishan Kumar Pareek, MCA – 6th Sem., Reg. No.: 571124530 Page: 2/107

Examiner’s Certificate

This is to certify that project report submitted by “Krishan Kumar Pareek” entitled “Railway Reservation System – eRail” is approved and is acceptable in quality and form.

Internal Examiner External Examiner Dr. A. K. Tiwari, Associate Professor, College / Organization

Page 3: MCA, Final Project for SMU

Railway Reservation System – eRail

Krishan Kumar Pareek, MCA – 6th Sem., Reg. No.: 571124530 Page: 3/107

Ref. No: 571124530 Date: April, 14th 2014

Certificate of Guide

This is to certify that project report entitled “Railway Reservation System – eRail”

Submitted in partial fulfillment and requirement for the degree of “Master of Computer

Application” to Sikkim Manipal University, India by “Krishan Kumar Pareek” has worked

under my supervision and guidance and that no part of this report has been submitted for

the award of any other degree, diploma, fellowship, or any similar titles or prizes and the

work has not been published in any journal or magazine.

Certified By- Dr. A. K .Tiwari Associate Professor College / Organization

Page 4: MCA, Final Project for SMU

Railway Reservation System – eRail

Krishan Kumar Pareek, MCA – 6th Sem., Reg. No.: 571124530 Page: 4/107

Declaration

I hereby declare that the project report entitled “Railway Reservation System – eRail”

submitted in partial fulfillment and requirement for the degree of “Master of Computer

Application” to Sikkim Manipal University, India is my original work and not submitted for

the award of any other degree, diploma, fellowship, or any similar title of prizes.

Place: - Jaipur (Raj) Krishan Kumar Pareek Date: - April, 14th 2014 Reg. No. 571124530 MCA – 6th Sem.

Page 5: MCA, Final Project for SMU

Railway Reservation System – eRail

Krishan Kumar Pareek, MCA – 6th Sem., Reg. No.: 571124530 Page: 5/107

Acknowledgement

I would like to express our heartiest thank to Dr. A. K. Tiwari, Associate Professor, for showing the complete confidence in me. I express my deep sense of gratitude to all my faculties and management of Tirupati College for Distance Learning, Pratap Nagar, Jaipur for providing me this great opportunity. I express my sincere gratitude towards Dr. A. K. Tiwari, Associate Professor, SMU for providing us the excellent environment for project making. I am also thankful to my friends and classmates, who were always there to help me out, motivate me towards the fulfillment of this project. I would like specially say thanks to Ms. Sonal Chouhan, who always council and guide me very well for ever for ever. Last but not the least it is the staff of Department of Computer Application, Tirupati College for Distance Learning, Pratap Nagar, Jaipur, to whom I am always indebted. I AM THANKFUL TO ALL OF THEM KRISHAN KUMAR PAREEK MCA, 6

th Sem.

Tirupati College for Distance Learning, Pratap Nagar, Jaipur

Page 6: MCA, Final Project for SMU

Railway Reservation System – eRail

Krishan Kumar Pareek, MCA – 6th Sem., Reg. No.: 571124530 Page: 6/107

Table of Contents

ABSTARCT ..................................................................................................................................................... 9

Railway Management System Benefits ......................................................................... 10

Scope and Features ........................................................................................................ 10

Security module ......................................................................................................... 11

Master Management module ..................................................................................... 11

Transaction Module ................................................................................................... 12

Query Module ............................................................................................................ 12

Out of Scope .................................................................................................................. 13

Goal and objective ......................................................................................................... 13

Solution Concept ........................................................................................................... 13

PROBLEM STATEMENT ......................................................................................................................... 14

Requirements Summary ................................................................................................ 14

Business Requirements .............................................................................................. 14

User Requirements .................................................................................................... 14

Operational Requirements ......................................................................................... 15

SYSTEM ARCHITECTURE ..................................................................................................................... 16

High Level Solution Architecture ................................................................................. 16

Data Flow and Process Flow Chart ............................................................................... 17

User Profiles .................................................................................................................. 17

User Profiles .................................................................................................................. 18

Usage Summary ............................................................................................................ 18

SOFTWARE AND HARDWARE REQUIREMENT .............................................................................. 20

General Requirement for Server/Client: .................................................................... 20

DEVELOPMENT TOOLS AND TECHNOLOGIES .............................................................................. 20

DEVELOPMENT TOOLS AND TECHNOLOGIES .............................................................................. 21

Front End ....................................................................................................................... 21

Back End ....................................................................................................................... 21

Development Environment ............................................................................................ 22

DESIGN GOALS AND CONSTRAINTS ................................................................................................. 22

Performance ................................................................................................................... 22

Availability .................................................................................................................... 22

Reliability ...................................................................................................................... 22

Scalability ...................................................................................................................... 22

Security .......................................................................................................................... 22

Interoperability .............................................................................................................. 22

Location ......................................................................................................................... 22

Setup/Installation ........................................................................................................... 22

USE CASE ................................................................................................................................................... 23

Page 7: MCA, Final Project for SMU

Railway Reservation System – eRail

Krishan Kumar Pareek, MCA – 6th Sem., Reg. No.: 571124530 Page: 7/107

Manage Users ................................................................................................................ 23

Description ................................................................................................................ 23

Business Need ........................................................................................................... 23

Priority ....................................................................................................................... 23

Manage Reservation ...................................................................................................... 23

Description ................................................................................................................ 23

Business Need ........................................................................................................... 23

Priority ....................................................................................................................... 23

Manage Cancellation ..................................................................................................... 23

Description ................................................................................................................ 23

Business Need ........................................................................................................... 23

Priority ....................................................................................................................... 23

PRN Query .................................................................................................................... 24

Description ................................................................................................................ 24

Business Need ........................................................................................................... 24

Priority ....................................................................................................................... 24

Use Case : Manage Users .............................................................................................. 24

Use Case Model: Manage Users ............................................................................... 25

Use Case Manage Reservation ............................................................................. 26

Use Case Manage Cancellation ............................................................................ 27

Use Case Manage Cancellation ............................................................................ 28

Use Case PRN Query ........................................................................................... 30

RAILWAY RESERVATION SYSTEM DATA DICTIONARY ............................................................ 32

Table : cancellation_rules .............................................................................................. 32

Table : cash_master ....................................................................................................... 32

Table : coach_type_master ............................................................................................ 33

Table : other_fees .......................................................................................................... 33

Table : reservation_master ............................................................................................ 34

Table : reservation_transaction ..................................................................................... 35

Table : stage_master ...................................................................................................... 35

Table : station_master ................................................................................................... 36

Table : train_master ....................................................................................................... 36

Table : train_schedule ................................................................................................... 37

Table : user_master ....................................................................................................... 37

RAILWAY RESERVATION SYSTEM– DATA SCHEMA ER DIAGRAM ........................................ 38

RAILWAY RESERVATION SYSTEM DFD (DATA FLOW DIAGRAM) .......................................... 39

Top Level DFD ............................................................................................................. 39

1st Level DFD ................................................................................................................ 39

CODING AND INTERFACE .................................................................................................................... 40

Railway Reservation System : Login ............................................................................ 40

Railway Reservation System : Main Screen ................................................................. 42

Railway Reservation System : User Master .................................................................. 44

Railway Reservation System : Change Password ......................................................... 50

Railway Reservation System : Station Master .............................................................. 53

Railway Reservation System : Train Master ................................................................. 59

Railway Reservation System : Train Schedule ............................................................. 66

Page 8: MCA, Final Project for SMU

Railway Reservation System – eRail

Krishan Kumar Pareek, MCA – 6th Sem., Reg. No.: 571124530 Page: 8/107

Railway Reservation System : Fare Rule Stage Master ................................................ 72

Railway Reservation System : Fare Rule Stage Master ................................................ 72

Railway Reservation System : Reservation ................................................................... 78

Railway Reservation System : Cancellation ................................................................. 90

Railway Reservation System : Cancellation ................................................................. 90

Railway Reservation System : Daily Transaction ......................................................... 95

Railway Reservation System : PRN Query ................................................................... 98

RAILWAY RESERVATION SYSTEM TEST PLAN ........................................................................... 101

Introduction ................................................................................................................. 101

Test Scope ................................................................................................................... 101

Test Strategy ................................................................................................................ 102

Preconditions ............................................................................................................... 102

Test Priorities .............................................................................................................. 102

Test Techniques ........................................................................................................... 103

Test Organization ........................................................................................................ 103

Roles and Responsibilities ........................................................................................... 103

Deliverables ................................................................................................................. 103

Test Environment ........................................................................................................ 104

Hardware and Software ............................................................................................... 104

Testing Automation Software ..................................................................................... 104

Application Configuration ........................................................................................... 104

Test Management ........................................................................................................ 105

Testing Schedules ........................................................................................................ 105

Threats to Testing ........................................................................................................ 105

CONCLUSION AND FUTURE ENHANCEMENT .............................................................................. 106

BIBLIOGRAPHY ..................................................................................................................................... 107

Websites ...................................................................................................................... 107

Books ........................................................................................................................... 107

Page 9: MCA, Final Project for SMU

Railway Reservation System – eRail

Krishan Kumar Pareek, MCA – 6th Sem., Reg. No.: 571124530 Page: 9/107

ABSTRACT

Proposed “Railway Reservation System” is developed for to automate the railway

reservation system. It includes modules required to successfully operate railway reversion

process smoothly. It has train master to add modify train information, Train schedule to

enter train journey details include all the station name, arrival time and departure time. It

includes automatic fare calculation as per the distance between two stations.

Reservation module consists of automatic seat no and coaches no allocation system. Daily

schedule for updation of not confirm seat and coach no.

All master like train master, train schedule, reservation fees, cancellation fees charges can be

modified individually from front end and changes reflect in all modules immediately.

Therefore proposed “Railway Reservation System” has been designed to automate the

process of railway for ticket reservation and back office activities. System can make the daily

activities efficient and providing the fast response.

It included inbuilt user management module to enhance security features as system handles

sensitive customer and finance data,

Page 10: MCA, Final Project for SMU

Railway Reservation System – eRail

Krishan Kumar Pareek, MCA – 6th Sem., Reg. No.: 571124530 Page: 10/107

Railway Management System Benefits

Complete end to end system for all the activities related to railway reservation

system.

Supports the full life cycle of ticket reservation, seat allocation, and ticket cancellation.

Reschedule the cancel seat to unconfirmed passenger.

It is a scalable system.

Has a clearly arranged and user-friendly interface

Easy to use and minimum data entry, all important details is mater driven and

provide in drop down list to make fast operation and avoid mistake.

Automatic fare calculation from stage master, in new updation of fare in stage master

will automatically reflect in all new reservation.

All important details can be updated by front end master module only.

Retrieval of forgotten passwords.

Integrated security features.

Scope and Features From an end-user perspective, the Railway Reservation System Project consists of three

functional elements: Security Module, Master Management Module, Transaction Module and

a Query Module.

Page 11: MCA, Final Project for SMU

Railway Reservation System – eRail

Krishan Kumar Pareek, MCA – 6th Sem., Reg. No.: 571124530 Page: 11/107

Security module

Security modules include security features like user management and application level

password management..

Maintain user master- Each user identified by the user name and user type. Only

admin user can create, edit user information.

Password must be 6 characters long.

Password must be alpha numeric.

While creating user system assign default password for the user, user must change

default password for first time login.

All login time stamp stored in the system for security audit.

Access level and roles and privileges are set for different type of users.

Master Management module

Master management module includes following sub modules..

Station Master – Every station is uniquely identified by system generated Station ID.

It also includes station code, station name and railway division name.

Train Master – Every train uniquely identified by train no, it includes train name,

train schedule which days of the week train will run. No of coaches available for 3 tier

AC, First Class, Slipper Class etc.

Train Schedule – It includes train journey details from start station to end station, all

in between station, distances between 2 station, arrival and departure time.

Fare Rule – It help to calculate fare by distance, support different type of fare

calculation for different class like AC1, AC3 etc.

Cancellation Fees Rule - It provide the master data for all ticket cancellation fees

calculation.

Reservation and Super Fast Fees – It provide the master data for all ticket

cancellation fees calculation.

Page 12: MCA, Final Project for SMU

Railway Reservation System – eRail

Krishan Kumar Pareek, MCA – 6th Sem., Reg. No.: 571124530 Page: 12/107

Transaction Module

Transaction module includes following sub modules.

Reservation – This module used to make reservation, it asks for input data like train

no, journey date, from station code, end station code. System has powerful validation

rule to check validation like journey date must be greeter than system date, journey

date must be within 90 days. Train should run for the selected day. Check for from

station and to station. Seat availability, While saving the record system generate PRN

no, seat no and coach no. Before save the system ask for final confirmation. System

automatically calculates the fare and save the details.

Cancellation – For cancellation of ticket it ask for PRN no, after entering the correct

PRN no system check for validity of the PRN no, whether it already cancelled, journey

date already expired. I it validate system display all the details of the reservation.

System automatically calculates the cancellation fees from the cancellation rule

master. Before save the record system ask for the confirmation.

Update Seat no for unconfirmed passenger – It is schedule activity, system query

for all cancelled ticket for particular journey date and allocates all vacant seat to

unconfirmed passenger.

Daily Cash Transaction – It shows daily transaction, like how much money received

and how much money refund. All data can be exported to MS Excel for review and

save in file system.

Query Module

A powerful query module give on screen information for particular PRN NO, it shows all the

reservation details and cancellation details, include current status for the seat no, coach no.

Both of these areas of functionality will be delivered as the first version of the Railway

Reservation System is released. Functionality is described in more detail later in this

document.

Page 13: MCA, Final Project for SMU

Railway Reservation System – eRail

Krishan Kumar Pareek, MCA – 6th Sem., Reg. No.: 571124530 Page: 13/107

Out of Scope

The following functions are considered out of scope for Version 1 of the Railway Reservation System. Versions 2.0 address items not in scope and those deemed not feasible during V1.0.

Function Comment Version

Linking and integration of any legacy system for accounting.

Required by management to control and maintain the accounting activity

2

Integration with banks and other credit verification agency

Help to updated and share the data

2

Connection to third-party OLAP applications

2

Sophisticated system to host in internet and used to connect all travel agents.

2

Electronic Data Interchange (EDI) system between different department

Aimed to reduce costs and time in the data sharing

2

Goal and objective

This section presents a conceptual overview of the solution, and then provides an

introduction to its requirements.

Solution Concept

The Railway Reservation System consists of:

Security Modules:

Security modules include security features like user management and application

level password management.

Master Management module: It includes all master like station, train, all rules which

are used to calculate fare and cancellation charges.

Transaction Module – It includes reservation, cancellation of ticket. Update of seat

no and coach no for unconfirmed passengers.

Query Modules.

A powerful query module give on screen information for particular PRN no, system

user can view all information for particular ticket in one screen by entering PRN no.

Page 14: MCA, Final Project for SMU

Railway Reservation System – eRail

Krishan Kumar Pareek, MCA – 6th Sem., Reg. No.: 571124530 Page: 14/107

Problem Statement

Requirements Summary

The following preliminary lists are based on initial interviews

Business Requirements

The business goal for the application is to support an increase the productivity and complete automation of existing manual or semi automatic railway reservation process. Business requirements are discussed in the Scope section, with the following additional detail:

Improve the search facility and system users should get all the information in a second.

System should have security features in built as it handles sensitive personal and finance information of the customer.

User must not delete any data, Administrator can only have the rights to delete the data,

System Administrator must able to control the access rights by each user as per requirement.

The application should support the capability to use multi user environment. The system users want to improve their current ability to analyze customer data. In particular, they want to focus on identifying their best customer and who are defaulter. To enable them to accomplish this goal, they want to extract meaningful data that easily answers the following questions:

What are the early warning signs of problems? Who is my best route? What is the most used and busy train? Payment pattern of the customer? Cancellation pattern of customer? What are my customers' issues as groups?

User Requirements

User requirements are categorized by user type. System Users

Able to search and view the ticket information by only PRN no.. Able to find all the information like reservation details, seat details, in one screen to

give answer to customer query. Must able to change the his or her own password System must able to calculate all fare automatically.

Page 15: MCA, Final Project for SMU

Railway Reservation System – eRail

Krishan Kumar Pareek, MCA – 6th Sem., Reg. No.: 571124530 Page: 15/107

Supervisor

All mater details should be updated from front end only.. All data must be exported to ms excel

Operational Requirements

The following requirements provide a high-level view of how the system will run:

Processor usage should not exceed 80 percent during concurrent uses. Backups will occur incrementally throughout the day. A full weekly backup is required to WORM drives. Ensure that information is easy to access either, and meaningful for the system users

and the company. Minimize the technical knowledge that system users need to access the data, generate

ad hoc queries, search and view information. Any change to information must be reflected immediately, and the changes must be

propagated to the search engine so that system users that perform searches see this new information.

The application should work with the existing communications and networking infrastructure.

The application should deploy with a minimum of additional operational processes, manual or otherwise.

Page 16: MCA, Final Project for SMU

Railway Reservation System – eRail

Krishan Kumar Pareek, MCA – 6th Sem., Reg. No.: 571124530 Page: 16/107

System Architecture

High Level Solution Architecture

High Level Solution Architecture of online Railway Reservation System

Data Data Warehouse

OLAP Access

Data Access

OLTP Access

Passenge

r

Train Schedule Fare Search and

Retrieval

of

Information

Transactional Facade Retrieval Facade

System

Windows

Application

Microsoft VB Run

Time

OLEDB Database

Engine

Analysis and

Query

Page 17: MCA, Final Project for SMU

Railway Reservation System – eRail

Krishan Kumar Pareek, MCA – 6th Sem., Reg. No.: 571124530 Page: 17/107

Data Flow and Process Flow Chart

Start

Login

Login Success

Reservation

Master

Management

End

Not Success

Start up

screen

Cancellation

Enter PRN no

and cancel the

ticket

Enter all

information

and add new

ticket

Process, as

per user

rights

Page 18: MCA, Final Project for SMU

Railway Reservation System – eRail

Krishan Kumar Pareek, MCA – 6th Sem., Reg. No.: 571124530 Page: 18/107

User Profiles

The following user types are expected for the Railway Reservation System: User Brief Description of Use Actions USER Minimum rights to the system, query the

information can add, edit some modules. Supervisor Reservation, Cancellation, Make, However can not

delete any information. System Administrator

Create new system users, set and alter the role and privilege to the system users for accessing the system resource. Can delete the data. Also responsible to database backup, backend performance. And overall the system performance.

Usage Summary

Railway Reservation System Version 1.0 will address the following use cases. The complete usage scenarios will be completed during the information-gathering process. Use cases will be created and prioritized. Selected use cases will be expanded into usage scenarios and features that are derived from both use cases and the usage scenarios, as represented in the following diagram:

Page 19: MCA, Final Project for SMU

Railway Reservation System – eRail

Krishan Kumar Pareek, MCA – 6th Sem., Reg. No.: 571124530 Page: 19/107

Usage summary use case

Page 20: MCA, Final Project for SMU

Railway Reservation System – eRail

Krishan Kumar Pareek, MCA – 6th Sem., Reg. No.: 571124530 Page: 20/107

Software and Hardware Requirement

General Requirement for Server/Client:

Type Software Hardware Work Station/ Node 1. Windows XP

2. VB Run time 3. MS Office

1. P-4 2. RAM -256 MB

Database Server 1.Win2000 Advance Server

1.P-4 2.RAM- 2GB 3.Hard Disk-160GB 4.RAID

Application Server 1.Win 2000 Advance Server

1.P-4 2.RAM- 1GB 3.Hard Disk-40GB

Application Server Data Base Server

Workstation 1 Workstation 2 Workstation 3 Workstation N

Page 21: MCA, Final Project for SMU

Railway Reservation System – eRail

Krishan Kumar Pareek, MCA – 6th Sem., Reg. No.: 571124530 Page: 21/107

Development Tools and Technologies

Front End

1. VB 6 Why VB6? VB6 is built on the Windows Server System to take major advantage of the OS and which comes with a host of different servers which allows for building, deploying, managing and maintaining Windows Based solutions. The Windows Server System is designed with performance as priority and it provides scalability, reliability. The advantage of VB.NET includes

Rapid Application Development (RAD) Support. Powerful Windows-based Applications Simplified Deployment Powerful, Flexible, Simplified Data Access Improved Coding Direct Access to the OS Platform Object-Oriented Constructs COM Interoperability

Back End 1. MS Access

Why MS Access? MS Access is desktop RDMS support small application with all features like relational query, different data types, joins, and query. Includes

Easy to use and easy to deployment. Integration with Windows OS Scalability Import and Export of data in all major database system. Centralized Management Reliability Automating Tasks

Page 22: MCA, Final Project for SMU

Railway Reservation System – eRail

Krishan Kumar Pareek, MCA – 6th Sem., Reg. No.: 571124530 Page: 22/107

Development Environment

1. Visual Studio 6.0 2. Microsoft Office

Design Goals and Constraints

Performance No more than 5-percent degradation in average query response is allowed while all concurrent users are using the system. Processor utilization should not exceed 80 percent during all concurrent users are using the system.

Availability Because the system is accessed by users of the bank and staff for customer query, and their should not be any single point of failure.

Reliability

Because of the need no single point failure, automatic failover will be required. In addition, existing disaster recovery and backup plans and procedures must be revised to incorporate the Railway Reservation System.

Scalability

Railway Reservation System an average load of 25 concurrent users after the system is fully operational, and expects that to grow by 5 percent each year for the next five years.

Security For the sensitive member information, all users will need to log on the system with their user id and password. Every resource in the system are defined by the role and privileged. System administrator assigned user role and privileged for their access rights.

Interoperability

In Version 1.0 of the Railway Reservation System, there are no requirements for interoperability with other systems.

Location The Railway Reservation System is implemented in banks existing network.

Setup/Installation Setup and installation must not interrupt the system user’s daily tasks and work flow.

Page 23: MCA, Final Project for SMU

Railway Reservation System – eRail

Krishan Kumar Pareek, MCA – 6th Sem., Reg. No.: 571124530 Page: 23/107

Use Case

Manage Users

Description

This function will enable administrator to modify user information.

Business Need

This function will enable system users to interact with Railway Reservation System catalog directly without the intervention of any other employees.

Priority

Medium

Manage Reservation

Description

This function allows user of Railway Reservation System to create new ticket reservation.

Business Need

This function will support the system users to create new reservation

Priority

High

Manage Cancellation

Description

This function enables the user to cancel ticket.

Business Need

This function enables user of Railway Reservation System to have enter PRN no and cancel ticket.

Priority

High

Page 24: MCA, Final Project for SMU

Railway Reservation System – eRail

Krishan Kumar Pareek, MCA – 6th Sem., Reg. No.: 571124530 Page: 24/107

PRN Query

Description

This function allows system user query to database for ticket information.

Business Need

This function will allow user to retrieve the latest ticket. Information by providing PRN no

Priority

High

Use Case : Manage Users

Title: Manage Users Abbreviated Title: Manage Users Requirement ID: 21 Intent Manage the user information; modify the contact details of a user. Scenario Narrative

Administrator may want to modify the contact details of a user.

Assumptions/Preconditions

System users have access rights to view user data.

Actors

Administrator

Basic Course

Use case begins when the actor decides to modify user information. System opens the user master information. Actor navigates the required information from. Actor press Edit button and make the necessary changes in the record. Actor press Save button to save the record in the user master catalog. Use case ends when the selected information is passed to a method of delivery.

Page 25: MCA, Final Project for SMU

Railway Reservation System – eRail

Krishan Kumar Pareek, MCA – 6th Sem., Reg. No.: 571124530 Page: 25/107

Alternate Course

If no appropriate user information, system reports this fact. Use case restarts to enable users to update the type of user information.

Future Requirements

The system users may want to apply filters to the retrieved data. The system users may want to sort the data. For example, the system user want to list the

names of user in chronological order based on the entry date.

Use Case Model: Manage Users

Administrator

Update Master

Navigate Users

User Master Modify Details

Apply

Validation

Page 26: MCA, Final Project for SMU

Railway Reservation System – eRail

Krishan Kumar Pareek, MCA – 6th Sem., Reg. No.: 571124530 Page: 26/107

Use Case Manage Reservation

Title: Manage Reservation Abbreviated Title: Manage Reservation Requirement ID: 13 Intent Enable actor to create new reservation. Scenario Narrative

Actors want to create new reservation

Assumptions/Preconditions

The actor has rights to access to the Railway Reservation System, and having rights to make new reservation.

Actors

User Supervisor Administrator

Basic Course:

Use case begins when actor decides create new reservation. The system displays new reservation screen. Actor supply all the required details like train no, journey date, station code, passenger

details. System validates all the information. System generates PRN no, new seat no and coach no, calculate ticket fare. System asks for user confirmation. Actor confirms the ticket. Use case ends when information is presented to the correct method of delivery.

Page 27: MCA, Final Project for SMU

Railway Reservation System – eRail

Krishan Kumar Pareek, MCA – 6th Sem., Reg. No.: 571124530 Page: 27/107

Use Case Model: Manage Reservation

User

Administrator

Transaction

Check train

schedule

Add passenger

details

Validation

Supervisor

Add Train No,

Journey details

Page 28: MCA, Final Project for SMU

Railway Reservation System – eRail

Krishan Kumar Pareek, MCA – 6th Sem., Reg. No.: 571124530 Page: 28/107

Use Case Manage Cancellation

Title: Manage Cancellation Abbreviated Title: Manage Cancellation Requirement ID: 16 Intent Enable actor to cancel the ticket.. Scenario Narrative

An actor wants to cancel ticket. Assumptions/Preconditions

The actor has rights to access to the Railway Reservation System, and having rights to cancel ticket.

Actor

User Supervisor Administrator

Basic Course:

Use case begins when actor decides to cancel ticket. Actor enters PRN No. System validates PRN no. Systems displays reservation details, calculate cancellation fees. System asks for confirmation. Actor confirms cancellation. System update the database: Use case ends when information is presented to the correct method of delivery.

Page 29: MCA, Final Project for SMU

Railway Reservation System – eRail

Krishan Kumar Pareek, MCA – 6th Sem., Reg. No.: 571124530 Page: 29/107

Use Case Model: Manage Cancellation

User

Cancellation

Rule

Ask for

confirmation

Enter PRN No

Calculate

Cancellation

Reservation

Deatils

Validate the

PRN No

Fees Master

Transcation

Update Details

Page 30: MCA, Final Project for SMU

Railway Reservation System – eRail

Krishan Kumar Pareek, MCA – 6th Sem., Reg. No.: 571124530 Page: 30/107

Use Case PRN Query

Title: PRN Query Abbreviated Title: PRN Query Requirement ID: 19 Intent Enable actor to query the database for latest ticket information. Scenario Narrative

An actor wants view the details of reservation by supplying PRN no.

Assumptions/Preconditions

The actor has rights to access to the Railway Reservation System, and having rights to query the database for reservation details.

Actors

User Supervisor

Basic Course:

Use case begins when actor want to view the reservation details. Actor enters PRN no. System validates PRN no. Systems displays latest information related to reservation, seat no coach no..

Page 31: MCA, Final Project for SMU

Railway Reservation System – eRail

Krishan Kumar Pareek, MCA – 6th Sem., Reg. No.: 571124530 Page: 31/107

Use Case: PRN Query

User

Reservation

Transaction

Display Fare

Enter PRN NO

Display

Passenger

DEatils

Reservation

Master

View the

Reservation

details

Latest Seat and

coach no

Fare Rules

Supervisor

Validate PRN

No

Page 32: MCA, Final Project for SMU

Railway Reservation System – eRail

Krishan Kumar Pareek, MCA – 6th Sem., Reg. No.: 571124530 Page: 32/107

Railway Reservation System Data Dictionary

Table : cancellation_rules Owner: dbo Destination DB name: erail Number of columns: 4 Number of indexes: 1 Number of foreign keys: 0 Extended attributes:

OnFileGroup PRIMARY Clustered PK Yes

Columns Data type Allow NULLs Value/range can_id Number Not allowed before_24h Number Not allowed before_12h Number Not allowed before_1h Number Not allowed Indexes Type Columns PK_cancellation_rules_can_id clustered, unique, primary key

located on PRIMARY can_id

Table : cash_master Owner: dbo Destination DB name: erail Number of columns: 6 Number of indexes: 2 Number of foreign keys: 1 Extended attributes:

OnFileGroup PRIMARY Clustered PK Yes

Columns Data type Allow NULLs Value/range cash_id Number Not allowed prn_no Number Not allowed amount_received Number Not allowed amount_refund Number Not allowed trn_date Date/Time Not allowed trn_by Number Not allowed Indexes Type Columns PK_cash_master_cash_id clustered, unique, primary key

located on PRIMARY cash_id

IX_cash_master_ prn_no nonclustered located on PRIMARY

prn_no

Page 33: MCA, Final Project for SMU

Railway Reservation System – eRail

Krishan Kumar Pareek, MCA – 6th Sem., Reg. No.: 571124530 Page: 33/107

Table : coach_type_master Owner: dbo Destination DB name: erail Number of columns: 1 Number of indexes: 1 Number of foreign keys: 0 Extended attributes:

OnFileGroup PRIMARY Clustered PK Yes

Columns Data type Allow NULLs Value/range coach_type Text Not allowed Indexes Type Columns PK_coach_type_master_coach_type clustered, unique, primary key

located on PRIMARY coach_type

Table : other_fees Owner: dbo Destination DB name: erail Number of columns: 3 Number of indexes: 2 Number of foreign keys: 1 Extended attributes:

OnFileGroup PRIMARY Clustered PK Yes

Columns Data type Allow NULLs Value/range coach_type Number Not allowed re_fess Number Not allowed sf_fees Number Not allowed Indexes Type Columns PK_other_fees_master_coach_type clustered, unique, primary key

located on PRIMARY coach_type

Page 34: MCA, Final Project for SMU

Railway Reservation System – eRail

Krishan Kumar Pareek, MCA – 6th Sem., Reg. No.: 571124530 Page: 34/107

Table : reservation_master Owner: dbo Destination DB name: erail Number of columns: 15 Number of indexes: 3 Number of foreign keys: 2 Extended attributes:

OnFileGroup PRIMARY Clustered PK Yes

Columns Data type Allow NULLs Value/range prn_no Number Not allowed train_no Number Not allowed coach_type Text Not allowed journey_date Date/Time Not allowed from_station Number Not allowed to_station Number Not allowed boarding_at Number Not allowed re_fees Number Not allowed sf_fees Number Not allowed ti_fees Number Not allowed cancel_fees Number Not allowed create_by Number Not allowed create_date Date/Time Not allowed cancel_by Number Allowed cancel_date Date/Time Allowed Indexes Type Columns PK_reservation_master_ prn_no clustered, unique, primary key

located on PRIMARY prn_no

IX_reservation_master_train_no nonclustered located on PRIMARY

train_no

IX_reservation_master_coach_type nonclustered located on PRIMARY

coach_type

Page 35: MCA, Final Project for SMU

Railway Reservation System – eRail

Krishan Kumar Pareek, MCA – 6th Sem., Reg. No.: 571124530 Page: 35/107

Table : reservation_transaction Owner: dbo Destination DB name: erail Number of columns: 9 Number of indexes: 2 Number of foreign keys: 1 Extended attributes:

OnFileGroup PRIMARY Clustered PK Yes

Columns Data type Allow NULLs Value/range trn_id Number Not allowed prn_no Text Not allowed p_name Text Not allowed p_gender Text Not allowed p_age Number Not allowed Coach Text Not allowed seat_no Text Allowed confirm Text Allowed is_cancel Text Allowed Indexes Type Columns PK_reservation_master_trn_id clustered, unique, primary key

located on PRIMARY Trn_id

IX_reservation_transaction_ prn_no nonclustered located on PRIMARY

prn_no

Table : stage_master Owner: dbo Destination DB name: erail Number of columns: 5 Number of indexes: 2 Number of foreign keys: 1 Extended attributes:

OnFileGroup PRIMARY Clustered PK Yes

Columns Data type Allow NULLs Value/range stage_id Number Not allowed coach_type Text Not allowed dis_from Number Not allowed dis_upto Number Not allowed ticket_amount Number Not allowed Indexes Type Columns PK_stage_master_stage_id clustered, unique, primary key

located on PRIMARY stage_id

IX_stage_master_ coach_type nonclustered located on PRIMARY

coach_type

Page 36: MCA, Final Project for SMU

Railway Reservation System – eRail

Krishan Kumar Pareek, MCA – 6th Sem., Reg. No.: 571124530 Page: 36/107

Table: station_master Owner: dbo Destination DB name: erail Number of columns: 4 Number of indexes: 1 Number of foreign keys: 0 Extended attributes:

OnFileGroup PRIMARY Clustered PK Yes

Columns Data type Allow NULLs Value/range station_id Number Not allowed station_code Text Not allowed station_name Text Not allowed railway_type Text Not allowed Indexes Type Columns PK_station_master_station_id clustered, unique, primary key

located on PRIMARY Station_id

Table : train_master Owner: dbo Destination DB name: erail Number of columns: 11 Number of indexes: 1 Number of foreign keys: 0 Extended attributes:

OnFileGroup PRIMARY Clustered PK Yes

Columns Data type Allow NULLs Value/range train_no Number Not allowed train_name Text Not allowed train_typ Text Not allowed schedule Text Not allowed A1 Number Not allowed A2 Number Not allowed A3 Number Not allowed SL Number Not allowed GN Number Not allowed GL Number Not allowed AR Number Not allowed Indexes Type Columns PK_train_master_ train_no clustered, unique, primary key

located on PRIMARY Train_no

Page 37: MCA, Final Project for SMU

Railway Reservation System – eRail

Krishan Kumar Pareek, MCA – 6th Sem., Reg. No.: 571124530 Page: 37/107

Table : train_schedule Owner: dbo Destination DB name: erail Number of columns: 7 Number of indexes: 2 Number of foreign keys: 1 Extended attributes:

OnFileGroup PRIMARY Clustered PK Yes

Columns Data type Allow NULLs Value/range schedule_id Number Not allowed train_no Number Not allowed station_id Number Not allowed distance Number Not allowed arival_time Date/Time Not allowed departure_time Date/Time Not allowed day Number Not allowed Indexes Type Columns PK_train_schedule_schedule_id clustered, unique, primary key

located on PRIMARY schedule_id

IX_stage_master_train_no nonclustered located on PRIMARY

train_no

Table : user_master Owner: dbo Destination DB name: data Number of columns: 16 Number of indexes: 2 Number of foreign keys: 0 Extended attributes:

OnFileGroup PRIMARY Clustered PK Yes

Columns Data type Allow NULLs Value/range user_id Number Not allowed user_name Text Not allowed user_password Text Not allowed user_type Text Not allowed user_active Number Not allowed user_department Text Not allowed user_desgination Text Allowed user_dob Text Allowed user_address Text Allowed user_contact_no Text Allowed user_email_id Text Allowed create_date Date/Time Not allowed create_by Number Not allowed last_pass_chg_date Date/Time Not allowed last_login1 Date/Time Not allowed last_login2 Date/Time Not allowed Indexes Type Columns PK_user_master_user_id clustered, unique, primary key

located on PRIMARY user_id

IX_ user_master_user_name nonclustered located on PRIMARY

User_name

Page 38: MCA, Final Project for SMU

Railway Reservation System – eRail

Krishan Kumar Pareek, MCA – 6th Sem., Reg. No.: 571124530 Page: 38/107

Railway Reservation System– Data Schema ER Diagram

Page 39: MCA, Final Project for SMU

Railway Reservation System – eRail

Krishan Kumar Pareek, MCA – 6th Sem., Reg. No.: 571124530 Page: 39/107

Railway Reservation System DFD (Data Flow Diagram)

Top Level DFD

1st Level DFD

Train No

Railway

Reservation

System

Fare Rules

Stations

PRN

Users

Search PRN

1

Reservation

Master

Calculate Fees

2

Cancel the Ticket

3

Passenger

Details

Page 40: MCA, Final Project for SMU

Railway Reservation System – eRail

Krishan Kumar Pareek, MCA – 6th Sem., Reg. No.: 571124530 Page: 40/107

Coding and Interface

Railway Reservation System : Login FrmLogin

Option Explicit '>>> check for no of attempt Dim intAttempt As Integer Private Sub CmdClose_Click() End End Sub Private Sub CmdOK_Click() '>>> check login '>>> validation If TxtUserName.Text = "" Then MsgBox "Enter user name", vbCritical TxtUserName.SetFocus Exit Sub End If If TxtPassword.Text = "" Then MsgBox "Enter password", vbCritical TxtPassword.SetFocus Exit Sub End If

Page 41: MCA, Final Project for SMU

Railway Reservation System – eRail

Krishan Kumar Pareek, MCA – 6th Sem., Reg. No.: 571124530 Page: 41/107

Dim ChValid As Boolean ChValid = False Dim Rs1 As New ADODB.Recordset If Rs1.State = 1 Then Rs1.Close Rs1.Open "select * from user_master where user_name='" & TxtUserName.Text & "'", Cn, adOpenStatic, adLockReadOnly If Rs1.RecordCount > 0 Then '>>> check for password If Rs1("user_password") = TxtPassword.Text Then UserName = Rs1("User_name") UserType = Rs1("user_type") UserID = Rs1("user_id") If IsNull(Rs1("last_login2")) = True Then LastLogin = "First Login" Else LastLogin = Rs1("last_login1") End If ChValid = True '>>> check for first login '>>> propmt for change password If IsNull(Rs1("last_pass_chg_date")) = True Then FirstLoin = True Else FirstLoin = False End If '>>> update login date Cn.Execute "update user_master set last_login2=last_login1, last_login1=now() where user_id =" & Rs1("user_id") Else '>>> invalid password MsgBox "Can't Login, invalid password.", vbCritical TxtPassword.SelStart = 0 TxtPassword.SelLength = Len(TxtPassword.Text) TxtPassword.SetFocus End If Else '>>> invalid user name MsgBox "Can't Login, user name not found.", vbCritical TxtUserName.SelStart = 0 TxtUserName.SelLength = Len(TxtUserName.Text) TxtUserName.SetFocus End If If Rs1.State = 1 Then Rs1.Close If ChValid = True Then Unload Me FrmMain.Show

Page 42: MCA, Final Project for SMU

Railway Reservation System – eRail

Krishan Kumar Pareek, MCA – 6th Sem., Reg. No.: 571124530 Page: 42/107

Else intAttempt = intAttempt + 1 If intAttempt > 4 Then MsgBox "You try more than 3 time with invalid login details, restart the application and try again.", vbExclamation CmdOK.Enabled = False Exit Sub End If End If End Sub Private Sub Form_Load() If Cn.State = 1 Then Cn.Close Cn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\DATA.mdb" & ";Persist Security Info=true" Cn.CursorLocation = adUseClient Cn.Open '>>> initital attempt intAttempt = 1 End Sub

Railway Reservation System : Main Screen

FrmMain

Page 43: MCA, Final Project for SMU

Railway Reservation System – eRail

Krishan Kumar Pareek, MCA – 6th Sem., Reg. No.: 571124530 Page: 43/107

Option Explicit Private Sub MDIForm_Activate() If CheckStartForm = False Then CheckStartForm = True frmStart.Show 1 End If End Sub Private Sub MDIForm_Load() If FirstLoin = True Then Dim OldCap As String OldCap = FrmChangePassword.Caption FrmChangePassword.Caption = "LMS :: CHANGE YOUR DEFAULT PASSWORD ... FOR FIRST TIME LOGIN" FrmChangePassword.Show 1 FrmChangePassword.Caption = OldCap FirstLoin = False End If StatusBar1.Panels(1).Text = UserName StatusBar1.Panels(2).Text = Now End Sub Private Sub Timer1_Timer() StatusBar1.Panels(2).Text = Now End Sub Private Sub Toolbar1_ButtonClick(ByVal Button As MSComctlLib.Button) '>>> open diffrent forms If Button.Key = "users" Then If UserType = "ADMIN" Then FrmUsers.Show 1 Else MsgBox "You don't have access rights to user master.", vbExclamation Exit Sub End If ElseIf Button.Key = "changepassword" Then FrmChangePassword.Show 1 ElseIf Button.Key = "user" Then If UserType = "USER" Then MsgBox "You are not authorized to view deatils.", vbExclamation, vbExclamation Exit Sub End If

Page 44: MCA, Final Project for SMU

Railway Reservation System – eRail

Krishan Kumar Pareek, MCA – 6th Sem., Reg. No.: 571124530 Page: 44/107

ElseIf Button.Key = "masters" Then FrmMasters.Show 1 ElseIf Button.Key = "reservation" Then FrmReservation.Show 1 ElseIf Button.Key = "cancellation" Then FrmCancellation.Show 1 ElseIf Button.Key = "pnrquery" Then FrmPRNQuery.Show 1 ElseIf Button.Key = "transaction" Then FrmTransaction.Show 1 ElseIf Button.Key = "exit" Then End End If End Sub

Railway Reservation System : User Master

FrmUsers

Option Explicit Dim Rs1 As New ADODB.Recordset Dim AddEdit As String Private Sub Command1_Click() '>>> close form Unload Me End Sub

Page 45: MCA, Final Project for SMU

Railway Reservation System – eRail

Krishan Kumar Pareek, MCA – 6th Sem., Reg. No.: 571124530 Page: 45/107

Private Sub Command11_Click() '>>> delete curren record '>>> only admin user can delete record If CheckAdminValid(UserType) = False Then Exit Sub If Rs1.State = adStateClosed Then Exit Sub If Rs1.RecordCount <= 0 Then Exit Sub On Error GoTo myer1 '>>> confirm before delete If MsgBox("Delete the Record ? ", vbCritical + vbYesNo) = vbYes Then Rs1.Delete Call ClearText '>>> show next record Command4_Click End If Exit Sub myer1: MsgBox "Error Occured : " & Err.Description, vbCritical End Sub Private Sub Command2_Click() '>>> move record set to first record and display the record On Error Resume Next If Rs1.State = adStateClosed Then Exit Sub If Rs1.RecordCount <= 0 Then Exit Sub Rs1.MoveFirst Call displayRecord End Sub Private Sub Command3_Click() '>>> move record set back and display the record On Error Resume Next If Rs1.State = adStateClosed Then Exit Sub If Rs1.RecordCount <= 0 Then Exit Sub '>>> check for recordset position If Rs1.AbsolutePosition > 1 Then Rs1.MovePrevious Else MsgBox "First Record ..", vbInformation Rs1.MoveFirst End If Call displayRecord End Sub Private Sub Command4_Click() '>>> move record set next and display the record On Error Resume Next If Rs1.State = adStateClosed Then Exit Sub If Rs1.RecordCount <= 0 Then Exit Sub

Page 46: MCA, Final Project for SMU

Railway Reservation System – eRail

Krishan Kumar Pareek, MCA – 6th Sem., Reg. No.: 571124530 Page: 46/107

'>>> check for recordset position If Rs1.AbsolutePosition < Rs1.RecordCount Then Rs1.MoveNext Else MsgBox "Last Record ..", vbInformation Rs1.MoveLast End If Call displayRecord End Sub Private Sub Command5_Click() '>>> move record set to last record and display the record On Error Resume Next If Rs1.State = adStateClosed Then Exit Sub If Rs1.RecordCount <= 0 Then Exit Sub Rs1.MoveLast Call displayRecord End Sub Private Sub Command6_Click() '>>> add new record '>>> set flag to add '>>> clear all fields If Rs1.State = adStateClosed Then Exit Sub AddEdit = "ADD" Call ClearText DE False, True TxtUserName.SetFocus End Sub Private Sub Command7_Click() '>>> edit the current record '>>> set flag to edit If Rs1.State = adStateClosed Then Exit Sub If Rs1.RecordCount <= 0 Then Exit Sub AddEdit = "EDIT" DE False, True TxtUserName.SetFocus End Sub Private Sub Command8_Click() '>>> update the record '>>> check the flag If Rs1.State = adStateClosed Then Exit Sub ''On Error GoTo myer1 '>>> valdation

Page 47: MCA, Final Project for SMU

Railway Reservation System – eRail

Krishan Kumar Pareek, MCA – 6th Sem., Reg. No.: 571124530 Page: 47/107

If Trim(TxtUserName.Text) = "" Then MsgBox "Enter user name ", vbCritical TxtUserName.SetFocus Exit Sub End If If Trim(CmbUserType.Text) = "" Then MsgBox "Enter/Select user type.", vbCritical CmbUserType.SetFocus Exit Sub End If '>>> check for user type, must select from the combo box Dim Ch As Boolean Ch = False Dim i As Integer For i = 0 To CmbUserType.ListCount - 1 If CmbUserType.Text = CmbUserType.List(i) Then Ch = True Exit For End If Next If Ch = False Then MsgBox "Select user type from the list.", vbExclamation CmbUserType.SetFocus Exit Sub End If '>>> check the add edit flag If AddEdit = "ADD" Then Dim LastSno As Integer Dim Rs2 As New ADODB.Recordset If Rs2.State = 1 Then Rs2.Close Rs2.Open "select max(user_id) from user_master", Cn, adOpenStatic, adLockReadOnly LastSno = IIf(IsNull(Rs2(0).Value) = True, 0, Rs2(0).Value) + 1 Rs1.AddNew Rs1("user_id") = LastSno Rs1("user_name") = TxtUserName.Text Rs1("user_password") = "123456" Rs1("user_type") = CmbUserType.Text If ChkActiveUser.Value = 1 Then Rs1("user_active") = 1 Else Rs1("user_active") = 0 End If Rs1("user_department") = TxtDepartment.Text Rs1("user_desgination") = TxtDesignnation.Text Rs1("user_dob") = DtDOB.Value Rs1("user_address") = TxtAddress.Text Rs1("user_contact_no") = TxtContactNo.Text Rs1("user_email_id") = TxtEmailID.Text

Page 48: MCA, Final Project for SMU

Railway Reservation System – eRail

Krishan Kumar Pareek, MCA – 6th Sem., Reg. No.: 571124530 Page: 48/107

Rs1("create_date") = Now Rs1("create_by") = UserID Rs1.Update Rs1.MoveLast Call displayRecord Else Rs1("user_name") = TxtUserName.Text Rs1("user_type") = CmbUserType.Text If ChkActiveUser.Value = 1 Then Rs1("user_active") = 1 Else Rs1("user_active") = 0 End If Rs1("user_department") = TxtDepartment.Text Rs1("user_desgination") = TxtDesignnation.Text Rs1("user_dob") = DtDOB.Value Rs1("user_address") = TxtAddress.Text Rs1("user_contact_no") = TxtContactNo.Text Rs1("user_email_id") = TxtEmailID.Text Rs1.Update Dim p As Integer p = Rs1.AbsolutePosition Rs1.Requery Rs1.MoveFirst Rs1.Move p - 1 Call displayRecord End If DE True, False Exit Sub myer1: MsgBox "Error Occured : " & Err.Description, vbCritical End Sub Private Sub Command9_Click() DE True, False End Sub Private Sub Form_Load() Me.Move (Screen.Width - Width) / 2, (Screen.Height - Height) / 2 ClearText CmbUserType.Clear CmbUserType.AddItem "ADMIN" CmbUserType.AddItem "SUPERVISOR" CmbUserType.AddItem "USER" If Rs1.State = adStateOpen Then Rs1.Close Rs1.Open "select * from user_master order by user_id ", Cn, adOpenDynamic, adLockOptimistic If Rs1.RecordCount > 0 Then

Page 49: MCA, Final Project for SMU

Railway Reservation System – eRail

Krishan Kumar Pareek, MCA – 6th Sem., Reg. No.: 571124530 Page: 49/107

Rs1.MoveFirst Call displayRecord End If DE True, False End Sub Private Sub ClearText() TxtUserID.Text = "" ChkActiveUser.Value = 1 TxtUserName.Text = "" CmbUserType.Text = "" TxtDepartment.Text = "" TxtDesignnation.Text = "" DtDOB.Value = Now TxtAddress.Text = "" TxtContactNo.Text = "" TxtEmailID.Text = "" End Sub Private Sub displayRecord() TxtUserID.Text = IIf(IsNull(Rs1("user_id")) = True, "", Rs1("user_id")) If Rs1("user_active") = 1 Then ChkActiveUser.Value = 1 Else ChkActiveUser.Enabled = 0 End If TxtUserName.Text = IIf(IsNull(Rs1("user_name")) = True, "", Rs1("user_name")) CmbUserType.Text = IIf(IsNull(Rs1("user_type")) = True, "", Rs1("user_type")) TxtDepartment.Text = IIf(IsNull(Rs1("user_department")) = True, "", Rs1("user_department")) TxtDesignnation.Text = IIf(IsNull(Rs1("user_desgination")) = True, "", Rs1("user_desgination")) DtDOB.Value = IIf(IsNull(Rs1("user_dob")) = True, Now, Rs1("user_dob")) TxtAddress.Text = IIf(IsNull(Rs1("user_address")) = True, "", Rs1("user_address")) TxtContactNo.Text = IIf(IsNull(Rs1("user_contact_no")) = True, "", Rs1("user_contact_no")) TxtEmailID.Text = IIf(IsNull(Rs1("user_email_id")) = True, "", Rs1("user_email_id")) Label17.Caption = Rs1.AbsolutePosition & "/" & Rs1.RecordCount End Sub Private Sub DE(t1 As Boolean, t2 As Boolean) '>>> enable / diable buttons Command2.Enabled = t1 Command3.Enabled = t1 Command4.Enabled = t1 Command5.Enabled = t1 Command6.Enabled = t1 Command7.Enabled = t1 Command11.Enabled = t1 Command8.Enabled = t2 Command9.Enabled = t2 End Sub

Page 50: MCA, Final Project for SMU

Railway Reservation System – eRail

Krishan Kumar Pareek, MCA – 6th Sem., Reg. No.: 571124530 Page: 50/107

Railway Reservation System : Change Password

FrmChangePassword

Option Explicit Private Sub Command1_Click() '>>> check for blank If Text1.Text = "" Then MsgBox "Enter Old Password ...", vbExclamation Text1.SetFocus Exit Sub End If If Text2.Text = "" Or Text3.Text = "" Then MsgBox "Enter New Password ...", vbExclamation Text3.Text = "" Text2.SetFocus Exit Sub End If '>>> check for length If Len(Text2.Text) < 6 Then MsgBox "Password should be at least 6 charcters long", vbExclamation Text2.SelStart = 0 Text2.SelLength = Len(Text2.Text) Text2.SetFocus Exit Sub End If '>>> check for alpha numeric Dim ChNumeric As Boolean Dim ChAlpha As Boolean '>> initial checker ChNumeric = False ChAlpha = False Dim i As Integer

Page 51: MCA, Final Project for SMU

Railway Reservation System – eRail

Krishan Kumar Pareek, MCA – 6th Sem., Reg. No.: 571124530 Page: 51/107

For i = 1 To Len(Text2.Text) Dim s1 As String s1 = Mid(Text2.Text, i, 1) If InStr("1234567890", s1) > 0 Then ChNumeric = True End If If InStr("abcdfghijklmnopqrstuvwxyz", LCase(s1)) > 0 Then ChAlpha = True End If Next If ChAlpha = False Or ChNumeric = False Then MsgBox "Password should be alpha neumeric.", vbExclamation Text2.SelStart = 0 Text2.SelLength = Len(Text2.Text) Text2.SetFocus Exit Sub End If '>>> check for match new and confirm password If Text2.Text <> Text3.Text Then MsgBox "Confirm password dosenot match with new password ...", vbExclamation Text3.Text = "" Text2.SetFocus Exit Sub End If '>>> update new password Dim rs As New ADODB.Recordset If rs.State = adStateOpen Then rs.Close rs.Open "select * from user_master where USER_name ='" & UserName & "' and user_password ='" & Text1.Text & "'", Cn, adOpenDynamic, adLockOptimistic If rs.RecordCount > 0 Then rs("user_password") = Text2.Text rs("last_pass_chg_date") = Now rs.Update MsgBox "Password Changed Successfully", vbInformation Unload Me Else MsgBox "Invalid Old Password cannot continue ...", vbExclamation, "Invalid Password" Text2.Text = "" Text3.Text = "" SendKeys "{home}+{end}" Text1.SetFocus Exit Sub End If End Sub Private Sub Command2_Click() If FirstLoin = True Then End Else

Page 52: MCA, Final Project for SMU

Railway Reservation System – eRail

Krishan Kumar Pareek, MCA – 6th Sem., Reg. No.: 571124530 Page: 52/107

Unload Me End If End Sub Private Sub Form_Load() Me.Move (Screen.Width - Width) / 2, (Screen.Height - Height) / 2 End Sub Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer) If FirstLoin = True Then End Else Unload Me End If

End Sub Railway Reservation System : Masters FrmMaster

Option Explicit Private Sub CmdClose_Click() Unload Me End Sub

Page 53: MCA, Final Project for SMU

Railway Reservation System – eRail

Krishan Kumar Pareek, MCA – 6th Sem., Reg. No.: 571124530 Page: 53/107

Private Sub CmdOK_Click() '>>>> 'load master form as per selection If OptStationMaster.Value = True Then FrmStationMaster.Show 1 End If If OptTrainMaster.Value = True Then FrmTrainMaster.Show 1 End If If OptTrainSchedule.Value = True Then FrmTrainScheduleMaster.Show 1 End If If OptFareStageMaster.Value = True Then FrmFareStageMaster.Show 1 End If If OptCancellationMaster.Value = True Then FrmCancellationRules.Show 1 End If If OptReservationFeesMaster.Value = True Then FrmReservationFees.Show 1 End If End Sub

Railway Reservation System : Station Master

FrmStationMaster

Page 54: MCA, Final Project for SMU

Railway Reservation System – eRail

Krishan Kumar Pareek, MCA – 6th Sem., Reg. No.: 571124530 Page: 54/107

Option Explicit Dim Rs1 As New ADODB.Recordset Dim AddEdit As String Private Sub ChkViewAll_Click() '>>> pass parameter to view all form StrViewAll = "select * from station_master view_all_filter order by station_id " StrViewAllFilter = "select distinct railway_type from station_master " StrFilterField = "railway_type" ViewQrNumeric = "C" FrmViewAll.LblCap.Caption = "View all station" FrmViewAll.LblFilter.Caption = "Filter by railway :" IntViewID = 0 FrmViewAll.Show 1 '>>>check view id if any id return from the grid '>>> get the record If IntViewID > 0 Then Dim p As Integer Rs1.Find "station_id = " & IntViewID p = Rs1.AbsolutePosition '>> Rs1.Requery Rs1.MoveFirst Rs1.Move p - 1 Call displayRecord

Page 55: MCA, Final Project for SMU

Railway Reservation System – eRail

Krishan Kumar Pareek, MCA – 6th Sem., Reg. No.: 571124530 Page: 55/107

End If End Sub Private Sub Command1_Click() '>>> close form Unload Me End Sub Private Sub Command11_Click() '>>> delete current record '>>> only admin user can delete record If CheckAdminValid(UserType) = False Then Exit Sub If Rs1.State = adStateClosed Then Exit Sub If Rs1.RecordCount <= 0 Then Exit Sub On Error GoTo myer1 '>>> confirm before delete If MsgBox("Delete the Record ? ", vbCritical + vbYesNo) = vbYes Then Rs1.Delete Call ClearText '>>> show next record Command4_Click End If Exit Sub myer1: MsgBox "Error Occured : " & Err.Description, vbCritical End Sub Private Sub Command2_Click() '>>> move record set to first record and display the record On Error Resume Next If Rs1.State = adStateClosed Then Exit Sub If Rs1.RecordCount <= 0 Then Exit Sub Rs1.MoveFirst Call displayRecord End Sub Private Sub Command3_Click() '>>> move record set back and display the record On Error Resume Next If Rs1.State = adStateClosed Then Exit Sub If Rs1.RecordCount <= 0 Then Exit Sub '>>> check for recordset position If Rs1.AbsolutePosition > 1 Then Rs1.MovePrevious Else MsgBox "First Record ..", vbInformation Rs1.MoveFirst End If Call displayRecord End Sub

Page 56: MCA, Final Project for SMU

Railway Reservation System – eRail

Krishan Kumar Pareek, MCA – 6th Sem., Reg. No.: 571124530 Page: 56/107

Private Sub Command4_Click() '>>> move record set next and display the record On Error Resume Next If Rs1.State = adStateClosed Then Exit Sub If Rs1.RecordCount <= 0 Then Exit Sub '>>> check for recordset position If Rs1.AbsolutePosition < Rs1.RecordCount Then Rs1.MoveNext Else MsgBox "Last Record ..", vbInformation Rs1.MoveLast End If Call displayRecord End Sub Private Sub Command5_Click() '>>> move record set to last record and display the record On Error Resume Next If Rs1.State = adStateClosed Then Exit Sub If Rs1.RecordCount <= 0 Then Exit Sub Rs1.MoveLast Call displayRecord End Sub Private Sub Command6_Click() '>>> add new record '>>> set flag to add '>>> clear all fields If Rs1.State = adStateClosed Then Exit Sub AddEdit = "ADD" Call ClearText DE False, True TxtStationCode.SetFocus End Sub Private Sub Command7_Click() '>>> edit the current record '>>> set flag to edit If Rs1.State = adStateClosed Then Exit Sub If Rs1.RecordCount <= 0 Then Exit Sub AddEdit = "EDIT" DE False, True TxtStationCode.SetFocus End Sub Private Sub Command8_Click() '>>> update the record '>>> check the flag If Rs1.State = adStateClosed Then Exit Sub

Page 57: MCA, Final Project for SMU

Railway Reservation System – eRail

Krishan Kumar Pareek, MCA – 6th Sem., Reg. No.: 571124530 Page: 57/107

''On Error GoTo myer1 '>>> valdation If Trim(TxtStationCode.Text) = "" Then MsgBox "Enter station code.", vbExclamation TxtStationCode.SetFocus Exit Sub End If If Trim(TxtStationName.Text) = "" Then MsgBox "Enter station name.", vbExclamation TxtStationName.SetFocus Exit Sub End If If Trim(TxtRailWay.Text) = "" Then MsgBox "Enter Railway.", vbExclamation TxtStationName.SetFocus Exit Sub End If '>>> check the add edit flag If AddEdit = "ADD" Then Dim LastSno As Integer Dim Rs2 As New ADODB.Recordset If Rs2.State = 1 Then Rs2.Close Rs2.Open "select max(station_id) from station_master", Cn, adOpenStatic, adLockReadOnly LastSno = IIf(IsNull(Rs2(0).Value) = True, 0, Rs2(0).Value) + 1 Rs1.AddNew Rs1("station_id") = LastSno Rs1("station_code") = TxtStationCode.Text Rs1("station_name") = TxtStationName.Text Rs1("railway_type") = TxtRailWay.Text Rs1.Update Rs1.MoveLast Call displayRecord Else Rs1("station_code") = TxtStationCode.Text Rs1("station_name") = TxtStationName.Text Rs1("railway_type") = TxtRailWay.Text Rs1.Update Dim p As Integer p = Rs1.AbsolutePosition Rs1.Requery Rs1.MoveFirst Rs1.Move p - 1 Call displayRecord End If DE True, False Exit Sub

Page 58: MCA, Final Project for SMU

Railway Reservation System – eRail

Krishan Kumar Pareek, MCA – 6th Sem., Reg. No.: 571124530 Page: 58/107

myer1: MsgBox "Error Occured : " & Err.Description, vbCritical End Sub Private Sub Command9_Click() DE True, False End Sub Private Sub Form_Load() Me.Move (Screen.Width - Width) / 2, (Screen.Height - Height) / 2 ClearText If Rs1.State = adStateOpen Then Rs1.Close Rs1.Open "select * from station_master order by station_id ", Cn, adOpenDynamic, adLockOptimistic If Rs1.RecordCount > 0 Then Rs1.MoveFirst Call displayRecord End If DE True, False End Sub Private Sub ClearText() TxtStationID.Text = "" TxtStationCode.Text = "" TxtStationName.Text = "" TxtRailWay.Text = "" End Sub Private Sub displayRecord() On Error Resume Next TxtStationID.Text = IIf(IsNull(Rs1("station_id")) = True, "", Rs1("station_id")) TxtStationCode.Text = IIf(IsNull(Rs1("station_code")) = True, "", Rs1("station_code")) TxtStationName.Text = IIf(IsNull(Rs1("station_name")) = True, "", Rs1("station_name")) TxtRailWay.Text = IIf(IsNull(Rs1("railway_type")) = True, "", Rs1("railway_type")) Label17.Caption = Rs1.AbsolutePosition & "/" & Rs1.RecordCount End Sub Private Sub DE(t1 As Boolean, t2 As Boolean) '>>> enable / diable buttons Command2.Enabled = t1 Command3.Enabled = t1 Command4.Enabled = t1 Command5.Enabled = t1 Command6.Enabled = t1 Command7.Enabled = t1 Command11.Enabled = t1 Command8.Enabled = t2 Command9.Enabled = t2 End Sub

Page 59: MCA, Final Project for SMU

Railway Reservation System – eRail

Krishan Kumar Pareek, MCA – 6th Sem., Reg. No.: 571124530 Page: 59/107

Railway Reservation System : Train Master

FrmTrainMaster

Option Explicit Dim Rs1 As New ADODB.Recordset Dim AddEdit As String Private Sub ChkViewAll_Click() '>>> pass parameter to view all form StrViewAll = "select * from train_master view_all_filter order by train_no " StrViewAllFilter = "select distinct train_type from train_type_master " StrFilterField = "train_type" ViewQrNumeric = "C" FrmViewAll.LblCap.Caption = "View all train" FrmViewAll.LblFilter.Caption = "Filter by train type :" IntViewID = 0 FrmViewAll.Show 1 '>>>check view id if any id return from the grid '>>> get the record If IntViewID > 0 Then Dim p As Integer Rs1.Find "train_no = " & IntViewID p = Rs1.AbsolutePosition '>> Rs1.Requery Rs1.MoveFirst Rs1.Move p - 1 Call displayRecord

Page 60: MCA, Final Project for SMU

Railway Reservation System – eRail

Krishan Kumar Pareek, MCA – 6th Sem., Reg. No.: 571124530 Page: 60/107

End If End Sub Private Sub Command1_Click() '>>> close form Unload Me End Sub Private Sub Command11_Click() '>>> delete current record '>>> only admin user can delete record If CheckAdminValid(UserType) = False Then Exit Sub If Rs1.State = adStateClosed Then Exit Sub If Rs1.RecordCount <= 0 Then Exit Sub On Error GoTo myer1 '>>> confirm before delete If MsgBox("Delete the Record ? ", vbCritical + vbYesNo) = vbYes Then Rs1.Delete Call ClearText '>>> show next record Command4_Click End If Exit Sub myer1: MsgBox "Error Occured : " & Err.Description, vbCritical End Sub Private Sub Command2_Click() '>>> move record set to first record and display the record On Error Resume Next If Rs1.State = adStateClosed Then Exit Sub If Rs1.RecordCount <= 0 Then Exit Sub Rs1.MoveFirst Call displayRecord End Sub Private Sub Command3_Click() '>>> move record set back and display the record On Error Resume Next If Rs1.State = adStateClosed Then Exit Sub If Rs1.RecordCount <= 0 Then Exit Sub '>>> check for recordset position If Rs1.AbsolutePosition > 1 Then Rs1.MovePrevious Else MsgBox "First Record ..", vbInformation Rs1.MoveFirst End If Call displayRecord End Sub

Page 61: MCA, Final Project for SMU

Railway Reservation System – eRail

Krishan Kumar Pareek, MCA – 6th Sem., Reg. No.: 571124530 Page: 61/107

Private Sub Command4_Click() '>>> move record set next and display the record On Error Resume Next If Rs1.State = adStateClosed Then Exit Sub If Rs1.RecordCount <= 0 Then Exit Sub '>>> check for recordset position If Rs1.AbsolutePosition < Rs1.RecordCount Then Rs1.MoveNext Else MsgBox "Last Record ..", vbInformation Rs1.MoveLast End If Call displayRecord End Sub Private Sub Command5_Click() '>>> move record set to last record and display the record On Error Resume Next If Rs1.State = adStateClosed Then Exit Sub If Rs1.RecordCount <= 0 Then Exit Sub Rs1.MoveLast Call displayRecord End Sub Private Sub Command6_Click() '>>> add new record '>>> set flag to add '>>> clear all fields If Rs1.State = adStateClosed Then Exit Sub TxtTrainNo.Locked = False TxtTrainNo.BackColor = TxtTrainName.BackColor AddEdit = "ADD" Call ClearText DE False, True TxtTrainNo.SetFocus End Sub Private Sub Command7_Click() '>>> edit the current record '>>> set flag to edit If Rs1.State = adStateClosed Then Exit Sub If Rs1.RecordCount <= 0 Then Exit Sub AddEdit = "EDIT" DE False, True TxtTrainName.SetFocus End Sub Private Sub Command8_Click() '>>> update the record '>>> check the flag If Rs1.State = adStateClosed Then Exit Sub

Page 62: MCA, Final Project for SMU

Railway Reservation System – eRail

Krishan Kumar Pareek, MCA – 6th Sem., Reg. No.: 571124530 Page: 62/107

''On Error GoTo myer1 '>>> valdation If IsNumeric(TxtTrainNo.Text) = False Then MsgBox "Enter train no.", vbExclamation TxtTrainNo.SetFocus Exit Sub End If If Trim(TxtTrainName.Text) = "" Then MsgBox "Enter train name.", vbExclamation TxtTrainName.SetFocus Exit Sub End If If Trim(CmbTrainType.Text) = "" Then MsgBox "Select train type.", vbExclamation CmbTrainType.SetFocus Exit Sub End If '>>> check the add edit flag If AddEdit = "ADD" Then Rs1.AddNew Rs1("train_no") = Val(TxtTrainNo.Text) Rs1("train_name") = TxtTrainName.Text Rs1("train_type") = CmbTrainType.Text Rs1("schedule") = GetSchedule() Rs1("a1") = Val(TxtA1.Text) Rs1("a2") = Val(TxtA2.Text) Rs1("a3") = Val(TxtA3.Text) Rs1("sl") = Val(TxtSL.Text) Rs1("gn") = Val(TxtGN.Text) Rs1("gl") = Val(TxtGL.Text) Rs1("ar") = Val(TxtAR.Text) Rs1.Update Rs1.MoveLast Call displayRecord Else Rs1("train_name") = TxtTrainName.Text Rs1("train_type") = CmbTrainType.Text Rs1("schedule") = GetSchedule() Rs1("a1") = Val(TxtA1.Text) Rs1("a2") = Val(TxtA2.Text) Rs1("a3") = Val(TxtA3.Text) Rs1("sl") = Val(TxtSL.Text) Rs1("gn") = Val(TxtGN.Text) Rs1("gl") = Val(TxtGL.Text) Rs1("ar") = Val(TxtAR.Text)

Page 63: MCA, Final Project for SMU

Railway Reservation System – eRail

Krishan Kumar Pareek, MCA – 6th Sem., Reg. No.: 571124530 Page: 63/107

Rs1.Update Dim p As Integer p = Rs1.AbsolutePosition Rs1.Requery Rs1.MoveFirst Rs1.Move p - 1 Call displayRecord End If DE True, False Exit Sub myer1: MsgBox "Error Occured : " & Err.Description, vbCritical End Sub Private Sub Command9_Click() DE True, False End Sub Private Sub Form_Load() Me.Move (Screen.Width - Width) / 2, (Screen.Height - Height) / 2 ClearText If Rs1.State = adStateOpen Then Rs1.Close CmbTrainType.Clear '>> fill train type Rs1.Open "select distinct train_type from train_type_master ", Cn, adOpenStatic, adLockReadOnly Dim i As Integer If Rs1.RecordCount > 0 Then Rs1.MoveFirst For i = 0 To Rs1.RecordCount - 1 CmbTrainType.AddItem Rs1(0) Rs1.MoveNext Next End If If Rs1.State = adStateOpen Then Rs1.Close Rs1.Open "select * from train_master order by train_no ", Cn, adOpenDynamic, adLockOptimistic If Rs1.RecordCount > 0 Then Rs1.MoveFirst Call displayRecord End If DE True, False End Sub Private Sub ClearText() TxtTrainNo.Text = "" TxtTrainName.Text = "" CmbTrainType.Text = "" ChkMO.Value = 0 ChkTU.Value = 0 ChkWE.Value = 0 ChkTH.Value = 0 ChkFR.Value = 0 ChkSA.Value = 0 ChkSU.Value = 0

Page 64: MCA, Final Project for SMU

Railway Reservation System – eRail

Krishan Kumar Pareek, MCA – 6th Sem., Reg. No.: 571124530 Page: 64/107

TxtA1.Text = 0 TxtA2.Text = 0 TxtA3.Text = 0 TxtSL.Text = 0 TxtGN.Text = 0 TxtGL.Text = 0 TxtSL.Text = 0 TxtAR.Text = 0 CmbTrainType.Text = "" End Sub Private Sub displayRecord() On Error Resume Next TxtTrainNo.Locked = True TxtTrainNo.BackColor = Me.BackColor TxtTrainNo.Text = IIf(IsNull(Rs1("train_no")) = True, "", Rs1("train_no")) TxtTrainName.Text = IIf(IsNull(Rs1("train_name")) = True, "", Rs1("train_name")) CmbTrainType.Text = IIf(IsNull(Rs1("train_type")) = True, "", Rs1("train_type")) Dim a() As String a = Split(Rs1("schedule"), "|") ChkMO.Value = Val(a(0)) ChkTU.Value = Val(a(1)) ChkWE.Value = Val(a(2)) ChkTH.Value = Val(a(3)) ChkFR.Value = Val(a(4)) ChkSA.Value = Val(a(5)) ChkSU.Value = Val(a(6)) TxtA1.Text = IIf(IsNull(Rs1("a1")) = True, 0, Rs1("a1")) TxtA2.Text = IIf(IsNull(Rs1("a2")) = True, 0, Rs1("a2")) TxtA3.Text = IIf(IsNull(Rs1("a3")) = True, 0, Rs1("a3")) TxtSL.Text = IIf(IsNull(Rs1("sl")) = True, 0, Rs1("sl")) TxtGN.Text = IIf(IsNull(Rs1("gn")) = True, 0, Rs1("gn")) TxtGL.Text = IIf(IsNull(Rs1("gl")) = True, 0, Rs1("gl")) TxtAR.Text = IIf(IsNull(Rs1("ar")) = True, 0, Rs1("ar")) Label17.Caption = Rs1.AbsolutePosition & "/" & Rs1.RecordCount End Sub Private Sub DE(t1 As Boolean, t2 As Boolean) '>>> enable / diable buttons Command2.Enabled = t1 Command3.Enabled = t1 Command4.Enabled = t1 Command5.Enabled = t1 Command6.Enabled = t1 Command7.Enabled = t1 Command11.Enabled = t1 Command8.Enabled = t2 Command9.Enabled = t2 End Sub

Page 65: MCA, Final Project for SMU

Railway Reservation System – eRail

Krishan Kumar Pareek, MCA – 6th Sem., Reg. No.: 571124530 Page: 65/107

Private Function GetSchedule() As String Dim s1 As String s1 = "" If ChkMO.Value = 1 Then s1 = s1 & "1|" Else s1 = s1 & "0|" End If If ChkTU.Value = 1 Then s1 = s1 & "1|" Else s1 = s1 & "0|" End If If ChkWE.Value = 1 Then s1 = s1 & "1|" Else s1 = s1 & "0|" End If If ChkTH.Value = 1 Then s1 = s1 & "1|" Else s1 = s1 & "0|" End If If ChkFR.Value = 1 Then s1 = s1 & "1|" Else s1 = s1 & "0|" End If If ChkSA.Value = 1 Then s1 = s1 & "1|" Else s1 = s1 & "0|" End If If ChkSU.Value = 1 Then s1 = s1 & "1|" Else s1 = s1 & "0|" End If GetSchedule = s1 End Function

Page 66: MCA, Final Project for SMU

Railway Reservation System – eRail

Krishan Kumar Pareek, MCA – 6th Sem., Reg. No.: 571124530 Page: 66/107

Railway Reservation System : Train Schedule

FrmTrainSchedule

Page 67: MCA, Final Project for SMU

Railway Reservation System – eRail

Krishan Kumar Pareek, MCA – 6th Sem., Reg. No.: 571124530 Page: 67/107

Option Explicit Dim Rs1 As New ADODB.Recordset Dim AddEdit As String Private Sub ChkViewAll_Click() '>>> pass parameter to view all form StrViewAll = "SELECT train_schedule.schedule_id, train_schedule.train_no, station_master.station_code, station_master.station_name, train_schedule.distance, train_schedule.arival_time, train_schedule.departure_time, train_schedule.day " _ & " FROM station_master INNER JOIN train_schedule ON station_master.station_id = train_schedule.station_id view_all_filter order by schedule_id " StrViewAllFilter = "select train_no from train_master " StrFilterField = "train_no" ViewQrNumeric = "N" FrmViewAll.LblCap.Caption = "View all schedule" FrmViewAll.LblFilter.Caption = "Filter by train no :" IntViewID = 0 FrmViewAll.Show 1 '>>>check view id if any id return from the grid '>>> get the record If IntViewID > 0 Then Dim p As Integer Rs1.Find "schedule_id = " & IntViewID p = Rs1.AbsolutePosition '>> Rs1.Requery Rs1.MoveFirst Rs1.Move p - 1 Call displayRecord End If End Sub Private Sub Command1_Click() '>>> close form Unload Me End Sub Private Sub Command11_Click() '>>> delete current record '>>> only admin user can delete record If CheckAdminValid(UserType) = False Then Exit Sub If Rs1.State = adStateClosed Then Exit Sub If Rs1.RecordCount <= 0 Then Exit Sub On Error GoTo myer1 '>>> confirm before delete

Page 68: MCA, Final Project for SMU

Railway Reservation System – eRail

Krishan Kumar Pareek, MCA – 6th Sem., Reg. No.: 571124530 Page: 68/107

If MsgBox("Delete the Record ? ", vbCritical + vbYesNo) = vbYes Then Rs1.Delete Call ClearText '>>> show next record Command4_Click End If Exit Sub myer1: MsgBox "Error Occured : " & Err.Description, vbCritical End Sub Private Sub Command2_Click() '>>> move record set to first record and display the record On Error Resume Next If Rs1.State = adStateClosed Then Exit Sub If Rs1.RecordCount <= 0 Then Exit Sub Rs1.MoveFirst Call displayRecord End Sub Private Sub Command3_Click() '>>> move record set back and display the record On Error Resume Next If Rs1.State = adStateClosed Then Exit Sub If Rs1.RecordCount <= 0 Then Exit Sub '>>> check for recordset position If Rs1.AbsolutePosition > 1 Then Rs1.MovePrevious Else MsgBox "First Record ..", vbInformation Rs1.MoveFirst End If Call displayRecord End Sub Private Sub Command4_Click() '>>> move record set next and display the record On Error Resume Next If Rs1.State = adStateClosed Then Exit Sub If Rs1.RecordCount <= 0 Then Exit Sub '>>> check for recordset position If Rs1.AbsolutePosition < Rs1.RecordCount Then Rs1.MoveNext Else MsgBox "Last Record ..", vbInformation Rs1.MoveLast End If Call displayRecord End Sub

Page 69: MCA, Final Project for SMU

Railway Reservation System – eRail

Krishan Kumar Pareek, MCA – 6th Sem., Reg. No.: 571124530 Page: 69/107

Private Sub Command5_Click() '>>> move record set to last record and display the record On Error Resume Next If Rs1.State = adStateClosed Then Exit Sub If Rs1.RecordCount <= 0 Then Exit Sub Rs1.MoveLast Call displayRecord End Sub Private Sub Command6_Click() '>>> add new record '>>> set flag to add '>>> clear all fields If Rs1.State = adStateClosed Then Exit Sub AddEdit = "ADD" Call ClearText DE False, True CmbTrainNo.SetFocus End Sub Private Sub Command7_Click() '>>> edit the current record '>>> set flag to edit If Rs1.State = adStateClosed Then Exit Sub If Rs1.RecordCount <= 0 Then Exit Sub AddEdit = "EDIT" DE False, True CmbTrainNo.SetFocus End Sub Private Sub Command8_Click() '>>> update the record '>>> check the flag If Rs1.State = adStateClosed Then Exit Sub ''On Error GoTo myer1 '>>> valdation If Trim(CmbTrainNo.Text) = "" Then MsgBox "Select train no.", vbExclamation CmbTrainNo.SetFocus Exit Sub End If If Trim(CmbStation.Text) = "" Then MsgBox "Select station.", vbExclamation CmbStation.SetFocus Exit Sub End If

Page 70: MCA, Final Project for SMU

Railway Reservation System – eRail

Krishan Kumar Pareek, MCA – 6th Sem., Reg. No.: 571124530 Page: 70/107

If IsNumeric(TxtDistance.Text) = False Then MsgBox "Enter distance", vbExclamation TxtDistance.SetFocus Exit Sub End If If IsNumeric(TxtDay.Text) = False Then MsgBox "Enter day", vbExclamation TxtDay.SetFocus Exit Sub End If '>>> check the add edit flag If AddEdit = "ADD" Then Dim LastSno As Integer Dim Rs2 As New ADODB.Recordset If Rs2.State = 1 Then Rs2.Close Rs2.Open "select max(schedule_id) from train_schedule", Cn, adOpenStatic, adLockReadOnly LastSno = IIf(IsNull(Rs2(0).Value) = True, 0, Rs2(0).Value) + 1 Rs1.AddNew Rs1("schedule_id") = LastSno Rs1("train_no") = Val(CmbTrainNo.Text) Rs1("station_id") = ReturnText("select station_id from station_master where station_code ='" & CmbStation.Text & "'") Rs1("distance") = Val(TxtDistance.Text) Rs1("arival_time") = DtArrivalTime.Value Rs1("departure_time") = DtDepartureTime.Value Rs1("day") = Val(TxtDay.Text) Rs1.Update Rs1.MoveLast Call displayRecord Else Rs1("train_no") = Val(CmbTrainNo.Text) Rs1("station_id") = ReturnText("select station_id from station_master where station_code ='" & CmbStation.Text & "'") Rs1("distance") = Val(TxtDistance.Text) Rs1("arival_time") = DtArrivalTime.Value Rs1("departure_time") = DtDepartureTime.Value Rs1("day") = Val(TxtDay.Text) Rs1.Update Dim p As Integer p = Rs1.AbsolutePosition Rs1.Requery Rs1.MoveFirst Rs1.Move p - 1 Call displayRecord End If

Page 71: MCA, Final Project for SMU

Railway Reservation System – eRail

Krishan Kumar Pareek, MCA – 6th Sem., Reg. No.: 571124530 Page: 71/107

DE True, False Exit Sub myer1: MsgBox "Error Occured : " & Err.Description, vbCritical End Sub Private Sub Command9_Click() DE True, False End Sub Private Sub Form_Load() Me.Move (Screen.Width - Width) / 2, (Screen.Height - Height) / 2 ClearText '>>> fill train no FillCombo "select train_no from train_master order by train_no", CmbTrainNo '>>> fill station FillCombo "select station_code from station_master order by station_code", CmbStation If Rs1.State = adStateOpen Then Rs1.Close Rs1.Open "select * from train_schedule order by schedule_id ", Cn, adOpenDynamic, adLockOptimistic If Rs1.RecordCount > 0 Then Rs1.MoveFirst Call displayRecord End If DE True, False End Sub Private Sub ClearText() TxtScheduleID.Text = "" CmbTrainNo.Text = "" CmbStation.Text = "" TxtDistance.Text = 0 TxtDay.Text = 1 End Sub Private Sub displayRecord() On Error Resume Next TxtScheduleID.Text = IIf(IsNull(Rs1("schedule_id")) = True, "", Rs1("schedule_id")) CmbTrainNo.Text = IIf(IsNull(Rs1("train_no")) = True, "", Rs1("train_no")) CmbStation.Text = ReturnText("select station_code from station_master where station_id =" & Rs1("station_id")) TxtDistance.Text = IIf(IsNull(Rs1("distance")) = True, "0", Rs1("distance")) DtArrivalTime.Value = IIf(IsNull(Rs1("arival_time")) = True, Time, Rs1("arival_time")) DtDepartureTime.Value = IIf(IsNull(Rs1("departure_time")) = True, Time, Rs1("departure_time")) TxtDay.Text = IIf(IsNull(Rs1("day")) = True, "0", Rs1("day"))

Page 72: MCA, Final Project for SMU

Railway Reservation System – eRail

Krishan Kumar Pareek, MCA – 6th Sem., Reg. No.: 571124530 Page: 72/107

Label17.Caption = Rs1.AbsolutePosition & "/" & Rs1.RecordCount End Sub Private Sub DE(t1 As Boolean, t2 As Boolean) '>>> enable / diable buttons Command2.Enabled = t1 Command3.Enabled = t1 Command4.Enabled = t1 Command5.Enabled = t1 Command6.Enabled = t1 Command7.Enabled = t1 Command11.Enabled = t1 Command8.Enabled = t2 Command9.Enabled = t2 End Sub

Railway Reservation System : Fare Rule Stage Master

FrmStageMaster

Page 73: MCA, Final Project for SMU

Railway Reservation System – eRail

Krishan Kumar Pareek, MCA – 6th Sem., Reg. No.: 571124530 Page: 73/107

Option Explicit Dim Rs1 As New ADODB.Recordset Dim AddEdit As String Private Sub ChkViewAll_Click() '>>> pass parameter to view all form StrViewAll = "select * from stage_master view_all_filter order by stage_id " StrViewAllFilter = "select distinct coach_type from coach_type_master " StrFilterField = "coach_type" ViewQrNumeric = "C" FrmViewAll.LblCap.Caption = "View all satge" FrmViewAll.LblFilter.Caption = "Filter by coach type :" IntViewID = 0 FrmViewAll.Show 1 '>>>check view id if any id return from the grid '>>> get the record If IntViewID > 0 Then Dim p As Integer Rs1.Find "stage_id = " & IntViewID p = Rs1.AbsolutePosition '>> Rs1.Requery Rs1.MoveFirst Rs1.Move p - 1 Call displayRecord

Page 74: MCA, Final Project for SMU

Railway Reservation System – eRail

Krishan Kumar Pareek, MCA – 6th Sem., Reg. No.: 571124530 Page: 74/107

End If End Sub Private Sub Command1_Click() '>>> close form Unload Me End Sub Private Sub Command11_Click() '>>> delete current record '>>> only admin user can delete record If CheckAdminValid(UserType) = False Then Exit Sub If Rs1.State = adStateClosed Then Exit Sub If Rs1.RecordCount <= 0 Then Exit Sub On Error GoTo myer1 '>>> confirm before delete If MsgBox("Delete the Record ? ", vbCritical + vbYesNo) = vbYes Then Rs1.Delete Call ClearText '>>> show next record Command4_Click End If Exit Sub myer1: MsgBox "Error Occured : " & Err.Description, vbCritical End Sub Private Sub Command2_Click() '>>> move record set to first record and display the record On Error Resume Next If Rs1.State = adStateClosed Then Exit Sub If Rs1.RecordCount <= 0 Then Exit Sub Rs1.MoveFirst Call displayRecord End Sub Private Sub Command3_Click() '>>> move record set back and display the record On Error Resume Next If Rs1.State = adStateClosed Then Exit Sub If Rs1.RecordCount <= 0 Then Exit Sub '>>> check for recordset position If Rs1.AbsolutePosition > 1 Then Rs1.MovePrevious Else MsgBox "First Record ..", vbInformation Rs1.MoveFirst End If Call displayRecord End Sub

Page 75: MCA, Final Project for SMU

Railway Reservation System – eRail

Krishan Kumar Pareek, MCA – 6th Sem., Reg. No.: 571124530 Page: 75/107

Private Sub Command4_Click() '>>> move record set next and display the record On Error Resume Next If Rs1.State = adStateClosed Then Exit Sub If Rs1.RecordCount <= 0 Then Exit Sub '>>> check for recordset position If Rs1.AbsolutePosition < Rs1.RecordCount Then Rs1.MoveNext Else MsgBox "Last Record ..", vbInformation Rs1.MoveLast End If Call displayRecord End Sub Private Sub Command5_Click() '>>> move record set to last record and display the record On Error Resume Next If Rs1.State = adStateClosed Then Exit Sub If Rs1.RecordCount <= 0 Then Exit Sub Rs1.MoveLast Call displayRecord End Sub Private Sub Command6_Click() '>>> add new record '>>> set flag to add '>>> clear all fields If Rs1.State = adStateClosed Then Exit Sub AddEdit = "ADD" Call ClearText DE False, True CmbCoachType.SetFocus End Sub Private Sub Command7_Click() '>>> edit the current record '>>> set flag to edit If Rs1.State = adStateClosed Then Exit Sub If Rs1.RecordCount <= 0 Then Exit Sub AddEdit = "EDIT" DE False, True CmbCoachType.SetFocus End Sub Private Sub Command8_Click() '>>> update the record '>>> check the flag If Rs1.State = adStateClosed Then Exit Sub

Page 76: MCA, Final Project for SMU

Railway Reservation System – eRail

Krishan Kumar Pareek, MCA – 6th Sem., Reg. No.: 571124530 Page: 76/107

''On Error GoTo myer1 '>>> valdation If Trim(CmbCoachType.Text) = "" Then MsgBox "Select coach type.", vbExclamation CmbCoachType.SetFocus Exit Sub End If If IsNumeric(TxtDistanceFrom.Text) = False Then MsgBox "Enter distance from.", vbExclamation TxtDistanceFrom.SetFocus Exit Sub End If If IsNumeric(TxtDistanceUpto.Text) = False Then MsgBox "Enter distance upto.", vbExclamation TxtDistanceUpto.SetFocus Exit Sub End If If IsNumeric(TxtFare.Text) = False Then MsgBox "Enter fare", vbExclamation TxtFare.SetFocus Exit Sub End If '>>> check the add edit flag If AddEdit = "ADD" Then Dim LastSno As Integer Dim Rs2 As New ADODB.Recordset If Rs2.State = 1 Then Rs2.Close Rs2.Open "select max(stage_id) from stage_master", Cn, adOpenStatic, adLockReadOnly LastSno = IIf(IsNull(Rs2(0).Value) = True, 0, Rs2(0).Value) + 1 Rs1.AddNew Rs1("stage_id") = LastSno Rs1("coach_type") = CmbCoachType.Text Rs1("dis_from") = Val(TxtDistanceFrom.Text) Rs1("dis_upto") = Val(TxtDistanceUpto.Text) Rs1("ticket_amount") = Val(TxtFare.Text) Rs1.Update Rs1.MoveLast Call displayRecord Else Rs1("coach_type") = CmbCoachType.Text Rs1("dis_from") = Val(TxtDistanceFrom.Text) Rs1("dis_upto") = Val(TxtDistanceUpto.Text) Rs1("ticket_amount") = Val(TxtFare.Text)

Page 77: MCA, Final Project for SMU

Railway Reservation System – eRail

Krishan Kumar Pareek, MCA – 6th Sem., Reg. No.: 571124530 Page: 77/107

Rs1.Update Dim p As Integer p = Rs1.AbsolutePosition Rs1.Requery Rs1.MoveFirst Rs1.Move p - 1 Call displayRecord End If DE True, False Exit Sub myer1: MsgBox "Error Occured : " & Err.Description, vbCritical End Sub Private Sub Command9_Click() DE True, False End Sub Private Sub Form_Load() Me.Move (Screen.Width - Width) / 2, (Screen.Height - Height) / 2 ClearText '>>> fill coach type FillCombo "select coach_type from coach_type_master ", CmbCoachType If Rs1.State = adStateOpen Then Rs1.Close Rs1.Open "select * from stage_master order by stage_id ", Cn, adOpenDynamic, adLockOptimistic If Rs1.RecordCount > 0 Then Rs1.MoveFirst Call displayRecord End If DE True, False End Sub Private Sub ClearText() TxtStageID.Text = "" CmbCoachType.Text = "" TxtDistanceFrom.Text = 0 TxtDistanceUpto.Text = 0 TxtFare.Text = 0 End Sub Private Sub displayRecord() On Error Resume Next TxtStageID.Text = IIf(IsNull(Rs1("stage_id")) = True, "", Rs1("stage_id")) CmbCoachType.Text = IIf(IsNull(Rs1("coach_type")) = True, "", Rs1("coach_type")) TxtDistanceFrom.Text = IIf(IsNull(Rs1("dis_from")) = True, 0, Rs1("dis_from")) TxtDistanceUpto.Text = IIf(IsNull(Rs1("dis_upto")) = True, "", Rs1("dis_upto")) TxtFare.Text = IIf(IsNull(Rs1("ticket_amount")) = True, "", Rs1("ticket_amount"))

Page 78: MCA, Final Project for SMU

Railway Reservation System – eRail

Krishan Kumar Pareek, MCA – 6th Sem., Reg. No.: 571124530 Page: 78/107

Label17.Caption = Rs1.AbsolutePosition & "/" & Rs1.RecordCount End Sub Private Sub DE(t1 As Boolean, t2 As Boolean) '>>> enable / diable buttons Command2.Enabled = t1 Command3.Enabled = t1 Command4.Enabled = t1 Command5.Enabled = t1 Command6.Enabled = t1 Command7.Enabled = t1 Command11.Enabled = t1 Command8.Enabled = t2 Command9.Enabled = t2 End Sub

Railway Reservation System : Reservation

FrmReservation

Option Explicit Dim Rs1 As New ADODB.Recordset Dim Rs2 As New ADODB.Recordset Private Sub CmbTrainNo_Change()

Page 79: MCA, Final Project for SMU

Railway Reservation System – eRail

Krishan Kumar Pareek, MCA – 6th Sem., Reg. No.: 571124530 Page: 79/107

FillCombo "SELECT station_master.station_code FROM station_master INNER JOIN train_schedule ON station_master.station_id = train_schedule.station_id where train_schedule.train_no =" & Val(CmbTrainNo.Text) & " order by station_master.station_id", CmbStationFrom FillCombo "SELECT station_master.station_code FROM station_master INNER JOIN train_schedule ON station_master.station_id = train_schedule.station_id where train_schedule.train_no =" & Val(CmbTrainNo.Text) & " order by station_master.station_id", CmbUpto FillCombo "SELECT station_master.station_code FROM station_master INNER JOIN train_schedule ON station_master.station_id = train_schedule.station_id where train_schedule.train_no =" & Val(CmbTrainNo.Text) & " order by station_master.station_id", CmbBoardingAt LblTrainName.Caption = ReturnText("select train_name from train_master where train_no =" & Val(CmbTrainNo.Text)) End Sub Private Sub CmbTrainNo_Click() FillCombo "SELECT station_master.station_code FROM station_master INNER JOIN train_schedule ON station_master.station_id = train_schedule.station_id where train_schedule.train_no =" & Val(CmbTrainNo.Text) & " order by station_master.station_id", CmbStationFrom FillCombo "SELECT station_master.station_code FROM station_master INNER JOIN train_schedule ON station_master.station_id = train_schedule.station_id where train_schedule.train_no =" & Val(CmbTrainNo.Text) & " order by station_master.station_id", CmbUpto FillCombo "SELECT station_master.station_code FROM station_master INNER JOIN train_schedule ON station_master.station_id = train_schedule.station_id where train_schedule.train_no =" & Val(CmbTrainNo.Text) & " order by station_master.station_id", CmbBoardingAt LblTrainName.Caption = ReturnText("select train_name from train_master where train_no =" & Val(CmbTrainNo.Text)) End Sub Private Sub CmdCheck_Click() '>>> validation for all details entered to check the status '>>> check journey date '>>> it should be less than 90 days. If DateDiff("d", Now, DtJourneyDate.Value) > 90 Then MsgBox "Check journey date, it shoud be less than 90 days.", vbExclamation DtJourneyDate.SetFocus Exit Sub End If If DtJourneyDate.Value < Date Then MsgBox "Journey date must not less than the current date.", vbExclamation DtJourneyDate.SetFocus Exit Sub End If If CheckListValue(CmbTrainNo.Text, CmbTrainNo) = False Then MsgBox "Select train no.", vbExclamation CmbTrainNo.SetFocus Exit Sub End If If CheckListValue(CmbCoachType.Text, CmbCoachType) = False Then MsgBox "Select coach type.", vbExclamation CmbCoachType.SetFocus Exit Sub End If

Page 80: MCA, Final Project for SMU

Railway Reservation System – eRail

Krishan Kumar Pareek, MCA – 6th Sem., Reg. No.: 571124530 Page: 80/107

If CheckListValue(CmbStationFrom.Text, CmbStationFrom) = False Then MsgBox "Select station from.", vbExclamation CmbStationFrom.SetFocus Exit Sub End If If CheckListValue(CmbUpto.Text, CmbUpto) = False Then MsgBox "Select station upto.", vbExclamation CmbUpto.SetFocus Exit Sub End If If CheckListValue(CmbBoardingAt.Text, CmbBoardingAt) = False Then MsgBox "Select boarding at.", vbExclamation CmbBoardingAt.SetFocus Exit Sub End If '>>> check wheather train start this day from schedule Dim AvaialbaleCaoch As Integer If Rs1.State = 1 Then Rs1.Close Rs1.Open "select * from train_master where train_no =" & Val(CmbTrainNo.Text), Cn, adOpenStatic, adLockReadOnly If Rs1.RecordCount > 0 Then '>>> display train name LblTrainName.Caption = Rs1("train_name") Dim a() As String a = Split(Rs1("schedule"), "|") Dim Jday As String Dim Ch As Boolean Ch = True Jday = UCase(Format(DtJourneyDate.Value, "DDD")) If Jday = "MON" Then If a(0) = 0 Then Ch = False End If End If If Jday = "TUE" Then If a(1) = 0 Then Ch = False End If End If If Jday = "WED" Then If a(2) = 0 Then Ch = False End If End If If Jday = "THU" Then If a(3) = 0 Then Ch = False End If

Page 81: MCA, Final Project for SMU

Railway Reservation System – eRail

Krishan Kumar Pareek, MCA – 6th Sem., Reg. No.: 571124530 Page: 81/107

End If If Jday = "FRI" Then If a(4) = 0 Then Ch = False End If End If If Jday = "SAT" Then If a(5) = 0 Then Ch = False End If End If If Jday = "SUN" Then If a(6) = 0 Then Ch = False End If End If If Ch = False Then MsgBox "Selected Train not start in " & Format(DtJourneyDate.Value, "Dddd"), vbExclamation Exit Sub End If '>>> get the no of coach AvaialbaleCaoch = Rs1(CmbCoachType.Text) Else MsgBox "No Details found for the selected train no.", vbExclamation LblTrainName.Caption = "" CmbTrainNo.SetFocus Exit Sub End If '>>> check for available seat '>>> get the coach type '>>> get the no of coach from train master '>>> get the no of seats by mutiple coach no * no of seats '>>> get the already booked seat for the date If AvaialbaleCaoch <= 0 Then MsgBox CmbCoachType.Text & " coach not availavle in train " & CmbTrainNo.Text, vbExclamation CmbCoachType.SetFocus Exit Sub End If Dim TotalSeat As Integer If CmbCoachType.Text = "A1" Then TotalSeat = AvaialbaleCaoch * 36 ElseIf CmbCoachType.Text = "A2" Then TotalSeat = AvaialbaleCaoch * 54 Else TotalSeat = AvaialbaleCaoch * 74 End If

Page 82: MCA, Final Project for SMU

Railway Reservation System – eRail

Krishan Kumar Pareek, MCA – 6th Sem., Reg. No.: 571124530 Page: 82/107

'>>> get the count already booked If Rs1.State = 1 Then Rs1.Close Rs1.Open "select count(*) from reservation_master where format(journey_date,'dd-MMM-yy')='" & Format(DtJourneyDate.Value, "dd-MMM-yy") & "' and coach_type ='" & CmbCoachType.Text & "'", Cn, adOpenStatic, adLockReadOnly MsgBox TotalSeat - Rs1(0) & " seats are available.", vbExclamation Exit Sub End Sub Private Sub Command2_Click() '>>> clear all ClearText End Sub Private Sub Command3_Click() '>>> save the record '>>> validate details again '>>> populate the data, and confirm before save. '>>> validate '>>> validation for all details entered to check the status '>>> check journey date '>>> it should be less than 90 days. If DateDiff("d", Now, DtJourneyDate.Value) > 90 Then MsgBox "Check journey date, it shoud be less than 90 days.", vbExclamation DtJourneyDate.SetFocus Exit Sub End If If DtJourneyDate.Value < Date Then MsgBox "Journey date must not less than the current date.", vbExclamation DtJourneyDate.SetFocus Exit Sub End If If CheckListValue(CmbTrainNo.Text, CmbTrainNo) = False Then MsgBox "Select train no.", vbExclamation CmbTrainNo.SetFocus Exit Sub End If If CheckListValue(CmbCoachType.Text, CmbCoachType) = False Then MsgBox "Select coach type.", vbExclamation CmbCoachType.SetFocus Exit Sub End If If CheckListValue(CmbStationFrom.Text, CmbStationFrom) = False Then MsgBox "Select station from.", vbExclamation CmbStationFrom.SetFocus Exit Sub End If

Page 83: MCA, Final Project for SMU

Railway Reservation System – eRail

Krishan Kumar Pareek, MCA – 6th Sem., Reg. No.: 571124530 Page: 83/107

If CheckListValue(CmbUpto.Text, CmbUpto) = False Then MsgBox "Select station upto.", vbExclamation CmbUpto.SetFocus Exit Sub End If If CheckListValue(CmbBoardingAt.Text, CmbBoardingAt) = False Then MsgBox "Select boarding at.", vbExclamation CmbBoardingAt.SetFocus Exit Sub End If '>>> check wheather train start this day from schedule Dim AvaialbaleCaoch As Integer If Rs1.State = 1 Then Rs1.Close Rs1.Open "select * from train_master where train_no =" & Val(CmbTrainNo.Text), Cn, adOpenStatic, adLockReadOnly If Rs1.RecordCount > 0 Then '>>> display train name LblTrainName.Caption = Rs1("train_name") Dim a() As String a = Split(Rs1("schedule"), "|") Dim Jday As String Dim Ch As Boolean Ch = True Jday = UCase(Format(DtJourneyDate.Value, "DDD")) If Jday = "MON" Then If a(0) = 0 Then Ch = False End If End If If Jday = "TUE" Then If a(1) = 0 Then Ch = False End If End If If Jday = "WED" Then If a(2) = 0 Then Ch = False End If End If If Jday = "THU" Then If a(3) = 0 Then Ch = False End If End If If Jday = "FRI" Then If a(4) = 0 Then Ch = False End If

Page 84: MCA, Final Project for SMU

Railway Reservation System – eRail

Krishan Kumar Pareek, MCA – 6th Sem., Reg. No.: 571124530 Page: 84/107

End If If Jday = "SAT" Then If a(5) = 0 Then Ch = False End If End If If Jday = "SUN" Then If a(6) = 0 Then Ch = False End If End If If Ch = False Then MsgBox "Selected Train not start in " & Format(DtJourneyDate.Value, "Dddd"), vbExclamation Exit Sub End If '>>> get the no of coach AvaialbaleCaoch = Rs1(CmbCoachType.Text) Else MsgBox "No Details found for the selected train no.", vbExclamation LblTrainName.Caption = "" CmbTrainNo.SetFocus Exit Sub End If '>>> check for available seat '>>> get the coach type '>>> get the no of coach from train master '>>> get the no of seats by mutiple coach no * no of seats '>>> get the already booked seat for the date If AvaialbaleCaoch <= 0 Then MsgBox CmbCoachType.Text & " coach not availavle in train " & CmbTrainNo.Text, vbExclamation CmbCoachType.SetFocus Exit Sub End If Dim TotalSeat As Integer If CmbCoachType.Text = "A1" Then TotalSeat = AvaialbaleCaoch * 36 ElseIf CmbCoachType.Text = "A2" Then TotalSeat = AvaialbaleCaoch * 54 Else TotalSeat = AvaialbaleCaoch * 74 End If '>>> get the count already booked If Rs1.State = 1 Then Rs1.Close Rs1.Open "select count(*) from reservation_master where format(journey_date,'dd-MMM-yy')='" & Format(DtJourneyDate.Value, "dd-MMM-yy") & "' and coach_type ='" & CmbCoachType.Text & "'", Cn, adOpenStatic, adLockReadOnly

Page 85: MCA, Final Project for SMU

Railway Reservation System – eRail

Krishan Kumar Pareek, MCA – 6th Sem., Reg. No.: 571124530 Page: 85/107

If MsgBox(TotalSeat - Rs1(0) & " seats are available. Do you want to continue?", vbExclamation + vbYesNo) = vbNo Then Exit Sub End If '>>> validate the passenger deatils Dim i As Integer Dim c As Integer c = 0 For i = 0 To 5 If Trim(TxtPassenger(i).Text) <> "" Then c = c + 1 End If Next If c <= 0 Then MsgBox "Enter Passenger deatils.", vbExclamation TxtPassenger(0).SetFocus Exit Sub End If '>>> check other validation, age.male feamale For i = 0 To c - 1 If Val(TxtAge(i)) <= 0 Then MsgBox "Enter age of the pasenger.", vbExclamation TxtAge(i).SetFocus Exit Sub End If If CheckListValue(CmbSex(i).Text, CmbSex(i)) = False Then MsgBox "Select gender of the passenger.", vbExclamation CmbSex(i).SetFocus Exit Sub End If Next '>>> calculate other fare If Rs1.State = 1 Then Rs1.Close Rs1.Open "select * from other_fees where coach_type ='" & CmbCoachType.Text & "'", Cn, adOpenStatic, adLockReadOnly If Rs1.RecordCount > 0 Then TxtReservationFees.Text = Rs1("re_fess") TxtSuperFastFees.Text = Rs1("sf_fees") End If '>>> calcluate ticket fare '>>> get the distance between two station Dim StartDistanace As Integer Dim EndDistance As Integer Dim TicketFare As Integer If Rs1.State = 1 Then Rs1.Close Rs1.Open "select distance from train_schedule where train_no =" & Val(CmbTrainNo.Text) & " and station_id = (select station_id from station_master where station_code='" & CmbStationFrom.Text & "')", Cn, adOpenStatic, adLockReadOnly If Rs1.RecordCount > 0 Then StartDistanace = Rs1(0) Else

Page 86: MCA, Final Project for SMU

Railway Reservation System – eRail

Krishan Kumar Pareek, MCA – 6th Sem., Reg. No.: 571124530 Page: 86/107

MsgBox "Selected station not found in the train schedule.", vbExclamation CmbStationFrom.SetFocus Exit Sub End If If Rs1.State = 1 Then Rs1.Close Rs1.Open "select distance from train_schedule where train_no =" & Val(CmbTrainNo.Text) & " and station_id = (select station_id from station_master where station_code='" & CmbUpto.Text & "')", Cn, adOpenStatic, adLockReadOnly If Rs1.RecordCount > 0 Then EndDistance = Rs1(0) Else MsgBox "Selected station not found in the train schedule.", vbExclamation CmbUpto.SetFocus Exit Sub End If Dim TotalDistance As Integer TotalDistance = EndDistance - StartDistanace If TotalDistance <= 0 Then MsgBox "Select strat station and end station properly.", vbExclamation CmbStationFrom.SetFocus Exit Sub End If '>>> get the fare from stage_master table If Rs1.State = 1 Then Rs1.Close Rs1.Open "select * from stage_master where coach_type='" & CmbCoachType.Text & "' order by stage_id ", Cn, adOpenStatic, adLockReadOnly If Rs1.RecordCount > 0 Then Rs1.MoveFirst For i = 0 To Rs1.RecordCount If TotalDistance > Rs1("dis_from") And TotalDistance <= Rs1("dis_upto") Then TicketFare = Rs1("ticket_amount") Exit For End If Rs1.MoveNext Next Else MsgBox "No fare details found for the train.", vbExclamation Exit Sub End If TxtTotalFees.Text = TicketFare * c + Val(TxtReservationFees.Text) + Val(TxtSuperFastFees.Text) '>>> save the record '>>> open the transaction to hold, for final confirmation Cn.BeginTrans Dim PrnID As Integer If Rs1.State = 1 Then Rs1.Close Rs1.Open "select max(prn_NO) from reservation_master", Cn, adOpenStatic, adLockReadOnly PrnID = IIf(IsNull(Rs1(0)) = True, 0, Rs1(0)) + 1 TxtPrnNo.Text = PrnID

Page 87: MCA, Final Project for SMU

Railway Reservation System – eRail

Krishan Kumar Pareek, MCA – 6th Sem., Reg. No.: 571124530 Page: 87/107

Dim TrnId As Integer If Rs1.State = 1 Then Rs1.Close Rs1.Open "select max(trn_id) from reservation_transaction ", Cn, adOpenStatic, adLockReadOnly TrnId = IIf(IsNull(Rs1(0)) = True, 0, Rs1(0)) + 1 Dim CashId As Integer If Rs1.State = 1 Then Rs1.Close Rs1.Open "select max(cash_id) from cash_master ", Cn, adOpenStatic, adLockReadOnly CashId = IIf(IsNull(Rs1(0)) = True, 0, Rs1(0)) + 1 '>>> save in reservation master If Rs1.State = 1 Then Rs1.Close Rs1.Open "select * from reservation_master where 1=2 ", Cn, adOpenDynamic, adLockOptimistic Rs1.AddNew Rs1("prn_no") = PrnID Rs1("train_no") = Val(CmbTrainNo.Text) Rs1("coach_type") = CmbCoachType.Text Rs1("journey_date") = DtJourneyDate.Value Rs1("from_station") = Val(ReturnText("select station_id from station_master where station_code='" & CmbStationFrom.Text & "'")) Rs1("to_station") = Val(ReturnText("select station_id from station_master where station_code='" & CmbUpto.Text & "'")) Rs1("boarding_at") = Val(ReturnText("select station_id from station_master where station_code='" & CmbBoardingAt.Text & "'")) Rs1("re_fees") = Val(TxtReservationFees.Text) Rs1("sf_fees") = Val(TxtSuperFastFees.Text) Rs1("ti_fees") = Val(TxtTotalFees.Text) Rs1("cancel_fees") = 0 Rs1("create_by") = UserID Rs1("create_date") = Now Rs1.Update '>>> save in reservation transaction If Rs1.State = 1 Then Rs1.Close Rs1.Open "select * from reservation_transaction where 1=2 ", Cn, adOpenDynamic, adLockOptimistic For i = 0 To c - 1 Rs1.AddNew Rs1("trn_id") = TrnId Rs1("prn_no") = PrnID Rs1("p_name") = TxtPassenger(i).Text Rs1("p_gender") = CmbSex(i).Text Rs1("p_age") = TxtAge(i).Text Rs1("confirm") = "Y" '>>> get coach /seat no If Rs2.State = 1 Then Rs2.Close Rs2.Open "select seat_no,coach from reservation_transaction where prn_no in (select prn_no from reservation_master where format(journey_date,'dd-MMM-yy')='" & Format(DtJourneyDate.Value, "dd-MMM-yy") & "' and coach_type ='" & CmbCoachType.Text & "' ) order by coach , seat_no desc ", Cn If Rs2.RecordCount <= 0 Then Rs1("seat_no") = 1 Rs1("coach") = 1 Else Dim SNo, CNo As Integer SNo = Rs2("seat_no") CNo = Rs2("coach")

Page 88: MCA, Final Project for SMU

Railway Reservation System – eRail

Krishan Kumar Pareek, MCA – 6th Sem., Reg. No.: 571124530 Page: 88/107

SNo = SNo + 1 Dim NoOfCach As Integer Dim NoOfSeat As Integer NoOfCach = Val(ReturnText("select " & CmbCoachType.Text & " from train_master where train_no =" & CmbTrainNo.Text)) If CmbCoachType.Text = "A1" Then NoOfSeat = 36 ElseIf CmbCoachType.Text = "A2" Then NoOfSeat = 54 Else NoOfSeat = 74 End If If SNo > NoOfSeat Then '>>> increaser coach no CNo = CNo + 1 SNo = 1 End If If CNo > NoOfCach Then CNo = CNo - 1 Rs1("confirm") = "N" End If Rs1("seat_no") = SNo Rs1("coach") = CNo End If Rs1("is_cancel") = 0 Rs1.Update TrnId = TrnId + 1 Next '>>> save in cash_master If Rs1.State = 1 Then Rs1.Close Rs1.Open "select * from cash_master where 1=2 ", Cn, adOpenDynamic, adLockOptimistic Rs1.AddNew Rs1("cash_id") = CashId Rs1("prn_no") = PrnID Rs1("amount_received") = Val(TxtTotalFees.Text) Rs1("amount_refund") = 0 Rs1("trn_date") = Now Rs1("trn_by") = UserID Rs1.Update If MsgBox("Do you want to save the record ?", vbExclamation Or vbYesNo) = vbNo Then Cn.RollbackTrans Else

Page 89: MCA, Final Project for SMU

Railway Reservation System – eRail

Krishan Kumar Pareek, MCA – 6th Sem., Reg. No.: 571124530 Page: 89/107

Cn.CommitTrans MsgBox "Ticket saved.", vbInformation ClearText End If End Sub Private Sub Command4_Click() Unload Me End Sub Private Sub Form_Load() FillCombo "select train_no from train_master order by train_no", CmbTrainNo FillCombo "select coach_type from coach_type_master ", CmbCoachType Dim i As Integer For i = 0 To 5 CmbSex(i).AddItem "M" CmbSex(i).AddItem "F" Next ClearText End Sub Private Sub ClearText() TxtPrnNo.Text = "" DtJourneyDate.Value = Date CmbTrainNo.Text = "" LblTrainName.Caption = "" CmbCoachType.Text = "" CmbStationFrom.Text = "" CmbUpto.Text = "" CmbBoardingAt.Text = "" Dim i As Integer For i = 0 To 5 TxtPassenger(i).Text = "" TxtAge(i).Text = "" CmbSex(i).Text = "" TxtCoach(i).Text = "" TxtSeat(i).Text = "" Next TxtReservationFees.Text = "" TxtSuperFastFees.Text = "" TxtTotalFees.Text = "" End Sub

Page 90: MCA, Final Project for SMU

Railway Reservation System – eRail

Krishan Kumar Pareek, MCA – 6th Sem., Reg. No.: 571124530 Page: 90/107

Railway Reservation System : Cancellation

FrmCancellation

Option Explicit Dim Rs1 As New ADODB.Recordset Private Sub Command2_Click() TxtPrnNo.Text = "" ClearText TxtPrnNo.SetFocus End Sub Private Sub Command3_Click() '>> validate If Rs1.State = 1 Then Rs1.Close Rs1.Open "select * from reservation_master where prn_no=" & Val(TxtPrnNo.Text), Cn, adOpenStatic, adLockReadOnly If Rs1.RecordCount > 0 Then '>>> check for already cancelled If IsNull(Rs1("cancel_date")) = False Then MsgBox "PRN no already cancelled.", vbExclamation Exit Sub End If

Page 91: MCA, Final Project for SMU

Railway Reservation System – eRail

Krishan Kumar Pareek, MCA – 6th Sem., Reg. No.: 571124530 Page: 91/107

'>>> check for already journey start Dim StrStartTime As String Dim Rs2 As New ADODB.Recordset If Rs2.State = 1 Then Rs2.Close Rs2.Open "select * from train_schedule where train_no =" & Rs1("train_no") & " order by schedule_id ", Cn, adOpenStatic, adLockReadOnly StrStartTime = Format(Rs2("arival_time"), "HH:nn") If Rs2.State = 1 Then Rs2.Close If CDate(Format(Rs1("journey_date"), "dd-MMM-yy ") & StrStartTime) < Now Then MsgBox "You can not cancel this ticket, journey date expired.", vbExclamation Exit Sub End If '>>> open transaction Dim CancellFeesPer As Integer Dim CanH As Integer CanH = DateDiff("h", Now, CDate(Format(Rs1("journey_date"), "dd-MMM-yy ") & StrStartTime)) If Rs2.State = 1 Then Rs2.Close Rs2.Open "select * from cancellation_rules ", Cn, adOpenStatic, adLockReadOnly If CanH <= 1 Then CancellFeesPer = Rs2("before_1h") ElseIf CanH <= 12 Then CancellFeesPer = Rs2("before_12h") Else CancellFeesPer = Rs2("before_24h") End If TxtCancellationFees.Text = Round(Val(TxtTotalFees.Text) * (CancellFeesPer / 100), 0) TxtTotalRefund.Text = Val(TxtTotalFees.Text) - Val(TxtCancellationFees.Text) Cn.BeginTrans Cn.Execute " update reservation_master set cancel_fees = " & Val(TxtCancellationFees.Text) & " , cancel_by =" & UserID & ",cancel_date = now() where prn_no =" & Val(TxtPrnNo.Text) Cn.Execute "update reservation_transaction set is_cancel = 1 where prn_no = " & Val(TxtPrnNo.Text) Dim CashId As Integer If Rs2.State = 1 Then Rs2.Close Rs2.Open "select max(cash_id) from cash_master ", Cn, adOpenStatic, adLockReadOnly CashId = IIf(IsNull(Rs1(0)) = True, 0, Rs1(0)) + 1 If Rs2.State = 1 Then Rs2.Close Rs2.Open "select * from cash_master where 1=2", Cn, adOpenDynamic, adLockOptimistic Rs2.AddNew Rs2("cash_id") = CashId Rs2("prn_no") = Val(TxtPrnNo.Text) Rs2("amount_received") = 0 Rs2("amount_refund") = Val(TxtTotalRefund) Rs2("trn_date") = Now Rs2("trn_by") = UserID Rs2.Update

Page 92: MCA, Final Project for SMU

Railway Reservation System – eRail

Krishan Kumar Pareek, MCA – 6th Sem., Reg. No.: 571124530 Page: 92/107

If MsgBox("Do you want to cancel this ticket?", vbExclamation Or vbYesNo) = vbNo Then Cn.RollbackTrans Else Cn.CommitTrans MsgBox "Ticket cancelled.", vbInformation ClearText TxtPrnNo.Text = "" TxtPrnNo.SetFocus End If Else MsgBox "Invalid PRN no, no deatils found.", vbExclamation Exit Sub End If End Sub Private Sub Command4_Click() Unload Me End Sub Private Sub Form_Load() TxtPrnNo.Text = "" ClearText End Sub Private Sub ClearText() TxtJourney.Text = "" TxtTrainNo.Text = "" LblTrainName.Caption = "" TxtCoachType.Text = "" TxtStationFrom.Text = "" TxtUpto.Text = "" TxtBoarding.Text = "" Dim i As Integer For i = 0 To 5 TxtPassenger(i).Text = "" TxtAge(i).Text = "" CmbSex(i).Text = "" TxtCoach(i).Text = "" TxtSeat(i).Text = "" Next TxtReservationFees.Text = "" TxtSuperFastFees.Text = "" TxtTotalFees.Text = "" TxtCancellationFees.Text = "" TxtTotalRefund.Text = "" End Sub

Page 93: MCA, Final Project for SMU

Railway Reservation System – eRail

Krishan Kumar Pareek, MCA – 6th Sem., Reg. No.: 571124530 Page: 93/107

Private Sub TxtPrnNo_KeyDown(KeyCode As Integer, Shift As Integer) If KeyCode = 13 Then ClearText If Rs1.State = 1 Then Rs1.Close Rs1.Open "select * from reservation_master where prn_no=" & Val(TxtPrnNo.Text), Cn, adOpenStatic, adLockReadOnly If Rs1.RecordCount > 0 Then '>>> check for already cancelled If IsNull(Rs1("cancel_date")) = False Then MsgBox "PRN no already cancelled.", vbExclamation Command3.Enabled = False 'Exit Sub End If '>>> check for already journey start Dim StrStartTime As String Dim Rs2 As New ADODB.Recordset If Rs2.State = 1 Then Rs2.Close Rs2.Open "select * from train_schedule where train_no =" & Rs1("train_no") & " order by schedule_id ", Cn, adOpenStatic, adLockReadOnly StrStartTime = Format(Rs2("arival_time"), "HH:nn") If Rs2.State = 1 Then Rs2.Close If CDate(Format(Rs1("journey_date"), "dd-MMM-yy ") & StrStartTime) < Now Then MsgBox "You can not cancel this ticket, journey date expired.", vbExclamation Exit Sub End If TxtJourney.Text = Rs1("journey_date") TxtTrainNo.Text = Rs1("train_no") TxtCoachType.Text = Rs1("coach_type") TxtStationFrom.Text = Rs1("from_station") TxtUpto.Text = Rs1("to_station") TxtBoarding.Text = Rs1("boarding_at") TxtReservationFees.Text = Rs1("re_fees") TxtSuperFastFees.Text = Rs1("re_fees") TxtTotalFees.Text = Rs1("ti_fees") If IsNull(Rs1("cancel_date")) = False Then Command3.Enabled = False TxtCancellationFees.Text = Rs1("cancel_fees") TxtTotalRefund.Text = Val(TxtTotalFees.Text) - Val(TxtCancellationFees.Text) Else Command3.Enabled = True TxtCancellationFees.Text = "" TxtTotalRefund.Text = "" End If

Page 94: MCA, Final Project for SMU

Railway Reservation System – eRail

Krishan Kumar Pareek, MCA – 6th Sem., Reg. No.: 571124530 Page: 94/107

'>>> get details from reservation trnsaction If Rs2.State = 1 Then Rs2.Close Rs2.Open "select * from reservation_transaction where prn_no =" & Val(TxtPrnNo.Text) & " order by trn_id ", Cn, adOpenStatic, adLockReadOnly If Rs2.RecordCount > 0 Then Dim i As Integer Rs2.MoveFirst For i = 0 To Rs2.RecordCount - 1 TxtPassenger(i).Text = Rs2("p_name") TxtAge(i).Text = Rs2("p_age") CmbSex(i).Text = Rs2("p_gender") TxtCoach(i).Text = Rs2("coach") TxtSeat(i).Text = Rs2("seat_no") Rs2.MoveNext Next End If Else MsgBox "Invalid PRN no, no deatils found.", vbExclamation Exit Sub End If End If End Sub

Page 95: MCA, Final Project for SMU

Railway Reservation System – eRail

Krishan Kumar Pareek, MCA – 6th Sem., Reg. No.: 571124530 Page: 95/107

Railway Reservation System : Daily Transaction

FrmDailyTranscation

Page 96: MCA, Final Project for SMU

Railway Reservation System – eRail

Krishan Kumar Pareek, MCA – 6th Sem., Reg. No.: 571124530 Page: 96/107

Option Explicit Dim Rs1 As New ADODB.Recordset Private Sub CmdClose_Click() Unload Me End Sub Private Sub CmdExportToExcel_Click() '>>> export data to excel CmdExportToExcel.Enabled = False Dim Ex As Object Dim Wb As Object Dim Ws As Object Set Ex = CreateObject("excel.application") Set Wb = Ex.workbooks.Add Set Ws = Wb.worksheets(1) Dim i, j As Integer '>>> grid to excel For i = 0 To MF1.Rows - 1 For j = 0 To MF1.Cols - 1 Ws.cells(1 + i, 1 + j).Value = MF1.TextMatrix(i, j) Next Next Ex.Visible = True Ex.quit '>>> realease memory Set Ws = Nothing Set Wb = Nothing Set Ws = Nothing CmdExportToExcel.Enabled = True End Sub Private Sub CmdShow_Click() '>>> create query for show data MF1.Rows = 2 MF1.Cols = 2 MF1.Clear MF1.Refresh If Rs1.State = adStateOpen Then Rs1.Close Rs1.Open "select * from cash_master where format(trn_date,'dd-MMM-yy')='" & Format(DTPicker1.Value, "dd-MMM-yy") & "' order by cash_id", Cn, adOpenDynamic, adLockOptimistic If Rs1.RecordCount > 0 Then Dim i As Integer Dim j As Integer

Page 97: MCA, Final Project for SMU

Railway Reservation System – eRail

Krishan Kumar Pareek, MCA – 6th Sem., Reg. No.: 571124530 Page: 97/107

MF1.Rows = Rs1.RecordCount + 1 MF1.Cols = Rs1.Fields.Count '>> create heading For j = 0 To Rs1.Fields.Count - 1 MF1.TextMatrix(0, j) = Rs1(j).Name Next Rs1.MoveFirst For i = 0 To Rs1.RecordCount - 1 For j = 0 To Rs1.Fields.Count - 1 If IsNull(Rs1(j).Value) = False Then MF1.TextMatrix(i + 1, j) = Rs1(j).Value End If Next Rs1.MoveNext Next Else MsgBox "No record found.", vbExclamation End If '>>close recordset If Rs1.State = adStateOpen Then Rs1.Close End Sub Private Sub Form_Load() '>> fil filter combo DTPicker1.Value = Date MF1.Rows = 2 MF1.Clear MF1.Refresh End Sub

Page 98: MCA, Final Project for SMU

Railway Reservation System – eRail

Krishan Kumar Pareek, MCA – 6th Sem., Reg. No.: 571124530 Page: 98/107

Railway Reservation System : PRN Query

FrmPRNQuery

Option Explicit Dim Rs1 As New ADODB.Recordset Private Sub Command2_Click() TxtPrnNo.Text = "" ClearText TxtPrnNo.SetFocus End Sub Private Sub Command4_Click() Unload Me End Sub Private Sub Form_Load() TxtPrnNo.Text = "" ClearText End Sub

Page 99: MCA, Final Project for SMU

Railway Reservation System – eRail

Krishan Kumar Pareek, MCA – 6th Sem., Reg. No.: 571124530 Page: 99/107

Private Sub ClearText() TxtJourney.Text = "" TxtTrainNo.Text = "" LblTrainName.Caption = "" TxtCoachType.Text = "" TxtStationFrom.Text = "" TxtUpto.Text = "" TxtBoarding.Text = "" Dim i As Integer For i = 0 To 5 TxtPassenger(i).Text = "" TxtAge(i).Text = "" CmbSex(i).Text = "" TxtCoach(i).Text = "" TxtSeat(i).Text = "" Next TxtReservationFees.Text = "" TxtSuperFastFees.Text = "" TxtTotalFees.Text = "" TxtCancellationFees.Text = "" TxtTotalRefund.Text = "" End Sub Private Sub TxtPrnNo_KeyDown(KeyCode As Integer, Shift As Integer) If KeyCode = 13 Then ClearText If Rs1.State = 1 Then Rs1.Close Rs1.Open "select * from reservation_master where prn_no=" & Val(TxtPrnNo.Text), Cn, adOpenStatic, adLockReadOnly If Rs1.RecordCount > 0 Then '>>> check for already cancelled If IsNull(Rs1("cancel_date")) = False Then MsgBox "PRN no already cancelled.", vbExclamation 'Exit Sub End If '>>> check for already journey start Dim StrStartTime As String Dim Rs2 As New ADODB.Recordset If Rs2.State = 1 Then Rs2.Close Rs2.Open "select * from train_schedule where train_no =" & Rs1("train_no") & " order by schedule_id ", Cn, adOpenStatic, adLockReadOnly StrStartTime = Format(Rs2("arival_time"), "HH:nn") If Rs2.State = 1 Then Rs2.Close

Page 100: MCA, Final Project for SMU

Railway Reservation System – eRail

Krishan Kumar Pareek, MCA – 6th Sem., Reg. No.: 571124530 Page: 100/107

If CDate(Format(Rs1("journey_date"), "dd-MMM-yy ") & StrStartTime) < Now Then MsgBox "You can not cancel this ticket, journey date expired.", vbExclamation Exit Sub End If TxtJourney.Text = Rs1("journey_date") TxtTrainNo.Text = Rs1("train_no") TxtCoachType.Text = Rs1("coach_type") TxtStationFrom.Text = Rs1("from_station") TxtUpto.Text = Rs1("to_station") TxtBoarding.Text = Rs1("boarding_at") TxtReservationFees.Text = Rs1("re_fees") TxtSuperFastFees.Text = Rs1("re_fees") TxtTotalFees.Text = Rs1("ti_fees") If IsNull(Rs1("cancel_date")) = False Then TxtCancellationFees.Text = Rs1("cancel_fees") TxtTotalRefund.Text = Val(TxtTotalFees.Text) - Val(TxtCancellationFees.Text) Else TxtCancellationFees.Text = "" TxtTotalRefund.Text = "" End If '>>> get details from reservation trnsaction If Rs2.State = 1 Then Rs2.Close Rs2.Open "select * from reservation_transaction where prn_no =" & Val(TxtPrnNo.Text) & " order by trn_id ", Cn, adOpenStatic, adLockReadOnly If Rs2.RecordCount > 0 Then Dim i As Integer Rs2.MoveFirst For i = 0 To Rs2.RecordCount - 1 TxtPassenger(i).Text = Rs2("p_name") TxtAge(i).Text = Rs2("p_age") CmbSex(i).Text = Rs2("p_gender") TxtCoach(i).Text = Rs2("coach") TxtSeat(i).Text = Rs2("seat_no") Rs2.MoveNext Next End If Else MsgBox "Invalid PRN no, no deatils found.", vbExclamation Exit Sub End If End If End Sub

Page 101: MCA, Final Project for SMU

Railway Reservation System – eRail

Krishan Kumar Pareek, MCA – 6th Sem., Reg. No.: 571124530 Page: 101/107

Railway Reservation System Test Plan

Introduction

This document describes the user acceptance test plan for the Railway Reservation System. The complete test strategy for the Railway Reservation System is to perform the following kinds of tests, in sequence:

1. Component testing of each component that makes up the Railway Reservation System

2. Integration testing of the Railway Reservation System, to ensure the correct interworking of its components

3. Validation testing of the Railway Reservation System, to ensure that it works correctly in a pseudo-live environment

4. User acceptance testing of the Railway Reservation System, to ensure that its function is acceptable to its users

Acceptance testing is the last set of tests to be performed before the application goes officially live.

Test Scope

The scope of the user acceptance testing covers:

Version 1 of the Railway Reservation System User-facing functionality defined by a set of use cases Administrator-facing functionality defined by a set of use cases

The aim of the testing is to determine how well the application meets its functional requirements from the perspective of the user, and to identify any issues so they can be resolved. Also, the testing serves to compile a set of test data and results that can be used during subsequent test cycles, to test for non-regression of the software in later releases or after the application is in maintenance. Working practices might vary from user to user and are considered outside the scope of the testing.

Page 102: MCA, Final Project for SMU

Railway Reservation System – eRail

Krishan Kumar Pareek, MCA – 6th Sem., Reg. No.: 571124530 Page: 102/107

Test Strategy

The basis of user acceptance testing is that other tests were completed successfully, so the application and its required infrastructure are considered to be stable and reliable. Acceptance testing concentrates on the application from the user’s perspective, that is, how the application is used and whether it meets the necessary quality criteria. Change requests will be sent to the development team as the actionable documentation. Change criteria will be determined by the Test team and the Development team prior to the beginning of testing. For instance, criteria may include impact to desired functionality, amount of code impacted by proposed change, and design required by proposed change. The tester will evaluate the criteria. The test lead will determine Change Required or not. Once a bug has been determined as Change Required, the bug report will be translated into a Change Request and passed on to development. The customer of the acceptance testing is the System Users, Supervisor and Adminstratorfor Railway Reservation System. The progress of the acceptance testing will be reported to the customer, together with any issues that are discovered and their planned resolutions. Sign-off of the tests, and therefore the acceptance of the application, will be performed by the customer or a selected representative.

Preconditions

The following items are required before testing can take place:

A complete and coherent functional specification of the Railway Reservation System expressed as use cases and usage scenarios

A complete and validation-tested release of Railway Reservation System, delivered according to the delivery plan

An agreed-upon procedure for dealing with any anomalies that are discovered during the testing process

A set of test specifications describing how each functional area of the Railway Reservation System is to be acceptance tested

An implemented test environment for the testing Sufficient, suitable resources to carry out the testing Available standards for the acceptance testing

Test Priorities During testing of the Railway Reservation System, the following qualities will be tested in order of priority:

Functionality—whether the required functions are available and working as expected Usability—how user-friendly and intuitive the Railway Reservation System is Security—how well-protected and guaranteed corporate and user data is Performance—whether the response times are within acceptable limits Customization—how straightforward it is to use the application in new, unpredicted

ways

Page 103: MCA, Final Project for SMU

Railway Reservation System – eRail

Krishan Kumar Pareek, MCA – 6th Sem., Reg. No.: 571124530 Page: 103/107

Test Techniques

The following techniques will be applied: Scripted tests—sequences of user interactions (based on the use case and usage

scenarios) using predefined data sets against predicted results Unscripted tests—based on scripted tests, the tester tries to modify the scenarios to

explore what-if possibilities Penetration tests—scripted tests to attempt unauthorized entry into the system Usability checklists—tests to determine the complexity of interactions Performance statistics—generation of performance information to check against

desired performance criteria

Test Organization

Roles and Responsibilities

The following roles are defined:

QA lead/test manager—responsible for planning and ensuring the smooth running of the test process

Tester—carries out the tests according to the test plan, and then reports the results Product manager—ensures that the tests are carried out successfully from a user

perspective Project sponsor/client—acts as main stakeholder, and ensures that the needs of the

customer community as a whole are considered Test support—provides technical assistance, such as test environment configuration,

and non-technical assistance, such as methodological support

Weekly team meetings will be held involving the test manager, testers, and product managers. At these meetings, the progress of the testing process will be reported, any issues will be discussed, and actions will be agreed upon.

Deliverables

The following deliverables will be expected from the user acceptance testing process:

Test plan—this document, together with any updates that have occurred during the testing process

Change requests—any bugs, defects, or other changes required to the Railway Reservation System as a result of the testing process

Weekly reports—progress reports to enable the status of the testing process to be determined

Completion report—a report to be signed off by the customer, to signify the successful completion of the user acceptance testing

Page 104: MCA, Final Project for SMU

Railway Reservation System – eRail

Krishan Kumar Pareek, MCA – 6th Sem., Reg. No.: 571124530 Page: 104/107

Test Environment

Hardware and Software

The test environment will consist of: Server

A single Intel-based computer running: Microsoft Windows Railway Reservation System components

Client Workstations

Two Intel-based client laptop computers, each running:

Microsoft Windows XP Professional Microsoft Office

The following additional hardware will be required:

One laser printer to print reports One color printer (laser or inkjet) to print screen dumps One CD-ROM drive to enable clean installation of the Railway Reservation System Networking connectivity to permit interconnection of the server, clients.

Testing Automation Software

No testing automation software packages are selected at present.

Application Configuration

The following user accounts will be configured on the server:

System Administrator System Users 1 System Users 2 Supervisor

Page 105: MCA, Final Project for SMU

Railway Reservation System – eRail

Krishan Kumar Pareek, MCA – 6th Sem., Reg. No.: 571124530 Page: 105/107

Test Management

Tests shall be managed according to the corporate test management standards, which cover:

Conduct of tests Reporting of test results Defect tracking and resolution Configuration management of the test environment Configuration control of test deliverables.

Testing Schedules

The user acceptance testing schedules are shown in the project structure document and resulting Gantt charts.

Threats to Testing

Potential threats to the testing process are as follows: Insufficient resources available for testing. Testing resources have been seconded

from the development departments, whose time is at a premium. Mitigation: ensure department heads apply a high priority to the testing of the Railway Reservation System.

Availability of sales personnel for testing. The test team should be overseen by at least one sales representative. Mitigation: gain prior agreement from the vice president of Sales for two sales representatives to be assigned to test the application.

Page 106: MCA, Final Project for SMU

Railway Reservation System – eRail

Krishan Kumar Pareek, MCA – 6th Sem., Reg. No.: 571124530 Page: 106/107

Conclusion and future enhancement This project was developed to fulfill user and business requirement; however there are lots

of scope to improve the performance of the Railway Reservation System in the area of user

interface, database performance, and query processing time. Etc.

So there are many things for future enhancement of this project. The future enhancements

that are possible in the project are as follows.

Linking and integration of any legacy system for accounting.

Integration with travel agent through Web Services

Connection to third-party OLAP applications

Electronic Data Interchange (EDI) system between banks, other credit verification

agency and their vendors

In the area of data security and system security.

Provide more online tips and help.

To optimize the query which is embedded in the system.

Page 107: MCA, Final Project for SMU

Railway Reservation System – eRail

Krishan Kumar Pareek, MCA – 6th Sem., Reg. No.: 571124530 Page: 107/107

Bibliography

Websites

http://www.google.com

http://www.microsoft.com

http://www.programmer2programmer.net

http://www.codeproject.com

http://www.msdn.com.

http://www.vb123.com

http://www.vbcode.com

http://www.sqltuner.com

Books

Mastering Visual Basic 6 (Paperback)

Mastering Visual Basic .NET (Paperback)

Visual Basic Black Book (Paperback)

SQL Bible, 2nd Edition (Paperback)

Database Development in Visual Basic