Sei sulla pagina 1di 83

CCSD INDIVIDUAL ASSIGNMENT

[APIIT SD INDIA]

Computing and Concurrent Systems Design


(CE00361-3)

Individual Assignment
Title: - Automated Online Railway Reservation System

Hand-Out-Date
28th February, 2011

Hand-In-Date
25th April, 2011

Submitted To: Mrs. Sonia Arora (Module Lecturer)

Submitted By: Deepti Mudgal (ptl00781122) CSE- Level 3

Deepti Mudgal (PTL0781122) Page 1

CCSD INDIVIDUAL ASSIGNMENT

[APIIT SD INDIA]

CERTIFICATE
This is to certify that the assignment has been successfully completed by Deepti Mudgal (PT0781122). She has shown very sincere efforts while making the assignment and has followed the assignment specification nicely. She has acquired the necessary concepts of the module and has got the learning out of the teaching. Overall I congratulate her for completing the assignment on time and putting in her sincere efforts for making the assignment successfully.

Mrs. Sonia Arora


(MODULE LECTURER)

Deepti Mudgal (PTL0781122) Page 2

CCSD INDIVIDUAL ASSIGNMENT

[APIIT SD INDIA]

ACKNOWLEDGEMENT
A thanks giving is not just a formality but it is the way to express our gratitude towards all the people who have been a source of information and have guided us at every step of this assignment. I have tried to give my best effort to Gather information, analyze, categorize to complete project in the best way. This assignment gave me the opportunity to get an upper hand in Concurrent Systems Designs. I learned how to develop FSP and LTS which helped me enhance my critical abilities. I also got an exposure to the programming techniques in Java where I learned to apply client server architecture in Online Railway Reservation System which will prove to be beneficial to me. I devoted a great deal of time working and developing this project. I am thankful to the management of APIIT for giving us such an opportunity. I would like to give my deep gratitude to our project and Module Coordinator, Mrs. Sonia Arora for giving his attention to overview the entire manuscript of the project. At last but not the least, I thank my colleagues and my seniors who assisted and regularly criticized at several points.

Thanks to all
DEEPTI MUDGAL

Deepti Mudgal (PTL0781122) Page 3

CCSD INDIVIDUAL ASSIGNMENT

[APIIT SD INDIA]

TABLE OF CONTENTS
Contents
Contents......................................................................................................................................................4 INTRODUCTION.....................................................................................................................................4 System to be made:................................................................................................................................5 Requirements:........................................................................................................................................5 Validations and Assumption:................................................................................................................5 Architecture of the Application:...............................................................................................................6 Java Concurrent Programming Techniques Used .................................................................................7 Finite State Process & LTS.....................................................................................................................10 FORM DESIGN.......................................................................................................................................16 Class Diagram..........................................................................................................................................20 Database tables........................................................................................................................................21 CRITICAL APPRAISAL........................................................................................................................23 References................................................................................................................................................24 APPENDIX:.............................................................................................................................................25

INTRODUCTION
In todays world of globalization, need for taking business online is increasing day by day. People from the corporate world salivate with anticipation with idea of having an e-commerce website and automated client server architecture based systems for themselves. The business world require realistic and compelling reasons to take their businesses online as it is transforming into a new future of business altogether. The client/server architecture is a widespread one. Modern web-servers, the Online Railway Reservation, Banking Networks and many operating systems use a client server model. Most of

Deepti Mudgal (PTL0781122) Page 4

CCSD INDIVIDUAL ASSIGNMENT

[APIIT SD INDIA]

these systems allow for multiple clients to interact with a server at once, and hence require the server to be safe when operating concurrently.

System to be made:
The Automated Online Railway Reservation System will service one customer at a time. A customer will be required to login and enter a password for validation. The customer will then be able to perform one or more actions as mentioned above. A 16 digits identification number (PIN) will entered in regards to pay the fare of any Ticket reservation.

Requirements:
An automated Online Railway Reservation System must be able to provide the following services to the customer: 1. A customer must be able to check the availability of seats. 2. A customer must be able to reserve the seats available with Seat/birth Details. 3. A customer must be able to check the reservation scheduled fares, Ticket Details, Seat/birth Details and status of Confirmation. 4. A customer can cancel the reservation and the status of the available seats should be updated in order to maintain the integrity and consistency. 5. A customer must be able to make a payment by entering a 16-digits code from any suitable account linked to any credit card to pay the fare. Proper validation should be there. 6. The customer can check the Booked Ticket Payment Details and Ticket Confirmation. 7. A customer must be able to abort a transaction in progress by pressing the Cancel key instead of responding to a request from the machine.

Validations and Assumption:


1. The Automated Online Railway Reservation System will verify all the actions taken. If the customer's identification number is invalid (not of 16 digits), the customer will be required to re-

Deepti Mudgal (PTL0781122) Page 5

CCSD INDIVIDUAL ASSIGNMENT

[APIIT SD INDIA]

enter the number before an action to be proceed. If the customer is unable to successfully enter the id number after three tries, the action should be canceled automatically. 2. The AORRS will display the Ticket Details with Customers Details for each successful paid fare. 3. The AORRS will also maintain an internal log of transactions to facilitate resolving ambiguities arising from a hardware failure in the middle of a transaction. Entries will be made in the log when the AORRS is started up and shut down, for each message sent to the Customer (along with the response back, if one is expected). Log entries may contain all the information, but for security will never contain an identification number.

Architecture of the Application:

The architecture of any system refers to splitting each piece of the applications functionality into separate components based on what they do and grouping each kind of component into a single logical tier. Client-server software architecture is versatile and flexible in todays fast-changing IT landscape. It is modular in structure and relies on messaging services for communication between components. They were designed to improve flexibility, usability, scalability, and interoperability. Software flexibility implies the ability for a program to change easily according to different users and different system requirements. Architecture Used Three Tier Architecture
Deepti Mudgal (PTL0781122) Page 6

CCSD INDIVIDUAL ASSIGNMENT

[APIIT SD INDIA]

In web applications, the client side is usually written in HTML meanwhile the application servers are usually written in C++ or Java. By using a scripting language embedded in HTML, web servers act as translation layers that allow for communication between the client and server layers.

Java Concurrent Programming Techniques Used

The java technologies and appropriate coding techniques should be used. First of all, the entire application could be divided into two major sections, namely presentation and business logic parts. All activities related to them are separated from the UI part to make the system modular, reusable and manageable. Utilization of inheritance, interface, and composition: - One of the major principles of the object oriented system design is to decouple as much as possible to make the system more manageable. In this way, the Online Railway Reservation application has been developed with the implementation of interfaces, use of inheritance and finally with composition for runtime dynamic requirement of the system.

Deepti Mudgal (PTL0781122) Page 7

CCSD INDIVIDUAL ASSIGNMENT

[APIIT SD INDIA]

Use of Composition:-Although the use of interface provides a better way for implement methods but still it works within the static structure of the system. If an object is to be used only at run time with variations in type and behavior of object, composition is the answer for it. Separation of monitors thread and associated class: classes are grouped as monitors, threads and associated classes based on the role and participation in the Online Railway Reservation system. Most of the UI part acts as passive so they are implemented as monitors and associated classes and the major events of the system are represented by the thread objects, such as an arrival of a Customer request.

Concurrent Programming: In a concurrent program, several streams of operations


may execute concurrently. Each stream of operations executes as it would in a sequential program except for the fact that streams can communicate and interfere with one another. It is used to increase the performance, throughput, and application responsiveness. Above all it more appropriate to represent simulations in the real world scenario.

Threads: A thread is runnable unless it executes a special operation requiring synchronization


that waits until a particular condition occurs. If more than one thread is runnable, all but one thread may starve (make no progress because none of its operations are being executed) unless the language makes a fairness guarantee. A fairness guarantee states that the next operation in a runnable thread eventually will execute. The Java language specification currently makes no fairness guarantees but most Java Virtual Machines guarantee fairness. The Java programming language relies primarily on shared variables to support communication between processes, but it also supports an explicit signaling mechanism.

Semaphores and monitors:


