You are on page 1of 280

Project Report On COUNSCELING

Submitted in partial fulfillment of Award of the Degree of Masters Of Computers Applications (2003 06)

Under the supervision of: -

Mr. Ajay Kumar Singh (Project Manager) Gnix Infosoft Ltd.

Submitted To: -

Submitted By: -

Prof. S.P. KandiKamal Deep Chairperson MCA Program Roll No. : - 0303814037 Session: - 2003 2006 MCA VIth Semester

Institute Of Technology & Science


Mohan Nagar, Ghaziabad 201007

(Affiliated to U.P. Technical University, Lucknow)

ACKNOWLEDGEMENT

This project would not have taken shape without the guidance provided by Mr. Ajay Kumar Singh of Gnix Infosoft, project manager of the project; I profusely thank him for giving his support, encouragement and assistance to complete the project on time. . I would also like to profusely express my gratitude to Prof. S. P. Kandy, Chairperson of I.T. Department for being a wonderful source of guidance for this project. I am grateful to him for lending his precious time and the patient listening they gave me every time I needed in spite of their busy schedule.

I am also grateful to the lab assistant and our seniors who have helped us in completing this project. Last but not the least, I thank to my team members and friends for their constant support.

Above all I wish to express my heartfelt gratitude to my parents, without their support, blessings and motivation, I would not have been able to undertake this project in the first place.

Kamal Deep MCA 6th Sem. Institute of Technology & Science, Mohan Nagar, Ghaziabad [Section Break]

Institute Of Technology & Science

G.T. Road, Mohan Nagar, Ghaziabad

Phone 0120 2657217 (IT Department), 2657258, 2657259

This is to certify that Mr. Kamal Deep, Student of MCA Program (Batch 200306) of this institute has successfully completed his project titled Counsceling at Gnix Infosoft Ltd. under the guidance of Mr. Ajay Kumar Singh (Project Manager) as a part of the course curriculum of MCA Program affiliated to U.P. Technical University, Lucknow.

To the best of my knowledge this project is an authentic record of students own work. During the execution of this project students sincerity and devotion was found per excellence.

I wish him success at every stage of his/her career.

Prof. S.P. Kandi Professor & Chairperson MCA Program Dept. of IT, Institute of Technology & Science, Mohan Nagar, Ghaziabad

TABLE OF CONTENTS
[1.INTRODUCTION

1.1Profile of the Company 2.ABOUT PROJECT 3.EVALUATION OF EXISTING SYSTEM 3.1Overview Of The Existing System 3.2Limitations of the Existing System 4.PROPOSED SYSTEM 4.1 Introduction

4.2Features of the proposed system 5.OBJECTIVE OF THE PROJECT 6.Scope of the project 7.System Analysis 7.1Introduction 7.2Requirement analysis 7.3S/w & H/w requirement specification 7.4Feasibility study 7.5Software engineering paradigm 8.System DESIGN 8.1Introduction 8.2Module description 8.3Data flow diagram

8.4E-r diagram 8.5Database design 8.6Input-output design 8.7Input-output forms

9.CODE DESIGN 10.testing 10.1System testing 10.2Unit testing 10.3Module testing 10.4Integration testing 10.5Acceptance testing 11.IMPLEMENTATION & MAINTENANCE 11.1Implementation 11.2Maintenance 11.3Cost estimation 12.CONCLUSIONS 13.bibliography
]

ABOUT PROJECT
Project Title: - Counseling

The Counseling is developed to enhance counseling. The software will be great relief to the students. The Counseling is developing to enhance the counseling, which fully works as an online. This software will be great relief to the student for Reporting, Registration and searching the information about college and university. This software gives an overview of the entire institute in a sort interval time and will be also great help to University to manage in the whole counseling procedure by there paper work and reducing their time. This project consist fallowing modules.

(1) Institute record - Covering Details regarding Institute (2) Student record - Covering Details regarding Students (3) Counseling - Helps in Category wise counseling.

EVALUATION OF EXISTING SYSTEM


Existing System: -

Present system or Existing system of Counseling Management System working manually or computerized in a building. Therefore all types works are maintain in building. So maintain all the counseling procedure very difficult. If we are reporting, then we need go to the University and get a form for reporting and fill the form and submit in the queue conditions. Then verify there form by the university and maintain the record in computer or register. The system is mainly related to online counseling management system. Which is developing an online web based application system, it is necessary to make a thorough study of the existing system .There is no online Counseling Management System .The all the information not maintains globally. Therefore to maintain all the information of university is very difficult

Limitations of the Existing System: The maintenance of various records and procedure of reporting are being done manually by the counseling department. This leads to many drawbacks some of which are:

It is a time consuming process. Proper arrangements should be made before and after the examination -which is both money spending and time consuming.

As the number of students increases counseling process becomes more and more difficult. Not globally maintain the information Evaluating of answer sheets also consumes heavy amount of time. Difficult to management the all types of information of college or university Further more, manual evaluation is prone to errors.

PROPOSED SYSTEM
4.1 Introduction: In proposed system at first reduce the problem, which is faced in Existing System. So In the proposed system, Counseling will provide the on line facility for reporting/registration or access any type of information about the college/university and globally maintain all the information by the university

and are- : -

this project consist fallowing modules

(1) Institute Record: Provide the fallowing types of facilities using different options: Insert:- This part allow any new institute, if we want to participate in counseling then enter its details regarding the institute - Institute Code ,Name of the institute, Name of the city, Category wise total number of seats i.e. General Seats, OBC Seats, SC/ST seats. Search: - It provides Searching for any institute details. - On the basis of its code. - On the basis of its name. Delete: - If any institute Withdraw from counseling then this part will help in deleting that institute record. Display: - It will help in displaying complete information about institute code name, city, and total seats according to category.

(2) Student record: - This module has two parts:


Search: - This will provide help in searching record of any student who is allotted seats in an institute during counseling procedure. Delete: - This will allow to deleting record of any student after counseling. The deletion

can be on the basis of Roll no, Name.

(3) Counseling: This is the third and important module .It is divided into category wise counseling. So there are three modes of counseling. (a) General counseling:Candidates in General Category enter in this counseling then he is allotted to see the status of vacant and occupied general eats in every institute the process STATUS if the satisfied he is allotted seats .In this procedure candidate fill the complete form which includes details Name, Roll No, Rank, Sex, Category, etc. But any Student want to

withdraw after allotted the seats then can be withdraw with the help in deleting the student record. b) OBC counseling:Candidates in OBC Category enter in this counseling then he is allotted to see the status of vacant and occupied general eats in every institute the process STATUS if the satisfied he is allotted seats . In this procedure candidate fill the complete form which includes detailsName, Roll No, Rank, Sex, Category, etc. But any Student want to withdraw after allotted the seats then can be withdraw with the help in deleting the student record . (c) C/ST Counseling:Candidates in SC/ST Category enter in this counseling then he is allotted to see the status of vacant and occupied general seats in every institute the process STATUS if the satisfied he is allotted seats .In this procedure candidate fill the complete form which includes details . Name, Roll no, Rank, Sex, Category, etc. But any Student want to withdraw after allotted the seats then can be withdraw with the help in deleting the student record.

Features Of The Proposed System: The proposed system will aim to automate all the activities and eliminate all the drawbacks that the existing system of manual operation faces. The important features of functionality of the proposed system are listed below-

The proposed system will save significant amount of time and effort invested by the university every year. The System fully works as an online. Centralized maintain all information. It helps the university to dynamically add records to the database. Easy to Searching the information about college or university. Easy to managing whole counseling procedure

[Page Break]

OBJECTIVE OF THE PROJECT


Counseling is fully work as online using the internet, which is provides facility online such as- Student Counseling , Managing the student record, Managing the Institute record and Searching the any other information about Counseling procedure/Institutes, this types of information easy to search through the website .
[Page Break]

SCOPE OF THE PROJECT


Types of information Online, and Efficient and systematic maintenance of the huge Database, speeding up queries and faster processing are also be factor for going for this project. This system is applicable for any other university /Institute, which is work as an online .The package will require data to be entered in user-friendly forms. This system provide the scope of online working using the internet such as Student reporting ,counseling ,Institute registration for counseling , searching the information of counseling procedure and total Seats of college etc. There are fallowing modules and forms are used-

(1) Institute Record. (2) Student Record. (3) Counseling. (4) Categorys selection form. (5) Reporting.
[Page Break]

SYSTEM ANALYSIS
Introduction: System Analysis is a detailed study of the various operations performed by a system and their relationship within and outside the system .It is a systematic technique that defines goals and objectives the goal of the development is to deliver the system in the line with the users requirements, and analysis is this process. System study has been conducted with the following objectives in mind:

Identify the clients need. Evaluate the system concept for feasibility. Perform economical and technical analysis. Allocate functional to hardware, software, people, database and other system elements Establish cost and schedule constraints.

Both hardware and software expertise is required to successfully attain the objectives.

Requirement Analysis: Information gathering is usually the first phase of the software development project. The purpose of this phase is to identify and document the exact requirements for the system. The users request identifies the need for a new information system and on investigation re-defined the new problem to be based on MIS, which supports

management. The objective is to determine whether the request is valid and feasible before a recommendation is made to build a new or existing manual system continues. The major steps are

Defining the user requirements. Studying the present system to verify the problem.

S/W and H/W Requirement Specification: -

Hardware Requirements: -

Pentium IV 1.8 GHz and Above 128 MB DDRAM or More 40 GB HDD Printer Power Backup Internet Connection

Software Requirements: -

Windows XP/Wins 2000 Professional My SQL IDE -My Eclipse

[Page Break]

Introduction To Java: Java is a high level, third-generation programming language, like C, FORTRAN, Perl and many others. It is a platform for distributed computing a development and run-time environment that contains built-in support for the World Wide Web.

History Of Java: -

Java development began at Sun Microsystems in 1991, the same year the World Wide Web was conceived. Javas creator, James Gosling did not design java for the Internet. His Objective was to create a common development environment for consumer electronic devices which was easily portable from one device to another. This effort evolved into a language, code named Oak and later renamed Java that retains much of the syntax and power of c++, but is simpler and more platforms independent.

Java Features: Some of the important features of Java are as follows:

Simplicity Object oriented Platform Independence Security Robust High Performance Multi Threading Dynamic linking. Garbage Collection.

One of the most important features of Java is Platform Independence which makes it famous and suitable language for World Wide Web.

Why Java Is Platform Independent?


Java is Platform Independent because of Java Virtual Machine (JVM).

Java Virtual Machine (JVM):The client application or operating system must have a java byte-code interpreter to execute byte-code instructions. The interpreter is a part of a lager program called the JVM. The JVM interprets the byte code into native code and is available on platforms that support java.

When the user runs a Java program, it is unto the JVM to load, possibly verify, and then execute it. The JVM can perform this function from within a browser or any other container program or directly on top of the operating system.

When a browser invokes the JVM to run a Java program, the JVM does a number of things: -

1. It validates the requested byte-codes, verifying that they pass various formatting and security checks. It allocates memory for the in coming java class files and guarantees that the security of JVM is not violated. This is known as the class loader. 2. It interprets the byte code instructions found in the class files to execute the program. Servlets / JSP are middleware technologies which are used in web based projects because they use:1. 2. 3. 4. HTTP Protocol to handle Request and Response. They are invoked through Browser. They give out put in HTML format. They need Browser Support.

We have designed web based forms using Servlets and JSP in which we have defined business logic.

About HTML: Hypertext Markup Language (HTML) is a language for describing how pages of text, graphics, and other information are organized. Hypertext means text stored in electronic form with cross-reference links between pages. An HTML page contains HTML tags, which are embedded commands that supply information about the pages structure, appearance, and contents. Web browsers use this information to determine how to display the page.

About ORACLE 8i: -

Oracle 8i contains all the features of previous version. It also supports some new features & enhancement to some existing features. Oracle servers provide effective solution for the major features.

Large Database & Space Management Control: -

Oracle supports the largest database potential hundreds of Giga Bytes in size. To make efficient use of expensive devices, it allows full control of space usage.

Many Concurrent Database Performances: -

It supports large no of concurrent users executing a variety of database Applications operation on the same data. It minimizes data connection & guarantees data concurrency.

High Transaction Processing Performance: -

Oracle maintains the processing features with a high degree of overall system performance. Database user doesnt suffer from slow processing performance.

High Availability: -

At some sets Oracle works 24 Hours per day with no downtime or limit database throughput. Normal system operation such as database backup & partial completion system failure dont interrupt database use.

Controlled Availability: -

Oracle can selectively control the availability of data at the database level & sub Database level. Eg- an administrator can disallow use of a specific application .Data can be reloaded without affecting other application.

Manageable Security: -

To protect against unauthorized database aspects & users .Oracle provides failsafe security features to limit & monitor the data area. The system makes it easy to manage even the most completed designs for data assets.

Database Enforced Integrity: -

Oracle enforces data integrity Business rules that dictates the standards for applicable data. As result the cost of coding & managing checks in many database applications are eliminated.

Distributed Database System: -

Distributed systems have same degree of user transparency & data consistency as non-distributed systems. Yet receives the advantages of local database management.

Portability: -

Oracle software is compatible to work under different operating system & same on all system. Application developed on Oracle can be used on virtually any system with little or no more modification.

Compatibility: -

Oracle software is compatible with industry standards, including most industry standards operating systems. Application developed on Oracle can be used on virtually any system with little or no modification.

Connectivity: -

Oracle software allows different types of computers & operating system to share information networks.

FEASIBILITY STUDY: Feasibility study is the process of determination of whether or not a project is worth doing. Feasibility studies are undertaken within tight time constraints and normally culminate in a written and oral feasibility report. I have taken two weeks in feasibility study with my co-developer. The contents and recommendations of this feasibility study helped us as a sound basis for deciding how to precede the project. It helped in taking decisions such as which software to use, hardware combinations, etc. The following is the process diagram for feasibility analysis. In the diagram, the feasibility analysis starts with the user set of requirements. With this, the existing system is also observed. The next step is to check for the deficiencies in the existing system. By evaluating the above points a fresh idea is conceived to define and quantify the required goals. The user consent is very important for the new plan. Along with, for implementing the new system, the ability of the organization is also checked. Besides that, a set of alternatives and their feasibility is also considered in case of any failure in the proposed system. Thus, feasibility study is an important part in software development.
[Drawing][Drawing][OLE Object]

(Figure 1) PROCESS DIAGRAM FOR FEASIBILITY ANALYSIS

In the SDLC (Systems Development Life Cycle) of our project we maintained a number of feasibility checkpoints between the two phases of the SDLC. These checkpoints indicate that the management decision to be made after a phase is complete. The feasibility checkpoints in our project were as follows: 1. 2. 3. 4. 5. Survey phase checkpoint Study phase checkpoint Selection phase checkpoint Acquisition phase checkpoint Design phase checkpoint

We together started measuring project feasibility, which lasted two week. During this period we have had consultation with our guide Mr. Ajay Kumar (project leader of Gnix Infosoft) and the management of the organization. In this course we

conducted three tests for Project feasibility namely, Technical, Economical, and Operational feasibilities.

Technical Feasibility: Technical feasibility determines whether the work for the project can be done with the existing equipment, software technology and available personnel. Technical feasibility is concerned with specifying equipment and software that will satisfy the user requirement. This project is feasible on technical remarks also, as the proposed system is more beneficiary in terms of having a sound proof system with new technical components installed on the system. The proposed system can run on any machines supporting Windows and Internet services and works on the best software and hardware that had been used while designing the system so it would be feasible in all technical terms of feasibility.

Technical Feasibility Addresses Three Major Issues: -

1. Is the proposed Technology or Solution Practical? The technologies used are matured enough so that they can be applied to our problems. The practicality of the solution we have developed is proved with the use of the technologies we have chosen. The technologies such as JAVA (JSP, Servlet), JavaScript and the compatible H/Ws are so familiar with the todays knowledge based industry that anyone can easily be compatible to the proposed environment.

2. Do we currently posses the necessary technology? We first make sure that whether the required technologies are available to us or nor. If they are available then we must ask if we have the capacity. For instance, Will our current Printer be able to handle the new reports and forms required of a new system? 3. Do we possess the necessary Technical Expertise and is the Schedule reasonable?

This consideration of technical feasibility is often forgotten during feasibility analysis. We may have the technology, but that doesnt mean we have the skills required to properly apply that technology. As far as our project is concerned we have the necessary expertise so that the proposed solution can be made feasible.

Economical Feasibility: Economical feasibility determines whether there are sufficient benefits in creating to make the cost acceptable, or is the cost of the system too high. As this signifies cost benefit analysis and savings. On the behalf of the cost-benefit analysis, the proposed system is feasible and is economical regarding its pre-assumed cost for making a system. During the economical feasibility test we maintained the balance between the Operational and Economical feasibilities, as the two were the conflicting. For example the solution that provides the best operational impact for the end-users may also be the most expensive and, therefore, the least economically feasible. We classified the costs of Online Counseling according to the phase in which they occur. As we know that the system development costs are usually one-time costs that will not recur after the project has been completed. For calculating the Development costs we evaluated certain cost categories viz. 1. 2. 3. 4. 5. Personnel costs Computer usage Training Supply and equipments costs Cost of any new computer equipments and software.

In order to test whether the Proposed System is cost-effective or not we evaluated it through three techniques viz.

Payback analysis Return on Investment: Net Present value

