<repo_name>Bulbul017/Online-Admission-System<file_sep>/README.md
# Online-Admission-System
It's a simple JAVA project which deals with online registration procedures for a university admission seeking student and after updating all the necessary informations, offers the student with an admit-card.

# Features
- This project has been developed using JAVA.
- It's a multi threaded project.
- Socket programming has been used.
- Any number of student can apply for the registration at any time.
- User friendly GUI.
- The design of the project is based on Client-Server module of networking.

# Installation
- Platform : Windows,Linux.
- Language : JAVA (JDK 1.8).
- Tool     : Netbeans IDE,Scene builder.
- Application type : JAVA FXML application.



<file_sep>/Admission System/AdmissionSystem/src/admissionsystem/FXMLDocumentController.java

package admissionsystem;

import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.net.InetAddress;
import java.net.Socket;
import java.net.URL;
import java.util.ResourceBundle;
import java.util.Scanner;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.fxml.Initializable;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.control.Tab;
import javafx.scene.control.TextField;
import javafx.scene.layout.AnchorPane;
import javafx.stage.Stage;

/**
 *
 * @author ac
 */
public class FXMLDocumentController implements Initializable {
    
    @FXML
    private  Button submitButton;
    
    @FXML
    private  Label errorInHscRoll;    
    @FXML
    private  TextField hscRollTextField;  
    private String hscRoll;
    
    @FXML
    private  Label errorInSscRoll; 
    @FXML
    private  TextField sscRollTextField;
    private String sscRoll;
    
    @FXML
    private  TextField hscPassingYearTextField;
    private String hscPassingYear;
    
    private String board;
    
    @FXML
    private  TextField serverTextField;
    private String serverAdress;
    @FXML
    private Tab ar;
    @FXML
    private TextField checkAdmitCardRoll;
    @FXML
    private Label ipAddressLabel;
    
    
    
    //Submit button action
    @FXML
    private void submitButtonOnAction(ActionEvent event)throws Exception {
        
        
        
        int flag1 = 1; //initialization
        int flag2 = 1; //initialization
        
        
        this.hscRoll = this.hscRollTextField.getText();
        
        System.out.println(this.hscRoll);
        
        //Checking validity of hsc roll
        try{
            
            this.errorInHscRoll.setText("") ;
            
            for (int i=0; i < this.hscRoll.length(); i++){
                
                //if invalid      
                if(this.hscRoll.charAt(i)<48 && this.hscRoll.charAt(i)>57){
                           
                           
                          flag1 = 0; 
                          throw new Exception();
                          
                          
                }
                      
            }
            
            this.errorInHscRoll.setText("") ;
            
        }catch(Exception e){
            
            flag1 = 0;
            //Showing the invalid message
            this.errorInHscRoll.setText("HSC Roll isn't correct") ;
            
        }
        try{
            
            if(this.hscRoll.length()!=6){
                 
                flag1 = 0;
                throw new Exception();
                       
            }
            
        }catch(Exception e){
            
            flag1 = 0;
            this.errorInHscRoll.setText("HSC Roll isn't correct") ;
            
        }
        
        this.sscRoll = this.sscRollTextField.getText();
        System.out.println(this.sscRoll);
        
        //Checking validity of hsc roll
        try{
            
            this.errorInSscRoll.setText("") ;
            
            for (int i=0; i < this.sscRoll.length(); i++){
                       
                if(this.sscRoll.charAt(i)<48 && this.sscRoll.charAt(i)>57){
                           
                           
                          flag2 = 0;
                          throw new Exception();
                          
                          
                }
                      
            }
            
            this.errorInSscRoll.setText("") ;
            
        }catch(Exception e){
              
              flag2 = 0;
              //showing error message
              this.errorInSscRoll.setText("SSC Roll isn't correct") ;
            
        }
        try{
            
            if(this.sscRoll.length()!=6){
                
                flag2 = 0;
                throw new Exception();
                       
            }
            
        }catch(Exception e){
            
            flag2 = 0;
            this.errorInSscRoll.setText("SSC Roll isn't correct") ;
            
        }
        
        this.hscPassingYear = this.hscPassingYearTextField.getText();
        System.out.println(this.hscPassingYear);
        System.out.println(this.board);
        
        this.serverAdress = this.serverTextField.getText();
        System.out.println(this.serverAdress);
        
        //If valid then create student object
        if (flag1 == 1  &&  flag2 == 1){
            
            
            System.out.println("All is well");
            
            Student student = new Student();
            student.setHSCRoll(this.hscRoll);
            student.setHSCPassingYear(this.hscPassingYear);
            student.setSSCRoll(this.sscRoll);
            student.setBoard(this.board);
            
            
            System.out.println(student);
            
            //connect to server
            this.connect();
            
            
            System.out.println("I have come out of cliet class");
             
             
             
             
                            
            
        }
        
    }
    