Semaphores: Is another data structure that provides mutual exclusion to critical sections. Semaphores can also be used as atomic counters. Semaphores support two operations: wait(semaphore): decrement, block until semaphore is open

Deepti Mudgal (PTL0781122) Page 8

CCSD INDIVIDUAL ASSIGNMENT

[APIIT SD INDIA]

Also P (), after the Dutch word for test, or down () signal(semaphore): increment, allow another thread to enter

Also V () after the Dutch word for increment, or up () Monitors: A monitor is a programming language construct that controls access to shared data Why is this advantage? A monitor is a module that encapsulates Shared data structures Procedures that operate on the shared data structures Synchronization between concurrent procedure invocations A monitor protects its data from unstructured access It guarantees that threads accessing its data through

A monitor guarantees mutual exclusion Only one thread can execute any monitor procedure at any If a second thread invokes a monitor procedure when a first Time (the thread is in the monitor) Thread is already executing one, it blocks So the monitor has to have a wait queue

If a thread within a monitor blocks, another one can enter.

Associated classes, safety and aliveness:


Apart from the monitors and threads, there are other classes which are support classes or business logic classes which does not fall into either category. In the online railways reservation system there are many classes under this categorization. Safety and aliveness of the system has been implemented in the form of monitors and conditional synchronizations.

Deepti Mudgal (PTL0781122) Page 9

CCSD INDIVIDUAL ASSIGNMENT

[APIIT SD INDIA]

Error debugging:
Elimination of Concurrency programming errors or difficulties When resources are shared and are accessed by concurrent threads it is clear there would be more chances for deadlock if all four deadlock conditions prevail. Apart from deadlock, another problem that may not hang the system but might cause serious problems is the data corruptions.

Finite State Process & LTS


Cancel Ticket

LTS

Deepti Mudgal (PTL0781122) Page 10

CCSD INDIVIDUAL ASSIGNMENT

[APIIT SD INDIA]

FSP: Const False = 0 Const True = 1 Range Bolo = False..True SEAT = SEAT[True], SEAT[cancelled:Bool] = ( cancel -> SEAT[False] | query[cancelled] -> SEAT[cancelled] | when (cancelled) cancel -> ERROR //error of reserved twice ). range Seats = 0..1 ||SEATS = (seat[Seats]:SEAT). TERMINAL = (choose[s:Seats] -> release -> seat[s].query[cancelled:Bool] -> if (!cancelled) then
Deepti Mudgal (PTL0781122) Page 11

CCSD INDIVIDUAL ASSIGNMENT

[APIIT SD INDIA]

(seat[s].cancel -> cancel-> TERMINAL) else (cancel -> TERMINAL) ). set Terminals = {a,b} ||CONCERT = (Terminals:TERMINAL || Terminals::SEATS). ||UNSAFECONCERT = (Terminals:TERMINAL || Terminals::SEATS).

Book Ticket

LTS:

Deepti Mudgal (PTL0781122) Page 12

CCSD INDIVIDUAL ASSIGNMENT

[APIIT SD INDIA]

FSP: const False = 0 const True = 1 range Bool = False..True SEAT = SEAT[False], SEAT[reserved:Bool] = ( reserve -> SEAT[True] | query[reserved] -> SEAT[reserved] | when (reserved) reserve -> ERROR ). range Seats = 0..1 ||SEATS = (seat[Seats]:SEAT). LOCK = (acquire -> release -> LOCK). BROKENLOCK = ({acquire,release}->BROKENLOCK). TERMINAL = (choose[s:Seats] -> acquire -> seat[s].query[reserved:Bool] -> if (!reserved) then
Deepti Mudgal (PTL0781122) Page 13

CCSD INDIVIDUAL ASSIGNMENT

[APIIT SD INDIA]

(seat[s].reserve -> release-> TERMINAL) else (release -> TERMINAL) ). set Terminals = {a,b} ||CONCERT = (Terminals:TERMINAL || Terminals::SEATS || Terminals::LOCK). ||UNSAFECONCERT = (Terminals:TERMINAL || Terminals::SEATS || Terminals::BROKENLOCK)

Payment

LTS:

Deepti Mudgal (PTL0781122) Page 14

CCSD INDIVIDUAL ASSIGNMENT

[APIIT SD INDIA]

FSP: PAYMENT (N=3) = (selectBank->enterCardNo->enterName->enterPin->submit>PAYMENT[N]), PAYMENT[i:0..N] = (when(i==N)sucess->PAYMENT |when(i>0)paymentFail->PAYMENT[i-1] |when(i==0) reject->PAYMENT |cancel->PAYMENT ).

Login

Deepti Mudgal (PTL0781122) Page 15

CCSD INDIVIDUAL ASSIGNMENT

[APIIT SD INDIA]

LTS:

FSP: LOGIN= (insert Username->insert Password->submit-> (mismatch-> (abort->LOGIN) |success-> (logout->LOGIN) |field Missing-> (abort->LOGIN))).

FORM DESIGN
LOGIN FORM:

Deepti Mudgal (PTL0781122) Page 16

CCSD INDIVIDUAL ASSIGNMENT

[APIIT SD INDIA]

MAIN MENU:

ADD NEW USER:

Validation. Wrong entry isnt getting saved.

Deepti Mudgal (PTL0781122) Page 17

CCSD INDIVIDUAL ASSIGNMENT

[APIIT SD INDIA]

CANCEL BOOKING:

Deepti Mudgal (PTL0781122) Page 18

CCSD INDIVIDUAL ASSIGNMENT FIND BOOKING DETAILS:

[APIIT SD INDIA]

ADD NEW BOOOKING:

Deepti Mudgal (PTL0781122) Page 19

CCSD INDIVIDUAL ASSIGNMENT

[APIIT SD INDIA]

Class Diagram

Deepti Mudgal (PTL0781122) Page 20

CCSD INDIVIDUAL ASSIGNMENT

[APIIT SD INDIA]

Database tables
Booking Info Table

Seat Info Table

Train Seat Booking info Table

Deepti Mudgal (PTL0781122) Page 21

CCSD INDIVIDUAL ASSIGNMENT Train Station info Table

[APIIT SD INDIA]

Train Seat info Table

User info Table

Deepti Mudgal (PTL0781122) Page 22

CCSD INDIVIDUAL ASSIGNMENT

[APIIT SD INDIA]

CRITICAL APPRAISAL
Computing and Concurrent System Design is a very important subject in field of Computer science regardless of specialization in any particular field. The assignment has covered all the practical aspects that we have learnt, with some additional requirement which really was a challenge We had never been exposed to the concept of concurrency programming. Till now in our course we had been working on object oriented programming language. It was very exciting for me to study Concurrency Programming in Java for the first time. But the problem which we faced was far complicated than the excitement. 1. I learnt how to prepare FSP, generate LTS diagram using tool LTSA. 2. Testing the model using the LTSA tool was really helpful in finding errors including safety and aliveness. 3. Acquired the skills to implement concurrent systems in Java in a systematic way, requirement -> Model -> Implementation. Extensive use of threads, monitors and other features helped the developer to learn concurrent programming in practice. 4. Obtained knowledge in the areas of concurrency, deadlock, deadlock avoidance, parallel composition of asynchronous processes, interleaving, structure diagrams, monitors and Conditional Synchronization, Safety & Aliveness properties. I referred to the book prescribed by my lecturer and many tutorials and online materials available to understand the workings in concurrency and State models and programming language. The concurrency concept leads to think the programming language in terms of real object in a simulated. In conclusion, I really appreciate the subject and plan to further research in this field. If I am given another project of this type, I will try to work on it by following the right steps based on the given approach and strategy of concurrent system design

Deepti Mudgal (PTL0781122) Page 23

CCSD INDIVIDUAL ASSIGNMENT

[APIIT SD INDIA]