Operational Feasibility: Operational feasibility criteria measure the urgency of the problem (survey and study phases) or the acceptability of a solution (selection, acquisition and design

phases). How do you measure operational feasibility? There are two aspects of operational feasibility to be considered: (a) Is the problem worth solving or will the solution to the problem work? There are certain measures, which decide, the effectiveness of the system. These measures can be collectively called as PIECES.

P (Performance): The counsceling provides adequate throughput and response time. I (Information): The counsceling provides Student and Staff with tamely, pertinent, accurate, and usefully formatted information. E (Economy): The counsceling of reduce the cost of the Counseling or Student reporting (selection). C (Control): The counsceling offer globally controls to protect against fraud and to guarantee the accuracy and security of the data and information. E (Efficiency): The counsceling makes maximum use of available resources and minimum processing delays. S (Services): The counsceling provides desirable and reliable service to those who need it. The counsceling is flexible and expandable.

(b) How do the students and staff feel about the problem (Solution)? It is not only important to evaluate whether a system can work. We must also evaluate whether a system will work. A workable solution might fail because of Students, Staff resistance.

In case of our project Counsceling we have examined all the concerns that can further affect its operational feasibility. The following points will explore those concerns. The Counsceling has complete support of the Student/Staff as an online reporting and access the information. The Counsceling has made the role of Student easiest one. The Student /Staff feel comfortable and upgraded with this system.

Software Engineering Paradigm Applied: The development strategy that encompasses the process, methods, and tools and the generic phases is called Software Engineering Paradigm. The s/w paradigm for software is chosen based on the nature of the project and application, the method and tools to be used, and the controls and deliverables that are required. All software development can be characterized as a problem-solving loops (fig. 2) in which four distinct stages are encountered: - status quo, problem definition, technical development, and solution integration.
[Drawing]

(Figure - 2) Problem Solving Loop

Status quo represents the current state of affairs, Problem definition identifies the specific problem to be solved, technical development solves the problem through the application of some technology, and solution integration delivers the results to those who requested the solution in the first place. There are various software paradigms, but we used Waterfall model (the linear sequential model), which states that the phases are organized in a linear order. The Waterfall model suggests a systematic, sequential approach to s/w development that begins at the system level and progresses through analysis, design, coding, testing, and maintenance and support as shown in below fig.3.

[Drawing]

Requirement Document & Project plan System & Detailed Design document Programs Test plan, Report & manuals

Installation Report

(Figure- 3) Waterfall model The sequence of activities performed in a software development project with the Waterfall model is: system analysis, system design, coding, testing & integration, installation, and maintenance. For a successful project resulting in a successful product, all phases listed in the waterfall model must be performed. Any different ordering of the phases will result in a less successful software product.

There are a number of project outputs in waterfall model that is produced to produce a successful product:

Requirement documents and project plan System and detailed design Programs (code) Test plan, test reports and manuals Installation reports

Limitations Of Waterfall Model: -

1. The waterfall model assumes that the requirements of a system can be baseline before the design begins. This is possible for system designed to automate an existing manual system. For our system, (Counsceling) this is a new system, determining the requirement is difficult, as the user does not even know the requirements. 2. Freezing the requirements usually requires choosing the hardware. 3. The waterfall model stipulates that the requirements be completely specified before the rest of the development can proceed. 4. It is a document driven process that requires formal documents at the end of each phase. This approach tends to make the process documentation-heavy and is not suitable for many applications (interactive applications). The waterfall model is the most widely used process model.

[Page Break]

SYSTEM DESIGN
Introduction: The objective of the system design is to deliver the requirements as specified in the feasibility report. System design involves first logical design (logical design) and then physical construction (detailed design) of the system. The logical design describes the structure and characteristics of features, such as the outputs, inputs, files, databases, and procedures. The physical construction produces actual program software, files, and a working system. System design goes through two phases of development: 1. Logical Design 2. Physical Design

Logical Design:We know that a data flow diagram shows the logical flow of a system and defines the boundaries of the system. Logical design specifies the user need at a level of details that virtually determine the information flow into and out of the system and the required data resources. Logical design describes the inputs, outputs, database and procedures .All in a format that meets the users requirements.

Physical Design:It provides the working system by defining the design specification that tells programmers exactly what that candidate system must do. In short it can state that physical design is the implementation of the logical design. Physical system design consists of the following1) Design the physical system

1. Specify input, output media 2. Design the database and specify backup procedures. 3. Design physical information flow through the system and a physical design walkthrough. 2) Plan system implementation

Module Description:Counsceling with the fallowing modules: (1) Counseling Helps in Category wise counseling (2) Institute record covering Details regarding Institute (3) Student record - covering Details regarding Students

Data flow Diagram: -

Zero - Level DFD of Counseling Module: -

Level-1 DFD of Counseling Module: -

Level - 2 DFD of Counseling Module: -

Entity-Relationship Diagram:-

E - R Diagram of Counseling Module: -

[Drawing]

Database Design: -

Usually, a collection of interrelated data is referring to as database. The database contains information about one particular enterprise. Database system is designed to shear and manage large volume of information .The management of data involves both the manipulation of information .In addition ,the database system must provide for safety information storage in the database ,despite system crashes or unauthorized access.

1.

Table Name: STUDENT RECORD: -

Field Name
ROLL_NO NAME CATEGORY RANK COLLEAGE SEX CCODE CITY STATE MOBILE F_NAME TRADE ADDRESS STATE PASSWORD

Data Type
VARCHAR2 VARCHAR2 VARCHAR2 VARCHAR2 VARCHAR2 VARCHAR2 VARCHAR2(10) VARCHAR VARCHAR VARCHAR VARCHAR VARCHAR VARCHAR VARCHAR VARCHAR

Size Constraints
15 30 5 5 25 1 Primary Key

Description
STUDENT ROLL NO. STUDENT NAME STUDENT CATEGORY STUDENT RANK STUDENT GIVEN COLLEAGE STUDENT SEX DETAIL

2.

[Page Break]

Table Name UNIVERSITY RECORD: -

Field Name Data Type Size Constraints DESCRIPTION


UNI_ID UNI_NAME CITY STATE EMAIL WEBSITE VARCHAR2 25 VARCHAR2 50 VARCHAR2 25 VARCHAR2 2 VARCHAR2 2 VARCHAR2 2 Primary Key CODE OF THE UNIVERSITY NAME OF THE UNIVERSITY UNIVERSITY CITY NAME UNIVERSITY STATE EMAILID OF UNIVERSITY WEBSITE OF UNIVERSITY

3.

Table Name: TRADE: -

FLIEDNAME
C_ID

DATATYPE SIZE CONSTRAINTS


REFERENCES VARCHAR2 25 COLLEAGE REFERENCES

DESCRIPTION
COLLEAGECODE GENERAL VACANT SEATS OF THE COLLEAGE GENERAL OCCUPIED SEATS OF THE COLLEAGE

T_ID

NUMBER

2 TRADE CHECK

T_NAME

NUMBER

2 (GENERAL_OCCSEATS<46) CHECK

GENERAL_SEATS NUMBER

GENERAL TOTAL SEATS OF THE (GENERAL_TOTALSEATS<46) COLLEAGE CHECK SC VACANT SEATS OF THE COLLEAGE SC OCCUPIED SEATS OF THE COLLEAGE COLLEAGE ST VACANT SEATS OF THE COLLEAGE

SC_SEATS

NUMBER

2 (SC_VACSEATS<19) CHECK

BC_SEATS SC BC

NUMBER NUMBER NUMBER

2 (SC_OCCSEATS<19) 2 2 (ST_VACSEATS<2) COLLEAGE CHECK

CHECK GENERAL NUMBER 2 (ST_OCCSEATS<2) V_TOTAL_SEATS NUMBER OTHERS NUMBER

ST OCCUPIED SEATS OF THE COLLEAGE

OTHER CATAGORY

4. Table Name:-COLLEAGE

Field Name UNI_ID C_ID C_NAME M_RANK CITY STATE PH_NO M_NO EMAIL

Data Type

Size

Constraints REFERENCES

Description STUDENT ROLL NO.

VARCHAR2 15 UNIVERSITY DATE 10

PRIMARY KEY COUNSELING DATE FATHER NAME PERMANENT ADDS PERMANENT CITY PERMANENT STATE PHON NO. MOBILE NO. E-MAIL ADDS

VARCHAR2 20 VARCHAR2 30 VARCHAR2 10 VARCHAR2 10 NUMBER NUMBER 11 11

VARCHAR2 20

5. TABLE NAME: ADMIN


FIELDNAME DATATYPE SIZE CONSTRAINT ID PASSWORD NUMBER VARCHAR 10 45 PRIMARY KEY NOT NULL DESCRIPTION DEFINE ADMIN-ID PASSWORD OFADMIN

[Page Break]

Input-Output Design: -

Input Design: -

The input design is a crucial part of any system errors. Inaccurate input data are the most common cause of the errors in the processing. Data entry errors can be controlled by input design. Input design is the process of converting user-oriented inputs to computer based formats .the goal of designing input data is to make data entry as easy, logical and free from errors as possible.

Output Design: -

Computer output is the most important and direct source of information to the users. Efficient intelligible output design should improve the systems relationship with the user and help in decision making. A major form of output is a hard copy from the printer. In the system under consideration, the output is in two forms, hard copy from the printer and output to the CRT screen in predefined format.

[Page Break]

Coding

Of

project
[Page Break]package

project;

import java.awt.BorderLayout; import java.awt.Color; import java.awt.Font; import java.awt.Graphics;

import java.awt.Image; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.KeyEvent; import java.sql.Connection; import java.sql.DriverManager; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement;

import javax.swing.BorderFactory; import javax.swing.JButton; import javax.swing.JComboBox; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JMenu; import javax.swing.JMenuBar; import javax.swing.JMenuItem; import javax.swing.JOptionPane; import javax.swing.JPanel; import javax.swing.JPasswordField; import javax.swing.JTextField; import javax.swing.KeyStroke; import javax.swing.border.TitledBorder;

@SuppressWarnings("serial") public class MainClass extends JFrame implements ActionListener {

private Connection con; private Statement st1; private ResultSet rs1; Background desktop; private JMenuBar menuBar; private JMenu menu1,menu2,menu3; private JMenuItem menuItema,menuItems,menuItemh,menuItemsc,menuItemsui,menuItemsci; private JComboBox category; private JPasswordField password; private JTextField id; private JButton loginButton,registerButton; private String war = ""; private JLabel warning; String u_id; final JOptionPane deloption = new JOptionPane( "Are you sure you want to Exit ?\n", JOptionPane.QUESTION_MESSAGE, JOptionPane.YES_NO_OPTION);

@SuppressWarnings("unused") private String user = null; Font font = new Font("Calibri", Font.PLAIN,13);

TitledBorder pstitle = BorderFactory.createTitledBorder("Login"); TitledBorder idtitle = BorderFactory.createTitledBorder("User ID"); TitledBorder passtitle = BorderFactory.createTitledBorder("Password");

public MainClass() { super("Welcome To Counselling System"); setResizable(false); setBounds(200,50,800,600); pstitle.setTitleFont(font); idtitle.setTitleFont(font); passtitle.setTitleFont(font); desktop = new Background(); setContentPane(desktop); setJMenuBar(createMenuBar()); JPanel ps1 = loginPanel(); ps1.setBounds(420, 300, 250, 190); ps1.setBackground(Color.WHITE); ps1.setBorder(pstitle);

menu1.setEnabled(false); menuItemsc.setEnabled(false); menuItemsui.setEnabled(false); menuItemsci.setEnabled(false);

warning = new JLabel(war); warning.setFont(font); warning.setBounds(422,500,350,20); warning.setForeground(Color.RED);

desktop.add(warning); desktop.add(ps1); }

private JPanel loginPanel() { JPanel ps = new JPanel(); String[] cb = {"Student","Admin"}; category = new JComboBox(cb); category.setFont(font); category.addActionListener(this); id = new JTextField(20); id.setFont(font); id.setBorder(idtitle); password = new JPasswordField(20); password.setBorder(passtitle); password.setFont(font); loginButton = new JButton("Login"); loginButton.addActionListener(this); loginButton.setFont(font);

registerButton = new JButton("Register"); registerButton.addActionListener(this); registerButton.setFont(font); ps.add(category, BorderLayout.WEST); ps.add(id, BorderLayout.NORTH); ps.add(password, BorderLayout.CENTER); ps.add(loginButton, BorderLayout.WEST); ps.add(registerButton, BorderLayout.SOUTH); return ps; }

private JMenuBar createMenuBar() { Font font = new Font("Calibri", Font.PLAIN,13); Font font2 = new Font("Calibri", Font.PLAIN,12);

//Create the menu bar menuBar = new JMenuBar(){ @Override protected void paintComponent(Graphics g) { Image image = new javax.swing.ImageIcon(this.getClass().getResource("images/menuback.jpg")).getImage(); g.drawImage(image, 0, 0, this); super.paintComponent(g); } }; menuBar.setOpaque(false); //Build the 1 menu

menu1 = new JMenu("Admin Area"); menu1.setFont(font); menu1.setMnemonic(KeyEvent.VK_A); menuBar.add(menu1);

menuItema = new JMenuItem("University Detail"); menuItema.setFont(font2); menuItema.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_U, ActionEvent.CTRL_MASK)); menuItema.addActionListener(this); menu1.add(menuItema);

menu1.addSeparator();

menuItema = new JMenuItem("College Detial"); menuItema.setFont(font2); menuItema.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_C, ActionEvent.CTRL_MASK)); menuItema.addActionListener(this); menu1.add(menuItema);

menu1.addSeparator();

menuItema = new JMenuItem("Trade Detail"); menuItema.setFont(font2); menuItema.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_T, ActionEvent.CTRL_MASK));

menuItema.addActionListener(this); menu1.add(menuItema);

menu1.addSeparator();

menuItema = new JMenuItem("Student Detail"); menuItema.setFont(font2); menuItema.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S, ActionEvent.CTRL_MASK)); menuItema.addActionListener(this); menu1.add(menuItema);

//Build the 2nd menu menu2 = new JMenu("Student Area"); menu2.setFont(font); menu2.setMnemonic(KeyEvent.VK_S); menuBar.add(menu2);

menuItems = new JMenuItem("Register Student"); menuItems.setFont(font2); menuItems.addActionListener(this); menu2.add(menuItems);

menu2.addSeparator();

menuItemsui = new JMenuItem("University Info"); menuItemsui.setFont(font2); menuItemsui.addActionListener(this); menu2.add(menuItemsui);

menu2.addSeparator();

menuItemsci = new JMenuItem("College Info"); menuItemsci.setFont(font2); menuItemsci.addActionListener(this); menu2.add(menuItemsci);

menu2.addSeparator();

menuItemsc = new JMenuItem("Start Counselling"); menuItemsc.setFont(font2); menuItemsc.addActionListener(this); menu2.add(menuItemsc);

//Build the 3rd menu

menu3 = new JMenu("Help"); menu3.setFont(font); menu3.setMnemonic(KeyEvent.VK_H); menuBar.add(menu3);

menuItemh = new JMenuItem("About Us"); menuItemh.setFont(font2); menuItemh.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F1, 0)); menuItemh.addActionListener(this); menu3.add(menuItemh);

menu3.addSeparator();

menuItemh = new JMenuItem("Exit"); menuItemh.setFont(font2); menuItemh.addActionListener(this); menu3.add(menuItemh);

return menuBar; } //admin area private void uniFrame() { University frame = new University(50,30); frame.setVisible(true); desktop.add(frame); try { frame.setSelected(true); } catch (java.beans.PropertyVetoException e) {} }

private void colFrame() { College cframe = new College(100,30); cframe.setVisible(true); desktop.add(cframe); try { cframe.setSelected(true); } catch (java.beans.PropertyVetoException e) {} }

private void tradeFrame() { Trade tframe = new Trade(150,30); tframe.setVisible(true); desktop.add(tframe); try { tframe.setSelected(true); } catch (java.beans.PropertyVetoException e) {} }

private void sFrame() { Student tframe = new Student(200,30); tframe.setVisible(true); desktop.add(tframe); try { tframe.setSelected(true);

} catch (java.beans.PropertyVetoException e) {} } // student area private void rsFrame() { Register_Student rframe = new Register_Student(50,30); rframe.setVisible(true); desktop.add(rframe); try { rframe.setSelected(true); } catch (java.beans.PropertyVetoException e) {} }

private void uniforstudentFrame() { University_for_student rframe = new University_for_student(100,30); rframe.setVisible(true); desktop.add(rframe); try { rframe.setSelected(true); } catch (java.beans.PropertyVetoException e) {} }

private void collforstudentFrame() { College_for_student rframe = new College_for_student(150,30); rframe.setVisible(true); desktop.add(rframe);

try { rframe.setSelected(true); } catch (java.beans.PropertyVetoException e) {} }

private void csFrame() { Counselling rframe = new Counselling(200,30, u_id); rframe.setVisible(true); desktop.add(rframe); try { rframe.setSelected(true); } catch (java.beans.PropertyVetoException e) {} }

private void About() { About frame = new About(); frame.setVisible(true); desktop.add(frame); try { frame.setSelected(true); } catch (java.beans.PropertyVetoException e) {} }

private void enableMenuBarAdmin(boolean t) {

menu1.setEnabled(t); menuItemsc.setEnabled(t); menuItemsui.setEnabled(t); menuItemsci.setEnabled(t); menuItemsc.setEnabled(false); } private void enableMenuBarStudent(boolean t) { menuItemsc.setEnabled(t); menuItemsui.setEnabled(t); menuItemsci.setEnabled(t); }