    @FXML
    private void barisalBoardAction(ActionEvent event)throws Exception{
        
        this.board = "Barisal";
        
    }
    
    @FXML
    private void dinajpurBoardAction(ActionEvent event)throws Exception{
        
        this.board = "Dinajpur";
        
    }
    
    @FXML
    private void dhakaBoardAction(ActionEvent event)throws Exception{
        
        this.board = "Dhaka";
        
    }
    
    @FXML
    private void rajshahiBoardAction(ActionEvent event)throws Exception{
        
        this.board = "Rajshahi";
        
    }
    
    @FXML
    private void jessoreBoardAction(ActionEvent event)throws Exception{
        
        this.board = "Jessore";
        
    }
    
    @FXML
    private void sylhetBoardAction(ActionEvent event)throws Exception{
        
        this.board = "Sylhet";
        
    }
    
    @FXML
    private void chittagongBoardAction(ActionEvent event)throws Exception{
        
        this.board = "Chittagong";
        
    }
    
    
    @Override
    public void initialize(URL url, ResourceBundle rb) {
        // TODO
    }
    
    //To connect with the server
    public void connect() throws IOException 
    { 
		try
		{ 
			
			
			
                        InetAddress ip = InetAddress.getByName("localhost"); 
			// establish the connection with server port 5056 
			//Socket s = new Socket(this.serverAdress, 5056); 
                        Socket s = new Socket(ip, 5056); 
	
			// obtaining input and out streams 
			DataInputStream dis = new DataInputStream(s.getInputStream()); 
			DataOutputStream dos = new DataOutputStream(s.getOutputStream()); 

			//Client sending information to server
			               
                            
                         
			dos.writeUTF(this.hscRoll);
                        dos.writeUTF(this.hscPassingYear);
                        dos.writeUTF(this.board);
                        dos.writeUTF(this.sscRoll);
                            
                        System.out.println("Just sent.....");
                        
                        String messageFromServer;
                        messageFromServer = dis.readUTF();
                        
                        if(messageFromServer.equals("New")){
                            
                            System.out.println("New Student");
                            Parent root = FXMLLoader.load(getClass().getResource("UserInfo.fxml"));
                            Scene scene = new Scene(root);
                            Stage stage = new Stage();
                            stage.setScene(scene);
                            stage.show();
                       
                        }
                        else if(messageFromServer.equals("Old")){
                            
                            System.out.println("Old Student");
                            Parent root = FXMLLoader.load(getClass().getResource("AlreadyRegistered.fxml"));
                            Scene scene = new Scene(root);
                            Stage stage = new Stage();
                            stage.setScene(scene);
                            stage.show();
                       
                        }
                        
            
                            
            
	
			
			// closing resources 
                        
			dos.writeUTF("Exit");
                        s.close();
                        System.out.println("Connection closed"); 
			dis.close(); 
			dos.close();
                        
                        
		}catch(Exception e){ 
			e.printStackTrace(); 
		}
                
                
    }