References
BOOKS Fowler, M. and Scott, K., UML Distilled Applying the Standard Object Modelling Language, 1997, Addison-Wesley. Magee, J. And Kramer, J., 2008, Concurrency: State Models & Java Programs, 2nd Edition, Wiley, J. and Sons. D.J.Hatley, I.A. Pirbhai, Strategies for Real-Time System Specification, 1988, Dorset House N.Y. Balagurusamy E, (ed) 2007, Programming with Java A premier, 3rd Edition, TATA McGraw-Hill, New Delhi. Herbert Schildt (2002), The Complete Reference Java 2, 5th Edition, TATA McGraw-Hill, New Delhi. Websites: OMG. (2004). Key Sucess in model based design. Available: http://www.omg.org/news/meetings/workshops/MIC_2004_Manual/01-1_Moore_etal.pdf. Last accessed 15 March 2011. http://www.echoecho.com/applets.html, Last accessed 17 April 2011. http://www.codeproject.com/KB/architecture/ManConcurrentSys.aspx, Last accessed 11 April 2011 http://cseweb.ucsd.edu/classes/fa05/cse120/lectures/120-l6.pdf, Last accessed 13 April 2011

Deepti Mudgal (PTL0781122) Page 24

CCSD INDIVIDUAL ASSIGNMENT

[APIIT SD INDIA]

APPENDIX:
Code for the pre given froms. ******Login Form******* package Indiarailreservation;

import javax.swing.*; import java.awt.Color; import java.awt.Font; import javax.swing.JDialog; import javax.swing.JLabel;

public class Login extends javax.swing.JFrame {

/** Creates new form Login */ public Login() {

initComponents();

this.setSize(700,700);

this.setVisible(true);

/** This method is called from within the constructor to

Deepti Mudgal (PTL0781122) Page 25

CCSD INDIVIDUAL ASSIGNMENT * initialize the form.

[APIIT SD INDIA]

* WARNING: Do NOT modify this code. The content of this method is * always regenerated by the Form Editor. */ @SuppressWarnings("unchecked") // <editor-fold defaultstate="collapsed" desc="Generated Code"> private void initComponents() {

jLabel1 = new javax.swing.JLabel(); jLabel2 = new javax.swing.JLabel(); loginid = new javax.swing.JTextField(); password = new javax.swing.JPasswordField(); jButton1 = new javax.swing.JButton(); jButton2 = new javax.swing.JButton(); jButton3 = new javax.swing.JButton(); jLabel3 = new javax.swing.JLabel();

setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); setTitle("Login Detail"); setBackground(new java.awt.Color(255, 255, 255));

jLabel1.setText("Enter Login ID");

jLabel2.setText("Enter Password");

jButton1.setText("Add User"); jButton1.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton1ActionPerformed(evt); Deepti Mudgal (PTL0781122) Page 26

CCSD INDIVIDUAL ASSIGNMENT } });

[APIIT SD INDIA]

jButton2.setText("Login"); jButton2.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton2ActionPerformed(evt); } });

jButton3.setText("Exit"); jButton3.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton3ActionPerformed(evt); } });

jLabel3.setFont(new java.awt.Font("Tahoma", 1, 36)); // NOI18N jLabel3.setText("INDIA RAIL RESRVATION");

javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addGap(71, 71, 71) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 521, javax.swing.GroupLayout.PREFERRED_SIZE) Deepti Mudgal (PTL0781122) Page 27

CCSD INDIVIDUAL ASSIGNMENT

[APIIT SD INDIA]

.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADIN G, false) .addGroup(layout.createSequentialGroup() .addGap(8, 8, 8) .addComponent(jButton2) .addGap(18, 18, 18) .addComponent(jButton1) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(jButton3)) .addGroup(layout.createSequentialGroup() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEA DING) .addComponent(jLabel1) .addComponent(jLabel2)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 18, Short.MAX_VALUE) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEA DING, false) .addComponent(password) .addComponent(loginid, javax.swing.GroupLayout.DEFAULT_SIZE, 168, Short.MAX_VALUE))))) .addContainerGap(144, Short.MAX_VALUE)) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addContainerGap() .addComponent(jLabel3) .addGap(25, 25, 25) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE ) Deepti Mudgal (PTL0781122) Page 28

CCSD INDIVIDUAL ASSIGNMENT .addComponent(jLabel1)

[APIIT SD INDIA]

.addComponent(loginid, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING ) .addComponent(jLabel2) .addComponent(password, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGap(18, 18, 18) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE ) .addComponent(jButton3) .addComponent(jButton1) .addComponent(jButton2)) .addContainerGap(185, Short.MAX_VALUE)) );

pack(); }// </editor-fold>

private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: System.exit(0); }

private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here:

String _loginid=loginid.getText();

Deepti Mudgal (PTL0781122) Page 29

CCSD INDIVIDUAL ASSIGNMENT

[APIIT SD INDIA]

String _password=password.getText();

if(_loginid==null || _password==null) return; else if(_loginid.trim().equals("") || _password.trim().equals("")) return; else { System.out.println("_loginid : " + _loginid); System.out.println("_password : " + _password); UserInfoDAO uidao=new UserInfoDAO(); boolean result=uidao.verify(_loginid, _password); if(result==true) { new Home().setVisible(true); this.setVisible(false);

} else { JDialog dialog = new JDialog(this, "Invalid user."); dialog.setSize(500, 200); dialog.setLayout(null); JLabel label = new JLabel("Invalid Login ID or Password."); label.setFont(new Font("arial", Font.BOLD,32)); label.setBounds(20, 20, 450, 100); dialog.add(label); dialog.setVisible(true); } Deepti Mudgal (PTL0781122) Page 30

CCSD INDIVIDUAL ASSIGNMENT } }

[APIIT SD INDIA]

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: NewUser newuser = new NewUser(); newuser.setVisible(true); this.setVisible(false);

/** * @param args the command line arguments */ public static void main(String args[]) { java.awt.EventQueue.invokeLater(new Runnable() { public void run() {

new Login().setVisible(true);

} }); }

// Variables declaration - do not modify private javax.swing.JButton jButton1; private javax.swing.JButton jButton2; private javax.swing.JButton jButton3; private javax.swing.JLabel jLabel1; Deepti Mudgal (PTL0781122) Page 31

CCSD INDIVIDUAL ASSIGNMENT private javax.swing.JLabel jLabel2; private javax.swing.JLabel jLabel3;

[APIIT SD INDIA]

private javax.swing.JTextField loginid; private javax.swing.JPasswordField password; // End of variables declaration

******Main Page ******* * To change this template, choose Tools | Templates * and open the template in the editor. */

/* * Home.java * * Created on Apr 23, 2011, 10:09:02 PM */

package Indiarailreservation;

/** * * @author Krishna */ public class Home extends javax.swing.JFrame {

/** Creates new form Home */ public Home() { Deepti Mudgal (PTL0781122) Page 32

CCSD INDIVIDUAL ASSIGNMENT initComponents(); }

[APIIT SD INDIA]

/** This method is called from within the constructor to * initialize the form. * WARNING: Do NOT modify this code. The content of this method is * always regenerated by the Form Editor. */ @SuppressWarnings("unchecked") // <editor-fold defaultstate="collapsed" desc="Generated Code"> private void initComponents() {

jLabel3 = new javax.swing.JLabel(); jMenuBar1 = new javax.swing.JMenuBar(); jMenu1 = new javax.swing.JMenu(); jMenuItem1 = new javax.swing.JMenuItem(); jMenuItem2 = new javax.swing.JMenuItem(); jMenuItem4 = new javax.swing.JMenuItem(); jMenuItem5 = new javax.swing.JMenuItem(); jSeparator1 = new javax.swing.JSeparator();

setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); setTitle("India Railways Reservevation ");

jLabel3.setFont(new java.awt.Font("Tahoma", 1, 24)); // NOI18N jLabel3.setText("Welcome Railway Booking System Choose your Option");

jMenu1.setText("Function Detail");

Deepti Mudgal (PTL0781122) Page 33

CCSD INDIVIDUAL ASSIGNMENT

[APIIT SD INDIA]

jMenuItem1.setText("Add Booking"); jMenuItem1.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jMenuItem1ActionPerformed(evt); } }); jMenu1.add(jMenuItem1);

jMenuItem2.setText("Delete Booking Record"); jMenuItem2.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jMenuItem2ActionPerformed(evt); } }); jMenu1.add(jMenuItem2);

jMenuItem4.setText("Find Booking Record"); jMenuItem4.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jMenuItem4ActionPerformed(evt); } }); jMenu1.add(jMenuItem4);