private void loggedInAdmin(boolean t) { id.setEnabled(!t); password.setEnabled(!t); enableMenuBarAdmin(t); if(t == true) {JOptionPane.showMessageDialog(this, "You have Successfully logged on as Admin."); loginButton.setText("Logout"); registerButton.setEnabled(!t); category.setEnabled(!t); } else

{JOptionPane.showMessageDialog(this, "You have been successfully logged out"); loginButton.setText("Login"); registerButton.setEnabled(!t); category.setEnabled(!t); } } private void loggedInStudent(boolean t) { u_id = id.getText(); id.setEnabled(!t); password.setEnabled(!t); enableMenuBarStudent(t); if(t == true) {JOptionPane.showMessageDialog(this, "You have Successfully logged on as Student."); loginButton.setText("Logout"); registerButton.setEnabled(!t); category.setEnabled(!t); } else {JOptionPane.showMessageDialog(this, "You have been successfully logged out"); loginButton.setText("Login"); registerButton.setEnabled(!t); category.setEnabled(!t); } }

@Override public void actionPerformed(ActionEvent a) { String action = a.getActionCommand();

if(action == "University Detail") { uniFrame(); } if(action == "College Detial") { colFrame(); } if(action == "Trade Detail") { tradeFrame(); } if(action == "Student Detail") { sFrame(); } if(action == "Register Student") { rsFrame(); }

if(action == "University Info") { uniforstudentFrame(); } if(action == "College Info") { collforstudentFrame(); } if(action == "Start Counselling") { csFrame(); } if(action == "About Us") { About(); } if(action == "Exit") { JOptionPane.showConfirmDialog(this, "Are You sure you want to exit ?"); //System.exit(1); } if(action == "Login") { war = ""; String test = id.getText();

if(test.length() < 2) { war = "Invalid ID."; } else { try{ @SuppressWarnings("unused") int testint = Integer.parseInt(test); } catch(NumberFormatException e) { war = "ID should be a valid number."; } } test = String.valueOf(password.getPassword()); if(test.length() < 5 && war == "") { war = "Invalid password."; } warning.setText(war); test = null; if(war == "") { login();

} } if(action == "Logout") { loggedInAdmin(false); password.setText(""); } if(action == "comboBoxChanged") { if(category.getSelectedIndex() == 1) { registerButton.setEnabled(false); } else { registerButton.setEnabled(true); } } if(action == "Register") { rsFrame(); }

private void login() { try { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); con = DriverManager.getConnection("jdbc:odbc:db1"); st1 = con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE); } catch(ClassNotFoundException sq) { JOptionPane.showConfirmDialog(this,sq.getMessage()); } catch(SQLException sqe) { JOptionPane.showConfirmDialog(this,sqe.getMessage()); } try {st1 = con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE); if(category.getSelectedIndex() == 0) {rs1=st1.executeQuery("SELECT * FROM `register student` where s_id ="+id.getText()+" and password = '"+String.valueOf(password.getPassword())+"';"); } else {rs1=st1.executeQuery("SELECT * FROM admin where id ="+id.getText()+" and password = '"+String.valueOf(password.getPassword())+"';");

} } catch(SQLException e) { JOptionPane.showMessageDialog(this, e.getMessage()); }

try { if(!rs1.next()) { war = "Invalid Login information."; warning.setText(war); } else {if(category.getSelectedIndex() == 1) { loggedInAdmin(true); } else { loggedInStudent(true); } } } catch (SQLException e) { JOptionPane.showMessageDialog(this, e.getMessage());

} }

private static void createAndShowGUI() { JFrame.setDefaultLookAndFeelDecorated(false); MainClass frame = new MainClass(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setVisible(true); }

public static void main(String[] args) { createAndShowGUI(); }

package project;

import javax.swing.JButton; import javax.swing.JComboBox; import javax.swing.JInternalFrame; import javax.swing.JLabel; import javax.swing.JOptionPane; import javax.swing.JTextField; import java.awt.event.*;

import java.awt.*; import java.sql.Connection; import java.sql.DriverManager; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement;

@SuppressWarnings("serial") public class University extends JInternalFrame implements ActionListener {

Connection con; Statement st1,st2; ResultSet rs1,rs2,rs3; int flag,flag2 = 1; boolean b = false; String si,cb,war=""; String f[];

JComboBox c_id; int selItem,rown; JLabel warning;

JTextField tf[] = {new JTextField(10), new JTextField(10), new JTextField(10), new JTextField(10), new JTextField(10), new JTextField(10), };

String labels[] = { "University ID","University Name","City","State","Email","Website"};

JButton btMove[] = { new JButton("<<"),new JButton("<"), new JButton(">"),new JButton(">>") };

JButton btActions[] = { new JButton("New"),new JButton("Edit"),new JButton("Delete"), n ew JButton("Save"), new JButton("Cancel") };

public University(int x, int y) { super("University Detail", false, //resizable true, //closable false, //maximizable true);//iconifiable

//***************************************************************** setLayout(null); setSize(400,310); setLocation(x,y); Font font = new Font("Calibri", Font.PLAIN,13);

warning = new JLabel(war); warning.setFont(font); warning.setBounds(20,210,350,20); warning.setForeground(Color.RED); add(warning);

for(int i=0;i<labels.length;i++) { JLabel lbl =new JLabel(labels[i]); lbl.setBounds(20,30+i*30,100,20); lbl.setFont(font); add(lbl); }

for(int i=0;i<tf.length;i++) { tf[i].setBounds(125,30+i*30,150,20); tf[i].setFont(font); add(tf[i]); }

for(int i=0;i<btMove.length;i++) { btMove[i].setBounds(20+i*55,240,50,20);

btMove[i].setFont(font); add(btMove[i]); btMove[i].addActionListener(this); }

for(int i=0;i<btActions.length;i++) { btActions[i].setBounds(290,30+i*25,80,20); btActions[i].setFont(font); add(btActions[i]); btActions[i].addActionListener(this); }

for(int i=0;i<tf.length;i++) tf[i].setEnabled(b);

btMove[0].setEnabled(b); btMove[1].setEnabled(b); btMove[2].setEnabled(!b); btMove[3].setEnabled(!b);

btActions[0].setEnabled(!b); btActions[1].setEnabled(!b); btActions[2].setEnabled(!b); btActions[3].setEnabled(b);

btActions[4].setEnabled(b);

try { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); con = DriverManager.getConnection("jdbc:odbc:db1"); st1 = con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE); } catch(ClassNotFoundException sq) { JOptionPane.showConfirmDialog(this,sq.getMessage()); } catch(SQLException sqe) { JOptionPane.showConfirmDialog(this,sqe.getMessage()); } // to fetch 1st college's detail in selected university try { st1 = con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE); rs2=st1.executeQuery("select * from university ;");

if(!rs2.next()) {Last(false);

First(false); btActions[1].setEnabled(false); btActions[2].setEnabled(false); flag = 3; } else { tf[0].setText(String.valueOf((rs2.getInt(1)))); tf[1].setText(rs2.getString(2)); tf[2].setText(rs2.getString(3)); tf[3].setText(rs2.getString(4)); tf[4].setText(rs2.getString(5)); tf[5].setText(rs2.getString(6)); } } catch(SQLException e) { JOptionPane.showConfirmDialog(this,e.getMessage()); } //button function try { if(rs2.isFirst()) { if(rs2.isLast()) {

First(false); Last(false); } else { First(false); Last(true); } } else {if(rs2.isLast()) { First(true); Last(false); } else { First(true); Last(true); } } } catch (SQLException e) { JOptionPane.showConfirmDialog(this,e.getMessage()); } }

public ResultSet updateRs(String table) throws SQLException {ResultSet rs; st1 = con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE); rs=st1.executeQuery("select * from university ;"); return rs; } public void displayRs() { try { tf[0].setText(String.valueOf((rs2.getInt(1)))); for(int i=1;i<tf.length;i++) tf[i].setText(rs2.getString(i+1)); } catch (SQLException e) { JOptionPane.showConfirmDialog(this,e.getMessage()); } } public void enableKey(boolean b) { for(int i=0;i<tf.length;i++) tf[i].setEnabled(b);

Last(!b); First(!b);

btActions[0].setEnabled(!b); btActions[1].setEnabled(!b); btActions[2].setEnabled(!b); btActions[3].setEnabled(b); btActions[4].setEnabled(b); } public void Last(boolean b) { btMove[2].setEnabled(b); btMove[3].setEnabled(b); } public void First(boolean b) { btMove[0].setEnabled(b); btMove[1].setEnabled(b); }

public void validate(int i, String type) {war=""; String test = tf[i].getText(); @SuppressWarnings("unused") int testInt;

if (test.length() == 0) {war = ""+labels[i]+ " cannot be empty"; warning.setText(war); } else {if(type == "int") {try {if(test.length()>5) test="i"; testInt = Integer.parseInt(test); } catch(NumberFormatException e) { war = ""+labels[i]+ " should be a valid number and < 1000000"; warning.setText(war); } } else {war = ""; warning.setText(war); } } }

public void button() { try { if(rs2.isFirst()) { if(rs2.isLast()) { First(false); Last(false); } else { First(false); Last(true); } } else {if(rs2.isLast()) { First(true); Last(false); } else {

First(true); Last(true); } } } catch (SQLException e) { JOptionPane.showConfirmDialog(this,e.getMessage()); } }

@Override public void actionPerformed(ActionEvent a) { String action = a.getActionCommand();

if(action == "New") { actionNew(); } if(action == "Edit") { actionEdit(); } if(action == "Delete") { actionDelete(); }

if(action == "Save") { for(int i=0;i<tf.length;i++) {if(i==0) validate(i,"int"); else validate(i,"str"); if(war != "") { break; } } if(war == "") { actionSave(); button(); } } if(action == "Cancel") { actionCancel(); } //Move Buttons if(action == "<<") {

try { rs2.first(); displayRs(); First(false); Last(true); } catch (SQLException e) { JOptionPane.showConfirmDialog(this,e.getMessage()); } } if(action == "<") { try { rs2.previous(); displayRs(); button(); } catch (SQLException e) { JOptionPane.showConfirmDialog(this,e.getMessage()); } } if(action == ">") { try { rs2.next();

displayRs(); button(); } catch (SQLException e) { JOptionPane.showConfirmDialog(this,e.getMessage()); } } if(action == ">>") { try {rs2.last(); displayRs(); First(true); Last(false); } catch (SQLException e) { JOptionPane.showConfirmDialog(this,e.getMessage()); } } }

public void actionNew() {

war = "All fields are mandatory"; warning.setText(war); enableKey(true); flag2 = 0; if(flag!=3) flag = 1; for(int i=0;i<tf.length;i++) { tf[i].setText(""); } try { rown = rs2.getRow(); } catch (SQLException e) { JOptionPane.showConfirmDialog(this,e.getMessage()); } } public void actionEdit() {war = ""; warning.setText(war); flag2 = 0; flag = 2; enableKey(true); try { rown = rs2.getRow(); } catch (SQLException e) {

JOptionPane.showConfirmDialog(this,e.getMessage()); } } public void actionDelete() { flag2 = 1; enableKey(false); try { rown = rs2.getRow(); rs2.deleteRow(); rs2 = updateRs("university"); if(rown == 1) { if(!rs2.next()) {for(int i=0;i<tf.length;i++) { tf[i].setText(""); } Last(false); First(false); btActions[1].setEnabled(false); btActions[2].setEnabled(false); flag = 3; } else

{ rs2.first(); button(); displayRs(); } } else { rs2.absolute(--rown); button(); displayRs(); } } catch (SQLException e) { JOptionPane.showConfirmDialog(this,e.getMessage()); } } public void actionSave() { flag2 = 1; enableKey(false); if(flag == 1 || flag == 3)// if saved from new { try {rs2.moveToInsertRow(); rs2.updateInt(1, Integer.parseInt(tf[0].getText()));

for(int i=1;i<=5;i++) rs2.updateString(i+1, tf[i].getText());

rs2.insertRow(); rs2 = updateRs("university"); rs2.first(); if(flag == 1) { st1 = con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE); rs3=st1.executeQuery("SELECT * FROM university where uni_id < "+Integer.parseInt(tf[0].getText())+";"); rs3.last(); int rn = rs3.getRow(); rs2.absolute(++rn); } button(); } catch (SQLException e) { JOptionPane.showConfirmDialog(this,e.getMessage()); } } else { if(flag !=3) // if saved from edit { try {

rs2.updateInt(1, Integer.parseInt(tf[0].getText())); for(int i=1;i<=5;i++) rs2.updateString(i+1, tf[i].getText());

rs2.updateRow(); rs2 = updateRs("university");

st1 = con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE); rs3=st1.executeQuery("SELECT * FROM university where uni_id < "+Integer.parseInt(tf[0].getText())+";"); rs3.last(); int rn = rs3.getRow(); rs2.absolute(++rn);

} catch (SQLException e) { JOptionPane.showConfirmDialog(this,e.getMessage()); } } } displayRs(); flag = 0; } public void actionCancel() { war = "";

warning.setText(war); flag2 = 1; if(flag == 3) { enableKey(false); btActions[1].setEnabled(false); btActions[2].setEnabled(false); First(false); Last(false); } else {flag = 0; enableKey(false); try { rs2.absolute(rown); displayRs(); button(); } catch (SQLException e) { JOptionPane.showConfirmDialog(this,e.getMessage()); } } }

} package project;

import javax.swing.JButton; import javax.swing.JComboBox; import javax.swing.JInternalFrame; import javax.swing.JLabel; import javax.swing.JOptionPane; import javax.swing.JTextField; import java.awt.event.*; import java.awt.*; import java.sql.Connection; import java.sql.DriverManager; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement;

@SuppressWarnings("serial") public class University extends JInternalFrame implements ActionListener {

Connection con; Statement st1,st2; ResultSet rs1,rs2,rs3; int flag,flag2 = 1; boolean b = false;

String si,cb,war=""; String f[];

JComboBox c_id; int selItem,rown; JLabel warning;

JTextField tf[] = {new JTextField(10), new JTextField(10), new JTextField(10), new JTextField(10), new JTextField(10), new JTextField(10), };

String labels[] = { "University ID","University Name","City","State","Email","Website"};

JButton btMove[] = { new JButton("<<"),new JButton("<"), new JButton(">"),new JButton(">>") };

JButton btActions[] = { new JButton("New"),new JButton("Edit"),new JButton("Delete"), n ew JButton("Save"), new JButton("Cancel") };

public University(int x, int y) { super("University Detail",

false, //resizable true, //closable false, //maximizable true);//iconifiable

//***************************************************************** setLayout(null); setSize(400,310); setLocation(x,y); Font font = new Font("Calibri", Font.PLAIN,13);

warning = new JLabel(war); warning.setFont(font); warning.setBounds(20,210,350,20); warning.setForeground(Color.RED); add(warning);

for(int i=0;i<labels.length;i++) { JLabel lbl =new JLabel(labels[i]); lbl.setBounds(20,30+i*30,100,20); lbl.setFont(font); add(lbl); }

for(int i=0;i<tf.length;i++) { tf[i].setBounds(125,30+i*30,150,20); tf[i].setFont(font); add(tf[i]); }

for(int i=0;i<btMove.length;i++) { btMove[i].setBounds(20+i*55,240,50,20); btMove[i].setFont(font); add(btMove[i]); btMove[i].addActionListener(this); }

for(int i=0;i<btActions.length;i++) { btActions[i].setBounds(290,30+i*25,80,20); btActions[i].setFont(font); add(btActions[i]); btActions[i].addActionListener(this); }

for(int i=0;i<tf.length;i++) tf[i].setEnabled(b);

btMove[0].setEnabled(b); btMove[1].setEnabled(b); btMove[2].setEnabled(!b); btMove[3].setEnabled(!b);

btActions[0].setEnabled(!b); btActions[1].setEnabled(!b); btActions[2].setEnabled(!b); btActions[3].setEnabled(b); btActions[4].setEnabled(b);

try { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); con = DriverManager.getConnection("jdbc:odbc:db1"); st1 = con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE); } catch(ClassNotFoundException sq) { JOptionPane.showConfirmDialog(this,sq.getMessage()); } catch(SQLException sqe) { JOptionPane.showConfirmDialog(this,sqe.getMessage());

} // to fetch 1st college's detail in selected university try { st1 = con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE); rs2=st1.executeQuery("select * from university ;");

if(!rs2.next()) {Last(false); First(false); btActions[1].setEnabled(false); btActions[2].setEnabled(false); flag = 3; } else { tf[0].setText(String.valueOf((rs2.getInt(1)))); tf[1].setText(rs2.getString(2)); tf[2].setText(rs2.getString(3)); tf[3].setText(rs2.getString(4)); tf[4].setText(rs2.getString(5)); tf[5].setText(rs2.getString(6)); } } catch(SQLException e)

{ JOptionPane.showConfirmDialog(this,e.getMessage()); } //button function try { if(rs2.isFirst()) { if(rs2.isLast()) { First(false); Last(false); } else { First(false); Last(true); } } else {if(rs2.isLast()) { First(true); Last(false); } else

{ First(true); Last(true); } } } catch (SQLException e) { JOptionPane.showConfirmDialog(this,e.getMessage()); } }