    @FXML
    private void checkSubmitOnAction(ActionEvent event) throws IOException {
        
        File file = new File("AdmitCardRoll.txt");
        if(!file.exists()){
            
            file.createNewFile();
            
        } 
        FileWriter fw1 = new FileWriter(file);
        fw1.write(this.checkAdmitCardRoll.getText());
        fw1.close();
        
        Parent root = FXMLLoader.load(getClass().getResource("AdmitCard.fxml"));
        Scene scene = new Scene(root);
        Stage stage = new Stage();
        stage.setScene(scene);
        stage.show();
        
    }

    
    
}
<file_sep>/Admission System/Server/src/server/ClientHandler.java

package server;

import java.io.*; 
import java.text.*; 
import java.util.*; 
import java.net.*; 

// ClientHandler class 
class ClientHandler extends Thread 
{ 
	
	final DataInputStream dis; 
	final DataOutputStream dos; 
	final Socket s; 
	
	private String HSCroll;
        private String HSCyear;
        private String board;
        private String SSCroll;
        

	// Constructor 
	public ClientHandler(Socket s, DataInputStream dis, DataOutputStream dos) 
	{ 
		this.s = s; 
		this.dis = dis; 
		this.dos = dos;
		

	} 

	@Override
	public void run() 
	{ 
		String received; 
		String toreturn;
                
                
		try { 

				StudentWithServer student = new StudentWithServer();
                    
                                //Getting information from client
                                
                                
                                
                                received = dis.readUTF();
                                student.setHSCRoll(received);
                                
                                received = dis.readUTF();
                                student.setHSCPassingYear(received);
                
                                received = dis.readUTF();
                                student.setBoard(received);
                
                                received = dis.readUTF();
                                student.setSSCRoll(received);
                                
                                System.out.println(student);
                           
                                //dos.writeUTF("New");
                                if(student.hscRollCheck()==0){
                                    
                                    dos.writeUTF("New");
                                    
                                   
                                }
                                else if(student.hscRollCheck()==1){
                                    
                                    dos.writeUTF("Old");
                                    
                                   
                                }
                                
                                    
                                 
                                //student.StoreInFile(registrationNumber, admitCardRoll);
                                
				received = dis.readUTF();
                                if(received.equals("Exit")) 
                                {  
                                        
                    
                                        this.s.close(); 
                                        System.out.println("Connection closed"); 
                                        try
                                        { 
                                            //close the strem
                                            this.dis.close(); 
                                            this.dos.close(); 
			
                                        }catch(IOException e){ 
                                            e.printStackTrace(); 
                                        } 
                    
                                }
				

					

				
				
				
			} catch (IOException e) { 
				e.printStackTrace(); 
			}
                        
		 
		
		
	} 
} 


<file_sep>/Admission System/ServerTwo/src/servertwo/ClientHandler.java

package servertwo;

import java.io.*; 
import java.text.*; 
import java.util.*; 
import java.net.*; 
import java.util.logging.Level;
import java.util.logging.Logger;

// ClientHandler class 
class ClientHandler extends Thread 
{ 
	
	final DataInputStream dis; 
	final DataOutputStream dos; 
	final Socket s; 
	private int registrationNumber;
        private int admitCardRoll;
        private String name;
        private String contactNo ;
        private String email;
        private String birthDate;
        private String unit;
        private String allocatedSeat;

	// Constructor 
	public ClientHandler(Socket s, DataInputStream dis, DataOutputStream dos,int registrationNumber,int admitCardRoll,String allocatedSeat) 
	{ 
		this.s = s; 
		this.dis = dis; 
		this.dos = dos;
		this.registrationNumber = registrationNumber;
		this.admitCardRoll = admitCardRoll;
                this.allocatedSeat = allocatedSeat;

	}
        