jMenuItem5.setText("Exit"); jMenuItem5.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jMenuItem5ActionPerformed(evt); } Deepti Mudgal (PTL0781122) Page 34

CCSD INDIVIDUAL ASSIGNMENT }); jMenu1.add(jMenuItem5); jMenu1.add(jSeparator1);

[APIIT SD INDIA]

jMenuBar1.add(jMenu1);

setJMenuBar(jMenuBar1);

javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addContainerGap() .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 673, javax.swing.GroupLayout.PREFERRED_SIZE) .addContainerGap(46, Short.MAX_VALUE)) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addGap(81, 81, 81) .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 116, javax.swing.GroupLayout.PREFERRED_SIZE) .addContainerGap(213, Short.MAX_VALUE)) );

pack(); }// </editor-fold>

Deepti Mudgal (PTL0781122) Page 35

CCSD INDIVIDUAL ASSIGNMENT

[APIIT SD INDIA]

private void jMenuItem5ActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: System.exit(0); }

private void jMenuItem1ActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: NewBooking newBooking = new NewBooking(); newBooking.setVisible(true); }

private void jMenuItem2ActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: new CancelBooking().setVisible(true); }

private void jMenuItem4ActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: new FindBooking().setVisible(true); }

/** * @param args the command line arguments */ public static void main(String args[]) { java.awt.EventQueue.invokeLater(new Runnable() { public void run() { new Home().setVisible(true); Deepti Mudgal (PTL0781122) Page 36

CCSD INDIVIDUAL ASSIGNMENT } }); }

[APIIT SD INDIA]

// Variables declaration - do not modify private javax.swing.JLabel jLabel3; private javax.swing.JMenu jMenu1; private javax.swing.JMenuBar jMenuBar1; private javax.swing.JMenuItem jMenuItem1; private javax.swing.JMenuItem jMenuItem2; private javax.swing.JMenuItem jMenuItem4; private javax.swing.JMenuItem jMenuItem5; private javax.swing.JSeparator jSeparator1; // End of variables declaration

*******New User ******** /* * To change this template, choose Tools | Templates * and open the template in the editor. */

/* * NewUser.java * * Created on Apr 23, 2011, 10:53:47 PM */ Deepti Mudgal (PTL0781122) Page 37

CCSD INDIVIDUAL ASSIGNMENT

[APIIT SD INDIA]

package Indiarailreservation;

import java.awt.Color; import java.awt.Font; import java.util.Calendar; import javax.swing.JDialog; import javax.swing.JLabel;

/** * * @author Krishna */ public class NewUser extends javax.swing.JFrame {

/** Creates new form NewUser */ public NewUser() { initComponents(); }

/** This method is called from within the constructor to * initialize the form. * WARNING: Do NOT modify this code. The content of this method is * always regenerated by the Form Editor. */ @SuppressWarnings("unchecked") // <editor-fold defaultstate="collapsed" desc="Generated Code"> private void initComponents() {

Deepti Mudgal (PTL0781122) Page 38

CCSD INDIVIDUAL ASSIGNMENT

[APIIT SD INDIA]

jLabel1 = new javax.swing.JLabel(); jLabel2 = new javax.swing.JLabel(); jLabel3 = new javax.swing.JLabel(); jLabel4 = new javax.swing.JLabel(); jLabel5 = new javax.swing.JLabel(); jLabel6 = new javax.swing.JLabel(); jLabel7 = new javax.swing.JLabel(); jLabel8 = new javax.swing.JLabel(); jLabel9 = new javax.swing.JLabel(); jLabel10 = new javax.swing.JLabel(); loginid = new javax.swing.JTextField(); password = new javax.swing.JPasswordField(); username = new javax.swing.JTextField(); address = new javax.swing.JTextField(); city = new javax.swing.JTextField(); state = new javax.swing.JTextField(); country = new javax.swing.JTextField(); mobile = new javax.swing.JTextField(); email = new javax.swing.JTextField(); jButton1 = new javax.swing.JButton(); jButton3 = new javax.swing.JButton(); message = new javax.swing.JLabel();

setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); setTitle("Add New user Information");

jLabel1.setFont(new java.awt.Font("Tahoma", 0, 18)); jLabel1.setText("Add New User");

Deepti Mudgal (PTL0781122) Page 39

CCSD INDIVIDUAL ASSIGNMENT jLabel2.setText("Login ID");

[APIIT SD INDIA]

jLabel3.setText("Password");

jLabel4.setText("Enter Name");

jLabel5.setText("Address");

jLabel6.setText("City");

jLabel7.setText("State");

jLabel8.setText("Country");

jLabel9.setText("Mobile Number");

jLabel10.setText("Email");

password.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { passwordActionPerformed(evt); } });

jButton1.setText("Exit"); jButton1.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton1ActionPerformed(evt); } Deepti Mudgal (PTL0781122) Page 40

CCSD INDIVIDUAL ASSIGNMENT });

[APIIT SD INDIA]

jButton3.setText("Save"); jButton3.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton3ActionPerformed(evt); } });

message.setText("**Fill all mandatory.");

javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addGap(158, 158, 158) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addComponent(jLabel1) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 170, Short.MAX_VALUE) .addComponent(message)) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADI NG) .addComponent(jLabel2) .addComponent(jLabel3) .addComponent(jLabel4) Deepti Mudgal (PTL0781122) Page 41

CCSD INDIVIDUAL ASSIGNMENT

[APIIT SD INDIA]

.addComponent(jLabel10) .addComponent(jLabel9) .addComponent(jLabel6) .addComponent(jLabel5) .addComponent(jLabel7) .addComponent(jLabel8)) .addGap(49, 49, 49) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADI NG) .addComponent(country, javax.swing.GroupLayout.DEFAULT_SIZE, 259, Short.MAX_VALUE) .addComponent(state, javax.swing.GroupLayout.DEFAULT_SIZE, 259, Short.MAX_VALUE) .addComponent(address, javax.swing.GroupLayout.DEFAULT_SIZE, 259, Short.MAX_VALUE) .addComponent(email, javax.swing.GroupLayout.DEFAULT_SIZE, 259, Short.MAX_VALUE) .addComponent(loginid, javax.swing.GroupLayout.DEFAULT_SIZE, 259, Short.MAX_VALUE) .addComponent(password, javax.swing.GroupLayout.DEFAULT_SIZE, 259, Short.MAX_VALUE) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() .addComponent(jButton3) .addGap(18, 18, 18) .addComponent(jButton1) .addGap(82, 82, 82)) .addComponent(username, javax.swing.GroupLayout.DEFAULT_SIZE, 259, Short.MAX_VALUE) .addComponent(mobile, javax.swing.GroupLayout.DEFAULT_SIZE, 259, Short.MAX_VALUE) .addComponent(city, javax.swing.GroupLayout.DEFAULT_SIZE, 259, Short.MAX_VALUE))))

Deepti Mudgal (PTL0781122) Page 42

CCSD INDIVIDUAL ASSIGNMENT .addContainerGap()) ); layout.setVerticalGroup(

[APIIT SD INDIA]

layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addContainerGap() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE ) .addComponent(jLabel1) .addComponent(message)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE ) .addComponent(jLabel2) .addComponent(loginid, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE ) .addComponent(jLabel3) .addComponent(password, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE ) .addComponent(jLabel4) .addComponent(username, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE ) .addComponent(email, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) Deepti Mudgal (PTL0781122) Page 43

CCSD INDIVIDUAL ASSIGNMENT .addComponent(jLabel10))

[APIIT SD INDIA]

.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE ) .addComponent(mobile, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jLabel9)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE ) .addComponent(city, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jLabel6)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE ) .addComponent(jLabel5) .addComponent(address, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGap(9, 9, 9) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE ) .addComponent(jLabel7) .addComponent(state, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING ) .addComponent(jLabel8) .addComponent(country, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)

Deepti Mudgal (PTL0781122) Page 44

CCSD INDIVIDUAL ASSIGNMENT

[APIIT SD INDIA]

.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE ) .addComponent(jButton3) .addComponent(jButton1)) .addGap(38, 38, 38)) );