public ResultSet updateRs(String table) throws SQLException {ResultSet rs; st1 = con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE); rs=st1.executeQuery("select * from university ;"); return rs; } public void displayRs() { try { tf[0].setText(String.valueOf((rs2.getInt(1)))); for(int i=1;i<tf.length;i++) tf[i].setText(rs2.getString(i+1)); } catch (SQLException e)

{ JOptionPane.showConfirmDialog(this,e.getMessage()); } } public void enableKey(boolean b) { for(int i=0;i<tf.length;i++) tf[i].setEnabled(b);

Last(!b); First(!b);

btActions[0].setEnabled(!b); btActions[1].setEnabled(!b); btActions[2].setEnabled(!b); btActions[3].setEnabled(b); btActions[4].setEnabled(b); } public void Last(boolean b) { btMove[2].setEnabled(b); btMove[3].setEnabled(b); } public void First(boolean b) {

btMove[0].setEnabled(b); btMove[1].setEnabled(b); }

public void validate(int i, String type) {war=""; String test = tf[i].getText(); @SuppressWarnings("unused") int testInt; if (test.length() == 0) {war = ""+labels[i]+ " cannot be empty"; warning.setText(war); } else {if(type == "int") {try {if(test.length()>5) test="i"; testInt = Integer.parseInt(test); } catch(NumberFormatException e) { war = ""+labels[i]+ " should be a valid number and < 1000000";

warning.setText(war); } } else {war = ""; warning.setText(war); } } }

public void button() { try { if(rs2.isFirst()) { if(rs2.isLast()) { First(false); Last(false); } else { First(false); Last(true); }

} else {if(rs2.isLast()) { First(true); Last(false); } else { First(true); Last(true); } } } catch (SQLException e) { JOptionPane.showConfirmDialog(this,e.getMessage()); } }

@Override public void actionPerformed(ActionEvent a) { String action = a.getActionCommand();

if(action == "New") { actionNew();

} if(action == "Edit") { actionEdit(); } if(action == "Delete") { actionDelete(); } if(action == "Save") { for(int i=0;i<tf.length;i++) {if(i==0) validate(i,"int"); else validate(i,"str"); if(war != "") { break; } } if(war == "") { actionSave(); button();

} } if(action == "Cancel") { actionCancel(); } //Move Buttons if(action == "<<") { try { rs2.first(); displayRs(); First(false); Last(true); } catch (SQLException e) { JOptionPane.showConfirmDialog(this,e.getMessage()); } } if(action == "<") { try { rs2.previous(); displayRs(); button();

} catch (SQLException e) { JOptionPane.showConfirmDialog(this,e.getMessage()); } } if(action == ">") { try { rs2.next(); displayRs(); button(); } catch (SQLException e) { JOptionPane.showConfirmDialog(this,e.getMessage()); } } if(action == ">>") { try {rs2.last(); displayRs(); First(true); Last(false); }

catch (SQLException e) { JOptionPane.showConfirmDialog(this,e.getMessage()); } } }

public void actionNew() { war = "All fields are mandatory"; warning.setText(war); enableKey(true); flag2 = 0; if(flag!=3) flag = 1; for(int i=0;i<tf.length;i++) { tf[i].setText(""); } try { rown = rs2.getRow(); } catch (SQLException e) { JOptionPane.showConfirmDialog(this,e.getMessage()); } }

public void actionEdit() {war = ""; warning.setText(war); flag2 = 0; flag = 2; enableKey(true); try { rown = rs2.getRow(); } catch (SQLException e) { JOptionPane.showConfirmDialog(this,e.getMessage()); } } public void actionDelete() { flag2 = 1; enableKey(false); try { rown = rs2.getRow(); rs2.deleteRow(); rs2 = updateRs("university"); if(rown == 1) { if(!rs2.next()) {for(int i=0;i<tf.length;i++) {

tf[i].setText(""); } Last(false); First(false); btActions[1].setEnabled(false); btActions[2].setEnabled(false); flag = 3; } else { rs2.first(); button(); displayRs(); } } else { rs2.absolute(--rown); button(); displayRs(); } } catch (SQLException e) { JOptionPane.showConfirmDialog(this,e.getMessage()); } }

public void actionSave() { flag2 = 1; enableKey(false); if(flag == 1 || flag == 3)// if saved from new { try {rs2.moveToInsertRow(); rs2.updateInt(1, Integer.parseInt(tf[0].getText())); for(int i=1;i<=5;i++) rs2.updateString(i+1, tf[i].getText());

rs2.insertRow(); rs2 = updateRs("university"); rs2.first(); if(flag == 1) { st1 = con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE); rs3=st1.executeQuery("SELECT * FROM university where uni_id < "+Integer.parseInt(tf[0].getText())+";"); rs3.last(); int rn = rs3.getRow(); rs2.absolute(++rn); } button();

} catch (SQLException e) { JOptionPane.showConfirmDialog(this,e.getMessage()); } } else { if(flag !=3) // if saved from edit { try { rs2.updateInt(1, Integer.parseInt(tf[0].getText())); for(int i=1;i<=5;i++) rs2.updateString(i+1, tf[i].getText());

rs2.updateRow(); rs2 = updateRs("university");

st1 = con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE); rs3=st1.executeQuery("SELECT * FROM university where uni_id < "+Integer.parseInt(tf[0].getText())+";"); rs3.last(); int rn = rs3.getRow(); rs2.absolute(++rn);

} catch (SQLException e) { JOptionPane.showConfirmDialog(this,e.getMessage());

} } } displayRs(); flag = 0; } public void actionCancel() { war = ""; warning.setText(war); flag2 = 1; if(flag == 3) { enableKey(false); btActions[1].setEnabled(false); btActions[2].setEnabled(false); First(false); Last(false); } else {flag = 0; enableKey(false); try { rs2.absolute(rown); displayRs();

button(); } catch (SQLException e) { JOptionPane.showConfirmDialog(this,e.getMessage()); } } }

} package project;

import javax.swing.JButton; import javax.swing.JComboBox; import javax.swing.JInternalFrame; import javax.swing.JLabel; import javax.swing.JOptionPane; import javax.swing.JTextField; import java.awt.event.*; import java.awt.*; import java.sql.Connection; import java.sql.DriverManager; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement;

@SuppressWarnings("serial") public class College extends JInternalFrame implements ActionListener {

Connection con; Statement st1,st2; ResultSet rs1,rs2,rs3; int flag,flag2 = 1; boolean b = false; String uids[] = new String[1000]; String si,cb,war; JComboBox uni_id; int selItem,rown; JLabel warning; boolean c_id,c_name,m_rank;

JTextField tf[] = {new JTextField(10), new JTextField(10), new JTextField(10), new JTextField(10), new JTextField(10), new JTextField(10), new JTextField(10),new JTextField(10) };

String labels[] = { "University ID","University Name","College ID *","College Name *","Min. Rank *","City","State","Email","Website"};

JButton btMove[] = { new JButton("<<"),new JButton("<"), new JButton(">"),new JButton(">>") };

JButton btActions[] = { new JButton("New"),new JButton("Edit"),new JButton("Delete"), n ew JButton("Save"), new JButton("Cancel") };

public College(int x, int y) { super("College Detail", false, //resizable true, //closable false, //maximizable true);//iconifiable setLayout(null); setSize(400,400); setLocation(x,y); //***************************************************************** Font font = new Font("Calibri", Font.PLAIN,13); //to show warnings

warning = new JLabel(war); warning.setFont(font);

warning.setBounds(20,300,300,20); warning.setForeground(Color.RED); add(warning);

for(int i=0;i<labels.length;i++) { JLabel lbl =new JLabel(labels[i]); lbl.setBounds(20,30+i*30,100,20); lbl.setFont(font); add(lbl); }

try { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); con = DriverManager.getConnection("jdbc:odbc:db1"); st1 = con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE); } catch(ClassNotFoundException sq) { JOptionPane.showConfirmDialog(this,sq.getMessage()); } catch(SQLException sqe) { JOptionPane.showConfirmDialog(this,sqe.getMessage());

} try {

rs1=st1.executeQuery("select * from university"); int i=0; while (rs1.next()) { uids[i] = String.valueOf((rs1.getInt("uni_id"))); i++; }

} catch(SQLException sqe) { JOptionPane.showConfirmDialog(this,sqe.getMessage()); }

uni_id = new JComboBox(uids); uni_id.setBounds(125,30,150,20); uni_id.setFont(font); uni_id.addActionListener(this); add(uni_id);

for(int i=0;i<tf.length;i++)

{ tf[i].setBounds(125,60+i*30,150,20); tf[i].setFont(font); add(tf[i]); }

for(int i=0;i<btMove.length;i++) { btMove[i].setBounds(20+i*55,330,50,20); btMove[i].setFont(font); add(btMove[i]); btMove[i].addActionListener(this); }

for(int i=0;i<btActions.length;i++) { btActions[i].setBounds(290,30+i*25,80,20); btActions[i].setFont(font); add(btActions[i]); btActions[i].addActionListener(this); }

// to fill the uni_name tf si = (String)uni_id.getSelectedItem(); selItem = Integer.parseInt(si);

try { st1 = con.createStatement(); rs1=st1.executeQuery("select * from university where uni_id ="+selItem+""); while (rs1.next()) { tf[0].setText(rs1.getString("uni_name")); } } catch(SQLException e) { JOptionPane.showConfirmDialog(this,e.getMessage()); }

tf[0].setEnabled(b); tf[1].setEnabled(b); tf[2].setEnabled(b); tf[3].setEnabled(b); tf[4].setEnabled(b); tf[5].setEnabled(b); tf[6].setEnabled(b); tf[7].setEnabled(b);

btMove[0].setEnabled(b); btMove[1].setEnabled(b);

btMove[2].setEnabled(!b); btMove[3].setEnabled(!b);

btActions[0].setEnabled(!b); btActions[1].setEnabled(!b); btActions[2].setEnabled(!b); btActions[3].setEnabled(b); btActions[4].setEnabled(b);

// to fetch 1st college's detail in selected university try { st1 = con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE); rs2=st1.executeQuery("select * from college where uni_id ="+selItem+"");

if(!rs2.next()) {Last(false); First(false); btActions[1].setEnabled(false); btActions[2].setEnabled(false); flag = 3; } else {rs2.first(); tf[1].setText(String.valueOf((rs2.getInt("c_id"))));

tf[2].setText(rs2.getString("c_name")); tf[3].setText(String.valueOf((rs2.getInt("m_rank")))); tf[4].setText(rs2.getString("city")); tf[5].setText(rs2.getString("state")); tf[6].setText(rs2.getString("email")); tf[7].setText(rs2.getString("website")); } } catch(SQLException e) { JOptionPane.showConfirmDialog(this,e.getMessage()); } //button function try { if(rs2.isFirst()) { if(rs2.isLast()) { First(false); Last(false); } else { First(false); Last(true);

} } else {if(rs2.isLast()) { First(true); Last(false); } else { First(true); Last(true); } } } catch (SQLException e) { JOptionPane.showConfirmDialog(this,e.getMessage()); } }

public ResultSet updateRs(String table) throws SQLException {ResultSet rs; st1 = con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE); rs=st1.executeQuery("select * from "+table+" where uni_id ="+selItem+""); return rs; }

public void displayRs() { try { tf[1].setText(String.valueOf((rs2.getInt("c_id")))); tf[2].setText(rs2.getString("c_name")); tf[3].setText(String.valueOf((rs2.getInt("m_rank")))); tf[4].setText(rs2.getString("city")); tf[5].setText(rs2.getString("state")); tf[6].setText(rs2.getString("email")); tf[7].setText(rs2.getString("website")); } catch (SQLException e) { JOptionPane.showConfirmDialog(this,e.getMessage()); } } public void enableKey(boolean b) { tf[0].setEnabled(false); tf[1].setEnabled(b); tf[2].setEnabled(b); tf[3].setEnabled(b); tf[4].setEnabled(b); tf[5].setEnabled(b);

tf[5].setEnabled(b); tf[6].setEnabled(b); tf[7].setEnabled(b);

Last(!b); First(!b);

btActions[0].setEnabled(!b); btActions[1].setEnabled(!b); btActions[2].setEnabled(!b); btActions[3].setEnabled(b); btActions[4].setEnabled(b); } public void Last(boolean b) { btMove[2].setEnabled(b); btMove[3].setEnabled(b); } public void First(boolean b) { btMove[0].setEnabled(b); btMove[1].setEnabled(b); }

public void validate(int i, String type)

{war=""; String test = tf[i].getText(); @SuppressWarnings("unused") int testInt; if (test.length() == 0) {war = ""+labels[i+1]+ " cannot be empty"; warning.setText(war); } else {if(type == "int") {try {if(test.length()>5) test="i"; testInt = Integer.parseInt(test); } catch(NumberFormatException e) { war = ""+labels[i+1]+ " should be a valid number and < 1000000"; warning.setText(war); } } else {war = "";

warning.setText(war); } } }

public void button() { try { if(rs2.isFirst()) { if(rs2.isLast()) { First(false); Last(false); } else { First(false); Last(true); } } else {if(rs2.isLast()) { First(true);

Last(false); } else { First(true); Last(true); } } } catch (SQLException e) { JOptionPane.showConfirmDialog(this,e.getMessage()); } } @Override public void actionPerformed(ActionEvent a) { String action = a.getActionCommand();

//Action Buttons if(action == "New") {actionNew(); } if(action == "Edit") { actionEdit(); } if(action == "Delete")

{ actionDelete(); } if(action == "Save") {validate(1,"int"); if(war == "") { validate(2,"str"); if(war == "") { validate(3,"int"); } } if(war == "") {actionSave(); button(); } } if(action == "Cancel") { actionCancel(); } //Move Buttons if(action == "<<") {war = "";

warning.setText(war); try { rs2.first(); displayRs(); First(false); Last(true); } catch (SQLException e) { JOptionPane.showConfirmDialog(this,e.getMessage()); } } if(action == "<") { try { rs2.previous(); displayRs(); button(); } catch (SQLException e) { JOptionPane.showConfirmDialog(this,e.getMessage()); } } if(action == ">") { try {

rs2.next(); displayRs(); button(); } catch (SQLException e) { JOptionPane.showConfirmDialog(this,e.getMessage()); } } if(action == ">>") {war = ""; warning.setText(war); try {rs2.last(); displayRs(); First(true); Last(false); } catch (SQLException e) { JOptionPane.showConfirmDialog(this,e.getMessage()); } } // Combo Box if(action == "comboBoxChanged")

{war = ""; warning.setText(war); cbChanged(); } }

public void actionNew() { war = "* fields are mandatory"; warning.setText(war); enableKey(true); flag2 = 0; if(flag!=3) flag = 1; cb = ((String) uni_id.getSelectedItem()); for(int i=1;i<tf.length;i++) { tf[i].setText(""); } try { rown = rs2.getRow(); } catch (SQLException e) { JOptionPane.showConfirmDialog(this,e.getMessage()); }

} public void actionEdit() {war = ""; warning.setText(war); flag2 = 0; flag = 2; cb = ((String) uni_id.getSelectedItem()); enableKey(true); try { rown = rs2.getRow(); } catch (SQLException e) { JOptionPane.showConfirmDialog(this,e.getMessage()); } } public void actionDelete() { flag2 = 1; enableKey(false); try { rown = rs2.getRow(); rs2.deleteRow(); rs2 = updateRs("college"); if(rown == 1) { if(!rs2.next())

{for(int i=1;i<tf.length;i++) { tf[i].setText(""); } Last(false); First(false); btActions[1].setEnabled(false); btActions[2].setEnabled(false); flag = 3; } else { rs2.first(); button(); displayRs(); } } else { rs2.absolute(--rown); button(); displayRs(); } } catch (SQLException e) { JOptionPane.showConfirmDialog(this,e.getMessage());

} } public void actionSave() { flag2 = 1; enableKey(false); if(flag == 1 || flag == 3)// if saved from new { try {cb = ((String) uni_id.getSelectedItem()); rs2.moveToInsertRow(); rs2.updateInt(1, Integer.parseInt(cb)); rs2.updateInt(2, Integer.parseInt(tf[1].getText())); rs2.updateString(3, tf[2].getText()); rs2.updateInt(4, Integer.parseInt(tf[3].getText())); rs2.updateString(5, tf[4].getText()); rs2.updateString(6, tf[5].getText()); rs2.updateString(7, tf[6].getText()); rs2.updateString(8, tf[7].getText()); rs2.insertRow(); rs2 = updateRs("college"); rs2.first(); if(flag == 1) { st1 = con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE);

rs3=st1.executeQuery("SELECT * FROM college where uni_id="+cb+" and c_id < "+Integer.parseInt(tf[1].getText())+";"); rs3.last(); int rn = rs3.getRow(); rs2.absolute(++rn); } button(); } catch (SQLException e) { JOptionPane.showConfirmDialog(this,e.getMessage()); } } else { if(flag !=3) // if saved from edit { try { cb = ((String) uni_id.getSelectedItem()); rs2.updateInt(1, Integer.parseInt(cb)); rs2.updateInt(2, Integer.parseInt(tf[1].getText())); rs2.updateString(3, tf[2].getText()); rs2.updateInt(4, Integer.parseInt(tf[3].getText())); rs2.updateString(5, tf[4].getText()); rs2.updateString(6, tf[5].getText()); rs2.updateString(7, tf[6].getText()); rs2.updateString(8, tf[7].getText()); rs2.updateRow();

rown = rs2.getRow(); rs2 = updateRs("college"); rs2.absolute(rown); } catch (SQLException e) { JOptionPane.showConfirmDialog(this,e.getMessage()); } } else // if saved from new when rs is null {

} } displayRs(); flag = 0; } public void actionCancel() { war = ""; warning.setText(war); flag2 = 1; if(flag == 3) { enableKey(false); btActions[1].setEnabled(false); btActions[2].setEnabled(false); First(false);

Last(false); } else {flag = 0; if(cb != ((String) uni_id.getSelectedItem())) uni_id.setSelectedItem(cb); enableKey(false); try { rs2.absolute(rown); displayRs(); button(); } catch (SQLException e) { JOptionPane.showConfirmDialog(this,e.getMessage()); } } } public void cbChanged() { si = (String)uni_id.getSelectedItem(); selItem = Integer.parseInt(si); try {rs1 = updateRs("university"); while (rs1.next())

{ tf[0].setText(rs1.getString("uni_name")); } if(flag2 == 1 ) {rs2 = updateRs("college"); if (!rs2.next())// is resultset 2 is null {flag = 3; for(int i=1;i<tf.length;i++) { tf[i].setText(""); } First(false); Last(false); btActions[1].setEnabled(false); btActions[2].setEnabled(false);

} else {enableKey(false); flag = 0; rs2.first(); displayRs(); if(rs2.isLast()) { First(false);

Last(false); } else { First(false); Last(true); } } } } catch(SQLException e) { JOptionPane.showConfirmDialog(this,e.getMessage()); } } }