        @Override
        public void run(){
            
            try{
                
                String received;
                StudentWithServerTwo student = new StudentWithServerTwo();
                
                received = dis.readUTF();
                student.setName(received);
                
                received = dis.readUTF();
                student.setContactNo(received);
                
                received = dis.readUTF();
                student.setEmail(received);
                
                received = dis.readUTF();
                student.setBirthDate(received);
                
                received = dis.readUTF();
                student.setUnit(received);
                
                String registrationNumber = Integer.toString(this.registrationNumber);
                student.setRegistrationNumber(registrationNumber);
                String admitCardRoll = Integer.toString(this.admitCardRoll);
                student.setAdmitCardRoll(admitCardRoll);
                dos.writeUTF(registrationNumber);
                dos.writeUTF(admitCardRoll);
                dos.writeUTF(this.allocatedSeat);
                
                System.out.println(student);
                
                student.storeInFile();
                
                received = dis.readUTF();
                
                if(received.equals("Exit")) 
                {  
                                        
                    this.s.close(); 
                    System.out.println("Connection closed"); 
                    try
                    { 
                        //close the strem
                        this.dis.close(); 
                        this.dos.close(); 
			
                    }catch(IOException e){ 
                        
                        e.printStackTrace(); 
                                        
                    }                    
                                         
                    
                }
                
            } catch (IOException ex) {
                
                ex.printStackTrace();
                
            }
        }

	
} 

<file_sep>/Admission System/Server/src/server/StudentWithServer.java

package server;

/**
 *
 * @author ac
 */


import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.util.Scanner;

/**
 *
 * @author <NAME>, Md. <NAME>, <NAME>
 */

public class StudentWithServer {

    
    
    
   
    private String HSCRoll;
    private String HSCPassingYear;
    private String board;
    private String SSCRoll;
    private String registrationNumber;
    private String admitCardRoll;
    
    


    StudentWithServer() {
        
    }
    
    //Checking the validity of HSC roll
    public int hscRollCheck() throws IOException{
        
        String fileName = this.getHSCRoll() + ".txt";
        File file = new File(fileName);
        if(!file.exists()){
            
              file.createNewFile();
              return 0;
            
        }
        else return 1;
        
    }
    

    /**
     * @return the HSCRoll
     */
    public String getHSCRoll() {
        return HSCRoll;
    }

    /**
     * @param HSCRoll the HSCRoll to set
     */
    public void setHSCRoll(String HSCRoll) {
        this.HSCRoll = HSCRoll;
    }

    /**
     * @return the HSCPassingYear
     */
    public String getHSCPassingYear() {
        return HSCPassingYear;
    }

    /**
     * @param HSCPassingYear the HSCPassingYear to set
     */
    public void setHSCPassingYear(String HSCPassingYear) {
        this.HSCPassingYear = HSCPassingYear;
    }

    /**
     * @return the board
     */
    public String getBoard() {
        return board;
    }

    /**
     * @param board the board to set
     */
    public void setBoard(String board) {
        this.board = board;
    }

    /**
     * @return the SSCRoll
     */
    public String getSSCRoll() {
        return SSCRoll;
    }

    /**
     * @param SSCRoll the SSCRoll to set
     */
    public void setSSCRoll(String SSCRoll) {
        this.SSCRoll = SSCRoll;
    }

    /**
     * @return the registrationNumber
     */
    public String getRegistrationNumber() {
        return registrationNumber;
    }

    /**
     * @param registrationNumber the registrationNumber to set
     */
    public void setRegistrationNumber(String registrationNumber) {
        this.registrationNumber = registrationNumber;
    }

    /**
     * @return the admitCardRoll
     */
    public String getAdmitCardRoll() {
        return admitCardRoll;
    }

    /**
     * @param admitCardRoll the admitCardRoll to set
     */
    public void setAdmitCardRoll(String admitCardRoll) {
        this.admitCardRoll = admitCardRoll;
    }
    
    
    
}


<file_sep>/Admission System/AdmissionSystem/src/admissionsystem/AdmitCardController.java

package admissionsystem;