layout.linkSize(javax.swing.SwingConstants.VERTICAL, new java.awt.Component[] {address, city, country, email, loginid, mobile, password, state, username});

pack(); }// </editor-fold>

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: System.exit(0); }

private void passwordActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: }

private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: if(loginid.getText().equals("")) { message.setText("Login ID missing."); loginid.setBackground(Color.YELLOW); return;

Deepti Mudgal (PTL0781122) Page 45

CCSD INDIVIDUAL ASSIGNMENT }

[APIIT SD INDIA]

else if(password.getText().equals("")) { message.setText("Password missing."); password.setBackground(Color.YELLOW); return; } else if(username.getText().equals("")) { message.setText("User name missing."); username.setBackground(Color.YELLOW); return; } else if(address.getText().equals("")) { message.setText("Address missing."); address.setBackground(Color.YELLOW); return; } else if(city.getText().equals("")) { message.setText("City missing."); city.setBackground(Color.YELLOW); return; } else if(state.getText().equals("")) { message.setText("State missing."); state.setBackground(Color.YELLOW); Deepti Mudgal (PTL0781122) Page 46

CCSD INDIVIDUAL ASSIGNMENT return; }

[APIIT SD INDIA]

else if(country.getText().equals("")) { message.setText("Country missing."); country.setBackground(Color.YELLOW); return; } else if(mobile.getText().equals("")) { message.setText("Mobile number missing."); mobile.setBackground(Color.YELLOW); return; } else if(email.getText().equals("")) { message.setText("Email missing."); email.setBackground(Color.YELLOW); return; } else if(new UserInfoDAO().isExist("userid",loginid.getText())==true) { message.setText("Login ID already exist."); email.setBackground(Color.YELLOW); return; } else { UserInfo userinfo=new UserInfo(); Deepti Mudgal (PTL0781122) Page 47

CCSD INDIVIDUAL ASSIGNMENT

[APIIT SD INDIA]

userinfo.setUserid(loginid.getText()); userinfo.setPassword(password.getText()); userinfo.setName(username.getText()); userinfo.setAddress(address.getText()); userinfo.setCity(city.getText()); userinfo.setState(state.getText()); userinfo.setCountry(country.getText()); userinfo.setMobile(mobile.getText()); userinfo.setEmail(email.getText()); userinfo.setPin(((int)(Math.random()*999.0)) + "" + Calendar.getInstance().getTimeInMillis()+""); userinfo.setRegistrationdate(new java.sql.Timestamp(Calendar.getInstance().getTimeInMillis()));

UserInfoDAO uidao = new UserInfoDAO(); boolean result = uidao.newUser(userinfo); if(result==true) { message.setText("User information saved."); JDialog dialog = new JDialog(this, "Confirmation."); dialog.setSize(500, 200); dialog.setLayout(null); JLabel label = new JLabel("User information saved."); label.setFont(new Font("arial", Font.BOLD,32)); label.setBounds(20, 20, 450, 100); dialog.add(label); dialog.setVisible(true); } else

Deepti Mudgal (PTL0781122) Page 48

CCSD INDIVIDUAL ASSIGNMENT {

[APIIT SD INDIA]

message.setText("User information not saved."); } }

/** * @param args the command line arguments */ public static void main(String args[]) { java.awt.EventQueue.invokeLater(new Runnable() { public void run() { new NewUser().setVisible(true); } }); }

// Variables declaration - do not modify private javax.swing.JTextField address; private javax.swing.JTextField city; private javax.swing.JTextField country; private javax.swing.JTextField email; private javax.swing.JButton jButton1; private javax.swing.JButton jButton3; private javax.swing.JLabel jLabel1; private javax.swing.JLabel jLabel10; Deepti Mudgal (PTL0781122) Page 49

CCSD INDIVIDUAL ASSIGNMENT private javax.swing.JLabel jLabel2; private javax.swing.JLabel jLabel3; private javax.swing.JLabel jLabel4; private javax.swing.JLabel jLabel5; private javax.swing.JLabel jLabel6; private javax.swing.JLabel jLabel7; private javax.swing.JLabel jLabel8; private javax.swing.JLabel jLabel9;

[APIIT SD INDIA]

private javax.swing.JTextField loginid; private javax.swing.JLabel message; private javax.swing.JTextField mobile; private javax.swing.JPasswordField password; private javax.swing.JTextField state; private javax.swing.JTextField username; // End of variables declaration

*******Cancel Booking******* /* * To change this template, choose Tools | Templates * and open the template in the editor. */

/* * CancelBooking.java * * Created on Apr 24, 2011, 11:44:47 AM */ Deepti Mudgal (PTL0781122) Page 50

CCSD INDIVIDUAL ASSIGNMENT

[APIIT SD INDIA]

package Indiarailreservation;

import java.awt.Font; import java.util.Vector; import javax.swing.JDialog; import javax.swing.JLabel;

/** * * @author Krishna */ public class CancelBooking extends javax.swing.JFrame {

/** Creates new form CancelBooking */ public CancelBooking() { initComponents(); }

/** This method is called from within the constructor to * initialize the form. * WARNING: Do NOT modify this code. The content of this method is * always regenerated by the Form Editor. */ @SuppressWarnings("unchecked") // <editor-fold defaultstate="collapsed" desc="Generated Code"> private void initComponents() {

jLabel1 = new javax.swing.JLabel(); Deepti Mudgal (PTL0781122) Page 51

CCSD INDIVIDUAL ASSIGNMENT

[APIIT SD INDIA]

jScrollPane1 = new javax.swing.JScrollPane(); result = new javax.swing.JList(); jButton1 = new javax.swing.JButton(); cancelbutton = new javax.swing.JButton(); jLabel2 = new javax.swing.JLabel(); bookingno = new javax.swing.JTextField(); jButton3 = new javax.swing.JButton();

setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); setTitle("Cancel Booking");

jLabel1.setFont(new java.awt.Font("Tahoma", 0, 24)); jLabel1.setText("Cancel Booking Detail");

jScrollPane1.setViewportView(result);

jButton1.setText("Close"); jButton1.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton1ActionPerformed(evt); } });

cancelbutton.setText("Cancel Booking"); cancelbutton.setEnabled(false); cancelbutton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { cancelbuttonActionPerformed(evt); } Deepti Mudgal (PTL0781122) Page 52

CCSD INDIVIDUAL ASSIGNMENT });

[APIIT SD INDIA]

jLabel2.setText(" Enter Booking No");

jButton3.setText("Search"); jButton3.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton3ActionPerformed(evt); } });

javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addContainerGap() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING ) .addGroup(layout.createSequentialGroup() .addComponent(cancelbutton) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jButton1)) .addComponent(jScrollPane1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 386, Short.MAX_VALUE) .addComponent(jLabel1, javax.swing.GroupLayout.Alignment.LEADING) .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup() .addComponent(jLabel2) .addGap(18, 18, 18) Deepti Mudgal (PTL0781122) Page 53

CCSD INDIVIDUAL ASSIGNMENT

[APIIT SD INDIA]

.addComponent(bookingno, javax.swing.GroupLayout.PREFERRED_SIZE, 200, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(18, 18, 18) .addComponent(jButton3))) .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addContainerGap() .addComponent(jLabel1) .addGap(18, 18, 18) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE ) .addComponent(jLabel2) .addComponent(bookingno, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jButton3)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 170, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE ) .addComponent(jButton1) .addComponent(cancelbutton)) .addContainerGap(18, Short.MAX_VALUE)) );

pack(); }// </editor-fold> Deepti Mudgal (PTL0781122) Page 54

CCSD INDIVIDUAL ASSIGNMENT

[APIIT SD INDIA]

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: this.setVisible(false); }

private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: String _bookingno = bookingno.getText().trim(); if(_bookingno==null || _bookingno.equals("")) return;