package project;

import javax.swing.JButton; import javax.swing.JComboBox; import javax.swing.JInternalFrame; import javax.swing.JLabel; import javax.swing.JOptionPane; import javax.swing.JTextField;

import java.awt.event.*; import java.awt.*; import java.sql.Connection; import java.sql.DriverManager; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement;

@SuppressWarnings("serial") public class Trade extends JInternalFrame implements ActionListener {

Connection con; Statement st1,st2; ResultSet rs1,rs2,rs3; int flag,flag2 = 1; boolean b = false,save; String cids[] = new String[100]; String si,cb,war; String f[];

JComboBox c_id; int selItem,rown; JLabel warning;

JTextField tf[] = {new JTextField(10), new JTextField(10), new JTextField(10),

new JTextField(10), new JTextField(10), new JTextField(10), new JTextField(10),new JTextField(10) };

String labels[] = { "College ID","College Name","Trade ID","Trade Name","SC Seats","BC Seats","General Seats","Other Seats","Total Seats"};

JButton btMove[] = { new JButton("<<"),new JButton("<"), new JButton(">"),new JButton(">>") };

JButton btActions[] = { new JButton("New"),new JButton("Edit"),new JButton("Delete"), n ew JButton("Save"), new JButton("Cancel") };

public Trade(int x,int y) { super("Trade Detail", false, //resizable true, //closable false, //maximizable true);//iconifiable setLayout(null); setSize(400,400); setLocation(x,y);

//***************************************************************** Font font = new Font("Calibri", Font.PLAIN,13);

warning = new JLabel(war); warning.setFont(font); warning.setBounds(20,300,300,20); warning.setForeground(Color.RED); add(warning);

for(int i=0;i<labels.length;i++) { JLabel lbl =new JLabel(labels[i]); lbl.setBounds(20,30+i*30,100,20); lbl.setFont(font); add(lbl); }

try { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); con = DriverManager.getConnection("jdbc:odbc:db1"); st1 = con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE); } catch(ClassNotFoundException e) {

JOptionPane.showMessageDialog(this,e.getMessage()); } catch(SQLException e) { JOptionPane.showMessageDialog(this,e.getMessage()); } try { rs1=st1.executeQuery("select * from college"); int i=0; while (rs1.next()) { cids[i] = String.valueOf((rs1.getInt("c_id"))); i++; } } catch(SQLException sqe) { JOptionPane.showConfirmDialog(this,sqe.getMessage()); }

c_id = new JComboBox(cids); c_id.setBounds(125,30,150,20); c_id.setFont(font); c_id.addActionListener(this);

add(c_id);

for(int i=0;i<tf.length;i++) { tf[i].setBounds(125,60+i*30,150,20); tf[i].setFont(font); add(tf[i]); }

for(int i=0;i<btMove.length;i++) { btMove[i].setBounds(20+i*55,330,50,20); btMove[i].setFont(font); add(btMove[i]); btMove[i].addActionListener(this); }

for(int i=0;i<btActions.length;i++) { btActions[i].setBounds(290,30+i*25,80,20); btActions[i].setFont(font); add(btActions[i]); btActions[i].addActionListener(this); }

// to fill the coll_name tf si = (String)c_id.getSelectedItem(); try { selItem = Integer.parseInt(si); } catch(NumberFormatException e) { JOptionPane.showConfirmDialog(this,"No college is registered"); } try { rs1=st1.executeQuery("select * from college where c_id ="+selItem+""); while(rs1.next()) { tf[0].setText(rs1.getString("c_name")); } } catch(SQLException sqe) { JOptionPane.showConfirmDialog(this,sqe.getMessage()); }

for(int i=0;i<tf.length;i++) tf[i].setEnabled(b);

btActions[3].setEnabled(b); btActions[4].setEnabled(b);

// to fetch 1st trade's detail in selected college try { st1 = con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE); rs2=st1.executeQuery("select * from trade where c_id ="+selItem+"");

if(!rs2.next()) { Last(false); First(false); btActions[1].setEnabled(false); btActions[2].setEnabled(false); flag = 3; } else { displayRs(); } } catch(SQLException e) {

JOptionPane.showConfirmDialog(this,e.getMessage()); } if(flag != 3) button(); }

public ResultSet updateRs(String table) throws SQLException {ResultSet rs; st1 = con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE); rs=st1.executeQuery("select * from "+table+" where c_id ="+selItem+""); return rs; } public void displayRs() { try { tf[1].setText(String.valueOf((rs2.getInt(2)))); tf[2].setText(rs2.getString(3)); for(int i=3;i<tf.length;i++) { tf[i].setText(String.valueOf((rs2.getInt(i+1)))); } } catch (SQLException e) {

JOptionPane.showConfirmDialog(this,e.getMessage()); } } public void enableKey(boolean b) { tf[0].setEnabled(false); tf[1].setEnabled(b); tf[2].setEnabled(b); tf[3].setEnabled(b); tf[4].setEnabled(b); tf[5].setEnabled(b); tf[5].setEnabled(b); tf[6].setEnabled(b); tf[7].setEnabled(b);

Last(!b); First(!b);

btActions[0].setEnabled(!b); btActions[1].setEnabled(!b); btActions[2].setEnabled(!b); btActions[3].setEnabled(b); btActions[4].setEnabled(b); } public void Last(boolean b)

{ btMove[2].setEnabled(b); btMove[3].setEnabled(b); } public void First(boolean b) { btMove[0].setEnabled(b); btMove[1].setEnabled(b); }

public void validate(int i, String type) {war=""; String test = tf[i].getText(); @SuppressWarnings("unused") int testInt; if (test.length() == 0) {war = ""+labels[i+1]+ " cannot be empty"; warning.setText(war); } else { if(type == "int") {try {if(test.length()>5)

test="i"; testInt = Integer.parseInt(test); } catch(NumberFormatException e) { war = ""+labels[i+1]+ " should be a valid number and < 1000000"; warning.setText(war); } } else {war = ""; warning.setText(war); } } }

public void button() { try { if(rs2.isFirst()) { if(rs2.isLast()) { First(false);

Last(false); } else { First(false); Last(true); } } else {if(rs2.isLast()) { First(true); Last(false); } else { First(true); Last(true); } } } catch (SQLException e) { JOptionPane.showConfirmDialog(this,e.getMessage()); } } @Override

public void actionPerformed(ActionEvent a) { String action = a.getActionCommand();

//Action Buttons if(action == "New") { actionNew(); } if(action == "Edit") { actionEdit(); } if(action == "Delete") { actionDelete(); } if(action == "Save") { for(int i = 0;i<tf.length;i++) {if(i==2 || i==0) validate(i,"str"); else validate(i,"int"); if(war != "") {

break; } } if(war == "") { actionSave(); button(); } } if(action == "Cancel") { actionCancel(); } //Move Buttons if(action == "<<") {war = ""; warning.setText(war); try { rs2.first(); displayRs(); First(false); Last(true); } catch (SQLException e) { JOptionPane.showConfirmDialog(this,e.getMessage()); }

} if(action == "<") { try { rs2.previous(); displayRs(); button(); } catch (SQLException e) { JOptionPane.showConfirmDialog(this,e.getMessage()); } } if(action == ">") { try { rs2.next(); displayRs(); button(); } catch (SQLException e) { JOptionPane.showConfirmDialog(this,e.getMessage()); } }

if(action == ">>") {war = ""; warning.setText(war); try {rs2.last(); displayRs(); First(true); Last(false); } catch (SQLException e) { JOptionPane.showConfirmDialog(this,e.getMessage()); } } // Combo Box if(action == "comboBoxChanged") { cbChanged(); } }

public void actionNew() { war = "* fields are mandatory"; warning.setText(war);

enableKey(true); flag2 = 0; if(flag!=3) flag = 1; cb = ((String) c_id.getSelectedItem()); for(int i=1;i<tf.length;i++) { tf[i].setText(""); } try { rown = rs2.getRow(); } catch (SQLException e) { JOptionPane.showConfirmDialog(this,e.getMessage()); } } public void actionEdit() { war = ""; warning.setText(war); flag2 = 0; flag = 2; cb = ((String) c_id.getSelectedItem()); enableKey(true); try { rown = rs2.getRow();

} catch (SQLException e) { JOptionPane.showConfirmDialog(this,e.getMessage()); } } public void actionDelete() { flag2 = 1; enableKey(false); try { rown = rs2.getRow(); rs2.deleteRow(); rs2 = updateRs("trade"); if(rown == 1) { if(!rs2.next()) {for(int i=1;i<tf.length;i++) { tf[i].setText(""); } Last(false); First(false); btActions[1].setEnabled(false); btActions[2].setEnabled(false); flag = 3; }

else { rs2.first(); button(); displayRs(); } } else { rs2.absolute(--rown); button(); displayRs(); } } catch (SQLException e) { JOptionPane.showConfirmDialog(this,e.getMessage()); } } public void actionSave() { flag2 = 1; enableKey(false); if(flag == 1 || flag == 3)// if saved from new { try {cb = ((String) c_id.getSelectedItem());

rs2.moveToInsertRow();

rs2.updateInt(1, Integer.parseInt(cb)); rs2.updateInt(2, Integer.parseInt(tf[1].getText())); rs2.updateString(3, tf[2].getText()); for(int i=3;i<tf.length;i++) { rs2.updateInt(i+1, Integer.parseInt(tf[i].getText())); }

rs2.insertRow(); rs2 = updateRs("trade"); rs2.first(); if(flag == 1) { st1 = con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE); rs3=st1.executeQuery("SELECT * FROM trade where c_id="+cb+" and t_id < "+Integer.parseInt(tf[1].getText())+";"); rs3.last(); int rn = rs3.getRow(); rs2.absolute(++rn); } } catch (SQLException e) { JOptionPane.showConfirmDialog(this,e.getMessage()); }

} else { if(flag !=3) // if saved from edit { try { cb = ((String) c_id.getSelectedItem());

rs2.updateInt(1, Integer.parseInt(cb)); rs2.updateInt(2, Integer.parseInt(tf[1].getText())); rs2.updateString(3, tf[2].getText()); for(int i=3;i<tf.length;i++) { rs2.updateInt(i+1, Integer.parseInt(tf[i].getText())); } rs2.updateRow(); rown = rs2.getRow(); rs2 = updateRs("trade"); rs2.absolute(rown); } catch (SQLException e) { JOptionPane.showConfirmDialog(this,e.getMessage()); } } } displayRs();

flag = 0; } public void actionCancel() { war = ""; warning.setText(war); flag2 = 1; if(flag == 3) { enableKey(false); btActions[1].setEnabled(false); btActions[2].setEnabled(false); First(false); Last(false); } else {flag = 0; if(cb != ((String) c_id.getSelectedItem())) c_id.setSelectedItem(cb); enableKey(false); try { rs2.absolute(rown); displayRs(); button(); }

catch (SQLException e) { JOptionPane.showConfirmDialog(this,e.getMessage()); } } } public void cbChanged() {war = ""; warning.setText(war); si = (String)c_id.getSelectedItem(); selItem = Integer.parseInt(si); try {rs1 = updateRs("college"); while (rs1.next()) { tf[0].setText(rs1.getString("c_name")); } if(flag2 == 1 ) {rs2 = updateRs("trade"); if (!rs2.next())// is resultset 2 is null {flag = 3; for(int i=1;i<tf.length;i++) { tf[i].setText(""); } First(false);

Last(false); btActions[1].setEnabled(false); btActions[2].setEnabled(false); } else {enableKey(false); flag = 0; rs2.first(); displayRs(); if(rs2.isLast()) { First(false); Last(false); } else { First(false); Last(true); } } } } catch(SQLException e) { JOptionPane.showConfirmDialog(this,e.getMessage());

} } } package project;

import javax.swing.JButton; import javax.swing.JComboBox; import javax.swing.JInternalFrame; import javax.swing.JLabel; import javax.swing.JOptionPane; import javax.swing.JTextField;

import java.awt.Color; import java.awt.Font; import java.awt.event.*;

import java.sql.Connection; import java.sql.DriverManager; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement;

@SuppressWarnings("serial") public class Student extends JInternalFrame implements ActionListener {

Connection con; Statement st1,st2; ResultSet rs1,rs2,rs3; int flag,flag2 = 1; boolean b = false,f; String si,cb,war="";

JComboBox c_id; int selItem,rown; JLabel warning;

JTextField tf[] = {new JTextField(10),new JTextField(10), new JTextField(10), new JTextField(10), new JTextField(10), new JTextField(10), new JTextField(10),new JTextField(10), new JTextField(10),new JTextField(10), new JTextField(10),new JTextField(10) };

String labels[] = { "Student ID","Name","Father Name","Address","City","State","Mobile No.","Rank","Category","Password","College","Trade"};

JButton btMove[] = { new JButton("<<"),new JButton("<"), new JButton(">"),new JButton(">>") };

JButton btActions[] = { new JButton("New"),new JButton("Edit"),new JButton("Delete"), n ew JButton("Save"), new JButton("Cancel") };

public Student(int x, int y) { super("Student Detail", false, //resizable true, //closable false, //maximizable true);//iconifiable

//***************************************************************** setLayout(null); setSize(400,490); setLocation(x,y); Font font = new Font("Calibri", Font.PLAIN,13);

warning = new JLabel(war); warning.setFont(font); warning.setBounds(20,330,350,20); warning.setForeground(Color.RED); add(warning);

for(int i=0;i<labels.length;i++)

{ JLabel lbl =new JLabel(labels[i]); lbl.setBounds(20,30+i*30,100,20); lbl.setFont(font); add(lbl); }

for(int i=0;i<tf.length;i++) { tf[i].setBounds(125,30+i*30,150,20); tf[i].setFont(font); add(tf[i]); }

for(int i=0;i<btMove.length;i++) { btMove[i].setBounds(20+i*55,420,50,20); btMove[i].setFont(font); add(btMove[i]); btMove[i].addActionListener(this); }

for(int i=0;i<btActions.length;i++) { btActions[i].setBounds(290,30+i*25,80,20);

btActions[i].setFont(font); add(btActions[i]); btActions[i].addActionListener(this); }

for(int i=0;i<tf.length;i++) tf[i].setEnabled(b);

btMove[0].setEnabled(b); btMove[1].setEnabled(b); btMove[2].setEnabled(!b); btMove[3].setEnabled(!b);

btActions[0].setEnabled(!b); btActions[1].setEnabled(!b); btActions[2].setEnabled(!b); btActions[3].setEnabled(b); btActions[4].setEnabled(b);

try { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); con = DriverManager.getConnection("jdbc:odbc:db1"); st1 = con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE); }

catch(ClassNotFoundException sq) { JOptionPane.showConfirmDialog(this,sq.getMessage()); } catch(SQLException sqe) { JOptionPane.showConfirmDialog(this,sqe.getMessage()); } // to fetch 1st college's detail in selected university try { st1 = con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE); rs2=st1.executeQuery("SELECT * FROM `register student` ;");

if(!rs2.next()) {Last(false); First(false); btActions[1].setEnabled(false); btActions[2].setEnabled(false); flag = 3; } else { for(int i=0;i<tf.length;i++) tf[i].setText(rs2.getString(i+1));

} } catch(SQLException e) { JOptionPane.showConfirmDialog(this,e.getMessage()); } //button function try { if(rs2.isFirst()) { if(rs2.isLast()) { First(false); Last(false); } else { First(false); Last(true); } } else {if(rs2.isLast()) {

First(true); Last(false); } else { First(true); Last(true); } } } catch (SQLException e) { JOptionPane.showConfirmDialog(this,e.getMessage()); } }

public ResultSet updateRs(String table) throws SQLException {ResultSet rs; st1 = con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE); rs=st1.executeQuery("select * from "+table+" ;"); return rs; } public void displayRs() { try { for(int i=0;i<tf.length;i++)

tf[i].setText(rs2.getString(i+1)); } catch (SQLException e) { JOptionPane.showConfirmDialog(this,e.getMessage()); } } public void enableKey(boolean b) { for(int i=0;i<tf.length;i++) tf[i].setEnabled(b);

Last(!b); First(!b);

btActions[0].setEnabled(!b); btActions[1].setEnabled(!b); btActions[2].setEnabled(!b); btActions[3].setEnabled(b); btActions[4].setEnabled(b); } public void Last(boolean b) { btMove[2].setEnabled(b);

btMove[3].setEnabled(b); } public void First(boolean b) { btMove[0].setEnabled(b); btMove[1].setEnabled(b); }