import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.net.URL;
import java.util.ResourceBundle;
import java.util.Scanner;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.control.Button;
import javafx.scene.control.TextField;

/**
 * FXML Controller class
 *
 * @author <NAME> & Md. <NAME> & <NAME>
 */
public class AdmitCardController implements Initializable {

    @FXML
    private TextField admissionRollTextField;
    @FXML
    private TextField registrationTextField;
    @FXML
    private TextField nameTextField;
    @FXML
    private TextField emailTextField;
    @FXML
    private TextField contactNoTextField;
    @FXML
    private TextField unitTextField;
    @FXML
    private Button downloadButton;
    @FXML
    private Button previewButton;
    
    private String readFromFile;
    private String readFromFile2;
    private String fileName;
    private File file;
    private FileWriter fw;
    private Scanner sc;
    @FXML
    private TextField seatTextField;
    
    

    /**
     * Initializes the controller class.
     */
    @Override
    public void initialize(URL url, ResourceBundle rb) {
        // TODO
    }    

    @FXML
    private void downloadButtonOnAction(ActionEvent event) {
    }

    //Preview button action 
    @FXML
    private void previewButtonOnAction(ActionEvent event) throws IOException {
        
        //Reading the admit roll of the student from file AdmitCardRoll.txt
        this.file = new File("AdmitCardRoll.txt");
        if(!this.file.exists()){
            
            this.file.createNewFile();
            
        }
        this.sc = new Scanner(this.file);
        this.readFromFile = sc.nextLine();
        
        //Getting information of the student from files
        this.fileName = this.readFromFile + "Name" + ".txt";
        this.file = new File(fileName);
        if(!this.file.exists()){
            
            this.file.createNewFile();
            
        }
        this.sc = new Scanner(this.file);
        this.readFromFile2 = sc.nextLine();
        this.nameTextField.setText(this.readFromFile2);
        
        this.fileName = this.readFromFile + "ContactNo" + ".txt";
        this.file = new File(fileName);
        if(!this.file.exists()){
            
            this.file.createNewFile();
            
        }
        this.sc = new Scanner(this.file);
        this.readFromFile2 = sc.nextLine();
        this.contactNoTextField.setText(this.readFromFile2);
        
        this.fileName = this.readFromFile + "Email" + ".txt";
        this.file = new File(fileName);
        if(!this.file.exists()){
            
            this.file.createNewFile();
            
        }
        this.sc = new Scanner(this.file);
        this.readFromFile2 = sc.nextLine();
        this.emailTextField.setText(this.readFromFile2);
        
        this.fileName = this.readFromFile + "Unit" + ".txt";
        this.file = new File(fileName);
        if(!this.file.exists()){
            
            this.file.createNewFile();
            
        }
        this.sc = new Scanner(this.file);
        this.readFromFile2 = sc.nextLine();
        this.unitTextField.setText(this.readFromFile2);
        
        this.fileName = this.readFromFile + "Registration" + ".txt";
        this.file = new File(fileName);
        if(!this.file.exists()){
            
            this.file.createNewFile();
            
        }
        this.sc = new Scanner(this.file);
        this.readFromFile2 = sc.nextLine();
        this.registrationTextField.setText(this.readFromFile2);
        
        this.fileName = this.readFromFile + "Admit" + ".txt";
        this.file = new File(fileName);
        if(!this.file.exists()){
            
            this.file.createNewFile();
            
        }
        this.sc = new Scanner(this.file);
        this.readFromFile2 = sc.nextLine();
        this.admissionRollTextField.setText(this.readFromFile2);
        
        
        this.fileName = this.readFromFile + "Seat" + ".txt";
        this.file = new File(fileName);
        if(!this.file.exists()){
            
            this.file.createNewFile();
            
        }
        this.sc = new Scanner(this.file);
        this.readFromFile2 = sc.nextLine();
        this.seatTextField.setText(this.readFromFile2);
        
        
    }
    
}