long bkno = Long.parseLong(_bookingno); BookingInfo binfo = new BookingInfoDAO().findBooking(bkno); if(binfo==null) { result.removeAll(); cancelbutton.setEnabled(false); return; } else { Vector<String> bkinfo = new Vector<String>(); bkinfo.add("Transaction No : " + binfo.getTransactionno()); bkinfo.add("Train No : " + binfo.getTrainno()); bkinfo.add("Travel Date : " + binfo.getTraveldate()); bkinfo.add("Travel From : " + binfo.getTravelfrom()); bkinfo.add("Travel To : " + binfo.getTravelto()); bkinfo.add("Booking seat : " + binfo.getSeatbooked()); Deepti Mudgal (PTL0781122) Page 55

CCSD INDIVIDUAL ASSIGNMENT result.removeAll(); result.setListData(bkinfo); cancelbutton.setEnabled(true); } }

[APIIT SD INDIA]

private void cancelbuttonActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here:

String _bookingno = bookingno.getText().trim(); if(_bookingno==null || _bookingno.equals("")) return;

long bkno = Long.parseLong(_bookingno); BookingInfo binfo = new BookingInfoDAO().findBooking(bkno); if(binfo==null) { result.removeAll(); cancelbutton.setEnabled(false); return; } else {

boolean cancelresult = new BookingInfoDAO().cancelBooking(binfo.getTransactionno()); if(cancelresult==true) { JDialog dialog = new JDialog(this, "Cancelation."); Deepti Mudgal (PTL0781122) Page 56

CCSD INDIVIDUAL ASSIGNMENT dialog.setSize(500, 200); dialog.setLayout(null);

[APIIT SD INDIA]

JLabel label = new JLabel("Reservation canceled."); label.setFont(new Font("arial", Font.BOLD,32)); label.setBounds(20, 20, 450, 100); dialog.add(label); dialog.setVisible(true); cancelbutton.setEnabled(false); } else { JDialog dialog = new JDialog(this, "Cancelation."); dialog.setSize(500, 200); dialog.setLayout(null); JLabel label = new JLabel("Reservation not canceled."); label.setFont(new Font("arial", Font.BOLD,32)); label.setBounds(20, 20, 450, 100); dialog.add(label); dialog.setVisible(true); }

//new BookingInfoDAO().cancelBooking(WIDTH); }

/** * @param args the command line arguments */ Deepti Mudgal (PTL0781122) Page 57

CCSD INDIVIDUAL ASSIGNMENT

[APIIT SD INDIA]

public static void main(String args[]) { java.awt.EventQueue.invokeLater(new Runnable() { public void run() { new CancelBooking().setVisible(true); } }); }

// Variables declaration - do not modify private javax.swing.JTextField bookingno; private javax.swing.JButton cancelbutton; private javax.swing.JButton jButton1; private javax.swing.JButton jButton3; private javax.swing.JLabel jLabel1; private javax.swing.JLabel jLabel2; private javax.swing.JScrollPane jScrollPane1; private javax.swing.JList result; // End of variables declaration

Deepti Mudgal (PTL0781122) Page 58

CCSD INDIVIDUAL ASSIGNMENT

[APIIT SD INDIA]

********Find Booking Details*********

/* * To change this template, choose Tools | Templates * and open the template in the editor. */

/* * FindBooking.java * * Created on Apr 24, 2011, 11:45:19 AM */

package Indiarailreservation;

import java.util.Vector;

/** * * @author Krishna */ public class FindBooking extends javax.swing.JFrame {

/** Creates new form FindBooking */ public FindBooking() { initComponents(); Deepti Mudgal (PTL0781122) Page 59

CCSD INDIVIDUAL ASSIGNMENT }

[APIIT SD INDIA]

/** This method is called from within the constructor to * initialize the form. * WARNING: Do NOT modify this code. The content of this method is * always regenerated by the Form Editor. */ @SuppressWarnings("unchecked") // <editor-fold defaultstate="collapsed" desc="Generated Code"> private void initComponents() {

jLabel1 = new javax.swing.JLabel(); jLabel2 = new javax.swing.JLabel(); bookingno = new javax.swing.JTextField(); jButton3 = new javax.swing.JButton(); jScrollPane1 = new javax.swing.JScrollPane(); result = new javax.swing.JList(); jButton1 = new javax.swing.JButton();

setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); setTitle("Find Boolink Record");

jLabel1.setFont(new java.awt.Font("Tahoma", 0, 24)); jLabel1.setText("Find Booking Detail");

jLabel2.setText("Enter Booking No");

jButton3.setText("Search"); jButton3.addActionListener(new java.awt.event.ActionListener() { Deepti Mudgal (PTL0781122) Page 60

CCSD INDIVIDUAL ASSIGNMENT

[APIIT SD INDIA]

public void actionPerformed(java.awt.event.ActionEvent evt) { jButton3ActionPerformed(evt); } });

jScrollPane1.setViewportView(result);

jButton1.setText("Close"); jButton1.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton1ActionPerformed(evt); } });

javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addContainerGap() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addGap(10, 10, 10) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAIL ING) .addGroup(layout.createSequentialGroup() .addGap(111, 111, 111) .addComponent(jButton1))

Deepti Mudgal (PTL0781122) Page 61

CCSD INDIVIDUAL ASSIGNMENT

[APIIT SD INDIA]

.addComponent(jScrollPane1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 383, Short.MAX_VALUE) .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup() .addComponent(jLabel2) .addGap(18, 18, 18) .addComponent(bookingno, javax.swing.GroupLayout.PREFERRED_SIZE, 200, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(18, 18, 18) .addComponent(jButton3)))) .addComponent(jLabel1)) .addContainerGap()) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addContainerGap() .addComponent(jLabel1) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 11, Short.MAX_VALUE) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE ) .addComponent(jLabel2) .addComponent(bookingno, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jButton3)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 170, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(jButton1) .addContainerGap()) Deepti Mudgal (PTL0781122) Page 62

CCSD INDIVIDUAL ASSIGNMENT );

[APIIT SD INDIA]

pack(); }// </editor-fold>

private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: String _bookingno = bookingno.getText().trim(); if(_bookingno==null || _bookingno.equals("")) return;

long bkno = Long.parseLong(_bookingno); BookingInfo binfo = new BookingInfoDAO().findBooking(bkno); if(binfo==null) { result.removeAll(); return; } else { Vector<String> bkinfo = new Vector<String>(); bkinfo.add("Transaction No : " + binfo.getTransactionno()); bkinfo.add("Train No : " + binfo.getTrainno()); bkinfo.add("Travel Date : " + binfo.getTraveldate()); bkinfo.add("Travel From : " + binfo.getTravelfrom()); bkinfo.add("Travel To : " + binfo.getTravelto()); bkinfo.add("Booking seat : " + binfo.getSeatbooked()); result.removeAll(); result.setListData(bkinfo); } }

Deepti Mudgal (PTL0781122) Page 63

CCSD INDIVIDUAL ASSIGNMENT

[APIIT SD INDIA]

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: this.setVisible(false); }

/** * @param args the command line arguments */ public static void main(String args[]) { java.awt.EventQueue.invokeLater(new Runnable() { public void run() { new FindBooking().setVisible(true); } }); }

// Variables declaration - do not modify private javax.swing.JTextField bookingno; private javax.swing.JButton jButton1; private javax.swing.JButton jButton3; private javax.swing.JLabel jLabel1; private javax.swing.JLabel jLabel2; private javax.swing.JScrollPane jScrollPane1; private javax.swing.JList result; // End of variables declaration

*******Add New Reservation Form********* Deepti Mudgal (PTL0781122) Page 64

CCSD INDIVIDUAL ASSIGNMENT

[APIIT SD INDIA]

package Indiarailreservation;

import java.awt.Font; import java.sql.Date; import java.sql.Timestamp; import java.util.Calendar; import java.util.Vector; import javax.swing.JDialog; import javax.swing.JLabel;