public void validate(int label,int diff, String type, int minlength,int maxlength) {war=""; f = true; String test = tf[label].getText(); if (test.length() == 0 && f == true) {war = ""+labels[label]+" cannot be empty"; f=false; } if(test.length()<minlength && f == true) { war = ""+labels[label]+" should minumum have "+minlength+" charachters."; f=false; } if(test.length()>maxlength && f == true) { war = ""+labels[label]+" can maximum have "+maxlength+" charachters."; f=false;

} if(type == "int" && f == true) {try { @SuppressWarnings("unused") double testInt = Double.parseDouble(test); } catch(NumberFormatException e) { war = ""+labels[label]+" should be a valid number."; f=false; } } warning.setText(war); }

public void button() { try { if(rs2.isFirst()) { if(rs2.isLast()) { First(false); Last(false);

} else { First(false); Last(true); } } else {if(rs2.isLast()) { First(true); Last(false); } else { First(true); Last(true); } } } catch (SQLException e) { JOptionPane.showConfirmDialog(this,e.getMessage()); } }

@Override

public void actionPerformed(ActionEvent a) { String action = a.getActionCommand();

if(action == "New") { actionNew(); } if(action == "Edit") { actionEdit(); } if(action == "Delete") { actionDelete(); } if(action == "Save") {for(int i = 0;i<tf.length;i++) {if(i >0 && i < 6) {validate(i,0,"str",3,40); } else { if(i==0) validate(0,0,"int",1,5); if(i==6)

validate(6,0,"int",10,10); if(i==7) validate(7,0,"int",1,5); if(i==8) validate(8,0,"str",2,5); if(i==9) validate(9,0,"str",5,10); } if(f == false) { break; }

} if(f == true) { actionSave(); button(); } } if(action == "Cancel") { actionCancel(); } //Move Buttons

if(action == "<<") { try { rs2.first(); displayRs(); First(false); Last(true); } catch (SQLException e) { JOptionPane.showConfirmDialog(this,e.getMessage()); } } if(action == "<") { try { rs2.previous(); displayRs(); button(); } catch (SQLException e) { JOptionPane.showConfirmDialog(this,e.getMessage()); } } if(action == ">") { try

{ rs2.next(); displayRs(); button(); } catch (SQLException e) { JOptionPane.showConfirmDialog(this,e.getMessage()); } } if(action == ">>") { try {rs2.last(); displayRs(); First(true); Last(false); } catch (SQLException e) { JOptionPane.showConfirmDialog(this,e.getMessage()); } } }

public void actionNew() { war = "All fields are mandatory"; warning.setText(war); enableKey(true); flag2 = 0; if(flag!=3) flag = 1; for(int i=0;i<tf.length;i++) { tf[i].setText(""); } try { rown = rs2.getRow(); } catch (SQLException e) { JOptionPane.showConfirmDialog(this,e.getMessage()); } } public void actionEdit() {war = ""; warning.setText(war); flag2 = 0; flag = 2; enableKey(true); try {

rown = rs2.getRow(); } catch (SQLException e) { JOptionPane.showConfirmDialog(this,e.getMessage()); } } public void actionDelete() { flag2 = 1; enableKey(false); try { rown = rs2.getRow(); rs2.deleteRow(); rs2 = updateRs("`register student`"); if(rown == 1) { if(!rs2.next()) {for(int i=0;i<tf.length;i++) { tf[i].setText(""); } Last(false); First(false); btActions[1].setEnabled(false); btActions[2].setEnabled(false); flag = 3;

} else { rs2.first(); button(); displayRs(); } } else { rs2.absolute(--rown); button(); displayRs(); } } catch (SQLException e) { JOptionPane.showConfirmDialog(this,e.getMessage()); } } public void actionSave() { flag2 = 1; enableKey(false); if(flag == 1 || flag == 3)// if saved from new { try

{rs2.moveToInsertRow(); rs2.updateInt(1, Integer.parseInt(tf[0].getText())); for(int i=1;i<tf.length;i++) rs2.updateString(i+1, tf[i].getText());

rs2.insertRow(); rs2 = updateRs("`register student`"); rs2.first(); if(flag == 1) { st1 = con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE); rs3=st1.executeQuery("SELECT * FROM `register student` where s_id < "+Integer.parseInt(tf[0].getText())+";"); rs3.last(); int rn = rs3.getRow(); rs2.absolute(++rn); } button(); } catch (SQLException e) { JOptionPane.showConfirmDialog(this,e.getMessage()); } } else { if(flag !=3) // if saved from edit

{ try { rs2.updateInt(1, Integer.parseInt(tf[0].getText())); for(int i=1;i<tf.length;i++) rs2.updateString(i+1, tf[i].getText());

rs2.updateRow(); rs2 = updateRs("`register student`");

st1 = con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE); rs3=st1.executeQuery("SELECT * FROM `register student` where s_id < "+Integer.parseInt(tf[0].getText())+";"); rs3.last(); int rn = rs3.getRow(); rs2.absolute(++rn);

} catch (SQLException e) { JOptionPane.showConfirmDialog(this,e.getMessage()); } } } displayRs(); flag = 0; } public void actionCancel()

{ war = ""; warning.setText(war); flag2 = 1; if(flag == 3) { enableKey(false); btActions[1].setEnabled(false); btActions[2].setEnabled(false); First(false); Last(false); } else {flag = 0; enableKey(false); try { rs2.absolute(rown); displayRs(); button(); } catch (SQLException e) { JOptionPane.showConfirmDialog(this,e.getMessage()); } } }

} package project; import javax.swing.JButton; import javax.swing.JComboBox; import javax.swing.JInternalFrame; import javax.swing.JLabel; import javax.swing.JOptionPane; import javax.swing.JPasswordField; import javax.swing.JTextField; import java.awt.event.*; import java.awt.*; import java.sql.Connection; import java.sql.DriverManager; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; import java.util.Arrays;

@SuppressWarnings("serial") public class Register_Student extends JInternalFrame implements ActionListener { Connection con; Statement st; ResultSet rs;

boolean b = false; boolean f = true; String si,war="All feild are mandatory.";

JComboBox category; JLabel warning;

private JPasswordField password,rpassword;

JTextField tf[] = {new JTextField(10),new JTextField(10), new JTextField(10), new JTextField(10), new JTextField(10), new JTextField(10), new JTextField(10), new JTextField(10) };

String labels[] = { "User ID","Name","Father Name","Address","City","State","Mobile No.","Rank","Category","Password","Repeat Password"};

JButton btMove[] = { new JButton("Register"),new JButton("Clear") };

public Register_Student(int x, int y) { super("Register Student", false, //resizable true, //closable

false, //maximizable true);//iconifiable

//***************************************************************** setLayout(null); setSize(400,460); setLocation(x,y); Font font = new Font("Calibri", Font.PLAIN,13);

warning = new JLabel(war); warning.setFont(font); warning.setBounds(20,360,350,20); warning.setForeground(Color.RED); add(warning);

for(int i=0;i<labels.length;i++) { JLabel lbl =new JLabel(labels[i]); lbl.setBounds(20,30+i*30,100,20); lbl.setFont(font); add(lbl); }

for(int i=0;i<tf.length;i++) {

tf[i].setBounds(125,30+i*30,240,20); tf[i].setFont(font); add(tf[i]); }

final String[] cb = {"Gen" , "SC" , "BC" , "Other"}; category = new JComboBox(cb); category.setBounds(125,270,240,20); category.setFont(font); category.addActionListener(this); add(category);

password = new JPasswordField(10); password.setBounds(125,300,240,20); add(password);

rpassword = new JPasswordField(10); rpassword.setBounds(125,330,240,20); add(rpassword);

for(int i=0;i<btMove.length;i++) { btMove[i].setBounds(160+i*105,390,100,20); btMove[i].setFont(font); add(btMove[i]);

btMove[i].addActionListener(this); }

try { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); con = DriverManager.getConnection("jdbc:odbc:db1"); st = con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE); } catch(ClassNotFoundException sq) { JOptionPane.showConfirmDialog(this,sq.getMessage()); } catch(SQLException sqe) { JOptionPane.showConfirmDialog(this,sqe.getMessage()); } }

public void checkpassword() { char[] pass = password.getPassword(); if(pass.length < 5) { war = "Password should have minimun 5 characters";

warning.setText(war); } else { char[] rpass = rpassword.getPassword(); if (pass.length != rpass.length) { war = "Passwords do not match."; warning.setText(war); } else { if(Arrays.equals(pass,rpass)) { war = ""; warning.setText(war); } else { war = "Passwords do not match."; warning.setText(war); } } }

public void validate(int label,int diff, String type, int minlength,int maxlength) {war=""; f = true; String test = tf[label+diff].getText(); if (test.length() == 0 && f == true) {war = ""+labels[label]+" cannot be empty"; f=false; } if(test.length()<minlength && f == true) { war = ""+labels[label]+" should minumum have "+minlength+" charachters."; f=false; } if(test.length()>maxlength && f == true) { war = ""+labels[label]+" can maximum have "+maxlength+" charachters."; f=false; } if(type == "int" && f == true) {try { @SuppressWarnings("unused")

double testInt = Double.parseDouble(test); } catch(NumberFormatException e) { war = ""+labels[label]+" should be a valid number."; f=false; } } warning.setText(war); }

public void disableKey(boolean b) { for(int i = 0;i<tf.length;i++) tf[i].setEnabled(b);

category.setEnabled(b); password.setEnabled(b); rpassword.setEnabled(b); btMove[1].setEnabled(b); btMove[0].setEnabled(b); } @Override public void actionPerformed(ActionEvent a) { String action = a.getActionCommand();

if(action == "Register") {for(int i = 0;i<tf.length;i++) {if(i>0 && i<6) validate(i,0,"str",3,40); else {if(i==6) { validate(i,0,"int",10,10); } else { validate(i,0,"int",1,10); } } if(f == false) { break; } }

if(f == true) {checkpassword(); if(war == "") actionSave(); }

} if(action == "Clear") { for(int i = 0;i<tf.length;i++) tf[i].setText(""); category.setSelectedIndex(0); password.setText(""); rpassword.setText(""); } } @SuppressWarnings("deprecation") public void actionSave() { try { st = con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE); rs=st.executeQuery("SELECT * FROM `register student` ;"); rs.last(); rs.moveToInsertRow();

for(int i=0;i<tf.length;i++) { rs.updateString(i+1, tf[i].getText()); }

rs.updateString(9, (String) category.getSelectedItem()); rs.updateString(10,password.getText());

rs.insertRow();

st = con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE); rs = st.executeQuery("SELECT * FROM `register student`;"); JOptionPane.showMessageDialog(this, "You are registered for counselling. \n\n" + "Remember your ID and Password for Counselling.", "Registered successfully !", 1); disableKey(false); } catch (SQLException e) { if(e.getMessage().equals("[MySQL][ODBC 5.1 Driver][mysqld5.5.14]Duplicate entry '"+tf[0].getText()+"' for key 'PRIMARY'")) {war = "User ID "+tf[0].getText()+" is already registered. Please use another."; warning.setText(war); } else JOptionPane.showConfirmDialog(this,e.getMessage()); } } } package project;

import javax.swing.JButton; import javax.swing.JComboBox; import javax.swing.JInternalFrame; import javax.swing.JLabel; import javax.swing.JOptionPane; import javax.swing.JTextField; import java.awt.event.*; import java.awt.*; import java.sql.Connection; import java.sql.DriverManager; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement;

@SuppressWarnings("serial") public class University_for_student extends JInternalFrame implements ActionListener {

Connection con; Statement st1,st2; ResultSet rs1,rs2,rs3; int flag,flag2 = 1; boolean b = false; String si,cb,war=""; String f[];

JComboBox c_id; int selItem,rown; JLabel warning;

JTextField tf[] = {new JTextField(10), new JTextField(10), new JTextField(10), new JTextField(10), new JTextField(10), new JTextField(10), };

String labels[] = { "University ID","University Name","City","State","Email","Website"};

JButton btMove[] = { new JButton("<<"),new JButton("<"),

new JButton(">"),new JButton(">>") } ;

public University_for_student(int x, int y) { super("University Detail", false, //resizable true, //closable false, //maximizable true);//iconifiable

//*****************************************************************

setLayout(null); setSize(400,310); setLocation(x,y); Font font = new Font("Calibri", Font.PLAIN,13);

warning = new JLabel(war); warning.setFont(font); warning.setBounds(20,210,350,20); warning.setForeground(Color.RED); add(warning);

for(int i=0;i<labels.length;i++) { JLabel lbl =new JLabel(labels[i]); lbl.setBounds(20,30+i*30,100,20); lbl.setFont(font); add(lbl); }

for(int i=0;i<tf.length;i++) { tf[i].setBounds(125,30+i*30,240,20); tf[i].setFont(font); add(tf[i]); }

for(int i=0;i<btMove.length;i++) { btMove[i].setBounds(20+i*55,240,50,20); btMove[i].setFont(font); add(btMove[i]); btMove[i].addActionListener(this); }

for(int i=0;i<tf.length;i++) tf[i].setEnabled(b);

btMove[0].setEnabled(b); btMove[1].setEnabled(b); btMove[2].setEnabled(!b); btMove[3].setEnabled(!b);

try { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); con = DriverManager.getConnection("jdbc:odbc:db1"); st1 = con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE); } catch(ClassNotFoundException sq)

{ JOptionPane.showConfirmDialog(this,sq.getMessage()); } catch(SQLException sqe) { JOptionPane.showConfirmDialog(this,sqe.getMessage()); } // to fetch 1st college's detail in selected university try { st1 = con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE); rs2=st1.executeQuery("select * from university ;");

if(!rs2.next()) {Last(false); First(false); flag = 3; } else { tf[0].setText(String.valueOf((rs2.getInt(1)))); tf[1].setText(rs2.getString(2)); tf[2].setText(rs2.getString(3)); tf[3].setText(rs2.getString(4)); tf[4].setText(rs2.getString(5));

tf[5].setText(rs2.getString(6)); } } catch(SQLException e) { JOptionPane.showConfirmDialog(this,e.getMessage()); } //button function try { if(rs2.isFirst()) { if(rs2.isLast()) { First(false); Last(false); } else { First(false); Last(true); } } else {if(rs2.isLast()) {

First(true); Last(false); } else { First(true); Last(true); } } } catch (SQLException e) { JOptionPane.showConfirmDialog(this,e.getMessage()); } }

public ResultSet updateRs(String table) throws SQLException {ResultSet rs; st1 = con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE); rs=st1.executeQuery("select * from university ;"); return rs; } public void displayRs() { try { tf[0].setText(String.valueOf((rs2.getInt(1))));

for(int i=1;i<tf.length;i++) tf[i].setText(rs2.getString(i+1)); } catch (SQLException e) { JOptionPane.showConfirmDialog(this,e.getMessage()); } } public void enableKey(boolean b) { for(int i=0;i<tf.length;i++) tf[i].setEnabled(b);

Last(!b); First(!b); } public void Last(boolean b) { btMove[2].setEnabled(b); btMove[3].setEnabled(b); } public void First(boolean b) { btMove[0].setEnabled(b); btMove[1].setEnabled(b);

public void validate(int i, String type) {war=""; String test = tf[i].getText(); @SuppressWarnings("unused") int testInt; if (test.length() == 0) {war = ""+labels[i]+ " cannot be empty"; warning.setText(war); } else {if(type == "int") {try {if(test.length()>5) test="i"; testInt = Integer.parseInt(test); } catch(NumberFormatException e) { war = ""+labels[i]+ " should be a valid number and < 1000000"; warning.setText(war); }

} else {war = ""; warning.setText(war); } } }

public void button() { try { if(rs2.isFirst()) { if(rs2.isLast()) { First(false); Last(false); } else { First(false); Last(true); } } else

{if(rs2.isLast()) { First(true); Last(false); } else { First(true); Last(true); } } } catch (SQLException e) { JOptionPane.showConfirmDialog(this,e.getMessage()); } }

@Override public void actionPerformed(ActionEvent a) { String action = a.getActionCommand();

if(action == "New") { actionNew(); } if(action == "Edit")

{ actionEdit(); } if(action == "Delete") { actionDelete(); } if(action == "Save") { for(int i=0;i<tf.length;i++) {if(i==0) validate(i,"int"); else validate(i,"str"); if(war != "") { break; } } if(war == "") { actionSave(); button(); } }

if(action == "Cancel") { actionCancel(); } //Move Buttons if(action == "<<") { try { rs2.first(); displayRs(); First(false); Last(true); } catch (SQLException e) { JOptionPane.showConfirmDialog(this,e.getMessage()); } } if(action == "<") { try { rs2.previous(); displayRs(); button(); } catch (SQLException e) { JOptionPane.showConfirmDialog(this,e.getMessage());

} } if(action == ">") { try { rs2.next(); displayRs(); button(); } catch (SQLException e) { JOptionPane.showConfirmDialog(this,e.getMessage()); } } if(action == ">>") { try {rs2.last(); displayRs(); First(true); Last(false); } catch (SQLException e) {

JOptionPane.showConfirmDialog(this,e.getMessage()); } } }

