<|start_filename|>src/sms/dbController/UserController.java<|end_filename|>
package sms.dbController;

import sms.db.DBConnection;
import sms.model.Staff;
import sms.model.User;

import java.sql.*;
import java.util.ArrayList;

/**
 * @author Safnaj on 11/9/2018
 * @project School Management System
 **/
public class UserController {

    public static int addUser(User user)throws ClassNotFoundException,SQLException {
        String SQL="INSERT INTO users VALUES(?,?)";
        Connection conn = DBConnection.getDBConnection().getConnection();
        PreparedStatement stm = conn.prepareStatement(SQL);
        stm.setObject(1, user.getUsername());
        stm.setObject(2, user.getPassword());

        return  stm.executeUpdate();
    }

    public static int updateUser(User user) throws ClassNotFoundException, SQLException {
        String sql = "UPDATE users SET username= ? ,password= ?  WHERE username= '" +user.getUsername()+ "'";
        Connection conn = DBConnection.getDBConnection().getConnection();
        PreparedStatement stm = conn.prepareStatement(sql);
        stm.setObject(1, user.getUsername());
        stm.setObject(2, user.getPassword());

        return  stm.executeUpdate();
    }

    public static int deleteUser(String username) throws ClassNotFoundException, SQLException {

        String sql = "DELETE FROM users WHERE username ='"+username+"'";
        Connection conn = DBConnection.getDBConnection().getConnection();
        PreparedStatement stm = conn.prepareStatement(sql);

        return  stm.executeUpdate();
    }

    public static ArrayList <User> getAllUsers() throws ClassNotFoundException, SQLException{
        Connection conn=DBConnection.getDBConnection().getConnection();
        Statement stm = conn.createStatement();
        ResultSet rst = stm.executeQuery("Select * From users");
        ArrayList <User> userList = new ArrayList<>();
        while(rst.next()){
            User user;
            user = new User(rst.getString(1),rst.getString(2));
            userList.add(user);
        }
        return userList;
    }
    public static User searchUser(String username) throws ClassNotFoundException, SQLException {
        String sql = "SELECT * FROM users WHERE username = ? ";
        Connection conn = DBConnection.getDBConnection().getConnection();
        PreparedStatement stm = conn.prepareStatement(sql);
        stm.setObject(1, username);
        ResultSet rst=stm.executeQuery();
        if(rst.next()){
            User user = new User(rst.getString("username"),rst.getString("password"));
            return user;
        }
        return null;
    }
}


<|start_filename|>src/sms/dbController/LoginController.java<|end_filename|>
package sms.dbController;

import sms.db.DBConnection;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

/**
 * @author Safnaj on 9/27/2018
 * @project School Management System
 **/
public class LoginController {

    public static boolean Login(String username, String password) throws SQLException, ClassNotFoundException {

        String SQL = "SELECT * FROM users WHERE username=? AND password=?";

        Connection conn = DBConnection.getDBConnection().getConnection();
        PreparedStatement stm = conn.prepareStatement(SQL);
        stm.setObject(1, username);
        stm.setObject(2, password);
        ResultSet rst = stm.executeQuery();

        if (rst.next()) {


        if(!rst.getString(1).equals(username)){
            return false;
        }
        String pwd = rst.getString(2);
        if (pwd.equals(password)) {
            return true;
        }
    }
        return false;

}
}


<|start_filename|>src/sms/dbController/TransferController.java<|end_filename|>
package sms.dbController;

import sms.db.DBConnection;
import sms.model.Student;
import sms.model.User;

import java.sql.*;
import java.util.ArrayList;

/**
 * @author Safnaj on 11/5/2018
 * @project School Management System
 **/
public class TransferController {

    public static int transferStudent(ArrayList<Student> student) throws ClassNotFoundException, SQLException {
        String SQL="INSERT INTO paststudents VALUES(?,?,?,?,?,?,?,?,?,?,?)";
       //String SQL="INSERT INTO paststudents(adNo,fullName,name,dob,doa,gender,year,parentName,nic,phone,)";
        Connection conn = DBConnection.getDBConnection().getConnection();
        PreparedStatement stm = conn.prepareStatement(SQL);
        /*stm.setObject(1, student.getAdNo());
        stm.setObject(2, student.getFullName());
        stm.setObject(3, student.getName());
        stm.setObject(4, student.getDob());
        stm.setObject(5, student.getDoa());
        stm.setObject(6, student.getGender());
        stm.setObject(7, student.getGrade());
        stm.setObject(8, student.getParentName());
        stm.setObject(9, student.getNic());
        stm.setObject(10, student.getPhone());
        stm.setObject(11, student.getAddress());*/

        return stm.executeUpdate();
    }

    public static int updateGrade(String year) throws ClassNotFoundException, SQLException {
        String sql = "UPDATE paststudents SET year= '" + year + "'  WHERE year= 'Grade 5'";
        Connection conn = DBConnection.getDBConnection().getConnection();
        PreparedStatement stm = conn.prepareStatement(sql);
//        stm.setObject(1, student.getGrade());

        return stm.executeUpdate();
    }

    public static int deleteStudent(String grade) throws ClassNotFoundException, SQLException {

        String sql = "DELETE FROM Students WHERE grade ='" + grade + "'";
        Connection conn = DBConnection.getDBConnection().getConnection();
        PreparedStatement stm = conn.prepareStatement(sql);

        return stm.executeUpdate();
    }

    public static ArrayList<Student> getGrade5() throws ClassNotFoundException, SQLException {
        Connection conn = DBConnection.getDBConnection().getConnection();
        Statement stm = conn.createStatement();
        ResultSet rst = stm.executeQuery("Select * From students Where grade = 'Grade 5'");
        ArrayList<Student> studentList = new ArrayList<>();
        while (rst.next()) {
            Student student = new Student(rst.getInt(1), rst.getString(2), rst.getString(3), rst.getString(4), rst.getString(5), rst.getString(6), rst.getString(7), rst.getString(8), rst.getString(9), rst.getString(10), rst.getString(11));
            studentList.add(student);
        }
        return studentList;
    }
}


<|start_filename|>src/sms/view/controller/PrintStaffsController.java<|end_filename|>
package sms.view.controller;

import com.jfoenix.controls.JFXButton;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.fxml.Initializable;
import javafx.scene.control.ComboBox;
import javafx.scene.control.TableColumn;
import javafx.scene.control.TableView;
import javafx.scene.control.cell.PropertyValueFactory;
import javafx.scene.layout.AnchorPane;
import net.sf.jasperreports.engine.*;
import net.sf.jasperreports.engine.design.JRDesignQuery;
import net.sf.jasperreports.engine.design.JasperDesign;
import net.sf.jasperreports.engine.xml.JRXmlLoader;
import net.sf.jasperreports.view.JasperViewer;
import sms.db.DBConnection;
import sms.tableModel.StaffTableModel;

import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.HashMap;
import java.util.Map;
import java.util.ResourceBundle;

/**
 * @author Safnaj on 11/6/2018
 * @project School Management System
 **/
public class PrintStaffsController implements Initializable {

    @Override
    public void initialize(URL location, ResourceBundle resources) {
        Type.getItems().addAll("Current Staffs", "Old Staffs");
    }
    @FXML
    private AnchorPane root;

    @FXML
    private ComboBox<String> Type;

    @FXML
    private JFXButton print;

    @FXML
    private JFXButton generate;

    @FXML
    private JFXButton Back;

    @FXML
    private TableView<StaffTableModel> staffTable;

    @FXML
    private TableColumn<StaffTableModel, String> EmpNoColumn;

    @FXML
    private TableColumn<StaffTableModel, String> NameColumn;

    @FXML
    private TableColumn<StaffTableModel, String> nicColumn;

    @FXML
    private TableColumn<StaffTableModel, String> dobColumn;

    @FXML
    private TableColumn<StaffTableModel, String> doaColumn;

    @FXML
    private TableColumn<StaffTableModel, String> genderColumn;

    @FXML
    private TableColumn<StaffTableModel, String> emailColumn;

    @FXML
    private TableColumn<StaffTableModel, String> assmpDutyColumn;

    @FXML
    private TableColumn<StaffTableModel, String> phoneColumn;

    @FXML
    private TableColumn<StaffTableModel, String> addressColumn;

    @FXML
    private TableColumn<StaffTableModel, String> incDateColumn;

    @FXML
    private TableColumn<StaffTableModel, String> gradeColumn;

    ObservableList<StaffTableModel> staffList = FXCollections.observableArrayList();

    @FXML
    void Back() {
        try {
            AnchorPane studentMgmt = FXMLLoader.load(getClass().getResource(("/sms/view/fxml/StaffManagement.fxml")));
            root.getChildren().setAll(studentMgmt);
        }catch(IOException e){
            System.out.println(e);
        }
    }

    @FXML
    void Type(ActionEvent event) {

    }
    //Below code for On key press methods..

    /*@FXML
    void gen(KeyEvent event){
        generate.setOnKeyTyped((e)->{
            if (e.getCode() == KeyCode.G){
                generate();
            }
        });
    }*/

    @FXML
    void generate() {

        try{
            staffTable.getItems().clear();
            String type = Type.getValue();

            Connection conn = DBConnection.getDBConnection().getConnection();

            if (type == "Current Staffs") {

                String sql = "select * from staffs";
                ResultSet rs = conn.createStatement().executeQuery(sql);

                while (rs.next()) {

                    StaffTableModel staff = new StaffTableModel(rs.getInt("empNo"),rs.getString("teacherName"),rs.getString("nic"),
                            rs.getString("dob"),rs.getString("doa"),rs.getString("gender"),rs.getString("email"),rs.getString("assumpOfDuties"),
                            rs.getString("phone"),rs.getString("address"),rs.getString("incDate"),rs.getString("prsntGrade"));
                    staffList.add(staff);
                }
            }
            else {

                String sql2 = "select * from oldstaffs";
                ResultSet rs = conn.createStatement().executeQuery(sql2);

                while (rs.next()) {

                    StaffTableModel staff = new StaffTableModel(rs.getInt("empNo"),rs.getString("teacherName"),rs.getString("nic"),
                            rs.getString("dob"),rs.getString("doa"),rs.getString("gender"),rs.getString("email"),rs.getString("assumpOfDuties"),
                            rs.getString("phone"),rs.getString("address"),rs.getString("incDate"),rs.getString("prsntGrade"));
                    staffList.add(staff);
                }
            }
            //Ctrl+D for copy above line
            EmpNoColumn.setCellValueFactory(new PropertyValueFactory<>("empNo"));
            NameColumn.setCellValueFactory(new PropertyValueFactory<>("teacherName"));
            nicColumn.setCellValueFactory(new PropertyValueFactory<>("nic"));
            dobColumn.setCellValueFactory(new PropertyValueFactory<>("dob"));
            doaColumn.setCellValueFactory(new PropertyValueFactory<>("doa"));
            emailColumn.setCellValueFactory(new PropertyValueFactory<>("email"));
            genderColumn.setCellValueFactory(new PropertyValueFactory<>("gender"));
            assmpDutyColumn.setCellValueFactory(new PropertyValueFactory<>("assumpOfDuties"));
            phoneColumn.setCellValueFactory(new PropertyValueFactory<>("phone"));
            addressColumn.setCellValueFactory(new PropertyValueFactory<>("address"));
            incDateColumn.setCellValueFactory(new PropertyValueFactory<>("incDate"));
            gradeColumn.setCellValueFactory(new PropertyValueFactory<>("prsntGrade"));

            staffTable.setItems(staffList);

            } catch (ClassNotFoundException e) {
                e.printStackTrace();
            } catch (SQLException e) {
                e.printStackTrace();
            }
    }

    @FXML
    void print(ActionEvent event) {

        staffTable.getItems().clear();
        String type = Type.getValue();

        try {
            Connection conn = DBConnection.getDBConnection().getConnection();

            InputStream report1 = getClass().getResourceAsStream("/sms/Reports/StaffList.jrxml");
            InputStream report2 = getClass().getResourceAsStream("/sms/Reports/StaffListPast.jrxml");

            JRDesignQuery query = new JRDesignQuery();

          /*  HashMap<String,Object> Logo = new HashMap<String, Object>();

            URL url = this.getClass().getClassLoader().getResource("sms/other/img/HikmaLogo.jpg");
            Logo.put("logo", url);*/

            if (type == "Current Staffs"){

                JasperDesign jd = JRXmlLoader.load(report1);
                query.setText("select * from staffs");
                jd.setQuery(query);
                ReportViewController r = new ReportViewController();
                r.viewReport(jd);
            }
            else {

                JasperDesign jd2 = JRXmlLoader.load(report2);
                query.setText("select * from oldstaffs");
                jd2.setQuery(query);
                ReportViewController r = new ReportViewController();
                r.viewReport(jd2);
            }
        } catch (JRException e) {
            e.printStackTrace();
        } catch (SQLException e) {
            e.printStackTrace();
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        }
    }

}


<|start_filename|>src/sms/view/controller/MainDashboardController.java<|end_filename|>
package sms.view.controller;

import com.jfoenix.controls.JFXButton;

import java.awt.*;
import java.io.IOException;
import java.net.URL;
import java.util.ResourceBundle;
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.Alert;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.layout.AnchorPane;
import javafx.stage.Stage;

/**
 *
 * @author Safnaj.MMA
 */
public class MainDashboardController implements Initializable{

        @Override
        public void initialize(URL location, ResourceBundle resources) {

        }
        @FXML
        private ImageView StudentMgmt;

        @FXML
        private JFXButton btnSchoolInfo;

        @FXML
        private JFXButton btnStudentMgmt;

        @FXML
        private JFXButton btnStaffMgmt;

        @FXML
        private JFXButton btnExamMgmt;

        @FXML
        private JFXButton btnLibraryMgmt;

        @FXML
        private JFXButton btnEventMgmt;

        @FXML
        private JFXButton btnInventory;

        @FXML
        private JFXButton btnNoticeMgmt;

        @FXML
        private JFXButton btnUserSettings;

//        @FXML
//        private TextField username;


        @FXML
        private AnchorPane root;

        @FXML
        void setBtnUserSettings(ActionEvent event) {

                try {
                        AnchorPane user = FXMLLoader.load(getClass().getResource(("/sms/view/fxml/UserAccount.fxml")));
                        root.getChildren().setAll(user);
                }catch(IOException e){
                        System.out.println(e);
                }

        }

        @FXML
        void setBtnSchoolInfo(ActionEvent event) {
                try {
                        AnchorPane user = FXMLLoader.load(getClass().getResource(("/sms/view/fxml/SchoolInfo.fxml")));
                        root.getChildren().setAll(user);
                }catch(IOException e){
                        System.out.println(e);
                }
        }