public class NewBooking extends javax.swing.JFrame {

/** Creates new form NewBooking */ public NewBooking() { initComponents(); }

/** This method is called from within the constructor to * initialize the form. * WARNING: Do NOT modify this code. The content of this method is * always regenerated by the Form Editor. */ @SuppressWarnings("unchecked") // <editor-fold defaultstate="collapsed" desc="Generated Code"> private void initComponents() {

Deepti Mudgal (PTL0781122) Page 65

CCSD INDIVIDUAL ASSIGNMENT

[APIIT SD INDIA]

jLabel1 = new javax.swing.JLabel(); jLabel2 = new javax.swing.JLabel(); jLabel3 = new javax.swing.JLabel(); jLabel4 = new javax.swing.JLabel(); mm = new javax.swing.JComboBox(); dd = new javax.swing.JComboBox(); yy = new javax.swing.JComboBox(); stationfrom = new javax.swing.JComboBox(); stationto = new javax.swing.JComboBox(); jButton1 = new javax.swing.JButton(); jButton2 = new javax.swing.JButton(); jScrollPane1 = new javax.swing.JScrollPane(); trainlist = new javax.swing.JList(); jLabel5 = new javax.swing.JLabel(); seatclass = new javax.swing.JComboBox(); jLabel6 = new javax.swing.JLabel(); nos = new javax.swing.JComboBox(); jButton3 = new javax.swing.JButton(); jScrollPane2 = new javax.swing.JScrollPane(); personlist = new javax.swing.JList(); jLabel7 = new javax.swing.JLabel(); pin = new javax.swing.JTextField(); jButton4 = new javax.swing.JButton(); jLabel8 = new javax.swing.JLabel(); personname = new javax.swing.JTextField(); jLabel9 = new javax.swing.JLabel(); age = new javax.swing.JTextField(); jLabel10 = new javax.swing.JLabel(); bankacno = new javax.swing.JTextField(); Deepti Mudgal (PTL0781122) Page 66

CCSD INDIVIDUAL ASSIGNMENT

[APIIT SD INDIA]

jLabel11 = new javax.swing.JLabel(); bankname = new javax.swing.JComboBox(); jButton5 = new javax.swing.JButton(); jLabel12 = new javax.swing.JLabel(); loginid = new javax.swing.JTextField();

setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); setTitle("Add New Booking");

jLabel1.setFont(new java.awt.Font("Tahoma", 0, 24)); jLabel1.setText("Railway Reservation");

jLabel2.setText(" Reservation");

jLabel3.setText("Reservation From");

jLabel4.setText(" Reservation To");

mm.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" }));

dd.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31" }));

yy.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "2011", "2012" }));

stationfrom.setModel(new javax.swing.DefaultComboBoxModel(new TrainStationInfoDAO().stationFrom_()));

Deepti Mudgal (PTL0781122) Page 67

CCSD INDIVIDUAL ASSIGNMENT

[APIIT SD INDIA]

stationto.setModel(new javax.swing.DefaultComboBoxModel(new TrainStationInfoDAO().stationTo_()));

jButton1.setText("Check"); jButton1.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton1ActionPerformed(evt); } });

jButton2.setText("Exit"); jButton2.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton2ActionPerformed(evt); } });

jScrollPane1.setViewportView(trainlist);

jLabel5.setText("Seat Type");

seatclass.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "First AC", "Second AC" }));

jLabel6.setText("No of Seats");

nos.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "20", "21" }));

jButton3.setText("Add in list"); Deepti Mudgal (PTL0781122) Page 68

CCSD INDIVIDUAL ASSIGNMENT

[APIIT SD INDIA]

jButton3.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton3ActionPerformed(evt); } });

jScrollPane2.setViewportView(personlist);

jLabel7.setText("Enter 16 digit Pin Number");

jButton4.setText("Reservation Now"); jButton4.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton4ActionPerformed(evt); } });

jLabel8.setText("Traveler Name");

jLabel9.setText("Age");

age.setText("0");

jLabel10.setText("Bank Account No");

jLabel11.setText("Bank Name");

bankname.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "PUNJAB NATIONAL BANK", "HDFC BANK", "STATE BANK OF INDIA", " " })); Deepti Mudgal (PTL0781122) Page 69

CCSD INDIVIDUAL ASSIGNMENT

[APIIT SD INDIA]

jButton5.setText("Seats Availablity"); jButton5.setActionCommand(" Seats Availablity"); jButton5.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton5ActionPerformed(evt); } });

jLabel12.setText("Enter Login ID");

javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addGap(50, 50, 50) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jLabel5) .addComponent(jLabel8)) .addGap(10, 10, 10) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING ) .addComponent(seatclass, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(personname, javax.swing.GroupLayout.PREFERRED_SIZE, 174, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGap(18, 18, 18) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

Deepti Mudgal (PTL0781122) Page 70

CCSD INDIVIDUAL ASSIGNMENT .addComponent(jLabel9) .addComponent(jLabel6)) .addGap(24, 24, 24)

[APIIT SD INDIA]

.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) .addGroup(layout.createSequentialGroup() .addComponent(age, javax.swing.GroupLayout.PREFERRED_SIZE, 31, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jButton3)) .addGroup(layout.createSequentialGroup() .addComponent(nos, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(18, 18, 18) .addComponent(jButton5))) .addContainerGap(406, Short.MAX_VALUE)) .addGroup(layout.createSequentialGroup() .addGap(137, 137, 137) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADI NG) .addComponent(jScrollPane2, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 779, Short.MAX_VALUE) .addComponent(jScrollPane1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 779, Short.MAX_VALUE) .addGroup(layout.createSequentialGroup() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.T RAILING, false) .addComponent(jLabel1, javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() Deepti Mudgal (PTL0781122) Page 71

CCSD INDIVIDUAL ASSIGNMENT

[APIIT SD INDIA]

.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignme nt.LEADING) .addComponent(jLabel2) .addComponent(jLabel3)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELAT ED, 36, Short.MAX_VALUE) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignme nt.LEADING, false) .addGroup(layout.createSequentialGroup() .addComponent(mm, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RE LATED) .addComponent(dd, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RE LATED) .addComponent(yy, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addComponent(stationfrom, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addGap(18, 18, 18) .addComponent(jLabel4))) .addGap(18, 18, 18) .addComponent(stationto, javax.swing.GroupLayout.PREFERRED_SIZE, 164, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(18, 18, 18) .addComponent(jButton1))) .addGap(58, 58, 58)) .addGroup(layout.createSequentialGroup() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADI NG) .addGroup(layout.createSequentialGroup()

Deepti Mudgal (PTL0781122) Page 72

CCSD INDIVIDUAL ASSIGNMENT

[APIIT SD INDIA]

.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.L EADING) .addGroup(layout.createSequentialGroup() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignme nt.LEADING) .addComponent(jLabel10) .addComponent(jLabel12)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELAT ED, 44, Short.MAX_VALUE)) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() .addComponent(jLabel11) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELAT ED, 72, Short.MAX_VALUE)) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() .addComponent(jLabel7) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELAT ED))) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.T RAILING) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment. LEADING) .addComponent(pin, javax.swing.GroupLayout.DEFAULT_SIZE, 499, Short.MAX_VALUE) .addComponent(bankname, javax.swing.GroupLayout.PREFERRED_SIZE, 499, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment. LEADING, false) .addComponent(loginid) .addComponent(bankacno, javax.swing.GroupLayout.DEFAULT_SIZE, 499, Short.MAX_VALUE))) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED))

Deepti Mudgal (PTL0781122) Page 73

CCSD INDIVIDUAL ASSIGNMENT

[APIIT SD INDIA]

.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() .addComponent(jButton4) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jButton2) .addGap(2, 2, 2))) .addGap(213, 213, 213)))) );

layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {bankacno, bankname});

layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addContainerGap() .addComponent(jLabel1) .addGap(26, 26, 26) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE ) .addComponent(jLabel2) .addComponent(mm, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(dd, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(yy, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGap(18, 18, 18) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE ) .addComponent(jLabel3)

Deepti Mudgal (PTL0781122) Page 74

CCSD INDIVIDUAL ASSIGNMENT

[APIIT SD INDIA]

.addComponent(stationfrom, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jLabel4) .addComponent(stationto, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jButton1)) .addGap(23, 23, 23) .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 166, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(18, 18, 18) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE ) .addComponent(jLabel5) .addComponent(seatclass, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jLabel6) .addComponent(nos, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jButton5)) .addGap(18, 18, 18) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE ) .addComponent(jLabel8) .addComponent(personname, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jLabel9) .addComponent(age, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jButton3)) .addGap(18, 18, 18) .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 148, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(12, 12, 12) Deepti Mudgal (PTL0781122) Page 75