public void actionNew() { war = "All fields are mandatory"; warning.setText(war); enableKey(true); flag2 = 0; if(flag!=3) flag = 1; for(int i=0;i<tf.length;i++) { tf[i].setText(""); } try { rown = rs2.getRow(); } catch (SQLException e) { JOptionPane.showConfirmDialog(this,e.getMessage()); } } public void actionEdit() {war = "";

warning.setText(war); flag2 = 0; flag = 2; enableKey(true); try { rown = rs2.getRow(); } catch (SQLException e) { JOptionPane.showConfirmDialog(this,e.getMessage()); } } public void actionDelete() { flag2 = 1; enableKey(false); try { rown = rs2.getRow(); rs2.deleteRow(); rs2 = updateRs("university"); if(rown == 1) { if(!rs2.next()) {for(int i=0;i<tf.length;i++) { tf[i].setText(""); }

Last(false); First(false); flag = 3; } else { rs2.first(); button(); displayRs(); } } else { rs2.absolute(--rown); button(); displayRs(); } } catch (SQLException e) { JOptionPane.showConfirmDialog(this,e.getMessage()); } } public void actionSave() { flag2 = 1; enableKey(false);

if(flag == 1 || flag == 3)// if saved from new { try {rs2.moveToInsertRow(); rs2.updateInt(1, Integer.parseInt(tf[0].getText())); for(int i=1;i<=5;i++) rs2.updateString(i+1, tf[i].getText());

rs2.insertRow(); rs2 = updateRs("university"); rs2.first(); if(flag == 1) { st1 = con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE); rs3=st1.executeQuery("SELECT * FROM university where uni_id < "+Integer.parseInt(tf[0].getText())+";"); rs3.last(); int rn = rs3.getRow(); rs2.absolute(++rn); } button(); } catch (SQLException e) { JOptionPane.showConfirmDialog(this,e.getMessage()); } }

else { if(flag !=3) // if saved from edit { try { rs2.updateInt(1, Integer.parseInt(tf[0].getText())); for(int i=1;i<=5;i++) rs2.updateString(i+1, tf[i].getText());

rs2.updateRow(); rs2 = updateRs("university");

st1 = con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE); rs3=st1.executeQuery("SELECT * FROM university where uni_id < "+Integer.parseInt(tf[0].getText())+";"); rs3.last(); int rn = rs3.getRow(); rs2.absolute(++rn);

} catch (SQLException e) { JOptionPane.showConfirmDialog(this,e.getMessage( )); } } } displayRs();

flag = 0; } public void actionCancel() { war = ""; warning.setText(war); flag2 = 1; if(flag == 3) { enableKey(false); First(false); Last(false); } else {flag = 0; enableKey(false); try { rs2.absolute(rown); displayRs(); button(); } catch (SQLException e) { JOptionPane.showConfirmDialog(this,e.getMessage()); } }

} package project;

import javax.swing.JButton; import javax.swing.JComboBox; import javax.swing.JInternalFrame; import javax.swing.JLabel; import javax.swing.JOptionPane; import javax.swing.JTextField; import java.awt.event.*; import java.awt.*; import java.sql.Connection; import java.sql.DriverManager; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement;

@SuppressWarnings("serial") public class College_for_student extends JInternalFrame implements ActionListener {

Connection con; Statement st1,st2;

ResultSet rs1,rs2,rs3; int flag,flag2 = 1; boolean b = false; String uids[] = new String[100]; String si,cb,war; JComboBox uni_id; int selItem,rown; JLabel warning; boolean c_id,c_name,m_rank; JTextField tf[] = {new JTextField(10), new JTextField(10), new JTextField(10), new JTextField(10), new JTextField(10), new JTextField(10), new JTextField(10),new JTextField(10) };

String labels[] = { "University ID","University Name","College ID","College Name","Min. Rank","City","State","Email","Website"};

JButton btMove[] = { new JButton("<<"),new JButton("<"),

new JButton(">"),new JButton(">>") } ;

public College_for_student(int x, int y) { super("College Detail", false, //resizable

true, //closable false, //maximizable true);//iconifiable setLayout(null); setSize(400,400); setLocation(x,y); //***************************************************************** Font font = new Font("Calibri", Font.PLAIN,13); //to show warnings

warning = new JLabel(war); warning.setFont(font); warning.setBounds(20,300,300,20); warning.setForeground(Color.RED); add(warning);

for(int i=0;i<labels.length;i++) { JLabel lbl =new JLabel(labels[i]); lbl.setBounds(20,30+i*30,100,20); lbl.setFont(font); add(lbl); }

try

{ Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); con = DriverManager.getConnection("jdbc:odbc:db1"); st1 = con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE); } catch(ClassNotFoundException sq) { JOptionPane.showConfirmDialog(this,sq.getMessage()); } catch(SQLException sqe) { JOptionPane.showConfirmDialog(this,sqe.getMessage()); } try {

rs1=st1.executeQuery("select * from university"); int i=0; while (rs1.next()) { uids[i] = String.valueOf((rs1.getInt("uni_id"))); i++; }

catch(SQLException sqe) { JOptionPane.showConfirmDialog(this,sqe.getMessage()); }

uni_id = new JComboBox(uids); uni_id.setBounds(125,30,240,20); uni_id.setFont(font); uni_id.addActionListener(this); add(uni_id);

for(int i=0;i<tf.length;i++) { tf[i].setBounds(125,60+i*30,240,20); tf[i].setFont(font); add(tf[i]); }

for(int i=0;i<btMove.length;i++) { btMove[i].setBounds(20+i*55,330,50,20); btMove[i].setFont(font); add(btMove[i]); btMove[i].addActionListener(this); }

// to fill the uni_name tf si = (String)uni_id.getSelectedItem(); selItem = Integer.parseInt(si); try { st1 = con.createStatement(); rs1=st1.executeQuery("select * from university where uni_id ="+selItem+""); while (rs1.next()) { tf[0].setText(rs1.getString("uni_name")); } } catch(SQLException e) { JOptionPane.showConfirmDialog(this,e.getMessage()); }

tf[0].setEnabled(b); tf[1].setEnabled(b); tf[2].setEnabled(b); tf[3].setEnabled(b); tf[4].setEnabled(b); tf[5].setEnabled(b);

tf[6].setEnabled(b); tf[7].setEnabled(b);

btMove[0].setEnabled(b); btMove[1].setEnabled(b); btMove[2].setEnabled(!b); btMove[3].setEnabled(!b);

// to fetch 1st college's detail in selected university try { st1 = con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE); rs2=st1.executeQuery("select * from college where uni_id ="+selItem+"");

if(!rs2.next()) {Last(false); First(false); flag = 3; } else {rs2.first(); tf[1].setText(String.valueOf((rs2.getInt("c_id")))); tf[2].setText(rs2.getString("c_name")); tf[3].setText(String.valueOf((rs2.getInt("m_rank"))));

tf[4].setText(rs2.getString("city")); tf[5].setText(rs2.getString("state")); tf[6].setText(rs2.getString("email")); tf[7].setText(rs2.getString("website")); } } catch(SQLException e) { JOptionPane.showConfirmDialog(this,e.getMessage()); } //button function try { if(rs2.isFirst()) { if(rs2.isLast()) { First(false); Last(false); } else { First(false); Last(true); } }

else {if(rs2.isLast()) { First(true); Last(false); } else { First(true); Last(true); } } } catch (SQLException e) { JOptionPane.showConfirmDialog(this,e.getMessage()); } }

public ResultSet updateRs(String table) throws SQLException {ResultSet rs; st1 = con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE); rs=st1.executeQuery("select * from "+table+" where uni_id ="+selItem+""); return rs; } public void displayRs() {

try { tf[1].setText(String.valueOf((rs2.getInt("c_id")))); tf[2].setText(rs2.getString("c_name")); tf[3].setText(String.valueOf((rs2.getInt("m_rank")))); tf[4].setText(rs2.getString("city")); tf[5].setText(rs2.getString("state")); tf[6].setText(rs2.getString("email")); tf[7].setText(rs2.getString("website")); } catch (SQLException e) { JOptionPane.showConfirmDialog(this,e.getMessage()); } } public void enableKey(boolean b) { tf[0].setEnabled(false); tf[1].setEnabled(b); tf[2].setEnabled(b); tf[3].setEnabled(b); tf[4].setEnabled(b); tf[5].setEnabled(b); tf[5].setEnabled(b); tf[6].setEnabled(b);

tf[7].setEnabled(b);

Last(!b); First(!b); } public void Last(boolean b) { btMove[2].setEnabled(b); btMove[3].setEnabled(b); } public void First(boolean b) { btMove[0].setEnabled(b); btMove[1].setEnabled(b); }

public void validate(int i, String type) {war=""; String test = tf[i].getText(); @SuppressWarnings("unused") int testInt; if (test.length() == 0) {war = ""+labels[i+1]+ " cannot be empty"; warning.setText(war);

} else {if(type == "int") {try {if(test.length()>5) test="i"; testInt = Integer.parseInt(test); } catch(NumberFormatException e) { war = ""+labels[i+1]+ " should be a valid number and < 1000000"; warning.setText(war); } } else {war = ""; warning.setText(war); } } }

public void button() { try {

if(rs2.isFirst()) { if(rs2.isLast()) { First(false); Last(false); } else { First(false); Last(true); } } else {if(rs2.isLast()) { First(true); Last(false); } else { First(true); Last(true); } }

} catch (SQLException e) { JOptionPane.showConfirmDialog(this,e.getMessage()); } } @Override public void actionPerformed(ActionEvent a) { String action = a.getActionCommand();

//Action Buttons if(action == "New") {actionNew(); } if(action == "Edit") { actionEdit(); } if(action == "Delete") { actionDelete(); } if(action == "Save") {validate(1,"int"); if(war == "") { validate(2,"str");

if(war == "") { validate(3,"int"); } } if(war == "") {actionSave(); button(); } } if(action == "Cancel") { actionCancel(); } //Move Buttons if(action == "<<") {war = ""; warning.setText(war); try { rs2.first(); displayRs(); First(false); Last(true); } catch (SQLException e) { JOptionPane.showConfirmDialog(this,e.getMessage());

} } if(action == "<") { try { rs2.previous(); displayRs(); button(); } catch (SQLException e) { JOptionPane.showConfirmDialog(this,e.getMessage()); } } if(action == ">") { try { rs2.next(); displayRs(); button(); } catch (SQLException e) { JOptionPane.showConfirmDialog(this,e.getMessage()); }

} if(action == ">>") {war = ""; warning.setText(war); try {rs2.last(); displayRs(); First(true); Last(false); } catch (SQLException e) { JOptionPane.showConfirmDialog(this,e.getMessage()); } } // Combo Box if(action == "comboBoxChanged") {war = ""; warning.setText(war); cbChanged(); } }

public void actionNew()

{ war = "* fields are mandatory"; warning.setText(war); enableKey(true); flag2 = 0; if(flag!=3) flag = 1; cb = ((String) uni_id.getSelectedItem()); for(int i=1;i<tf.length;i++) { tf[i].setText(""); } try { rown = rs2.getRow(); } catch (SQLException e) { JOptionPane.showConfirmDialog(this,e.getMessage()); } } public void actionEdit() {war = ""; warning.setText(war); flag2 = 0; flag = 2; cb = ((String) uni_id.getSelectedItem()); enableKey(true);

try { rown = rs2.getRow(); } catch (SQLException e) { JOptionPane.showConfirmDialog(this,e.getMessage()); } } public void actionDelete() { flag2 = 1; enableKey(false); try { rown = rs2.getRow(); rs2.deleteRow(); rs2 = updateRs("college"); if(rown == 1) { if(!rs2.next()) {for(int i=1;i<tf.length;i++) { tf[i].setText(""); } Last(false); First(false); flag = 3; }

else { rs2.first(); button(); displayRs(); } } else { rs2.absolute(--rown); button(); displayRs(); } } catch (SQLException e) { JOptionPane.showConfirmDialog(this,e.getMessage()); } } public void actionSave() { flag2 = 1; enableKey(false); if(flag == 1 || flag == 3)// if saved from new { try {cb = ((String) uni_id.getSelectedItem());

rs2.moveToInsertRow(); rs2.updateInt(1, Integer.parseInt(cb)); rs2.updateInt(2, Integer.parseInt(tf[1].getText())); rs2.updateString(3, tf[2].getText()); rs2.updateInt(4, Integer.parseInt(tf[3].getText())); rs2.updateString(5, tf[4].getText()); rs2.updateString(6, tf[5].getText()); rs2.updateString(7, tf[6].getText()); rs2.updateString(8, tf[7].getText()); rs2.insertRow(); rs2 = updateRs("college"); rs2.first(); if(flag == 1) { st1 = con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE); rs3=st1.executeQuery("SELECT * FROM college where uni_id="+cb+" and c_id < "+Integer.parseInt(tf[1].getText())+";"); rs3.last(); int rn = rs3.getRow(); rs2.absolute(++rn); } button(); } catch (SQLException e) { JOptionPane.showConfirmDialog(this,e.getMessage()); } }

else { if(flag !=3) // if saved from edit { try { cb = ((String) uni_id.getSelectedItem()); rs2.updateInt(1, Integer.parseInt(cb)); rs2.updateInt(2, Integer.parseInt(tf[1].getText())); rs2.updateString(3, tf[2].getText()); rs2.updateInt(4, Integer.parseInt(tf[3].getText())); rs2.updateString(5, tf[4].getText()); rs2.updateString(6, tf[5].getText()); rs2.updateString(7, tf[6].getText()); rs2.updateString(8, tf[7].getText()); rs2.updateRow(); rown = rs2.getRow(); rs2 = updateRs("college"); rs2.absolute(rown); } catch (SQLException e) { JOptionPane.showConfirmDialog(this,e.getMessage( )); } } else // if saved from new when rs is null {

} } displayRs(); flag = 0; } public void actionCancel() { war = ""; warning.setText(war); flag2 = 1; if(flag == 3) { enableKey(false); First(false); Last(false); } else {flag = 0; if(cb != ((String) uni_id.getSelectedItem())) uni_id.setSelectedItem(cb); enableKey(false); try { rs2.absolute(rown); displayRs(); button();

} catch (SQLException e) { JOptionPane.showConfirmDialog(this,e.getMessage()); } } } public void cbChanged() { si = (String)uni_id.getSelectedItem(); selItem = Integer.parseInt(si); try {rs1 = updateRs("university"); while (rs1.next()) { tf[0].setText(rs1.getString("uni_name")); } if(flag2 == 1 ) {rs2 = updateRs("college"); if (!rs2.next())// is resultset 2 is null {flag = 3; for(int i=1;i<tf.length;i++) { tf[i].setText(""); } First(false);

Last(false); } else {enableKey(false); flag = 0; rs2.first(); displayRs(); if(rs2.isLast()) { First(false); Last(false); } else { First(false); Last(true); } } } } catch(SQLException e) { JOptionPane.showConfirmDialog(this,e.getMessage()); } }

} package project;

import java.awt.Font; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.ItemEvent; import java.awt.event.ItemListener; import java.sql.Connection; import java.sql.DriverManager; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement;

import javax.swing.JButton; import javax.swing.JComboBox; import javax.swing.JInternalFrame; import javax.swing.JLabel; import javax.swing.JOptionPane; import javax.swing.JTextField;

@SuppressWarnings("serial") public class Counselling extends JInternalFrame implements ActionListener,ItemListener{ Connection con; Statement st;

ResultSet rs,rs1,rs2; JComboBox college,trade; String[] College = new String[100]; String[] Trade = {"Select Trade","CSE","ECE","ME","AM","IT"};

JTextField tf[] = {new JTextField(10),new JTextField(10), new JTextField(10), new JTextField(10), new JTextField(10), new JTextField(10), new JTextField(10), new JTextField(10), new JTextField(10), new JTextField(10), new JTextField(10) }; String labels[] = { "Your Information","User ID","Name","Rank","Category","Available Colleges", "College","University","Trade","Total Seats","Vaccent Seats",};

JButton btMove = new JButton("Confirm");

public Counselling(int x, int y, String u_id) { super("Counselling", false, //resizable true, //closable false, //maximizable true);//iconifiable

//***************************************************************** setLayout(null); setSize(400,460); setLocation(x,y); Font font = new Font("Calibri", Font.PLAIN,13); Font font2 = new Font("Calibri", Font.BOLD,16);

for(int i=0;i<labels.length;i++) { JLabel lbl =new JLabel(labels[i]); lbl.setBounds(20,30+i*30,100,20); lbl.setFont(font); add(lbl); if(i == 5 || i == 0) { lbl.setBounds(20,30+i*30,300,20); lbl.setFont(font2); }

for(int i=0;i<tf.length;i++) {if(i == 0 || i == 5 || i == 6 || i == 8) {} else

{ tf[i].setBounds(125,30+i*30,240,20); tf[i].setFont(font); tf[i].setEnabled(false); add(tf[i]); } }

btMove.setBounds(265,390,100,20); btMove.setFont(font); add(btMove); btMove.addActionListener(this); btMove.setEnabled(false);

trade = new JComboBox(Trade); trade.setBounds(125,270,240,20); trade.setFont(font); trade.setEnabled(false); trade.addItemListener(this); add(trade);

// connection try { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");

con = DriverManager.getConnection("jdbc:odbc:db1"); st = con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE); } catch(ClassNotFoundException sq) { JOptionPane.showConfirmDialog(this,sq.getMessage()); } catch(SQLException sqe) { JOptionPane.showConfirmDialog(this,sqe.getMessage()); } loadStudentInfo(u_id); loadCollege(); College[0] = "Select College"; college = new JComboBox(College); college.setBounds(125,210,240,20); college.setFont(font); college.addItemListener(this); add(college); }

public void loadStudentInfo(String u_id1) {String check = ""; try

{st = con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE); rs=st.executeQuery("SELECT * FROM `register student` where s_id = "+u_id1+";"); while (rs.next()) {tf[1].setText(rs.getString(1)); tf[2].setText(rs.getString(2)); tf[3].setText(rs.getString(8)); tf[4].setText(rs.getString(9)); check = rs.getString(11); } if(check.equals("Not Available")) { btMove.setText("Confirm"); } else { btMove.setText("Update"); } } catch(SQLException sqe) { JOptionPane.showConfirmDialog(this,sqe.getMessage()); } }