        @FXML
        void setBtnStudentMgmt(ActionEvent event) {

                try {
                        AnchorPane user = FXMLLoader.load(getClass().getResource(("/sms/view/fxml/StudentManagement.fxml")));
                        root.getChildren().setAll(user);
                }catch(IOException e){
                        System.out.println(e);
                }

                /*try {
                        Parent root = FXMLLoader.load(getClass().getResource("/sms/view/fxml/StudentManagement.fxml"));
                        Stage stage = new Stage();
                        stage.setTitle("Student Management");
                        stage.setScene(new Scene(root));
                        stage.getIcons().add(new Image(getClass().getResourceAsStream("/sms/other/img/HikmaLogo.jpg")));
                        stage.show();

                }catch(IOException e){
                        System.out.println(e);
                }*/
        }
        @FXML
        void btnStaffMgmt(ActionEvent event){

                try {
                        AnchorPane user = FXMLLoader.load(getClass().getResource(("/sms/view/fxml/StaffManagement.fxml")));
                        root.getChildren().setAll(user);
                }catch(IOException e){
                        System.out.println(e);
                }

                /*Parent root = null;
                try {
                        root = FXMLLoader.load(getClass().getResource("/sms/view/fxml/StaffManagement.fxml"));
                        Stage stage = new Stage();
                        stage.setTitle("School Information");
                        stage.setScene(new Scene(root));
                        stage.getIcons().add(new Image(getClass().getResourceAsStream("/sms/other/img/HikmaLogo.jpg")));
                        stage.show();

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

        @FXML
        void btnEventMgmt(ActionEvent event) {

                Alert alert = new Alert(Alert.AlertType.INFORMATION);
                alert.setTitle("School Management System");
                alert.setHeaderText(null);
                alert.setContentText("Sorry..! This feature currently Unavailable for this Version.");
                alert.showAndWait();
        }

        @FXML
        void btnExamMgmt(ActionEvent event) {

                Alert alert = new Alert(Alert.AlertType.INFORMATION);
                alert.setTitle("School Management System");
                alert.setHeaderText(null);
                alert.setContentText("Sorry..! This feature currently Unavailable for this Version.");
                alert.showAndWait();
        }

        @FXML
        void btnInventory(ActionEvent event) {

                Alert alert = new Alert(Alert.AlertType.INFORMATION);
                alert.setTitle("School Management System");
                alert.setHeaderText(null);
                alert.setContentText("Sorry..! This feature currently Unavailable for this Version.");
                alert.showAndWait();
        }

        @FXML
        void btnLibraryMgmt(ActionEvent event) {

                Alert alert = new Alert(Alert.AlertType.INFORMATION);
                alert.setTitle("School Management System");
                alert.setHeaderText(null);
                alert.setContentText("Sorry..! This feature currently Unavailable for this Version.");
                alert.showAndWait();
        }

        @FXML
        void btnNoticeMgmt(ActionEvent event) {

                Alert alert = new Alert(Alert.AlertType.INFORMATION);
                alert.setTitle("School Management System");
                alert.setHeaderText(null);
                alert.setContentText("Sorry..! This feature currently Unavailable for this Version.");
                alert.showAndWait();
        }

}



<|start_filename|>src/sms/model/Student.java<|end_filename|>
package sms.model;

/**
 * @author Safnaj on 8/25/2018
 * @project School Management System
 **/
public class Student {

    private int adNo;
    private String fullName;
    private String name;
    private String dob;
    private String doa;
    private String gender;
    private String grade;
    private String parentName;
    private String nic;
    private String phone;
    private String address;


    public Student(int adNo, String fullName, String name, String dob, String doa, String gender, String grade, String parentName, String nic, String phone, String address) {
        this.adNo = adNo;
        this.fullName = fullName;
        this.name = name;
        this.dob = dob;
        this.doa = doa;
        this.gender = gender;
        this.grade = grade;
        this.parentName = parentName;
        this.nic = nic;
        this.phone = phone;
        this.address = address;
    }

    public Student(String grade) {
        this.grade = grade;
    }

    public Integer getAdNo() {return adNo;}

    public void setAdNo(int adNo) {
        this.adNo = adNo;
    }

    public String getFullName() {
        return fullName;
    }

    public void setFullName(String fullName) {
        this.fullName = fullName;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getDob() {
        return dob;
    }

    public void setDob(String dob) {
        this.dob = dob;
    }

    public String getDoa() {
        return doa;
    }

    public void setDoa(String doa) {
        this.doa = doa;
    }

    public String getGender() {
        return gender;
    }

    public void setGender(String gender) {
        this.gender = gender;
    }

    public String getGrade() {
        return grade;
    }

    public void setGrade(String grade) {
        this.grade = grade;
    }

    public String getParentName() {
        return parentName;
    }

    public void setParentName(String parentName) {
        this.parentName = parentName;
    }

    public String getNic() {
        return nic;
    }

    public void setNic(String nic) {
        this.nic = nic;
    }

    public String getPhone() {
        return phone;
    }

    public void setPhone(String phone) {
        this.phone = phone;
    }

    public String getAddress() {
        return address;
    }

    public void setAddress(String address) {
        this.address = address;
    }
}


<|start_filename|>src/sms/view/controller/TransferStudentsController.java<|end_filename|>
package sms.view.controller;

import com.jfoenix.controls.JFXButton;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.fxml.Initializable;
import javafx.scene.control.Alert;
import javafx.scene.control.ComboBox;
import javafx.scene.control.TextField;
import javafx.scene.layout.AnchorPane;
import javafx.scene.media.Track;
import sms.db.DBConnection;
import sms.dbController.GradeController;
import sms.dbController.TransferController;
import sms.dbController.UserController;
import sms.model.Student;
import sms.model.User;

import java.io.IOException;
import java.net.URL;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.ResourceBundle;

/**
 * @author Safnaj on 11/5/2018
 * @project School Management System
 **/
public class TransferStudentsController implements Initializable {

    @Override
    public void initialize(URL location, ResourceBundle resources) {
        loadCombo1();
        loadCombo2();
        loadComboBox();
    }

    @FXML
    private AnchorPane root;

    @FXML
    private JFXButton btnUpdate;

    @FXML
    private JFXButton move1;

    @FXML
    private ComboBox<String> loadCombo;

    @FXML
    private TextField yearField;

    @FXML
    private ComboBox<String> loadCombo1;

    @FXML
    private ComboBox<String> loadCombo2;

    @FXML
    private JFXButton searchStudent1;

    @FXML
    private JFXButton Back;

    @FXML
    void Back(ActionEvent event) {

        try {
            AnchorPane studentMgmt = FXMLLoader.load(getClass().getResource(("/sms/view/fxml/StudentManagement.fxml")));
            root.getChildren().setAll(studentMgmt);
        }catch(IOException e){
            System.out.println(e);
        }
    }

    @FXML
    void btnUpdate(ActionEvent event) {

    }

    @FXML
    void loadCombo1() {
        ArrayList arrayList = null;
        try {
            arrayList = GradeController.getGrades();
        } catch (ClassNotFoundException | SQLException e) {
            e.printStackTrace();
        }
        ObservableList observableArray = FXCollections.observableArrayList();
        observableArray.addAll(arrayList);

        if (observableArray != null) {
            loadCombo1.setItems(observableArray);
        }
    }

    @FXML
    void loadCombo2() {
        ArrayList arrayList = null;
        try {
            arrayList = GradeController.getGrades();
        } catch (ClassNotFoundException | SQLException e) {
            e.printStackTrace();
        }
        ObservableList observableArray = FXCollections.observableArrayList();
        observableArray.addAll(arrayList);

        if (observableArray != null) {
            loadCombo2.setItems(observableArray);
        }
    }

    @FXML
    void loadComboBox() {
        ArrayList arrayList = null;
        try {
            arrayList = GradeController.getGrades();
        } catch (ClassNotFoundException | SQLException e) {
            e.printStackTrace();
        }
        ObservableList observableArray = FXCollections.observableArrayList();
        observableArray.addAll(arrayList);

        if (observableArray != null) {
            loadCombo.setItems(observableArray);
        }
    }

    @FXML
    void move1(ActionEvent event) {
        try {

        String grade5 = loadCombo.getValue();
        String year = yearField.getText();

            Connection conn = DBConnection.getDBConnection().getConnection();

            String sql ="INSERT INTO paststudents (adNo,fullName,name,dob,doa,gender,year,parentName,nic,phone,address) " +
                        "SELECT * FROM students where grade = 'Grade 5'";
            PreparedStatement stm = conn.prepareStatement(sql);
            stm.executeUpdate();

            int a = TransferController.deleteStudent(grade5);
            int b = TransferController.updateGrade(year);

            if (a > 0) {

                if(b > 0) {

                    Alert alert = new Alert(Alert.AlertType.INFORMATION);
                    alert.setTitle("Transfer Students");
                    alert.setHeaderText(null);
                    alert.setContentText("Updated..!");
                    alert.showAndWait();
                }

            }else {

                Alert alert = new Alert(Alert.AlertType.ERROR);
                alert.setTitle("Transfer Students");
                alert.setHeaderText(null);
                alert.setContentText("Oops..! There is an Error in Transfering Students..!");
                alert.showAndWait();
            }

        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        } catch (SQLException e) {
            e.printStackTrace();
        }

    }
    @FXML
    void move2(ActionEvent event) {
        try {

            String gradeA = loadCombo1.getValue();
            String gradeB = loadCombo2.getValue();

            Connection conn = DBConnection.getDBConnection().getConnection();

            String sql = "UPDATE students SET grade= '" + gradeB + "' WHERE grade= '" + gradeA + "'";
            PreparedStatement stm = conn.prepareStatement(sql);
            stm.executeUpdate();

            Alert alert = new Alert(Alert.AlertType.INFORMATION);
            alert.setTitle("Transfer Students");
            alert.setHeaderText(null);
            alert.setContentText("Grade Updated Successfully..!");
            alert.showAndWait();

            loadCombo1.setValue(null);
            loadCombo2.setValue(null);

        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        } catch (SQLException e) {
            e.printStackTrace();
        }
    }
}


<|start_filename|>src/sms/view/controller/LoginFormController.java<|end_filename|>
package sms.view.controller;

import com.jfoenix.controls.JFXButton;
import com.jfoenix.controls.JFXPasswordField;
import com.jfoenix.controls.JFXTextField;
import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.fxml.Initializable;
import javafx.scene.control.Alert;
import javafx.scene.input.KeyCode;
import javafx.scene.layout.AnchorPane;
import sms.dbController.LoginController;

import java.awt.event.ActionEvent;
import java.awt.event.KeyEvent;
import java.io.IOException;
import java.net.URL;
import java.sql.SQLException;
import java.util.ResourceBundle;

/**
 * @author Safnaj on 8/12/2018
 * @project School Management System
 **/

public class LoginFormController implements Initializable {


    @FXML
    private AnchorPane login;

    @FXML
    private JFXTextField usernameField;

    @FXML
    private JFXPasswordField pwdField;

    @FXML
    private JFXButton Login;

    @Override
    public void initialize(URL location, ResourceBundle resources) {

    }

    LoginController log = new LoginController();

    @FXML
    public void Login() {

        String username = usernameField.getText();
        String password = <PASSWORD>Field.getText();

        if(username.isEmpty() || password.isEmpty()){

            Alert alert = new Alert(Alert.AlertType.INFORMATION);
            alert.setTitle("Login");
            alert.setHeaderText(null);
            alert.setContentText("Username & Password Required..!");
            alert.showAndWait();
        }
        else {

            if(username.startsWith("admin")){

                try {
                    if (log.Login(username, password)){

                        AnchorPane user = FXMLLoader.load(getClass().getResource(("/sms/view/fxml/MainDashboard.fxml")));
                        login.getChildren().setAll(user);

                    } else {
                        Alert alert = new Alert(Alert.AlertType.INFORMATION);
                        alert.setTitle("Login");
                        alert.setHeaderText(null);
                        alert.setContentText("Invalid Username or Password..!");
                        alert.showAndWait();
                    }

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

                }else if((username.startsWith("teacher"))) {

                try {
                    if (log.Login(username, password)){

                        AnchorPane user = FXMLLoader.load(getClass().getResource(("/sms/view/fxml/PrintStudents2.fxml")));
                        login.getChildren().setAll(user);

                    } else {
                        Alert alert = new Alert(Alert.AlertType.INFORMATION);
                        alert.setTitle("Login");
                        alert.setHeaderText(null);
                        alert.setContentText("Invalid Username or Password..!");
                        alert.showAndWait();
                    }

                } catch(SQLException e){
                    e.printStackTrace();
                } catch(ClassNotFoundException e){
                    e.printStackTrace();
                } catch(IOException e){
                    e.printStackTrace();
                }
            }else {

                Alert alert = new Alert(Alert.AlertType.INFORMATION);
                alert.setTitle("Login");
                alert.setHeaderText(null);
                alert.setContentText("Invalid Username or Password..!");
                alert.showAndWait();

            }

            }

    }

}



<|start_filename|>src/sms/view/controller/UserAccountController.java<|end_filename|>
package sms.view.controller;

import com.jfoenix.controls.JFXButton;
import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.fxml.Initializable;
import javafx.scene.image.ImageView;
import javafx.scene.input.MouseEvent;
import javafx.scene.layout.AnchorPane;
import java.awt.event.ActionEvent;
import java.io.IOException;
import java.net.URL;
import java.util.ResourceBundle;

/**
 * @author Safnaj on 8/12/2018
 * @project School Management System
 **/

public class UserAccountController implements Initializable {

    @Override
    public void initialize(URL location, ResourceBundle resources) {

    }

    @FXML
    private AnchorPane userAccount;

    @FXML
    private JFXButton btnLogout;

    @FXML
    private JFXButton ManageUsers;

    @FXML
    private JFXButton Back;

    @FXML
    private void Back() {
        try {
            AnchorPane studentMgmt = FXMLLoader.load(getClass().getResource(("/sms/view/fxml/MainDashboard.fxml")));
            userAccount.getChildren().setAll(studentMgmt);
        }catch(IOException e){
            System.out.println(e);
        }
    }

    @FXML
    private void ManageUsers() {
        try {
            AnchorPane studentMgmt = FXMLLoader.load(getClass().getResource(("/sms/view/fxml/ManageUsers.fxml")));
            userAccount.getChildren().setAll(studentMgmt);
        }catch(IOException e){
            System.out.println(e);
        }
    }

    @FXML
    private void btnLogout() {
        try {
            AnchorPane studentMgmt = FXMLLoader.load(getClass().getResource(("/sms/view/fxml/login.fxml")));
            userAccount.getChildren().setAll(studentMgmt);
        }catch(IOException e){
            System.out.println(e);
        }
    }
}


<|start_filename|>src/sms/view/controller/StudentManagementController.java<|end_filename|>
package sms.view.controller;

import com.jfoenix.controls.JFXButton;
import java.io.IOException;
import java.net.URL;
import java.util.ResourceBundle;
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.image.ImageView;
import javafx.scene.layout.AnchorPane;
import javafx.stage.Stage;

/**
 * @author Safnaj on 8/12/2018
 * @project School Management System
 **/

public class StudentManagementController implements Initializable {

    @Override
    public void initialize(URL location, ResourceBundle resources) {

    }

    @FXML
    private ImageView StaffMgmt;

    @FXML
    private ImageView StudentMgmt;

    @FXML
    private JFXButton btnStudentReg;

    @FXML
    private JFXButton btnStudentMnge;

    @FXML
    private JFXButton btnPrintStudents;

    @FXML
    private AnchorPane manageStudents;

    @FXML
    private JFXButton Back;

    @FXML
    void Back() {
        try {
            AnchorPane studentMgmt = FXMLLoader.load(getClass().getResource(("/sms/view/fxml/MainDashboard.fxml")));
            manageStudents.getChildren().setAll(studentMgmt);
        }catch(IOException e){
            System.out.println(e);
        }
    }

    @FXML
    void SetBtnStudentReg(ActionEvent event) {
        try {
            AnchorPane studentMgmt = FXMLLoader.load(getClass().getResource(("/sms/view/fxml/RegisterStudent.fxml")));
            manageStudents.getChildren().setAll(studentMgmt);
        }catch(IOException e){
            System.out.println(e);
        }
    }

    @FXML
    void setBtnStudentMnge(ActionEvent event) {
        try {
            AnchorPane studentMgmt = FXMLLoader.load(getClass().getResource(("/sms/view/fxml/ManageStudents.fxml")));
            manageStudents.getChildren().setAll(studentMgmt);
        }catch(IOException e){
            System.out.println(e);
        }
    }

    @FXML
    void btnPrintStudents(ActionEvent event) {
        try {
            AnchorPane studentMgmt = FXMLLoader.load(getClass().getResource(("/sms/view/fxml/PrintStudents.fxml")));
            manageStudents.getChildren().setAll(studentMgmt);
        }catch(IOException e){
            System.out.println(e);
        }
    }
    @FXML
    void transfer(ActionEvent event) {
        try {
            AnchorPane studentMgmt = FXMLLoader.load(getClass().getResource(("/sms/view/fxml/TransferStudents.fxml")));
            manageStudents.getChildren().setAll(studentMgmt);
        }catch(IOException e){
            System.out.println(e);
        }
    }

}


<|start_filename|>out/production/School Management System/sms/view/fxml/css/RegStudent.css<|end_filename|>
.jfx-button{
    -fx-background-color:  #1976D2;
    -fx-text-fill: white;
}
.jfx-button:hover{
    -fx-background-color: #c62828;
}


<|start_filename|>src/sms/view/controller/StaffManagementController.java<|end_filename|>
package sms.view.controller;

import com.jfoenix.controls.JFXButton;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.fxml.Initializable;
import javafx.scene.image.ImageView;
import javafx.scene.layout.AnchorPane;

import java.io.IOException;
import java.net.URL;
import java.util.ResourceBundle;

/**
 * @author Safnaj on 11/1/2018
 * @project School Management System
 **/
public class StaffManagementController implements Initializable {

    @Override
    public void initialize(URL location, ResourceBundle resources) {

    }

    @FXML
    private AnchorPane studentManagement;

    @FXML
    private ImageView StaffMgmt;

    @FXML
    private ImageView StudentMgmt;

    @FXML
    private JFXButton btnStaffReg;

    @FXML
    private JFXButton btnStaffMnge;

    @FXML
    private ImageView StaffMgmt1;

    @FXML
    private JFXButton btnPrintStaff;

    @FXML
    private JFXButton Back;

    @FXML
    void Back(ActionEvent event) {
        try {
            AnchorPane studentMgmt = FXMLLoader.load(getClass().getResource(("/sms/view/fxml/MainDashboard.fxml")));
            studentManagement.getChildren().setAll(studentMgmt);
        }catch(IOException e){
            System.out.println(e);
        }
    }

    @FXML
    void btnPrintStaff(ActionEvent event) {
        try {
            AnchorPane studentMgmt = FXMLLoader.load(getClass().getResource(("/sms/view/fxml/PrintStaffs.fxml")));
            studentManagement.getChildren().setAll(studentMgmt);
        }catch(IOException e){
            System.out.println(e);
        }
    }

    @FXML
    void btnStaffMnge(ActionEvent event) {
        try {
            AnchorPane studentMgmt = FXMLLoader.load(getClass().getResource(("/sms/view/fxml/ManageStaffs.fxml")));
            studentManagement.getChildren().setAll(studentMgmt);
        }catch(IOException e){
            System.out.println(e);
        }
    }

    @FXML
    void btnStaffReg(ActionEvent event) {
        try {
            AnchorPane studentMgmt = FXMLLoader.load(getClass().getResource(("/sms/view/fxml/RegisterStaff.fxml")));
            studentManagement.getChildren().setAll(studentMgmt);
        }catch(IOException e){
            System.out.println(e);
        }
    }


}


<|start_filename|>src/sms/view/controller/loginController.java<|end_filename|>
package sms.view.controller;

import com.jfoenix.controls.JFXButton;
import com.jfoenix.controls.JFXPasswordField;
import com.jfoenix.controls.JFXTextField;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.layout.AnchorPane;
import java.awt.event.ActionEvent;
import java.net.URL;
import java.util.ResourceBundle;

/**
 * @author Safnaj on 8/12/2018
 * @project School Management System
 **/

public class loginController implements Initializable {

    @Override
    public void initialize(URL location, ResourceBundle resources) {

    }
    @FXML
    private AnchorPane login;

    @FXML
    private JFXTextField username;

    @FXML
    private JFXPasswordField password;

    @FXML
    private JFXButton btnLogin;

    @FXML
    private void btnLogin() {

    }
}


<|start_filename|>src/sms/dbController/StaffController.java<|end_filename|>
package sms.dbController;

import sms.db.DBConnection;
import sms.model.Staff;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

/**
 * @author Safnaj on 11/1/2018
 * @project School Management System
 **/
public class StaffController {

    public static int AddStaff(Staff staff)throws ClassNotFoundException,SQLException {
        String SQL="INSERT INTO staffs VALUES(?,?,?,?,?,?,?,?,?,?,?,?)";
        Connection conn = DBConnection.getDBConnection().getConnection();
        PreparedStatement stm = conn.prepareStatement(SQL);
        stm.setObject(1, staff.getEmpNo());
        stm.setObject(2, staff.getTeacherName());
        stm.setObject(3, staff.getNic());
        stm.setObject(4, staff.getDob());
        stm.setObject(5, staff.getDoa());
        stm.setObject(6, staff.getGender());
        stm.setObject(7, staff.getEmail());
        stm.setObject(8, staff.getAssumpOfDuties());
        stm.setObject(9, staff.getPhone());
        stm.setObject(10, staff.getAddress());
        stm.setObject(11, staff.getIncDate());
        stm.setObject(12, staff.getPrsntGrade());

        return  stm.executeUpdate();
    }

    public static Staff searchStaff(Integer empNo) throws ClassNotFoundException, SQLException {
        String sql = "SELECT * FROM staffs WHERE empNo = ? ";
        Connection conn = DBConnection.getDBConnection().getConnection();
        PreparedStatement stm = conn.prepareStatement(sql);
        stm.setObject(1, empNo);
        ResultSet rst=stm.executeQuery();
        if(rst.next()){
            Staff staff = new Staff(rst.getInt(1),rst.getString(2),rst.getString(3), rst.getString(4), rst.getString(5), rst.getString(6), rst.getString(7), rst.getString(8), rst.getString(9), rst.getString(10), rst.getString(11),rst.getString(12));
            return staff;
        }
        return null;
    }

    public static Staff searchStaffByName(String teacherName) throws ClassNotFoundException, SQLException {
        String sql = "SELECT * FROM staffs WHERE teacherName LIKE '%"+teacherName+"'";
        Connection conn = DBConnection.getDBConnection().getConnection();
        PreparedStatement stm = conn.prepareStatement(sql);
       // stm.setObject(1, name);
        ResultSet rst=stm.executeQuery();
        if(rst.next()){
            Staff staff = new Staff(rst.getInt(1),rst.getString(2),rst.getString(3), rst.getString(4), rst.getString(5), rst.getString(6), rst.getString(7), rst.getString(8), rst.getString(9), rst.getString(10), rst.getString(11),rst.getString(12));
            return staff;
        }
        return null;
    }

    public static Staff searchOldStaff(Integer empNo) throws ClassNotFoundException, SQLException {
        String sql = "SELECT * FROM oldstaffs WHERE empNo = ? ";
        Connection conn = DBConnection.getDBConnection().getConnection();
        PreparedStatement stm = conn.prepareStatement(sql);
        stm.setObject(1, empNo);
        ResultSet rst=stm.executeQuery();
        if(rst.next()){
            Staff staff = new Staff(rst.getInt(1),rst.getString(2),rst.getString(3), rst.getString(4), rst.getString(5), rst.getString(6), rst.getString(7), rst.getString(8), rst.getString(9), rst.getString(10), rst.getString(11),rst.getString(12));
            return staff;
        }
        return null;
    }

    public static int deleteStaff(Integer empNo) throws ClassNotFoundException, SQLException{
        String sql = "DELETE FROM staffs WHERE empNo ='"+empNo+"'";
        Connection conn = DBConnection.getDBConnection().getConnection();
        PreparedStatement stm = conn.prepareStatement(sql);

        return  stm.executeUpdate();
    }

    public static int moveStaff(Staff staff)throws ClassNotFoundException,SQLException {
        String SQL="INSERT INTO oldstaffs VALUES(?,?,?,?,?,?,?,?,?,?,?,?)";
        Connection conn = DBConnection.getDBConnection().getConnection();
        PreparedStatement stm = conn.prepareStatement(SQL);
        stm.setObject(1, staff.getEmpNo());
        stm.setObject(2, staff.getTeacherName());
        stm.setObject(3, staff.getNic());
        stm.setObject(4, staff.getDob());
        stm.setObject(5, staff.getDoa());
        stm.setObject(6, staff.getGender());
        stm.setObject(7, staff.getEmail());
        stm.setObject(8, staff.getAssumpOfDuties());
        stm.setObject(9, staff.getPhone());
        stm.setObject(10, staff.getAddress());
        stm.setObject(11, staff.getIncDate());
        stm.setObject(12, staff.getPrsntGrade());

        return  stm.executeUpdate();
    }

    public static int updateStaff(Staff staff) throws ClassNotFoundException, SQLException {
        String sql = "UPDATE staffs SET empNo= ? ,teacherName= ? ,nic= ? ,dob= ? ,doa= ? ,gender= ? ,email=? ,assumpOfDuties= ? ,phone= ? ,address= ? ,incDate=? ,prsntGrade=? WHERE empNo= '" +staff.getEmpNo()+ "'";
        Connection conn = DBConnection.getDBConnection().getConnection();
        PreparedStatement stm = conn.prepareStatement(sql);
        stm.setObject(1, staff.getEmpNo());
        stm.setObject(2, staff.getTeacherName());
        stm.setObject(3, staff.getNic());
        stm.setObject(4, staff.getDob());
        stm.setObject(5, staff.getDoa());
        stm.setObject(6, staff.getGender());
        stm.setObject(7, staff.getEmail());
        stm.setObject(8, staff.getAssumpOfDuties());
        stm.setObject(9, staff.getPhone());
        stm.setObject(10, staff.getAddress());
        stm.setObject(11, staff.getIncDate());
        stm.setObject(12, staff.getPrsntGrade());

        return  stm.executeUpdate();
    }

    public static int updateOldStaff(Staff staff) throws ClassNotFoundException, SQLException {
        String sql = "UPDATE staffs SET empNo= ? ,teacherName= ? ,nic= ? ,dob= ? ,doa= ? ,gender= ? ,email=? ,assumpOfDuties= ? ,phone= ? ,address= ? ,incDate=? ,prsntGrade=? WHERE empNo= '" +staff.getEmpNo()+ "'";
        Connection conn = DBConnection.getDBConnection().getConnection();
        PreparedStatement stm = conn.prepareStatement(sql);
        stm.setObject(1, staff.getEmpNo());
        stm.setObject(2, staff.getTeacherName());
        stm.setObject(3, staff.getNic());
        stm.setObject(4, staff.getDob());
        stm.setObject(5, staff.getDoa());
        stm.setObject(6, staff.getGender());
        stm.setObject(7, staff.getEmail());
        stm.setObject(8, staff.getAssumpOfDuties());
        stm.setObject(9, staff.getPhone());
        stm.setObject(10, staff.getAddress());
        stm.setObject(11, staff.getIncDate());
        stm.setObject(12, staff.getPrsntGrade());

        return  stm.executeUpdate();
    }
}


<|start_filename|>src/sms/view/controller/ManageStudentsController.java<|end_filename|>
package sms.view.controller;

import javafx.event.ActionEvent;
import javafx.fxml.FXMLLoader;
import javafx.fxml.Initializable;

import com.jfoenix.controls.JFXButton;
import com.jfoenix.controls.JFXComboBox;
import com.jfoenix.controls.JFXRadioButton;
import javafx.fxml.FXML;
import javafx.scene.control.*;
import javafx.scene.layout.AnchorPane;
import net.sf.jasperreports.engine.JRException;
import net.sf.jasperreports.engine.design.JRDesignQuery;
import net.sf.jasperreports.engine.design.JasperDesign;
import net.sf.jasperreports.engine.xml.JRXmlLoader;
import sms.db.DBConnection;
import sms.dbController.StudentController;
import sms.model.Student;

import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ResourceBundle;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 * @author Safnaj on 8/12/2018
 * @project School Management System
 **/

public class ManageStudentsController implements Initializable {

    @Override
    public void initialize(URL location, ResourceBundle resources) {

    }

    @FXML
    private AnchorPane manageStudents;

    @FXML
    private TextField AdNo;

    @FXML
    private TextField adNoField;

    @FXML
    private TextField fullNameField;

    @FXML
    private TextField nameField;

    @FXML
    private TextField dobField;

    @FXML
    private TextField doaField;

    @FXML
    private TextField genderField;

    @FXML
    private TextField gradeField;

    @FXML
    private TextField parentNameField;

    @FXML
    private TextField nicField;

    @FXML
    private TextField phoneField;

    @FXML
    private TextField addressField;

    @FXML
    private TextField AdNo1;

    @FXML
    private JFXButton searchPastStudent;

    @FXML
    private JFXButton btnDelete;

    @FXML
    private JFXButton btnUpdate;

    @FXML
    private JFXButton searchStudent;

    @FXML
    private JFXButton btnPrint;

    @FXML
    private JFXButton Back;

    @FXML
    void Back(ActionEvent event) {
        try {
            AnchorPane studentMgmt = FXMLLoader.load(getClass().getResource(("/sms/view/fxml/StudentManagement.fxml")));
            manageStudents.getChildren().setAll(studentMgmt);
        }catch(IOException e){
            System.out.println(e);
        }
    }
    //Delete Method
    @FXML
    void btnDelete(ActionEvent event) {
        try {
            String adNo = adNoField.getText();
            Student s = new Student(Integer.parseInt(adNoField.getText()), fullNameField.getText(), nameField.getText(), dobField.getText(), doaField.getText(),
                    genderField.getText(), gradeField.getText(), parentNameField.getText(), nicField.getText(), phoneField.getText(), addressField.getText());

            if(AdNo1.getText().isEmpty()) {

                int moveStudent = StudentController.moveStudent(s);
                if (moveStudent > 0) {

                    int deleteStudent = StudentController.deleteStudent(adNo);
                    if (deleteStudent > 0) {

                        Alert alert = new Alert(Alert.AlertType.INFORMATION);
                        alert.setTitle("Delete Student");
                        alert.setHeaderText(null);
                        alert.setContentText("Student " + adNo + " has been deleted sucessfully..!");
                        alert.showAndWait();

                        AdNo.setText(null);
                        adNoField.setText(null);
                        fullNameField.setText(null);
                        nameField.setText(null);
                        dobField.setText(null);
                        doaField.setText(null);
                        gradeField.setText(null);
                        genderField.setText(null);
                        adNoField.setText(null);
                        parentNameField.setText(null);
                        nicField.setText(null);
                        phoneField.setText(null);
                        fullNameField.setText(null);
                        addressField.setText(null);


                    } else {
                        Alert alert = new Alert(Alert.AlertType.ERROR);
                        alert.setTitle("Delete Student");
                        alert.setHeaderText(null);
                        alert.setContentText("There is an error deleting Student");
                        alert.showAndWait();
                    }
                }else{
                    Alert alert = new Alert(Alert.AlertType.ERROR);
                    alert.setTitle("Delete Student");
                    alert.setHeaderText(null);
                    alert.setContentText("There is an error deleting Student");
                    alert.showAndWait();
                }
            }
            else{

                int forceDelete = StudentController.deleteLeftStudent(adNo);
                if (forceDelete > 0) {

                    Alert alert = new Alert(Alert.AlertType.INFORMATION);
                    alert.setTitle("Delete Student");
                    alert.setHeaderText(null);
                    alert.setContentText("Student " + adNo + " has been deleted sucessfully..!");
                    alert.showAndWait();

                    AdNo.setText(null);
                    AdNo1.setText(null);
                    adNoField.setText(null);
                    fullNameField.setText(null);
                    nameField.setText(null);
                    dobField.setText(null);
                    doaField.setText(null);
                    gradeField.setText(null);
                    genderField.setText(null);
                    adNoField.setText(null);
                    parentNameField.setText(null);
                    nicField.setText(null);
                    phoneField.setText(null);
                    fullNameField.setText(null);
                    addressField.setText(null);


                } else {
                    Alert alert = new Alert(Alert.AlertType.ERROR);
                    alert.setTitle("Delete Student");
                    alert.setHeaderText(null);
                    alert.setContentText("There is an error deleting Student");
                    alert.showAndWait();
                }
            }
            } catch(ClassNotFoundException | SQLException ex){
                Logger.getLogger(StudentController.class.getName()).log(Level.SEVERE, null, ex);
            }
    }

    @FXML
    void btnPrint(ActionEvent event) {

        String adNo = adNoField.getText();

        try {
            Connection conn = DBConnection.getDBConnection().getConnection();
            InputStream report1 = getClass().getResourceAsStream("/sms/Reports/StudentAdmission.jrxml");

            JRDesignQuery query = new JRDesignQuery();

            JasperDesign jd = JRXmlLoader.load(report1);
            query.setText("select * from students where adNo = '" + adNo + "'");
            jd.setQuery(query);
            ReportViewController r = new ReportViewController();
            r.viewReport(jd);


        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        } catch (SQLException e) {
            e.printStackTrace();
        } catch (JRException e) {
            e.printStackTrace();
        }

    }

    //Update Method
    @FXML
    void btnUpdate(ActionEvent event) throws SQLException {
        try {

            ValidationController v = new ValidationController();

            if (v.validateNIC(nicField) && v.numbersOnly(adNoField) && v.validatePhone(phoneField)) {

                int adNo = Integer.parseInt(adNoField.getText());
                String fullName = fullNameField.getText();
                String name = nameField.getText();
                String dob = dobField.getText();
                String doa = doaField.getText();
                String gender = genderField.getText();
                String grade = gradeField.getText();
                String parentName = parentNameField.getText();
                String nic = nicField.getText();
                String phone = phoneField.getText();
                String address = addressField.getText();

                Student s = new Student(adNo, fullName, name, dob, doa, gender, grade, parentName, nic, phone, address);
                int d = StudentController.updateLeftStudent(s);
                int i = StudentController.updateStudent(s);

                if (d > 0){
                    Alert alert = new Alert(Alert.AlertType.INFORMATION);
                    alert.setTitle("Student Management");
                    alert.setHeaderText(null);
                    alert.setContentText("Student " + adNo + " Updated Successfully..!");
                    alert.showAndWait();

                    AdNo1.setText(null);
                    adNoField.setText(null);
                    fullNameField.setText(null);
                    nameField.setText(null);
                    dobField.setText(null);
                    doaField.setText(null);
                    gradeField.setText(null);
                    genderField.setText(null);
                    adNoField.setText(null);
                    parentNameField.setText(null);
                    nicField.setText(null);
                    phoneField.setText(null);
                    fullNameField.setText(null);
                    addressField.setText(null);
                }

                else if (i > 0) {

                    Alert alert = new Alert(Alert.AlertType.INFORMATION);
                    alert.setTitle("Student Management");
                    alert.setHeaderText(null);
                    alert.setContentText("Student " + adNo + " Updated Successfully..!");
                    alert.showAndWait();

                    AdNo.setText(null);
                    adNoField.setText(null);
                    fullNameField.setText(null);
                    nameField.setText(null);
                    dobField.setText(null);
                    doaField.setText(null);
                    gradeField.setText(null);
                    genderField.setText(null);
                    adNoField.setText(null);
                    parentNameField.setText(null);
                    nicField.setText(null);
                    phoneField.setText(null);
                    fullNameField.setText(null);
                    addressField.setText(null);

                } else {
                    Alert alert = new Alert(Alert.AlertType.ERROR);
                    alert.setTitle("Student Management");
                    alert.setHeaderText(null);
                    alert.setContentText("OOPs there is an error updating Student..!");
                    alert.showAndWait();
                }
            }
        } catch (ClassNotFoundException | SQLException ex) {
            Logger.getLogger(StudentController.class.getName()).log(Level.SEVERE, null, ex);
        }
    }


    //Search Method
    @FXML
    void searchStudent(ActionEvent event) {
        try {
            int adNo = Integer.parseInt(AdNo.getText());
            Student s = StudentController.searchStudent(adNo);
            if (s != null) {
                adNoField.setText(String.valueOf(s.getAdNo()));
                fullNameField.setText(s.getFullName());
                nameField.setText(s.getName());
                dobField.setText(s.getDob());
                doaField.setText(s.getDoa());
                genderField.setText(s.getGender());
                gradeField.setText(s.getGrade());
                parentNameField.setText(s.getParentName());
                nicField.setText(s.getNic());
                phoneField.setText(s.getPhone());
                addressField.setText(s.getAddress());


            } else {
                Alert alert = new Alert(Alert.AlertType.ERROR);
                alert.setTitle("Student Search");
                alert.setHeaderText(null);
                alert.setContentText("Student Not Found");
                alert.showAndWait();

                AdNo.setText(null);
                adNoField.setText(null);
                fullNameField.setText(null);
                nameField.setText(null);
                dobField.setText(null);
                doaField.setText(null);
                gradeField.setText(null);
                genderField.setText(null);
                adNoField.setText(null);
                parentNameField.setText(null);
                nicField.setText(null);
                phoneField.setText(null);
                fullNameField.setText(null);
                addressField.setText(null);
            }
        } catch (ClassNotFoundException | SQLException ex) {
            Logger.getLogger(StudentController.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

    @FXML
    void searchPastStudent(ActionEvent event) {
        try {
            int adNo = Integer.parseInt(AdNo1.getText());
            Student s = StudentController.searchPastStudent(adNo);
            if (s != null) {
                adNoField.setText(String.valueOf(s.getAdNo()));
                fullNameField.setText(s.getFullName());
                nameField.setText(s.getName());
                dobField.setText(s.getDob());
                doaField.setText(s.getDoa());
                genderField.setText(s.getGender());
                gradeField.setText(s.getGrade());
                parentNameField.setText(s.getParentName());
                nicField.setText(s.getNic());
                phoneField.setText(s.getPhone());
                addressField.setText(s.getAddress());


            } else {
                Alert alert = new Alert(Alert.AlertType.ERROR);
                alert.setTitle("Student Search");
                alert.setHeaderText(null);
                alert.setContentText("Student Not Found");
                alert.showAndWait();

                AdNo.setText(null);
                adNoField.setText(null);
                fullNameField.setText(null);
                nameField.setText(null);
                dobField.setText(null);
                doaField.setText(null);
                gradeField.setText(null);
                genderField.setText(null);
                adNoField.setText(null);
                parentNameField.setText(null);
                nicField.setText(null);
                phoneField.setText(null);
                fullNameField.setText(null);
                addressField.setText(null);
            }
        } catch (ClassNotFoundException | SQLException ex) {
            Logger.getLogger(StudentController.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
}






<|start_filename|>src/sms/model/School.java<|end_filename|>
package sms.model;

/**
 * @author Safnaj on 8/26/2018
 * @project School Management System
 **/
public class School {
    private String schoolName;
    private String schoolAddress;
    private String classAvailable;
    private String schoolType;
    private String deoDivision;
    private String municpalCouncil;
    private String policeArea;
    private String postalCode;
    private String gsDivision;
    private String eduZone;
    private String eduDistrict;
    private String adminDistrict;
    private String electorate;
    private String dateOfEstd;
    private String schoolID;
    private String schoolCensus;
    private String schoolExamId;
    private String totalLandArea;
    private String province;
    private String nameOfPrincipal;
    private String pricipalNo;

    public School(){

    }

    public School(String schoolName, String schoolAddress, String classAvailable, String schoolType, String deoDivision, String municpalCouncil, String policeArea, String postalCode, String gsDivision, String eduZone, String eduDistrict, String adminDistrict, String electorate, String dateOfEstd, String schoolID, String schoolCensus, String schoolExamId, String totalLandArea, String province, String nameOfPrincipal, String pricipalNo) {
        this.schoolName = schoolName;
        this.schoolAddress = schoolAddress;
        this.classAvailable = classAvailable;
        this.schoolType = schoolType;
        this.deoDivision = deoDivision;
        this.municpalCouncil = municpalCouncil;
        this.policeArea = policeArea;
        this.postalCode = postalCode;
        this.gsDivision = gsDivision;
        this.eduZone = eduZone;
        this.eduDistrict = eduDistrict;
        this.adminDistrict = adminDistrict;
        this.electorate = electorate;
        this.dateOfEstd = dateOfEstd;
        this.schoolID = schoolID;
        this.schoolCensus = schoolCensus;
        this.schoolExamId = schoolExamId;
        this.totalLandArea = totalLandArea;
        this.province = province;
        this.nameOfPrincipal = nameOfPrincipal;
        this.pricipalNo = pricipalNo;
    }

    public String getSchoolName() {
        return schoolName;
    }

    public void setSchoolName(String schoolName) {
        schoolName = schoolName;
    }

    public String getSchoolAddress() {
        return schoolAddress;
    }

    public void setSchoolAddress(String schoolAddress) {
        schoolAddress = schoolAddress;
    }

    public String getClassAvailable() {
        return classAvailable;
    }

    public void setClassAvailable(String classAvailable) {
        this.classAvailable = classAvailable;
    }

    public String getSchoolType() {
        return schoolType;
    }

    public void setSchoolType(String schoolType) {
        this.schoolType = schoolType;
    }

    public String getDeoDivision() {
        return deoDivision;
    }

    public void setDeoDivision(String deoDivision) {
        this.deoDivision = deoDivision;
    }

    public String getMunicpalCouncil() {
        return municpalCouncil;
    }

    public void setMunicpalCouncil(String municpalCouncil) {
        this.municpalCouncil = municpalCouncil;
    }

    public String getPoliceArea() {
        return policeArea;
    }

    public void setPoliceArea(String policeArea) {
        this.policeArea = policeArea;
    }

    public String getPostalCode() {
        return postalCode;
    }

    public void setPostalCode(String postalCode) {
        this.postalCode = postalCode;
    }

    public String getGsDivision() {
        return gsDivision;
    }

    public void setGsDivision(String gsDivision) {
        this.gsDivision = gsDivision;
    }

    public String getEduZone() {
        return eduZone;
    }

    public void setEduZone(String eduZone) {
        this.eduZone = eduZone;
    }

    public String getEduDistrict() {
        return eduDistrict;
    }

    public void setEduDistrict(String eduDistrict) {
        this.eduDistrict = eduDistrict;
    }

    public String getAdminDistrict() {
        return adminDistrict;
    }

    public void setAdminDistrict(String adminDistrict) {
        this.adminDistrict = adminDistrict;
    }

    public String getElectorate() {
        return electorate;
    }

    public void setElectorate(String electorate) {
        this.electorate = electorate;
    }

    public String getDateOfEstd() {
        return dateOfEstd;
    }

    public void setDateOfEstd(String dateOfEstd) {
        this.dateOfEstd = dateOfEstd;
    }

    public String getSchoolID() {
        return schoolID;
    }

    public void setSchoolID(String schoolID) {
        this.schoolID = schoolID;
    }

    public String getSchoolCensus() {
        return schoolCensus;
    }

    public void setSchoolCensus(String schoolCensus) {
        this.schoolCensus = schoolCensus;
    }

    public String getSchoolExamId() {
        return schoolExamId;
    }

    public void setSchoolExamId(String schoolExamId) {
        this.schoolExamId = schoolExamId;
    }

    public String getTotalLandArea() {
        return totalLandArea;
    }

    public void setTotalLandArea(String totalLandArea) {
        this.totalLandArea = totalLandArea;
    }

    public String getProvince() {
        return province;
    }

    public void setProvince(String province) {
        this.province = province;
    }

    public String getNameOfPrincipal() {
        return nameOfPrincipal;
    }

    public void setNameOfPrincipal(String nameOfPrincipal) {
        this.nameOfPrincipal = nameOfPrincipal;
    }

    public String getPricipalNo() {
        return pricipalNo;
    }

    public void setPricipalNo(String pricipalNo) {
        this.pricipalNo = pricipalNo;
    }
}


<|start_filename|>src/sms/view/controller/DashboardController.java<|end_filename|>
package sms.view.controller;

import com.jfoenix.controls.JFXButton;
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.Alert;
import javafx.scene.control.TextField;
import javafx.scene.image.ImageView;
import javafx.scene.layout.AnchorPane;
import javafx.stage.Stage;

import java.io.IOException;
import java.net.URL;
import java.util.ResourceBundle;

/**
 * @author Safnaj on 8/28/2018
 * @project School Management System
 **/
public class DashboardController implements Initializable {

    @Override
    public void initialize(URL location, ResourceBundle resources) {

    }
    @FXML
    private AnchorPane root;

    @FXML
    private ImageView ExamMgmt;

    @FXML
    private ImageView LibraryMgmt;

    @FXML
    private ImageView EventMgmt;

    @FXML
    private ImageView StudentMgmt;

    @FXML
    private JFXButton btnStudentMgmt;

    @FXML
    private JFXButton btnExamMgmt;

    @FXML
    private JFXButton btnLibraryMgmt;

    @FXML
    private JFXButton btnEventMgmt;

    @FXML
    private JFXButton btnUserSettings;

    @FXML
    private TextField username;

    @FXML
    void btnEventMgmt(ActionEvent event) {
        Alert alert = new Alert(Alert.AlertType.INFORMATION);
        alert.setTitle("School Management System");
        alert.setHeaderText(null);
        alert.setContentText("Sorry..! This feature currently Unavailable for this Version.");
        alert.showAndWait();
    }

    @FXML
    void btnExamMgmt(ActionEvent event) {
        Alert alert = new Alert(Alert.AlertType.INFORMATION);
        alert.setTitle("School Management System");
        alert.setHeaderText(null);
        alert.setContentText("Sorry..! This feature currently Unavailable for this Version.");
        alert.showAndWait();
    }

    @FXML
    void btnLibraryMgmt(ActionEvent event) {
        Alert alert = new Alert(Alert.AlertType.INFORMATION);
        alert.setTitle("School Management System");
        alert.setHeaderText(null);
        alert.setContentText("Sorry..! This feature currently Unavailable for this Version.");
        alert.showAndWait();
    }

    @FXML
    void btnStudentMgmt(ActionEvent event) throws IOException {

        try {
            AnchorPane user = FXMLLoader.load(getClass().getResource(("/sms/view/fxml/StudentManagementTr.fxml")));
            root.getChildren().setAll(user);
        }catch(IOException e){
            System.out.println(e);
        }
    }

    @FXML
    void setBtnUserSettings(ActionEvent event) {
        try {
            AnchorPane user = FXMLLoader.load(getClass().getResource(("/sms/view/fxml/UserAccount2.fxml")));
            root.getChildren().setAll(user);
        }catch(IOException e){
            System.out.println(e);
        }
    }

}


<|start_filename|>src/sms/view/controller/ValidationController.java<|end_filename|>
package sms.view.controller;

import javafx.scene.control.Alert;
import javafx.scene.control.TextField;

/**
 * @author Safnaj on 9/1/2018
 * @project School Management System
 **/
public class ValidationController {

    public static boolean validateEmpty(TextField txt) {
        if (txt.getText().isEmpty()) {
            Alert alert = new Alert(Alert.AlertType.INFORMATION);
            alert.setTitle("Student Registration");
            alert.setHeaderText(null);
            alert.setContentText("Please Fill Required Fields..!");
            alert.showAndWait();

            return false;
        }
        return true;
    }

    public boolean validateNIC(TextField txt) {
        if (txt.getText().matches("^(\\d{9}|\\d{12})[VvXx]$")|| (txt.getText().isEmpty())) {

            return true;
        } else {
            Alert alert = new Alert(Alert.AlertType.INFORMATION);
            alert.setTitle("Student Registration");
            alert.setHeaderText(null);
            alert.setContentText("Invalid NIC Number..!");
            alert.showAndWait();

            return false;
        }
    }

    public boolean numbersOnly(TextField txt) {
        if (txt.getText().matches("[0-9]+")) {

            return true;
        } else {
            Alert alert = new Alert(Alert.AlertType.INFORMATION);
            alert.setTitle("Student Registration");
            alert.setHeaderText(null);
            alert.setContentText("Invalid Input Type..!");
            alert.showAndWait();

            return false;
        }
    }

    public boolean validatePhone(TextField txt) {
        if (txt.getText().matches("^(\\d{10})")) {

            return true;
        } else {
            Alert alert = new Alert(Alert.AlertType.INFORMATION);
            alert.setTitle("Student Registration");
            alert.setHeaderText(null);
            alert.setContentText("Invalid Phone Number..!");
            alert.showAndWait();

            return false;
        }
    }

    public boolean validateDate(TextField txt) {
        if (txt.getText().matches("\\d{4}-\\d{2}-\\d{2}")) {

            return true;
        } else {
            Alert alert = new Alert(Alert.AlertType.INFORMATION);
            alert.setTitle("Student Registration");
            alert.setHeaderText(null);
            alert.setContentText("Invalid Date..!");
            alert.showAndWait();

            return false;
        }
    }
}


<|start_filename|>src/sms/view/controller/UserAccount2Controller.java<|end_filename|>
package sms.view.controller;

import com.jfoenix.controls.JFXButton;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.fxml.Initializable;
import javafx.scene.layout.AnchorPane;

import java.io.IOException;
import java.net.URL;
import java.util.ResourceBundle;

/**
 * @author Safnaj on 11/11/2018
 * @project School Management System
 **/
public class UserAccount2Controller implements Initializable {

    @Override
    public void initialize(URL location, ResourceBundle resources) {

    }
    @FXML
    private AnchorPane userAccount;

    @FXML
    private JFXButton btnLogout1;

    @FXML
    private JFXButton Back;

    @FXML
    void Back(ActionEvent event) {
        try {
            AnchorPane studentMgmt = FXMLLoader.load(getClass().getResource(("/sms/view/fxml/PrintStudents2.fxml")));
            userAccount.getChildren().setAll(studentMgmt);
        }catch(IOException e){
            System.out.println(e);
        }
    }

    @FXML
    void btnLogout(ActionEvent event) {
        try {
            AnchorPane studentMgmt = FXMLLoader.load(getClass().getResource(("/sms/view/fxml/login.fxml")));
            userAccount.getChildren().setAll(studentMgmt);
        }catch(IOException e){
            System.out.println(e);
        }
    }
}


<|start_filename|>src/sms/view/controller/RegisterStudentController.java<|end_filename|>
package sms.view.controller;


import com.jfoenix.controls.JFXButton;
import com.jfoenix.controls.JFXRadioButton;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.fxml.FXMLLoader;
import javafx.scene.layout.AnchorPane;
import sms.db.DBConnection;
import sms.dbController.GradeController;
import sms.dbController.StudentController;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.control.*;
import sms.model.Grade;
import sms.model.Student;
import javafx.scene.control.TextField;

import java.io.IOException;
import java.net.URL;
import java.sql.*;
import java.util.ArrayList;
import java.util.List;
import java.util.ResourceBundle;
import java.util.logging.Level;
import java.util.logging.Logger;


/**
 * @author chamodshehanka on 7/16/2018
 * @project School-Management-System
 **/

public class RegisterStudentController implements Initializable {
    @FXML
    private TextField adNoField;

    @FXML
    private TextField fullNameField;

    @FXML
    private TextField nameField;

    @FXML
    private TextField dobField;

    @FXML
    private TextField doaField;

    @FXML
    private JFXRadioButton genderField;

    @FXML
    private ToggleGroup g;

    @FXML
    private ComboBox<String> loadCombo;

    @FXML
    private TextField parentNameField;

    @FXML
    private TextField nicField;

    @FXML
    private TextField phoneField;

    @FXML
    private TextField addressField;

    @FXML
    private JFXButton Back;

    @FXML
    private AnchorPane root;



    @Override
    public void initialize(URL location, ResourceBundle resources){

        loadComboBox();
    }

    @FXML
    void Back() {
        try {
            AnchorPane studentMgmt = FXMLLoader.load(getClass().getResource(("/sms/view/fxml/StudentManagement.fxml")));
            root.getChildren().setAll(studentMgmt);
        }catch(IOException e){
            System.out.println(e);
        }
    }

    @FXML
    private void AddStudent(ActionEvent event) {
        try {

            ValidationController v = new ValidationController();

           // if(ValidationController.validateEmpty(adNoField)) //This can be used for Static Methods

            if (v.validateEmpty(adNoField) && v.validateEmpty(nameField) && v.validateEmpty(dobField) && v.validateEmpty(doaField) &&
                    v.validateEmpty(parentNameField) && v.validateEmpty(phoneField) && v.validateNIC(nicField) && v.numbersOnly(adNoField)
                    && v.validatePhone(phoneField) && v.validateDate(doaField) && v.validateDate(dobField)) {


                int adNo = Integer.parseInt(adNoField.getText());
                String fullName = fullNameField.getText();
                String name = nameField.getText();
                String dob = dobField.getText();
                String doa = doaField.getText();
                RadioButton selectedRadioButton = (RadioButton) g.getSelectedToggle(); //Getting Selected Radio Button
                String gender = selectedRadioButton.getText();
                String grade = loadCombo.getValue();
                String parentName = parentNameField.getText();
                String nic = nicField.getText();
                String phone = phoneField.getText();
                String address = addressField.getText();

                Student s = new Student(adNo, fullName, name, dob, doa, gender, grade, parentName, nic, phone, address);
                int i = StudentController.AddStudent(s);

                if (i > 0) {
                    Alert alert = new Alert(Alert.AlertType.INFORMATION);
                    alert.setTitle("Student Registration");
                    alert.setHeaderText(null);
                    alert.setContentText("Student ID " + adNo + " Registered Successfully..!");
                    alert.showAndWait();

                    adNoField.setText(null);
                    fullNameField.setText(null);
                    nameField.setText(null);
                    dobField.setText(null);
                    doaField.setText(null);
                    loadCombo.setValue(null);
                    adNoField.setText(null);
                    parentNameField.setText(null);
                    nicField.setText(null);
                    phoneField.setText(null);
                    fullNameField.setText(null);
                    addressField.setText(null);

                } else {
                    Alert alert = new Alert(Alert.AlertType.ERROR);
                    alert.setTitle("Student Registration");
                    alert.setHeaderText(null);
                    alert.setContentText("OOPs there is an error adding Student");
                    alert.showAndWait();
                }
            }

        } catch (ClassNotFoundException | SQLException ex) {
            Logger.getLogger(StudentController.class.getName()).log(Level.SEVERE, null, ex);
        }

    }

    @FXML
    private void reset() {

        adNoField.setText(null);
        fullNameField.setText(null);
        nameField.setText(null);
        dobField.setText(null);
        doaField.setText(null);
        loadCombo.setValue(null);
        adNoField.setText(null);
        parentNameField.setText(null);
        nicField.setText(null);
        phoneField.setText(null);
        fullNameField.setText(null);
        addressField.setText(null);
    }

    @FXML
    private void loadComboBox(){
        ArrayList arrayList = null;
        try {
            arrayList = GradeController.getGrades();
        } catch (ClassNotFoundException | SQLException e) {
            e.printStackTrace();
        }
        ObservableList observableArray = FXCollections.observableArrayList();
        observableArray.addAll(arrayList);

        if (observableArray != null){
            loadCombo.setItems(observableArray);
        }

    }

}





<|start_filename|>src/sms/view/controller/ManageStaffsController.java<|end_filename|>
package sms.view.controller;

import com.jfoenix.controls.JFXButton;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.fxml.Initializable;
import javafx.scene.control.Alert;
import javafx.scene.control.RadioButton;
import javafx.scene.control.TextField;
import javafx.scene.layout.AnchorPane;
import net.sf.jasperreports.engine.JRException;
import net.sf.jasperreports.engine.design.JRDesignQuery;
import net.sf.jasperreports.engine.design.JasperDesign;
import net.sf.jasperreports.engine.xml.JRXmlLoader;
import sms.db.DBConnection;
import sms.dbController.StaffController;
import sms.dbController.StudentController;
import sms.model.Staff;
import sms.model.Student;

import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.ResourceBundle;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 * @author Safnaj on 11/1/2018
 * @project School Management System
 **/
public class ManageStaffsController implements Initializable {

    @Override
    public void initialize(URL location, ResourceBundle resources) {

    }

    @FXML
    private AnchorPane root;

    @FXML
    private TextField empNoField;

    @FXML
    private TextField teacherNameField;

    @FXML
    private TextField nicField;

    @FXML
    private TextField dobField;

    @FXML
    private TextField doaField;

    @FXML
    private TextField phoneField;

    @FXML
    private TextField addressField;

    @FXML
    private TextField emailField;

    @FXML
    private TextField asmOfDutyField;

    @FXML
    private TextField incDateField;

    @FXML
    private TextField prsntGradeField;

    @FXML
    private TextField empNoOld;

    @FXML
    private JFXButton deleteStaff;

    @FXML
    private JFXButton update;

    @FXML
    private TextField genderField;

    @FXML
    private TextField EmpNo;

    @FXML
    private JFXButton searchStaff;

    @FXML
    private TextField empName;

    @FXML
    private JFXButton searchByName;

    @FXML
    private JFXButton searchOldStaff;

    @FXML
    private JFXButton printStaff;

    @FXML
    private JFXButton Back;

    @FXML
    void Back(ActionEvent event) {
        try {
            AnchorPane studentMgmt = FXMLLoader.load(getClass().getResource(("/sms/view/fxml/StaffManagement.fxml")));
            root.getChildren().setAll(studentMgmt);
        }catch(IOException e){
            System.out.println(e);
        }
    }

    @FXML
    void searchByName(ActionEvent event) {
        try {
            String teacherName = empName.getText();
            Staff s = StaffController.searchStaffByName(teacherName);
            if (s != null) {
                empNoField.setText(String.valueOf(s.getEmpNo()));
                teacherNameField.setText(s.getTeacherName());
                nicField.setText(s.getNic());
                dobField.setText(s.getDob());
                doaField.setText(s.getDoa());
                genderField.setText(s.getGender());
                emailField.setText(s.getEmail());
                asmOfDutyField.setText(s.getAssumpOfDuties());
                phoneField.setText(s.getPhone());
                addressField.setText(s.getAddress());
                incDateField.setText(s.getIncDate());
                prsntGradeField.setText(s.getPrsntGrade());


            } else {
                Alert alert = new Alert(Alert.AlertType.ERROR);
                alert.setTitle("Staff Search");
                alert.setHeaderText(null);
                alert.setContentText("Staff Not Found");
                alert.showAndWait();

                empNoField.setText(null);
                teacherNameField.setText(null);
                nicField.setText(null);
                dobField.setText(null);
                doaField.setText(null);
                emailField.setText(null);
                asmOfDutyField.setText(null);
                nicField.setText(null);
                genderField.setText(null);
                phoneField.setText(null);
                addressField.setText(null);
                incDateField.setText(null);
                prsntGradeField.setText(null);
                empName.setText(null);
                empNoOld.setText(null);
                EmpNo.setText(null);
            }
        } catch (ClassNotFoundException | SQLException ex) {
            Logger.getLogger(StaffController.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

    @FXML
    void searchOldStaff(ActionEvent event) {
        try {
            int EmpNo2 = Integer.parseInt(empNoOld.getText());
            Staff s = StaffController.searchOldStaff(EmpNo2);
            if (s != null) {
                empNoField.setText(String.valueOf(s.getEmpNo()));
                teacherNameField.setText(s.getTeacherName());
                nicField.setText(s.getNic());
                dobField.setText(s.getDob());
                doaField.setText(s.getDoa());
                genderField.setText(s.getGender());
                emailField.setText(s.getEmail());
                asmOfDutyField.setText(s.getAssumpOfDuties());
                phoneField.setText(s.getPhone());
                addressField.setText(s.getAddress());
                incDateField.setText(s.getIncDate());
                prsntGradeField.setText(s.getPrsntGrade());


            } else {
                Alert alert = new Alert(Alert.AlertType.ERROR);
                alert.setTitle("Staff Search");
                alert.setHeaderText(null);
                alert.setContentText("Staff Not Found");
                alert.showAndWait();

                empNoField.setText(null);
                teacherNameField.setText(null);
                nicField.setText(null);
                dobField.setText(null);
                doaField.setText(null);
                emailField.setText(null);
                asmOfDutyField.setText(null);
                nicField.setText(null);
                genderField.setText(null);
                phoneField.setText(null);
                addressField.setText(null);
                incDateField.setText(null);
                prsntGradeField.setText(null);
                empName.setText(null);
                empNoOld.setText(null);
                EmpNo.setText(null);
            }
        } catch (ClassNotFoundException | SQLException ex) {
            Logger.getLogger(StaffController.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

    @FXML
    void searchStaff(ActionEvent event) {
        try {
            int empNo = Integer.parseInt(EmpNo.getText());
            Staff s = StaffController.searchStaff(empNo);
            if (s != null) {
                empNoField.setText(String.valueOf(s.getEmpNo()));
                teacherNameField.setText(s.getTeacherName());
                nicField.setText(s.getNic());
                dobField.setText(s.getDob());
                doaField.setText(s.getDoa());
                genderField.setText(s.getGender());
                emailField.setText(s.getEmail());
                asmOfDutyField.setText(s.getAssumpOfDuties());
                phoneField.setText(s.getPhone());
                addressField.setText(s.getAddress());
                incDateField.setText(s.getIncDate());
                prsntGradeField.setText(s.getPrsntGrade());


            } else {
                Alert alert = new Alert(Alert.AlertType.ERROR);
                alert.setTitle("Staff Search");
                alert.setHeaderText(null);
                alert.setContentText("Staff Not Found");
                alert.showAndWait();

                empNoField.setText(null);
                teacherNameField.setText(null);
                nicField.setText(null);
                dobField.setText(null);
                doaField.setText(null);
                emailField.setText(null);
                asmOfDutyField.setText(null);
                nicField.setText(null);
                genderField.setText(null);
                phoneField.setText(null);
                addressField.setText(null);
                incDateField.setText(null);
                prsntGradeField.setText(null);
                empName.setText(null);
                empNoOld.setText(null);
                EmpNo.setText(null);
            }
        } catch (ClassNotFoundException | SQLException ex) {
            Logger.getLogger(StaffController.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

    @FXML
    void deleteStaff(ActionEvent event) {
        try {
            int empNo = Integer.parseInt(empNoField.getText());
            Staff s = new Staff(Integer.parseInt(empNoField.getText()), teacherNameField.getText(), nicField.getText(), dobField.getText(), doaField.getText(),
                    genderField.getText(), emailField.getText(), asmOfDutyField.getText(), phoneField.getText(), addressField.getText(), incDateField.getText(),prsntGradeField.getText());

            int moveStaff = StaffController.moveStaff(s);
            if (moveStaff > 0) {

                int deleteStaff = StaffController.deleteStaff(empNo);
                if (deleteStaff > 0) {

                    Alert alert = new Alert(Alert.AlertType.INFORMATION);
                    alert.setTitle("Staff Management");
                    alert.setHeaderText(null);
                    alert.setContentText("Staff " + empNo + " Has Been Deleted Sucessfully..!");
                    alert.showAndWait();

                    empNoField.setText(null);
                    teacherNameField.setText(null);
                    nicField.setText(null);
                    dobField.setText(null);
                    doaField.setText(null);
                    emailField.setText(null);
                    genderField.setText(null);
                    asmOfDutyField.setText(null);
                    nicField.setText(null);
                    phoneField.setText(null);
                    addressField.setText(null);
                    incDateField.setText(null);
                    prsntGradeField.setText(null);


                } else {
                    Alert alert = new Alert(Alert.AlertType.ERROR);
                    alert.setTitle("Staff Management");
                    alert.setHeaderText(null);
                    alert.setContentText("There is an error deleting Staff..!");
                    alert.showAndWait();
                }
            }
        } catch(ClassNotFoundException | SQLException ex){
            Logger.getLogger(StaffController.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

    @FXML
    void printStaff(ActionEvent event) {
        try {
            String empNo = empNoField.getText();

            InputStream report1 = getClass().getResourceAsStream("/sms/Reports/StaffInfo.jrxml");
            InputStream report2 = getClass().getResourceAsStream("/sms/Reports/StaffInfoPast.jrxml");

            JRDesignQuery query = new JRDesignQuery();

            if(empNoOld.getText().isEmpty()){

                JasperDesign jd = JRXmlLoader.load(report1);
                query.setText("select * from staffs where empNo = '" + empNo + "'");
                jd.setQuery(query);
                ReportViewController r = new ReportViewController();
                r.viewReport(jd);
            }
            else{

                JasperDesign jd2 = JRXmlLoader.load(report2);
                query.setText("select * from oldstaffs where empNo = '" + empNo + "'");
                jd2.setQuery(query);
                ReportViewController r = new ReportViewController();
                r.viewReport(jd2);
            }

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

    @FXML
    void update(ActionEvent event) {
        try {

            ValidationController v = new ValidationController();

            if(v.validateEmpty(empNoField)&& v.validateEmpty(teacherNameField)&& v.validateEmpty(nicField)&& v.validateEmpty(dobField)
                    && v.validateEmpty(doaField)&& v.validateEmpty(phoneField)&& v.validateDate(dobField)&& v.validateDate(doaField)&& v.validateDate(asmOfDutyField)
                    && v.validateDate(incDateField)&& v.validateNIC(nicField)&& v.validatePhone(phoneField)&& v.numbersOnly(empNoField)&& v.numbersOnly(phoneField)){


                int empNo = Integer.parseInt(empNoField.getText());
                String teacherName = teacherNameField.getText();
                String nic = nicField.getText();
                String dob = dobField.getText();
                String doa = doaField.getText();
                String gender = genderField.getText();
                String email = emailField.getText();
                String assumpOfDuties = asmOfDutyField.getText();
                String phone = phoneField.getText();
                String address = addressField.getText();
                String incDate = incDateField.getText();
                String prsntGrade = prsntGradeField.getText();

                Staff s = new Staff(empNo, teacherName, nic, dob, doa, gender, email, assumpOfDuties, phone, address, incDate, prsntGrade);
                int i = StaffController.updateStaff(s);
                int d = StaffController.updateOldStaff(s);

                if (i > 0){

                    Alert alert = new Alert(Alert.AlertType.INFORMATION);
                    alert.setTitle("Staff Management");
                    alert.setHeaderText(null);
                    alert.setContentText("Staff Informations Updated Successfully..!");
                    alert.showAndWait();

                    empNoField.setText(null);
                    teacherNameField.setText(null);
                    nicField.setText(null);
                    dobField.setText(null);
                    doaField.setText(null);
                    emailField.setText(null);
                    genderField.setText(null);
                    asmOfDutyField.setText(null);
                    nicField.setText(null);
                    phoneField.setText(null);
                    addressField.setText(null);
                    incDateField.setText(null);
                    prsntGradeField.setText(null);

                }
                else if (d > 0) {

                    Alert alert = new Alert(Alert.AlertType.INFORMATION);
                    alert.setTitle("Staff Management");
                    alert.setHeaderText(null);
                    alert.setContentText("Staff Informations Updated Successfully..!");
                    alert.showAndWait();

                    empNoField.setText(null);
                    teacherNameField.setText(null);
                    nicField.setText(null);
                    dobField.setText(null);
                    doaField.setText(null);
                    emailField.setText(null);
                    genderField.setText(null);
                    asmOfDutyField.setText(null);
                    nicField.setText(null);
                    phoneField.setText(null);
                    addressField.setText(null);
                    incDateField.setText(null);
                    prsntGradeField.setText(null);

                } else {
                    Alert alert = new Alert(Alert.AlertType.ERROR);
                    alert.setTitle("Staff Management");
                    alert.setHeaderText(null);
                    alert.setContentText("OOPS there is an error updating Staff..!");
                    alert.showAndWait();
                }
            }
        } catch (ClassNotFoundException | SQLException ex) {
            Logger.getLogger(StaffController.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

}



<|start_filename|>src/sms/view/controller/RegisterStaffController.java<|end_filename|>
package sms.view.controller;

import com.jfoenix.controls.JFXButton;
import com.jfoenix.controls.JFXRadioButton;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.fxml.Initializable;
import javafx.scene.control.Alert;
import javafx.scene.control.RadioButton;
import javafx.scene.control.TextField;
import javafx.scene.control.ToggleGroup;
import javafx.scene.layout.AnchorPane;
import sms.dbController.StaffController;
import sms.dbController.StudentController;
import sms.model.Staff;
import sms.model.Student;

import java.io.IOException;
import java.net.URL;
import java.sql.SQLException;
import java.util.ResourceBundle;

/**
 * @author Safnaj on 11/1/2018
 * @project School Management System
 **/
public class RegisterStaffController implements Initializable {

    @Override
    public void initialize(URL location, ResourceBundle resources) {

    }
    @FXML
    private AnchorPane root;

    @FXML
    private TextField empNoField;

    @FXML
    private TextField teacherNameField;

    @FXML
    private TextField nicField;

    @FXML
    private TextField dobField;

    @FXML
    private TextField doaField;

    @FXML
    private JFXRadioButton genderField;

    @FXML
    private ToggleGroup g;

    @FXML
    private TextField emailField;

    @FXML
    private TextField asmOfDutyField;

    @FXML
    private TextField phoneField;

    @FXML
    private TextField addressField;

    @FXML
    private JFXButton AddStaff;

    @FXML
    private JFXButton reset;

    @FXML
    private TextField incDateField;

    @FXML
    private TextField prsntGradeField;

    @FXML
    private JFXButton Back;

    @FXML
    void Back(ActionEvent event) {
        try {
            AnchorPane studentMgmt = FXMLLoader.load(getClass().getResource(("/sms/view/fxml/StaffManagement.fxml")));
            root.getChildren().setAll(studentMgmt);
        }catch(IOException e){
            System.out.println(e);
        }
    }

    @FXML
    void AddStaff(ActionEvent event) {

        try {

            ValidationController v = new ValidationController();

            if(v.validateEmpty(empNoField)&& v.validateEmpty(teacherNameField)&& v.validateEmpty(nicField)&& v.validateEmpty(dobField)
                    && v.validateEmpty(doaField)&& v.validateEmpty(phoneField)&& v.validateDate(dobField)&& v.validateDate(doaField)&& v.validateDate(asmOfDutyField)
                    && v.validateDate(incDateField)&& v.validateNIC(nicField)&& v.validatePhone(phoneField)&& v.numbersOnly(empNoField)&& v.numbersOnly(phoneField)){

                int empNo = Integer.parseInt(empNoField.getText());
                String teacherName = teacherNameField.getText();
                String nic = nicField.getText();
                String dob = dobField.getText();
                String doa = doaField.getText();
                RadioButton selectedRadioButton = (RadioButton) g.getSelectedToggle();
                String gender = selectedRadioButton.getText();
                String email = emailField.getText();
                String assumpOfDuties = asmOfDutyField.getText();
                String phone = phoneField.getText();
                String address = addressField.getText();
                String incDate = incDateField.getText();
                String prsntGrade = prsntGradeField.getText();

                Staff s = new Staff(empNo, teacherName, nic, dob, doa, gender, email, assumpOfDuties, phone, address, incDate, prsntGrade);
                int i = StaffController.AddStaff(s);


                if (i > 0) {
                    Alert alert = new Alert(Alert.AlertType.INFORMATION);
                    alert.setTitle("Staff Registration");
                    alert.setHeaderText(null);
                    alert.setContentText("Staff Registered Successfully..!");
                    alert.showAndWait();

                    empNoField.setText(null);
                    teacherNameField.setText(null);
                    nicField.setText(null);
                    dobField.setText(null);
                    doaField.setText(null);
                    emailField.setText(null);
                    asmOfDutyField.setText(null);
                    nicField.setText(null);
                    phoneField.setText(null);
                    addressField.setText(null);
                    incDateField.setText(null);
                    prsntGradeField.setText(null);

                } else {
                    Alert alert = new Alert(Alert.AlertType.ERROR);
                    alert.setTitle("Staff Registration");
                    alert.setHeaderText(null);
                    alert.setContentText("OOPS there is an error adding Staff..!");
                    alert.showAndWait();
                }
            }

    } catch (SQLException e) {
            e.printStackTrace();
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        }

    }

    @FXML
    void reset(ActionEvent event) {

        empNoField.setText(null);
        teacherNameField.setText(null);
        nicField.setText(null);
        dobField.setText(null);
        doaField.setText(null);
        emailField.setText(null);
        asmOfDutyField.setText(null);
        nicField.setText(null);
        addressField.setText(null);
        phoneField.setText(null);
        incDateField.setText(null);
        prsntGradeField.setText(null);

    }
}


<|start_filename|>src/sms/view/controller/SchoolInfoController.java<|end_filename|>
package sms.view.controller;
import javafx.fxml.FXMLLoader;
import net.sf.jasperreports.engine.*;
import net.sf.jasperreports.engine.design.JRDesignQuery;
import net.sf.jasperreports.engine.design.JasperDesign;
import net.sf.jasperreports.engine.xml.JRXmlLoader;
import net.sf.jasperreports.view.JasperViewer;
import sms.db.DBConnection;
import sms.dbController.SchoolController;
import sms.model.School;
import javafx.event.ActionEvent;
import javafx.fxml.Initializable;

import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.ResourceBundle;
import java.util.logging.Level;
import java.util.logging.Logger;

import com.jfoenix.controls.JFXButton;
import javafx.fxml.FXML;
import javafx.scene.control.Alert;
import javafx.scene.control.RadioButton;
import javafx.scene.control.TextField;
import javafx.scene.layout.AnchorPane;
import sms.dbController.StudentController;



/**
 * @author Safnaj on 8/26/2018
 * @project School Management System
 **/
public class SchoolInfoController implements Initializable {

    @Override
    public void initialize(URL location, ResourceBundle resources) {
        try {
            School s = SchoolController.schoolInfo();
            if (s != null) {
                SchoolNameField.setText(s.getSchoolName());
                SchoolAddressField.setText(s.getSchoolAddress());
                classAvailableField.setText(s.getClassAvailable());
                schoolTypeField.setText(s.getSchoolType());
                deoDivisionField.setText(s.getDeoDivision());
                municpalCouncilField.setText(s.getMunicpalCouncil());
                policeAreaField.setText(s.getPoliceArea());
                postalCodeField.setText(s.getPostalCode());
                gsDivisionField.setText(s.getDeoDivision());
                eduZoneField.setText(s.getEduZone());
                eduDistrictField.setText(s.getEduDistrict());
                adminDistrictField.setText(s.getAdminDistrict());
                electorateField.setText(s.getElectorate());
                dateOfEstdField.setText(s.getDateOfEstd());
                schoolIDField.setText(s.getSchoolID());
                schoolCensusField.setText(s.getSchoolCensus());
                schoolExamIdField.setText(s.getSchoolExamId());
                totalLandAreaField.setText(s.getTotalLandArea());
                provinceField.setText(s.getProvince());
                nameOfPrincipalField.setText(s.getNameOfPrincipal());
                pricipalNoField.setText(s.getPricipalNo());


            }else{
                Alert alert = new Alert(Alert.AlertType.ERROR);
                alert.setTitle("School Information");
                alert.setHeaderText(null);
                alert.setContentText("No Information Found..!");
                alert.showAndWait();
            }
        } catch (ClassNotFoundException | SQLException ex) {
            Logger.getLogger(SchoolController.class.getName()).log(Level.SEVERE, null, ex);
        }
    }


    @FXML
    private AnchorPane root;

    @FXML
    private TextField SchoolNameField;

    @FXML
    private TextField SchoolAddressField;

    @FXML
    private TextField classAvailableField;

    @FXML
    private TextField schoolTypeField;

    @FXML
    private TextField deoDivisionField;

    @FXML
    private TextField municpalCouncilField;

    @FXML
    private TextField policeAreaField;

    @FXML
    private TextField postalCodeField;

    @FXML
    private TextField gsDivisionField;

    @FXML
    private JFXButton updateDetails;

    @FXML
    private JFXButton addDetails;

    @FXML
    private TextField eduZoneField;

    @FXML
    private TextField eduDistrictField;

    @FXML
    private TextField adminDistrictField;

    @FXML
    private TextField electorateField;

    @FXML
    private TextField dateOfEstdField;

    @FXML
    private TextField schoolIDField;

    @FXML
    private TextField schoolCensusField;

    @FXML
    private TextField schoolExamIdField;

    @FXML
    private TextField totalLandAreaField;

    @FXML
    private TextField provinceField;

    @FXML
    private TextField nameOfPrincipalField;

    @FXML
    private TextField pricipalNoField;

    @FXML
    private JFXButton printDetails;

    @FXML
    private JFXButton Back;

    @FXML
    void Back(ActionEvent event) {

        try {
            AnchorPane user = FXMLLoader.load(getClass().getResource(("/sms/view/fxml/MainDashboard.fxml")));
            root.getChildren().setAll(user);
        }catch(IOException e){
            System.out.println(e);
        }

    }

    @FXML
    void addDetails(ActionEvent event) {            //This Method Button Removed Due to Unwanted
        try {

            ValidationController v = new ValidationController();

            if (v.numbersOnly(classAvailableField)&&(v.numbersOnly(postalCodeField))&&(v.validatePhone(pricipalNoField))) {

                String SchoolName = SchoolNameField.getText();
                String SchoolAddress = SchoolNameField.getText();
                String classAvailable = classAvailableField.getText();
                String schoolType = schoolTypeField.getText();
                String deoDivision = deoDivisionField.getText();
                String municpalCouncil = municpalCouncilField.getText();
                String policeArea = policeAreaField.getText();
                String postalCode = postalCodeField.getText();
                String gsDivision = gsDivisionField.getText();
                String eduZone = eduZoneField.getText();
                String eduDistrict = eduDistrictField.getText();
                String adminDistrict = adminDistrictField.getText();
                String electorate = electorateField.getText();
                String dateOfEstd = dateOfEstdField.getText();
                String schoolID = schoolIDField.getText();
                String schoolCensus = schoolCensusField.getText();
                String schoolExamId = schoolExamIdField.getText();
                String totalLandArea = totalLandAreaField.getText();
                String province = provinceField.getText();
                String nameOfPrincipal = nameOfPrincipalField.getText();
                String pricipalNo = pricipalNoField.getText();


                School sch = new School(SchoolName, SchoolAddress, classAvailable, schoolType, deoDivision, municpalCouncil, policeArea, postalCode, gsDivision, eduZone, eduDistrict, adminDistrict, electorate, dateOfEstd, schoolID, schoolCensus, schoolExamId, totalLandArea, province, nameOfPrincipal, pricipalNo);
                int i = SchoolController.AddDetails(sch);

                if (i > 0) {

                    Alert alert = new Alert(Alert.AlertType.INFORMATION);
                    alert.setTitle("School Information");
                    alert.setHeaderText(null);
                    alert.setContentText("Updated Successfully");
                    alert.showAndWait();

                } else {
                    Alert alert = new Alert(Alert.AlertType.ERROR);
                    alert.setTitle("School Information");
                    alert.setHeaderText(null);
                    alert.setContentText("OOPs there is an error in Updating Details..!");
                    alert.showAndWait();
                }
            }
        } catch (ClassNotFoundException | SQLException ex) {
            Logger.getLogger(StudentController.class.getName()).log(Level.SEVERE, null, ex);
        }

    }

    @FXML
    void printDetails(ActionEvent event) {

        try {
            Connection conn = DBConnection.getDBConnection().getConnection();
            InputStream report = getClass().getResourceAsStream("/sms/Reports/SchoolInfo.jrxml");
            JasperDesign jd = JRXmlLoader.load(report);
            JRDesignQuery query = new JRDesignQuery();
            query.setText("select * from schoolinfo");
            jd.setQuery(query);
            ReportViewController r = new ReportViewController();
            r.viewReport(jd);


        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        } catch (SQLException e) {
            e.printStackTrace();
        } catch (JRException e) {
            e.printStackTrace();
        }

    }

    @FXML
    void updateDetails(ActionEvent event) {
        try {
            String SchoolName = SchoolNameField.getText();
            String SchoolAddress = SchoolAddressField.getText();
            String classAvailable = classAvailableField.getText();
            String schoolType = schoolTypeField.getText();
            String deoDivision = deoDivisionField.getText();
            String municpalCouncil = municpalCouncilField.getText();
            String policeArea = policeAreaField.getText();
            String postalCode = postalCodeField.getText();
            String gsDivision = gsDivisionField.getText();
            String eduZone = eduZoneField.getText();
            String eduDistrict = eduDistrictField.getText();
            String adminDistrict = adminDistrictField.getText();
            String electorate = electorateField.getText();
            String dateOfEstd = dateOfEstdField.getText();
            String schoolID = schoolIDField.getText();
            String schoolCensus = schoolCensusField.getText();
            String schoolExamId = schoolExamIdField.getText();
            String totalLandArea = totalLandAreaField.getText();
            String province = provinceField.getText();
            String nameOfPrincipal = nameOfPrincipalField.getText();
            String pricipalNo = pricipalNoField.getText();

            School sch = new School(SchoolName,SchoolAddress,classAvailable,schoolType,deoDivision,municpalCouncil,policeArea,postalCode,gsDivision,eduZone,eduDistrict,adminDistrict,electorate,dateOfEstd,schoolID,schoolCensus,schoolExamId,totalLandArea,province,nameOfPrincipal,pricipalNo);
            int i = SchoolController.updateInfo(sch);

            if (i > 0) {

                Alert alert = new Alert(Alert.AlertType.INFORMATION);
                alert.setTitle("School Information");
                alert.setHeaderText(null);
                alert.setContentText("Information Updated Successfully...!");
                alert.showAndWait();

            } else {
                Alert alert = new Alert(Alert.AlertType.ERROR);
                alert.setTitle("School Information");
                alert.setHeaderText(null);
                alert.setContentText("OOPs there is an error Updating Details");
                alert.showAndWait();
            }

        }catch (ClassNotFoundException | SQLException ex) {
           Logger.getLogger(SchoolController.class.getName()).log(Level.SEVERE, null, ex);
    }

    }
}


<|start_filename|>out/production/School Management System/sms/view/fxml/css/DashboardCSS.css<|end_filename|>
.jfx-button:hover{
    -fx-background-color: #c62828;
}
.jfx-button{
    -fx-background-image: url("../../../other/img/StudentMgmt.png");
}

<|start_filename|>src/sms/view/controller/PrintStudents2Controller.java<|end_filename|>
package sms.view.controller;

import com.jfoenix.controls.JFXButton;
import com.jfoenix.controls.JFXCheckBox;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
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.ComboBox;
import javafx.scene.control.TableColumn;
import javafx.scene.control.TableView;
import javafx.scene.control.cell.PropertyValueFactory;
import javafx.scene.layout.AnchorPane;
import javafx.stage.Stage;
import net.sf.jasperreports.engine.JRException;
import net.sf.jasperreports.engine.JasperFillManager;
import net.sf.jasperreports.engine.JasperPrint;
import net.sf.jasperreports.engine.JasperReport;
import net.sf.jasperreports.engine.design.JRDesignQuery;
import net.sf.jasperreports.engine.design.JasperDesign;
import net.sf.jasperreports.engine.util.JRLoader;
import net.sf.jasperreports.engine.xml.JRXmlLoader;
import sms.main.StartProject;
import sms.tableModel.StudentTableModel;
import sms.db.DBConnection;
import sms.dbController.GradeController;

import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import java.util.ResourceBundle;

/**
 * @author Safnaj on 8/29/2018
 * @project School Management System
 **/
public class PrintStudents2Controller implements Initializable {


    @FXML
    private TableView<StudentTableModel> studentTable;

    @FXML
    private TableColumn<StudentTableModel, String> adNoColumn;

    @FXML
    private TableColumn<StudentTableModel, String> fullNameColumn;

    @FXML
    private TableColumn<StudentTableModel, String> nameColumn;

    @FXML
    private TableColumn<StudentTableModel, String> dobColumn;

    @FXML
    private TableColumn<StudentTableModel, String> doaColumn;

    @FXML
    private TableColumn<StudentTableModel, String> genderColumn;

    @FXML
    private TableColumn<StudentTableModel, String> gradeColumn;

    @FXML
    private TableColumn<StudentTableModel, String> parentNameColumn;

    @FXML
    private TableColumn<StudentTableModel, String> nicColumn;

    @FXML
    private TableColumn<StudentTableModel, String> contactNoColumn;

    @FXML
    private TableColumn<StudentTableModel, String> addressColumn;

    @FXML
    private ComboBox<String> loadGrades;

    @FXML
    private ComboBox<String> loadYears;

    @FXML
    private ComboBox<String> loadGender;

    @FXML
    private JFXButton generate;

    @FXML
    private JFXButton printStudents;

    @FXML
    private JFXCheckBox adNoCheckBox;

    @FXML
    private JFXCheckBox fullNameCheckBox;

    @FXML
    private JFXCheckBox nameCheckBox;

    @FXML
    private JFXCheckBox dobCheckBox;

    @FXML
    private JFXCheckBox doaCheckBox;

    @FXML
    private JFXCheckBox genderCheckBox;

    @FXML
    private JFXCheckBox parentCheckBox;

    @FXML
    private JFXCheckBox nicCheckBox;

    @FXML
    private JFXCheckBox contactCheckBox;

    @FXML
    private JFXCheckBox addressCheckBox;

    @FXML
    private AnchorPane root;

    @FXML
    private JFXButton userAccount;

    @FXML
    private JFXButton Back;

    ObservableList<StudentTableModel> studentList = FXCollections.observableArrayList();

    @FXML
    void userAccount(ActionEvent event) {
        try {
            AnchorPane studentMgmt = FXMLLoader.load(getClass().getResource(("/sms/view/fxml/UserAccount2.fxml")));
            root.getChildren().setAll(studentMgmt);
        }catch(IOException e){
            System.out.println(e);
        }
    }

    @Override
    public void initialize(URL location, ResourceBundle resources) {
        loadGrades();
        loadYears();
        loadGender.getItems().addAll("All", "Male", "Female");
    }

    @FXML
    void loadGender() {

    }

    @FXML
    void loadGrades() {
        ArrayList arrayList = null;
        try {
            arrayList = GradeController.getGrades();
        } catch (ClassNotFoundException | SQLException e) {
            e.printStackTrace();
        }
        ObservableList observableArray = FXCollections.observableArrayList();
        observableArray.addAll(arrayList);

        if (observableArray != null) {
            loadGrades.setItems(observableArray);
        }
    }


    @FXML
    void loadYears() {
        ArrayList arrayList = null;
        try {
            arrayList = GradeController.getYears();
        } catch (ClassNotFoundException | SQLException e) {
            e.printStackTrace();
        }
        ObservableList observableArray = FXCollections.observableArrayList();
        observableArray.addAll(arrayList);

        if (observableArray != null) {
            loadYears.setItems(observableArray);
        }
    }

    @FXML
    void generate(ActionEvent event) {

        try {
            studentTable.getItems().clear();
            String grade = loadGrades.getValue();
            String gender = loadGender.getValue();
            String year = loadYears.getValue();

            Connection conn = DBConnection.getDBConnection().getConnection();

            // if((loadGrades != null)&&(loadGender != null)){

            if (gender == "All") {

                String sql = "select * from students where grade = '" + grade + "'";
                ResultSet rs = conn.createStatement().executeQuery(sql);

                while (rs.next()) {
                    StudentTableModel s = new StudentTableModel(rs.getInt("adNo"), rs.getString("fullName"), rs.getString("name"),
                            rs.getString("dob"), rs.getString("doa"), rs.getString("gender"), rs.getString("grade"), rs.getString("parentName"),
                            rs.getString("nic"), rs.getString("phone"), rs.getString("address"));
                    studentList.add(s);
                }
            } else {
                String sql2 = "select * from students where grade = '" + grade + "' AND gender = '" + gender + "'";
                ResultSet rs = conn.createStatement().executeQuery(sql2);

                while (rs.next()) {
                    StudentTableModel s = new StudentTableModel(rs.getInt("adNo"), rs.getString("fullName"), rs.getString("name"),
                            rs.getString("dob"), rs.getString("doa"), rs.getString("gender"), rs.getString("grade"), rs.getString("parentName"),
                            rs.getString("nic"), rs.getString("phone"), rs.getString("address"));
                    studentList.add(s);
                }
                //    }
            }
            if (loadGrades != null) {

                // studentTable.getItems().clear();

                if (gender == "All") {
                    String sql = "select * from paststudents where year = '" + year + "'";
                    ResultSet rs = conn.createStatement().executeQuery(sql);

                    while (rs.next()) {
                        StudentTableModel s = new StudentTableModel(rs.getInt("adNo"), rs.getString("fullName"), rs.getString("name"),
                                rs.getString("dob"), rs.getString("doa"), rs.getString("gender"), rs.getString("year"), rs.getString("parentName"),
                                rs.getString("nic"), rs.getString("phone"), rs.getString("address"));
                        studentList.add(s);
                    }
                } else {
                    String sql2 = "select * from paststudents where year = '" + year + "' AND gender = '" + gender + "'";
                    ResultSet rs = conn.createStatement().executeQuery(sql2);

                    while (rs.next()) {
                        StudentTableModel s = new StudentTableModel(rs.getInt("adNo"), rs.getString("fullName"), rs.getString("name"),
                                rs.getString("dob"), rs.getString("doa"), rs.getString("gender"), rs.getString("year"), rs.getString("parentName"),
                                rs.getString("nic"), rs.getString("phone"), rs.getString("address"));
                        studentList.add(s);
                    }
                }
            }
           /* if(adNoCheckBox.isSelected()){
                adNoColumn.setCellValueFactory(new PropertyValueFactory<>("adNo"));
                gradeColumn.setCellValueFactory(new PropertyValueFactory<>("grade"));
                studentTable.setItems(studentList);

            }
            if(fullNameCheckBox.isSelected()){
                fullNameColumn.setCellValueFactory(new PropertyValueFactory<>("fullName"));
                gradeColumn.setCellValueFactory(new PropertyValueFactory<>("grade"));
                studentTable.setItems(studentList);
            }*/

            adNoColumn.setCellValueFactory(new PropertyValueFactory<>("adNo"));
            fullNameColumn.setCellValueFactory(new PropertyValueFactory<>("fullName"));
            nameColumn.setCellValueFactory(new PropertyValueFactory<>("name"));
            dobColumn.setCellValueFactory(new PropertyValueFactory<>("dob"));
            doaColumn.setCellValueFactory(new PropertyValueFactory<>("doa"));
            genderColumn.setCellValueFactory(new PropertyValueFactory<>("gender"));
            gradeColumn.setCellValueFactory(new PropertyValueFactory<>("grade"));
            parentNameColumn.setCellValueFactory(new PropertyValueFactory<>("parentName"));
            nicColumn.setCellValueFactory(new PropertyValueFactory<>("nic"));
            contactNoColumn.setCellValueFactory(new PropertyValueFactory<>("phone"));
            addressColumn.setCellValueFactory(new PropertyValueFactory<>("address"));

            studentTable.setItems(studentList);


        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        } catch (SQLException e) {
            e.printStackTrace();
        }

    }

    @FXML
    void printStudents(ActionEvent event) {

        try {
            studentTable.getItems().clear();
            String grade = loadGrades.getValue();
            String gender = loadGender.getValue();
            String year = loadYears.getValue();

            Connection conn = DBConnection.getDBConnection().getConnection();
            InputStream report1 = getClass().getResourceAsStream("/sms/Reports/StudentList.jrxml");
            InputStream report2 = getClass().getResourceAsStream("/sms/Reports/StudentListGender.jrxml");
            InputStream report3 = getClass().getResourceAsStream("/sms/Reports/PastStudentList.jrxml");
            InputStream report4 = getClass().getResourceAsStream("/sms/Reports/PastStudentListGender.jrxml");

            JRDesignQuery query = new JRDesignQuery();

            if(loadYears.getValue()==null) {

                if (loadGrades != null) {

                    if (gender == "All") {

                        JasperDesign jd = JRXmlLoader.load(report1);
                        query.setText("select * from students where grade = '" + grade + "'");
                        jd.setQuery(query);
                        ReportViewController r = new ReportViewController();
                        r.viewReport(jd);

                /*Connection conn = DBConnection.getDBConnection().getConnection();
                JasperDesign jd = JRXmlLoader.load("src\\sms\\Reports\\StudentList.jrxml");
                JRDesignQuery query = new JRDesignQuery();
                query.setText("select * from students");
                query.setText("select * from students where grade = '"+grade+"'");
                jd.setQuery(query);
                ReportViewController r = new ReportViewController();
                r.viewReport(jd);*/

                    } else {
                        JasperDesign jd2 = JRXmlLoader.load(report2);
                        query.setText("select * from students where grade = '" + grade + "' AND gender = '" + gender + "'");
                        jd2.setQuery(query);
                        ReportViewController r = new ReportViewController();
                        r.viewReport(jd2);
                    }
                }
            }
            if (loadYears.getValue() != null) {

                if (gender == "All") {

                    JasperDesign jd3 = JRXmlLoader.load(report3);
                    query.setText("select * from paststudents where year = '" + year + "'");
                    jd3.setQuery(query);
                    ReportViewController r = new ReportViewController();
                    r.viewReport(jd3);

                } else {

                    JasperDesign jd4 = JRXmlLoader.load(report4);
                    query.setText("select * from paststudents where year = '" + year + "' AND gender = '" + gender + "'");
                    jd4.setQuery(query);
                    ReportViewController r = new ReportViewController();
                    r.viewReport(jd4);
                }
            }

        }catch (ClassNotFoundException e) {
            e.printStackTrace();
        } catch (SQLException e) {
            e.printStackTrace();
        } catch (JRException e) {
            e.printStackTrace();
        }

    }
}



<|start_filename|>src/sms/dbController/StudentController.java<|end_filename|>
package sms.dbController;

import javafx.scene.control.Alert;
import sms.model.Student;
import sms.db.DBConnection;

import java.sql.*;
import java.util.ArrayList;

/**
 * @author Safnaj on 8/25/2018
 * @project School Management System
 **/
public class StudentController {

    public static int AddStudent(Student student)throws ClassNotFoundException,SQLException {
        String SQL="INSERT INTO students VALUES(?,?,?,?,?,?,?,?,?,?,?)";
        Connection conn = DBConnection.getDBConnection().getConnection();
        PreparedStatement stm = conn.prepareStatement(SQL);
        stm.setObject(1, student.getAdNo());
        stm.setObject(2, student.getFullName());
        stm.setObject(3, student.getName());
        stm.setObject(4, student.getDob());
        stm.setObject(5, student.getDoa());
        stm.setObject(6, student.getGender());
        stm.setObject(7, student.getGrade());
        stm.setObject(8, student.getParentName());
        stm.setObject(9, student.getNic());
        stm.setObject(10, student.getPhone());
        stm.setObject(11, student.getAddress());

        return  stm.executeUpdate();
    }
    public static Student searchStudent(Integer adNo) throws ClassNotFoundException, SQLException {
        String sql = "SELECT * FROM students WHERE adNo = ? ";
        Connection conn = DBConnection.getDBConnection().getConnection();
        PreparedStatement stm = conn.prepareStatement(sql);
        stm.setObject(1, adNo);
        ResultSet rst=stm.executeQuery();
        if(rst.next()){
            Student s=new Student(rst.getInt(1),rst.getString(2),rst.getString(3), rst.getString(4), rst.getString(5), rst.getString(6), rst.getString(7), rst.getString(8), rst.getString(9), rst.getString(10), rst.getString(11));
            return s;
        }
        return null;
    }

    public static Student searchPastStudent(Integer adNo) throws ClassNotFoundException, SQLException {
        String sql = "SELECT * FROM leftstudents WHERE adNo = ? ";
        Connection conn = DBConnection.getDBConnection().getConnection();
        PreparedStatement stm = conn.prepareStatement(sql);
        stm.setObject(1, adNo);
        ResultSet rst=stm.executeQuery();
        if(rst.next()){
            Student s=new Student(rst.getInt(1),rst.getString(2),rst.getString(3), rst.getString(4), rst.getString(5), rst.getString(6), rst.getString(7), rst.getString(8), rst.getString(9), rst.getString(10), rst.getString(11));
            return s;
        }
        return null;
    }

    public static int deleteStudent(String adNo) throws ClassNotFoundException, SQLException {

        String sql = "DELETE FROM Students WHERE adNo ='"+adNo+"'";
        Connection conn = DBConnection.getDBConnection().getConnection();
        PreparedStatement stm = conn.prepareStatement(sql);


        return  stm.executeUpdate();
    }

    public static int deleteLeftStudent(String adNo) throws ClassNotFoundException, SQLException {

        String sql = "DELETE FROM leftstudents WHERE adNo ='"+adNo+"'";
        Connection conn = DBConnection.getDBConnection().getConnection();
        PreparedStatement stm = conn.prepareStatement(sql);


        return  stm.executeUpdate();
    }

    public static int moveStudent(Student student)throws ClassNotFoundException,SQLException {
        String SQL="INSERT INTO leftstudents VALUES(?,?,?,?,?,?,?,?,?,?,?)";
        Connection conn = DBConnection.getDBConnection().getConnection();
        PreparedStatement stm = conn.prepareStatement(SQL);
        stm.setObject(1, student.getAdNo());
        stm.setObject(2, student.getFullName());
        stm.setObject(3, student.getName());
        stm.setObject(4, student.getDob());
        stm.setObject(5, student.getDoa());
        stm.setObject(6, student.getGender());
        stm.setObject(7, student.getGrade());
        stm.setObject(8, student.getParentName());
        stm.setObject(9, student.getNic());
        stm.setObject(10, student.getPhone());
        stm.setObject(11, student.getAddress());

        return  stm.executeUpdate();
    }

    public static int updateStudent(Student student) throws ClassNotFoundException, SQLException {
        String sql = "UPDATE students SET adNo= ? ,fullName= ? ,name= ? ,dob= ? ,doa= ? ,gender= ? ,grade=? ,parentName= ? ,nic= ? ,phone= ? ,address=? WHERE adNo= '" +student.getAdNo()+ "'";
        Connection conn = DBConnection.getDBConnection().getConnection();
        PreparedStatement stm = conn.prepareStatement(sql);
        stm.setObject(1, student.getAdNo());
        stm.setObject(2, student.getFullName());
        stm.setObject(3, student.getName());
        stm.setObject(4, student.getDob());
        stm.setObject(5,student.getDoa());
        stm.setObject(6,student.getGender());
        stm.setObject(7,student.getGrade());
        stm.setObject(8,student.getParentName());
        stm.setObject(9,student.getNic());
        stm.setObject(10,student.getPhone());
        stm.setObject(11,student.getAddress());

        return  stm.executeUpdate();
    }

    public static int updateLeftStudent(Student student) throws ClassNotFoundException, SQLException {
        String sql = "UPDATE leftstudents SET adNo= ? ,fullName= ? ,name= ? ,dob= ? ,doa= ? ,gender= ? ,grade=? ,parentName= ? ,nic= ? ,phone= ? ,address=? WHERE adNo= '" +student.getAdNo()+ "'";
        Connection conn = DBConnection.getDBConnection().getConnection();
        PreparedStatement stm = conn.prepareStatement(sql);
        stm.setObject(1, student.getAdNo());
        stm.setObject(2, student.getFullName());
        stm.setObject(3, student.getName());
        stm.setObject(4, student.getDob());
        stm.setObject(5,student.getDoa());
        stm.setObject(6,student.getGender());
        stm.setObject(7,student.getGrade());
        stm.setObject(8,student.getParentName());
        stm.setObject(9,student.getNic());
        stm.setObject(10,student.getPhone());
        stm.setObject(11,student.getAddress());

        return  stm.executeUpdate();
    }


}


<|start_filename|>src/sms/tableModel/StaffTableModel.java<|end_filename|>
package sms.tableModel;

/**
 * @author Safnaj on 11/3/2018
 * @project School Management System
 **/
public class StaffTableModel {

    int empNo;
    String teacherName;
    String nic;
    String dob;
    String doa;
    String gender;
    String email;
    String assumpOfDuties;
    String phone;
    String address;
    String incDate;
    String prsntGrade;

    public StaffTableModel(int empNo, String teacherName, String nic, String dob, String doa, String gender, String email, String assumpOfDuties, String phone, String address, String incDate, String prsntGrade) {
        this.empNo = empNo;
        this.teacherName = teacherName;
        this.nic = nic;
        this.dob = dob;
        this.doa = doa;
        this.gender = gender;
        this.email = email;
        this.assumpOfDuties = assumpOfDuties;
        this.phone = phone;
        this.address = address;
        this.incDate = incDate;
        this.prsntGrade = prsntGrade;
    }

    public int getEmpNo() {
        return empNo;
    }

    public void setEmpNo(int empNo) {
        this.empNo = empNo;
    }

    public String getTeacherName() {
        return teacherName;
    }

    public void setTeacherName(String teacherName) {
        this.teacherName = teacherName;
    }

    public String getNic() {
        return nic;
    }

    public void setNic(String nic) {
        this.nic = nic;
    }

    public String getDob() {
        return dob;
    }

    public void setDob(String dob) {
        this.dob = dob;
    }

    public String getDoa() {
        return doa;
    }

    public void setDoa(String doa) {
        this.doa = doa;
    }

    public String getGender() {
        return gender;
    }

    public void setGender(String gender) {
        this.gender = gender;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public String getAssumpOfDuties() {
        return assumpOfDuties;
    }

    public void setAssumpOfDuties(String assumpOfDuties) {
        this.assumpOfDuties = assumpOfDuties;
    }

    public String getPhone() {
        return phone;
    }

    public void setPhone(String phone) {
        this.phone = phone;
    }

    public String getAddress() {
        return address;
    }

    public void setAddress(String address) {
        this.address = address;
    }

    public String getIncDate() {
        return incDate;
    }

    public void setIncDate(String incDate) {
        this.incDate = incDate;
    }

    public String getPrsntGrade() {
        return prsntGrade;
    }

    public void setPrsntGrade(String prsntGrade) {
        this.prsntGrade = prsntGrade;
    }
}


<|start_filename|>src/sms/dbController/GradeController.java<|end_filename|>
package sms.dbController;

import com.mysql.jdbc.PreparedStatement;
import sms.db.DBConnection;
import sms.model.Grade;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;


/**
 * @author Safnaj on 8/29/2018
 * @project School Management System
 **/
public class GradeController {

    public static ArrayList<String> getGrades() throws ClassNotFoundException, SQLException{
        Connection conn=DBConnection.getDBConnection().getConnection();
        Statement stm=conn.createStatement();
        ResultSet rst=stm.executeQuery("Select grade From grades");

        ArrayList<String>gradeList=new ArrayList<>();
        while(rst.next()){
            //Grade grade;
            //grade = new Grade(rst.getString("grade"));
            gradeList.add(rst.getString("grade"));
        }
        return gradeList;
    }

    public static ArrayList<String> getYears() throws ClassNotFoundException, SQLException{
        Connection conn=DBConnection.getDBConnection().getConnection();
        Statement stm=conn.createStatement();
        ResultSet rst=stm.executeQuery("Select distinct year from paststudents");

        ArrayList<String>yearlist=new ArrayList<>();
        while(rst.next()){
            yearlist.add(rst.getString("year"));
        }
        return yearlist;
    }

}


<|start_filename|>src/sms/model/Grade.java<|end_filename|>
package sms.model;

/**
 * @author Safnaj on 8/29/2018
 * @project School Management System
 **/
public class Grade {

    private int gradeID;
    private String grade;
    private int noOfStudents;

    public Grade(String grade) {
        this.grade = grade;
    }

    public Grade(int graddeID, String grade, int noOfStudents) {
        this.gradeID = graddeID;
        this.grade = grade;
        this.noOfStudents = noOfStudents;
    }

    public int getGraddeID() {

        return gradeID;
    }

    public void setGraddeID(int graddeID)
    {
        this.gradeID = graddeID;
    }

    public String getGrade() {

        return grade;
    }

    public void setGrade(String grade)
    {
        this.grade = grade;
    }

    public int getNoOfStudents() {

        return noOfStudents;
    }

    public void setNoOfStudents(int noOfStudents)
    {
        this.noOfStudents = noOfStudents;
    }
}


<|start_filename|>src/sms/dbController/SchoolController.java<|end_filename|>
package sms.dbController;

import sms.db.DBConnection;
import sms.model.School;
import sms.model.Student;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

/**
 * @author Safnaj on 8/26/2018
 * @project School Management System
 **/
public class SchoolController {

    public static School schoolInfo() throws ClassNotFoundException, SQLException {
        String sql = "SELECT * FROM schoolinfo";
        Connection conn = DBConnection.getDBConnection().getConnection();
        PreparedStatement stm = conn.prepareStatement(sql);
        ResultSet rst=stm.executeQuery();
        if(rst.next()){
            School s=new School(rst.getString("SchoolName"),rst.getString("SchoolAddress"),rst.getString("classAvailable"),
                    rst.getString("schoolType"), rst.getString("deoDivision"), rst.getString("municpalCouncil"), rst.getString("policeArea"),
                    rst.getString("postalCode"), rst.getString("gsDivision"), rst.getString("eduZone"), rst.getString("eduDistrict"),
                    rst.getString("adminDistrict"), rst.getString("electorate"), rst.getString("dateOfEstd"), rst.getString("schoolID"),
                    rst.getString("schoolCensus"), rst.getString("schoolExamId"), rst.getString("totalLandArea"), rst.getString("province"),
                    rst.getString("nameOfPrincipal"), rst.getString("pricipalNo"));

            return s;
        }
        return null;
    }

    public static int AddDetails(School school)throws ClassNotFoundException,SQLException {
        String SQL="INSERT INTO schoolinfo VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
        Connection conn = DBConnection.getDBConnection().getConnection();
        PreparedStatement stm = conn.prepareStatement(SQL);
        stm.setObject(1, school.getSchoolName());
        stm.setObject(2, school.getSchoolAddress());
        stm.setObject(3, school.getClassAvailable());
        stm.setObject(4, school.getSchoolType());
        stm.setObject(5, school.getDeoDivision());
        stm.setObject(6, school.getMunicpalCouncil());
        stm.setObject(7, school.getPoliceArea());
        stm.setObject(8, school.getPostalCode());
        stm.setObject(9, school.getGsDivision());
        stm.setObject(10, school.getEduZone());
        stm.setObject(11, school.getEduDistrict());
        stm.setObject(12, school.getAdminDistrict());
        stm.setObject(13, school.getElectorate());
        stm.setObject(14, school.getDateOfEstd());
        stm.setObject(15, school.getSchoolID());
        stm.setObject(16, school.getSchoolCensus());
        stm.setObject(17, school.getSchoolExamId());
        stm.setObject(18, school.getTotalLandArea());
        stm.setObject(19, school.getProvince());
        stm.setObject(20, school.getNameOfPrincipal());
        stm.setObject(21, school.getPricipalNo());


        return  stm.executeUpdate();
    }

    public static int updateInfo(School school) throws ClassNotFoundException, SQLException {
        String sql = "UPDATE schoolinfo SET SchoolName= ? ,SchoolAddress= ? ,classAvailable= ? ,schoolType= ? ,deoDivision= ? ,municpalCouncil= ? ,policeArea=? ,postalCode= ? " +
                ",gsDivision= ? ,eduZone= ? ,eduDistrict=? ,adminDistrict=? ,electorate=? ,dateOfEstd=? ,schoolID=? ,schoolCensus=? ,schoolExamId=? ,totalLandArea=? ,province=?" +
                ",nameOfPrincipal=? , pricipalNo=? ";
        Connection conn = DBConnection.getDBConnection().getConnection();
        PreparedStatement stm = conn.prepareStatement(sql);
        stm.setObject(1, school.getSchoolName());
        stm.setObject(2, school.getSchoolAddress());
        stm.setObject(3, school.getClassAvailable());
        stm.setObject(4, school.getSchoolType());
        stm.setObject(5, school.getDeoDivision());
        stm.setObject(6, school.getMunicpalCouncil());
        stm.setObject(7, school.getPoliceArea());
        stm.setObject(8, school.getPostalCode());
        stm.setObject(9, school.getGsDivision());
        stm.setObject(10,school.getEduZone());
        stm.setObject(11,school.getEduDistrict());
        stm.setObject(12, school.getAdminDistrict());
        stm.setObject(13, school.getElectorate());
        stm.setObject(14, school.getDateOfEstd());
        stm.setObject(15, school.getSchoolID());
        stm.setObject(16, school.getSchoolCensus());
        stm.setObject(17, school.getSchoolExamId());
        stm.setObject(18, school.getTotalLandArea());
        stm.setObject(19, school.getProvince());
        stm.setObject(20, school.getNameOfPrincipal());
        stm.setObject(21, school.getPricipalNo());


        return  stm.executeUpdate();
    }
}