CCSD INDIVIDUAL ASSIGNMENT

[APIIT SD INDIA]

.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING ) .addComponent(jLabel12) .addComponent(loginid, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE ) .addComponent(jLabel10) .addComponent(bankacno, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGap(12, 12, 12) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE ) .addComponent(jLabel11) .addComponent(bankname, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGap(12, 12, 12) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE ) .addComponent(pin, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jLabel7)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jButton2) .addComponent(jButton4)) .addGap(16, 16, 16)) );

pack(); }// </editor-fold> Deepti Mudgal (PTL0781122) Page 76

CCSD INDIVIDUAL ASSIGNMENT

[APIIT SD INDIA]

private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: this.setVisible(false); }

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: trainlist.setListData(new TrainStationInfoDAO().allTrain_(stationfrom.getSelectedItem().toString(), stationto.getSelectedItem().toString())); }

private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here String _personname = personname.getText(); String _age = age.getText(); if(_personname.trim().equals("") || _age.trim().equals("") || _age.trim().equals("0")) return;

if(plist.contains(_personname.concat("-").concat(_age))) return;

int noss = Integer.parseInt(nos.getSelectedItem().toString()); System.out.println("noss : " + noss); System.out.println("plist.size() : " + plist.size()); if(plist.size()<noss) plist.add(_personname.concat("-").concat(_age)); else

Deepti Mudgal (PTL0781122) Page 77

CCSD INDIVIDUAL ASSIGNMENT return;

[APIIT SD INDIA]

personlist.setListData(plist); }

private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here:

long _trxno = Calendar.getInstance().getTimeInMillis(); String[] traindata = trainlist.getSelectedValue().toString().split("-"); String _trainno = traindata[0].trim(); long _bookingno = _trxno; Timestamp _bookingon = new Timestamp(_trxno); String _pin = pin.getText().trim(); int _dd = dd.getSelectedIndex()+1; int _mm = mm.getSelectedIndex()+1; String _loginid=loginid.getText().trim(); int _yy = Integer.parseInt(yy.getSelectedItem().toString())-1900; Date _traveldate = new Date(_yy, _mm, _dd); String _travelfrom = stationfrom.getSelectedItem().toString(); String _travelto = stationto.getSelectedItem().toString(); int _seatclass = seatclass.getSelectedIndex()+1; int _nos = nos.getSelectedIndex()+1; String _bankacno = bankacno.getText().trim(); String _bankname=bankname.getSelectedItem().toString();

String _mypin = new UserInfoDAO().pin(_loginid);

if(_mypin!=null && _mypin.equals(_pin)) Deepti Mudgal (PTL0781122) Page 78

CCSD INDIVIDUAL ASSIGNMENT {

[APIIT SD INDIA]

BookingInfo binfo = new BookingInfo(); binfo.setTransactionno(_trxno); binfo.setTrainno(_trainno); binfo.setBookingno(_bookingno); binfo.setBookingdate(_bookingon); binfo.setPin(_pin); binfo.setLoginid(_loginid); binfo.setTraveldate(_traveldate); binfo.setTravelfrom(_travelfrom); binfo.setTravelto(_travelto); binfo.setSeatclass(_seatclass); binfo.setSeatbooked(_nos); binfo.setStatus("B"); binfo.setStatusupdatedon(_bookingon); binfo.setBankname(_bankname); binfo.setBookingno(_bookingno);

long result = new BookingInfoDAO().newBooking(binfo); if(result!=0) { System.out.println("Saved."); JDialog dialog = new JDialog(this, "Confirmation"); dialog.setSize(600, 200); dialog.setLayout(null); JLabel label = new JLabel("Seats booked successfully. Booking no : " + _trxno); label.setFont(new Font("arial", Font.BOLD,20)); label.setBounds(20, 20, 550, 100); dialog.add(label); Deepti Mudgal (PTL0781122) Page 79

CCSD INDIVIDUAL ASSIGNMENT dialog.setVisible(true); } else {

[APIIT SD INDIA]

System.out.println("Information not saved."); } } else { bookingcounter++; if(bookingcounter>3) { System.exit(0); }

JDialog dialog = new JDialog(this, "Alert Counter : " + bookingcounter); dialog.setSize(600, 200); dialog.setLayout(null); JLabel label = new JLabel("Invalid PIN No."); label.setFont(new Font("arial", Font.BOLD,20)); label.setBounds(20, 20, 550, 100); dialog.add(label); dialog.setVisible(true);

} }

private void jButton5ActionPerformed(java.awt.event.ActionEvent evt) { Deepti Mudgal (PTL0781122) Page 80

CCSD INDIVIDUAL ASSIGNMENT

[APIIT SD INDIA]

// TODO add your handling code here: String _trainno = ((trainlist.getSelectedValue().toString().split("-"))[0]); int _dd = dd.getSelectedIndex()+1; int _mm = mm.getSelectedIndex()+1; int _yy = Integer.parseInt(yy.getSelectedItem().toString())-1900; Date _traveldate = new Date(_yy, _mm, _dd);

Vector<String> result=new BookingInfoDAO().findSeatsAvailablity(_trainno, _traveldate);

JDialog dialog = new JDialog(this, "Alert"); dialog.setSize(600, 400); dialog.setLayout(null); JLabel label1 = new JLabel(result.get(0)); JLabel label2 = new JLabel(result.get(1)); JLabel label3 = new JLabel(result.get(2)); JLabel label4 = new JLabel(result.get(3)); label1.setFont(new Font("arial", Font.BOLD,14)); label2.setFont(new Font("arial", Font.BOLD,14)); label3.setFont(new Font("arial", Font.BOLD,14)); label4.setFont(new Font("arial", Font.BOLD,14)); label1.setBounds(20, 20, 450, 100); label2.setBounds(20, 50, 450, 100); label3.setBounds(20, 80, 450, 100); label4.setBounds(20, 110, 450, 100); dialog.add(label1); dialog.add(label2); dialog.add(label3); dialog.add(label4); dialog.setVisible(true); Deepti Mudgal (PTL0781122) Page 81

CCSD INDIVIDUAL ASSIGNMENT

[APIIT SD INDIA]

/** * @param args the command line arguments */ public static void main(String args[]) { java.awt.EventQueue.invokeLater(new Runnable() { public void run() { new NewBooking().setVisible(true); } }); }

Vector<String> plist = new Vector<String>(); private int bookingcounter=0;

// Variables declaration - do not modify private javax.swing.JTextField age; private javax.swing.JTextField bankacno; private javax.swing.JComboBox bankname; private javax.swing.JComboBox dd; private javax.swing.JButton jButton1; private javax.swing.JButton jButton2; private javax.swing.JButton jButton3; private javax.swing.JButton jButton4; private javax.swing.JButton jButton5; private javax.swing.JLabel jLabel1; private javax.swing.JLabel jLabel10; Deepti Mudgal (PTL0781122) Page 82

CCSD INDIVIDUAL ASSIGNMENT private javax.swing.JLabel jLabel11; private javax.swing.JLabel jLabel12; private javax.swing.JLabel jLabel2; private javax.swing.JLabel jLabel3; private javax.swing.JLabel jLabel4; private javax.swing.JLabel jLabel5; private javax.swing.JLabel jLabel6; private javax.swing.JLabel jLabel7; private javax.swing.JLabel jLabel8; private javax.swing.JLabel jLabel9;

[APIIT SD INDIA]

private javax.swing.JScrollPane jScrollPane1; private javax.swing.JScrollPane jScrollPane2; private javax.swing.JTextField loginid; private javax.swing.JComboBox mm; private javax.swing.JComboBox nos; private javax.swing.JList personlist; private javax.swing.JTextField personname; private javax.swing.JTextField pin; private javax.swing.JComboBox seatclass; private javax.swing.JComboBox stationfrom; private javax.swing.JComboBox stationto; private javax.swing.JList trainlist; private javax.swing.JComboBox yy; // End of variables declaration

Deepti Mudgal (PTL0781122) Page 83

Potrebbero piacerti anche