public void loadCollege() { int rank = Integer.parseInt(tf[3].getText()); try {st = con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE); rs=st.executeQuery("select * from college where m_rank > "+rank+";"); int i=1; while (rs.next()) { College[i] = rs.getString("c_name"); i++; } } catch(SQLException sqe) { JOptionPane.showConfirmDialog(this,sqe.getMessage()); } }

public void loadUniversity() { try { st = con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE); rs=st.executeQuery("select uni_name from university join college on " +

"university.uni_id=college.uni_id where c_name = '"+ (String)college.getSelectedItem()+"' ;"); while (rs.next()) { tf[7].setText(rs.getString(1)); } } catch (SQLException e) { JOptionPane.showMessageDialog(this,e.getMessage()); } }

public void loadSeats() {int c = 0; String cat = tf[4].getText(); if(cat.equals("SC")) c = 4; if(cat.equals("BC")) c = 5; if(cat.equals("Gen")) c = 6; if(cat.equals("Other")) c = 7; if(c != 0) {

tf[9].setText("No Seat Available");

tf[10].setText("No Seat Available"); btMove.setEnabled(false); try { st = con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE); rs2=st.executeQuery("select * from trade where t_name = '"+ (String)trade.getSelectedItem()+"' ;");

while (rs2.next()) { tf[9].setText(rs2.getString(c)); tf[10].setText(rs2.getString(c+5)); btMove.setEnabled(true); }

} catch (SQLException e) { JOptionPane.showMessageDialog(this,e.getMessage()); } } else { tf[9].setText("No Seat Available"); tf[10].setText("No Seat Available"); btMove.setEnabled(false); } }

@Override public void actionPerformed(ActionEvent a) { String action = a.getActionCommand(); if(action.equals("Confirm") || action.equals("Update")) { if(college.getSelectedIndex() != 0 || college.getSelectedIndex() != -1) { int seats = Integer.parseInt(tf[10].getText());

if(seats > 0) { try { st = con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE); st.executeUpdate("update `register student` set college='"+(String)college.getSelectedItem()+"', " + "trade='"+ (String)trade.getSelectedItem()+"' where s_id = "+tf[1].getText()+";");

st.executeUpdate("update trade join college on college.c_id=trade.c_id" + " set "+tf[4].getText()+" = "+tf[4].getText()+"-1 where c_name ='"+(String)college.getSelectedItem()+"' " + " and t_name = '"+ (String)trade.getSelectedItem()+"';"); college.setEnabled(false); trade.setEnabled(false);

btMove.setEnabled(false); JOptionPane.showMessageDialog(this,"You are allotted seat in "+(String)college.getSelectedItem()+" College . \n\nThanks For Using Our Counselling Software.","Congratulations !",1);

} catch (SQLException e) { JOptionPane.showMessageDialog(this,e.getMessage( )); }

} }

} }

@Override public void itemStateChanged(ItemEvent a) { if(a.getSource() == college) { if(college.getSelectedIndex() == 0 || college.getSelectedIndex() == -1) { tf[7].setText(""); trade.setEnabled(false); } else {

trade.setEnabled(true); loadUniversity(); } } if(a.getSource() == trade) { if(trade.getSelectedIndex() == 0 || trade.getSelectedIndex() == -1) {} else { loadSeats(); } }

} package project;

import java.awt.BorderLayout; import java.awt.Color; import java.awt.Font;

import javax.swing.BorderFactory; import javax.swing.JInternalFrame;

import javax.swing.JPanel; import javax.swing.JTextArea; import javax.swing.JTextField; import javax.swing.border.TitledBorder;

@SuppressWarnings("serial") public class About extends JInternalFrame { JTextArea about; TitledBorder title = BorderFactory.createTitledBorder("About Us"); public About() { super("About Us", false, //resizable true, //closable false, //maximizable true);//iconifiable

//***************************************************************** setLayout(null); setSize(400,460); setLocation(200,50); Font font = new Font("Calibri", Font.PLAIN,15); setBackground(Color.white); JPanel ps = new JPanel(new BorderLayout()); ps.setBounds(20,20, 350, 390);

add(ps);

String abt ="Online counseling System is fully work as online using\n" + "the internet, which is provides facility online such as \n" + "Student Counseling, Managing the student record, \n" + "Managing the Institute record and Searching the any \n" + "other information about Counseling procedure/Institutes,\n" + "this types of information easy to search through the website.\n";

about = new JTextArea(abt,2,5); about.setFont(font); about.setBorder(title); ps.setBackground(Color.blue); ps.add(about, BorderLayout.CENTER); }

}[Page Break]Input-Output

Forms: -

Code Design
Code design for the system follows the following pattern. The java programs for the accessing the database server consists of functions that retrieve data and return that data in the required format. These java functions are put into classes. These classes are identified by the module which they service. The classes are all part of a package. This package is used in the JSP scripting to declare objects of a particular class. Once the objects have been declared, the functions of that object can be easily accessed by a normal objectName.functionName kind of call to it. The function performs the necessary tasks and then returns the data to the JSP script. The web server then processes these data and prepares an HTML file to be displayed to the user. This process is depicted in the figure.

[Page Break]

TESTING

System Testing: -

Prior to the actual implementation of the system it had to be tested comprehensively and every possible error uncovered. Since it is not possible to test the system exhaustively, the black box testing method was used for system testing. The black box testing usually demonstrates that software functions are operational; that the input is properly accepted and the output is correctly produced; and that integrity of external information (databases) is maintained.

Table 10.1 outlines the tests that were performed on the system to ensure correctness and unearth errors which were subsequently debugged.

Table:- Tests Conducted on the System: -

Testing Phase Objectives Unit The various functions within each program and the program blocks are tested for proper working. Testing Module A module is composed of various programs related to that module. Module testing is done to check the module functionality and interaction between units within a module Testing Integration Integration testing is done to test the functionality and interfacing between Testing the modules. Acceptance Acceptance testing is done after implementation to check if the system runs Testing successfully in the customer environment/site.
[Page Break]

Unit Testing: -

Unit Testing will be done to test field validations, navigation, functionality of the programs and its blocks. These tests are applied on various functions within each program and other critical program blocks. Table 10.2 and 10.3 outline two sample test cases for Unit Testing performed on the system

Table:- Unit Testing Test Case 1: -

Test Case Description This test case deals with the creation of Student information. The creation program takes many inputs. The test should check for proper inputs and verify whether the creation function is called properly with the correct input parameters. Expected Inputs Student details for reporting from the user (Counseling). Expected Outputs Alert window for erroneous inputs. Confirmation of Student Counseling. Actual Test Results An alert window was shown whenever the user gave some erroneous data, such as entering numbers in the name field, entering characters in numeric fields.

Confirmation of Insertion of details was displayed on submission to the add function, implying that the function was called properly.

[Page Break]

Table:- Unit Testing Test Case 2: -

Test Case Description This test case deals with the Withdraw of counseling Student by the java function for that does the Withdraw. The test will check if the java function receives the Withdraw properly and checks if the Withdraw is performed correctly. Expected Inputs Withdraw Counseling Student from the web server. Expected Outputs The java function should return the Student Withdraw Message with correct Rank and Roll-on of student. Actual Test Results

The java function received the Withdraw Massage properly.

Module Testing: Module testing will be done to test the interaction between the various programs within one module. It checks the functionality of each program with relation to other programs within the same module. It then tests the overall functionality of each module. Table 10.4 and 10.5 outline two sample test case for Module Testing performed on the system.

Table :-Module Testing Test Case 1: -

Test Case Description This test case deals with the module creation in the Counseling module. Expected Inputs Student details for Counseling. Expected Outputs This new module should appear in the insertion /Registration programs. Actual Test Results The new module appears in the insertion /Registration programs.

Table:- Module Testing Test Case 2: -

Test Case Description This test case deals with the Withdraw and Reconciling for the Withdraw programs in the Withdraw and Reconciling Module. Expected Inputs Withdraw and recounseling of student details. Expected Outputs Student Withdraw Massage with correct Rank and Roll-on of student, with provisions to Recounseling. Actual Test Results Displayed the correctly Withdraw massage, with provisions to Recounseling for the Student.

Integration Testing: -

Integration testing is done to test the functionality and interfacing between the modules. The system is built up of various modules which work together to automate the activities. These modules should work together in a seamless way to achieve the desired results. Integration testing will test for this property of the modules. The modules display a cause and effect relationship, if data in one module is changed, then it affects the data to change

in some other module also. Integration testing needs to check if the modifications do not adversely affect some other modules.

Table:- Integration Testing Test Case 1: -

Test Case Description This test case deals with the Counseling module. After the Student Reporting and final counseling. Expected Inputs Student Roll No, Rank and category for confirmation. Expected Outputs The student must be confirmation Counseling. Actual Test Results Once the details are registered Student and on seeing the details in the Counseling module, the student record details are displayed.

10.5 Acceptance Testing: -

Acceptance testing was done after the implementation of the system. The acceptance testing will check if the system works correctly in the user environment and if all the user specified functionalities are present. It also tests if the system adheres to the company policies and quality standard. The On-Line Counseling system was tested and accepted by Gnix Infosoft after the acceptance testing.

IMPLEMENTATION AND MAINTENANCE

11.1 Implementation:Implementation uses the design document to produce code. Demonstration that the program satisfies its specifications validates the code. Typically, sample runs of the program demonstrating the behavior for expected data values and boundary values are required. Small programs are written using the model: Write/Compile/ Test It may take several iterations of the model to produce a working program. As programs get more complicated, testing and debugging alone may not be enough to produce reliable code. Instead, we have to write programs in a manner that will help insure that errors are caught or avoided.

Top-Down Implementation: Top down implementation begins with the user-invoked module and works toward the modules that do not call any other modules. The implementation may precede depth-first or breadth-first.

Bottom-Up Implementation: Implementation begins with modules that do not call any other modules and works toward the main program. Test harness (see below) is used to test individual modules. The main module constitutes the final test harness.

Stub Programming: Stub programming is the implementation analogue of top-down and stepwise refinement. It supports incremental program development by allowing for error and improvement. A stub program is a stripped-down, skeleton version of a final program. It doesn't implement details of the algorithm or fulfill all the job requirements. However, it does contain rough versions of all subprograms and their parameter lists. Furthermore, it can be compiled and run. Extensive use of procedures and parameter are the difference between stub programs and prototypes. Quick and dirty prototypes should be improved-they should be rewritten. A stub program helps demonstrates that a program's structure is plausible. Its procedures and functions are unsophisticated versions of their final forms, but they allow limited use of the entire program. In particular, it may work for a limited data set. Often the high-level procedures are ready to call lower-level code, even if the more detailed subprograms haven't even been written. Such sections of code are commented out. The comment brackets can be moved, call-by-call, as the underlying procedures are actually written.

Incremental Program Development: -

As program become more complex, changes have a tendency to introduce unexpected effects. Incremental programming tries to isolate the effects of changes. We add new features in preference to adding new functions, and add new function rather than writing new programs. The program implementation model becomes: ------ Define types/compile/fix; ------ Add load and dump functions/compile/test; ------ Add first processing function/compile/test/fix; ------ Add features/compile/test/fix; ------ Add second processing function/compile/test/fix; ------ Keep adding features/and compiling/and testing/ and fixing.

Maintenance: Once the software is delivered and deployed, then maintenance phase starts. Software requires maintenance because there are some residual errors remaining in the system that must be removed as they discovered. Maintenance involves understanding the existing software (code and related documents), understanding the effect of change, making the changes, testing the new changes, and retesting the old parts that were not changed. The complexity of the maintenance task makes maintenance the most costly activity in the life of software product. It is believed that almost all software that is developed has residual errors, or bugs, in them. These errors need to be removed when discovered that leads to the software change. This is called Corrective Maintenance. Corrective maintenance

means repairing, processing or performance failures or making alterations because of previously ill-defined problems. Software undergoes change frequently even without bugs because the software must be upgraded and enhanced to include more features and provide more services. This also requires modification of the software. The changed software changes the environment, which in turn requires further change. This phenomenon is called the law of software evaluation. Maintenance due to this phenomenon is called adaptive maintenance. Adaptive maintenance means changing the program function. Perfect maintenance means enhancing the performance or modifying the programs according to the users additional or changing needs. The keys to reduce the need for maintenance are: 1. More accurately defining the users requirement during system development. 2. Preparation of system documentation in a better way. 3. Using more effective ways for designing processing logic and communicating it to project team members. 4. Making better use of existing tools and techniques. 5. Managing the system engineering process effectively.

COST ESTIMATION OF THE PROJECT: -

The objective of the cost estimation is to enable the client or developer to perform a costbenefit analysis and for project monitoring and control. The accuracy of the estimate depends on the amount of reliable information about the final product. When the product is delivered, the cost can be accurately determined, as all the data about the project and the resource spent can be fully known by then. The obtainable accuracy of the estimates as it varies with the different phases is shown in below figure: [Drawing][Drawing]

[Drawing][Drawing]

[Drawing][Drawing][Drawing][Drawing][Drawing][Drawing][Drawing]

Feasibility Analysis Design

Requirement System Design Testing Software

DetailedCoding and Accepted

(Figure Accuracy of cost estimation)

[OLE Object]

(Figure Graph of Accuracy of Cost Estimation)

Cost Of Correcting Errors: According to the established S/W Engineering standard of estimating the cost of correcting errors the phase wise distribution of occurrences of errors is as given below: Requirement Analysis Design Coding 50% 20% 30%

The cost of correcting errors of different phases is not the same and depends on when the error is detected and corrected. The relative cost of correcting requirement errors as a function of where they are detected is shown below figure-.

[Drawing] [Drawing]

1000

[Drawing][Drawing]

[Drawing]

100

[Drawing]

50

[Drawing]

10

[Drawing]

[Drawing]

[Drawing][Drawing][Drawing][Drawing][Drawing][Drawing][Drawing]

Requirements Operation

Design

Code

Development Acceptance Test Test

[Drawing]Phase

in Which Error Was Detected

(Figure - 10) Cost of correcting errors

One can perform cost estimation at any point in the software life cycle. As the cost of the project depends on the nature and characteristics of the project, at any point, the accuracy of the estimate will depend on the amount of reliable information we have about the final product. The figure depicted below shows the accuracy of the cost estimation. On Size estimation of Schedule and Cost of the Project: this approach implies that size is the primary factor for cost; other factors have lesser effect. Here we will discuss one such model called the Constructive Cost Model (COCOMO) developed by Boehm. This model also estimates the total effort in terms of person-months of the technical project staff. The basic steps of this model are as follows:

Obtain the initial estimate of the development effort from the estimate of thousands of delivered lines of source code (KDLOC). Determine a set of multiplying factors from different attributes of the project. Adjust the effort estimate by multiplying the initial estimate with all the multiplying factors.

The initial estimate also called nominal estimate is determined by an equation of the form used in the static single-variable models, using KDLOC as the measure of size. To determine the initial effort Ei in person-months the equation used is of the type Ei = a*(KDLOC)b In COCOMO model the values of constants a and b are different with different type of projects. As our project is Organic type the values of a and b are 3.2 and 1.05 respectively. The total thousand delivered code (KDLOC) of our system has been estimated as around 2. In order to determine the multiplying factors commonly known as cost driver attributes we have taken rating of these attributes according to our requirements. From these, the effort adjustment factor (EAF) of our project has been estimated as 1.16.

Now the final efforts estimate, E, of our project is obtained by multiplying the initial estimate by the EAF. i.e., E = EAF*Ei

The project duration is estimated for an Organic project by the formula D = 2.5 * E0.38 and according to this formula I have estimated the project duration 6 months.

CONCLUSIONS

This was the first considerably large and important project undertaken by me during my MSC (IT) course. It was an experience that changed the way I perceived project development. The coding could not be started before the whole system was completely finalized. Even then there were so many changes required and the coding needed to be changed. I attribute this to inadequate information gathering from the user. Though there were many meetings with the user and most of the requirements were gathered, a few misinterpretations of the requirements still crept in. It made me realize how important the systems analysis phase is. The project is a classic example for the adage that learning of concepts needs to be supplemented with application of that knowledge.

On the whole it was a wonderful experience developing this project and I would have considered my education incomplete without undertaking such a project which allowed me to apply all that I have learnt.
[Page Break]

13. BIBLIOGRAPHY

The following books were used extensively for the project development and implementation.

1. Chuck Musciano and Bill Kennedy (1998) HTML: The Definitive Guide OReilly & Associates Ltd 2. George Koch and Kevin Loney. (1997) Oracle 8, The Complete Reference Oracle Press Edition. 3. Herbert Schildt (2001) The Complete Java Reference Tata McGraw-Hill Publishing Company Limited. 4. Marty Hall (2000) Core Servlets and JavaServer Pages Sun MicroSystem Press. 5. Matthew Siple. (1998) The Complete Guide to Java Database Programming Tata McGraw-Hill Publishing Company Limited. 6. Roger S. Pressman (1997) Software Engineering, A Practitioners Approach Tata McGraw-Hill Publishing Company Limited.

7.

Professional JSP, Wrox Publications.

The following Links were searched and exploited extensively for the project development and implementation.

1. 2. 3.

http://java.sun.com/products/jsp http://www.aw.com/cseng/ http://jakarta.apache.org