Skip to content

Leave Setting(Employee Payroll Project) Update Leave Setting

March 13, 2013
The following given source codes is used in payroll management project to manage the leave setting of a company for all employee. By using it we can update the leaves if company changes the policy of leaves after one or more year.

package leave;

import Validations.Validation;
import database.ConnectionSetting;
import java.sql.*;
import javax.swing.*;
import java.awt.event.*;
import java.awt.*;
public class LeaveSetting extends JInternalFrame implements ActionListener, ItemListener
{
    /*Declaring Object Name of all Components*/
    JLabel Leavelbl, Januarylbl, Februarylbl, Marchlbl, Aprillbl, Maylbl, Junelbl, Julylbl, Augustlbl, Septemberlbl, Octoberlbl, Novemberlbl, Decemberlbl, headinglbl,oplbl;
    JTextField JanuaryTF, FebruaryTF, MarchTF, AprilTF, MayTF, JuneTF, JulyTF, AugustTF, SeptemberTF, OctoberTF, NovemberTF, DecemberTF;
    JComboBox leavetype;
    JButton CancelBtn, updateBtn;
    JPanel head, MainPanel;
        Connection con= null;
    public LeaveSetting()
    {      
                /*Creating Connection between Back End and Front End*/
        try
        {
            ConnectionSetting conn = new ConnectionSetting();
            con = conn.getConnection();
        }
        catch(Exception e)
        {
            JOptionPane.showMessageDialog(this,e,”DataSource Error”,1);
        }
            /*Declaring Properties of Frame*/
        this.setTitle(“Leave Setting”);
        this.setResizable(true);
        this.setFrameIcon(new ImageIcon(“Images/leave.jpg”));
        this.setLocation(0,25);
        this.setSize(1010,685);
        this.setClosable(true);
        this.setVisible(true);
        this.setLayout(null);

            /*Initializing all Panels*/           
        head = new JPanel();
        MainPanel = new JPanel();
       
            /*Initializing all Labels*/       
        headinglbl = new JLabel(“Pay System”);
        oplbl = new JLabel(“Leave Setting”);
            /*Initializing all Buttons*/
        CancelBtn = new JButton(“Cancel”);
        updateBtn = new JButton(“Update”);
            /*Initializing all TextFields, Radio Button and TextArea and adding on MainPanel*/
        MainPanel.add(leavetype = new JComboBox());
                MainPanel.add(Januarylbl = new JLabel(“January”));
        MainPanel.add(Februarylbl = new JLabel(“February”));
        MainPanel.add(Marchlbl = new JLabel(“March”));
        MainPanel.add(Aprillbl = new JLabel(“April”));
        MainPanel.add(Maylbl = new JLabel(“May”));
        MainPanel.add(Junelbl = new JLabel(“June”));
        MainPanel.add(Julylbl = new JLabel(“July”));
        MainPanel.add(Augustlbl = new JLabel(“August”));
        MainPanel.add(Septemberlbl = new JLabel(“September”));
        MainPanel.add(Octoberlbl = new JLabel(“October”));
        MainPanel.add(Novemberlbl = new JLabel(“November”));
        MainPanel.add(Decemberlbl = new JLabel(“December”));
        MainPanel.add(Leavelbl = new JLabel(“Leave Type”));
            /*Adding items in LeaveTypd combobox*/
        leavetype.addItem(“Select Any”);
                leavetype.addItem(“Absent”);
                leavetype.addItem(“Sickness”);
                leavetype.addItem(“Casual”);
                leavetype.addItem(“Break”);
                    /*Adding TextFiels on MainPanel*/
        MainPanel.add(JanuaryTF = new JTextField());
        MainPanel.add(FebruaryTF = new JTextField());
        MainPanel.add(MarchTF = new JTextField());
        MainPanel.add(AprilTF = new JTextField());
        MainPanel.add(MayTF = new JTextField());
        MainPanel.add(JuneTF = new JTextField());
        MainPanel.add(JulyTF = new JTextField());
        MainPanel.add(AugustTF = new JTextField());
        MainPanel.add(SeptemberTF = new JTextField());
        MainPanel.add(OctoberTF = new JTextField());
        MainPanel.add(NovemberTF = new JTextField());
        MainPanel.add(DecemberTF = new JTextField());
            /*Specifying size and location of Combobox and labels*/
        Leavelbl.setBounds(375,50,100,20);
        leavetype.setBounds(475,50,100,20);
        Januarylbl.setBounds(250,120,100,20);
        Februarylbl.setBounds(250,170,100,20);
        Marchlbl.setBounds(250,220,100,20);
        Aprillbl.setBounds(250,270,100,20);
        Maylbl.setBounds(250,320,100,20);
        Junelbl.setBounds(250,370,100,20);
        Julylbl.setBounds(570,120,100,20);
        Augustlbl.setBounds(570,170,100,20);
        Septemberlbl.setBounds(570,220,100,20);
        Octoberlbl.setBounds(570,270,100,20);
        Novemberlbl.setBounds(570,320,100,20);
        Decemberlbl.setBounds(570,370,100,20);
            /*Specifying size and location of All TexBoxes*/
        JanuaryTF.setBounds(350,120,50,25);
        FebruaryTF.setBounds(350,170,50,25);
        MarchTF.setBounds(350,220,50,25);
        AprilTF.setBounds(350,270,50,25);
        MayTF.setBounds(350,320,50,25);
        JuneTF.setBounds(350,370,50,25);
        JulyTF.setBounds(670,120,50,25);
        AugustTF.setBounds(670,170,50,25);
        SeptemberTF.setBounds(670,220,50,25);
        OctoberTF.setBounds(670,270,50,25);
        NovemberTF.setBounds(670,320,50,25);
        DecemberTF.setBounds(670,370,50,25);
            /*setting size of panels*/       
        head.setBounds(5,5,990,100);
        MainPanel.setBounds(5,110,990,500);
        MainPanel.setBorder(BorderFactory.createLineBorder(Color.RED));
            /*Setting size of all Labels*/
        headinglbl.setBounds(350,20,300,40);
        oplbl.setBounds(400,60,300,40);
            /*Setting size of all buttons*/
        CancelBtn.setBounds(600,615,80,25);
        updateBtn.setBounds(350,615,80,25);
            /*Setting Background Color of Panels*/
        head.setBackground(Color.LIGHT_GRAY);
        MainPanel.setBackground(Color.CYAN);
            /*Adding Heading label on head panel*/
        head.add(headinglbl);
        head.add(oplbl);
            /*Setting null layout of panels*/
        head.setLayout(null);
        MainPanel.setLayout(null);
            /*adding all panels on Frame*/
        this.add(head);
        this.add(MainPanel);       
        this.add(updateBtn);
        this.add(CancelBtn);
            /*Specifying Font Type for Heading Labels and there heights*/       
        headinglbl.setFont(new Font(“Algerian”,Font.BOLD,40));
        oplbl.setFont(new Font(“Castellar”,Font.PLAIN,20));
            /*Specifying or Performing actions on Buttons Spefified    */
        CancelBtn.addActionListener(this);
        updateBtn.addActionListener(this);
        leavetype.addItemListener(this);
    }
    /*Specifying or Performing actions on Buttons Spefified    */
    public void actionPerformed(ActionEvent ae)
    {
        /*Getting Source which Button is Pressed or Clicked*/
        Object ob = ae.getSource();
        /*Performing Close Operation on JInternalFrame when
        Cancel Button is Clicked or Pressed and Released*/
        if(ob == CancelBtn)
        {
            this.dispose();
        }
        /*Performing Open Dialog Box Operation when Upload
        Button is clicked or Pressed and Released*/
        if(ob == updateBtn)
        {
           
            /*here a valid object is created to get the methods defined in
            Validation class to validate the Date, String and Number Fields*/
            Validation valid = new Validation();
            /*Validating all fields here*/
            if(leavetype.getSelectedItem().equals(“Select Any”))
                JOptionPane.showMessageDialog(this,”Please Select Any Leave Type.”,”Not Selected”,1);
                        else if(JanuaryTF.getText().length()<=0)
                JOptionPane.showMessageDialog(this,”January Field Required”,”Empty Field Found”,1);
                        else if(valid.isValidNumber(JanuaryTF.getText()))
                JOptionPane.showMessageDialog(this,”January Field Must Be In Numeric!\nSpecial Characters (!,\\/. Etc) Are Not Allowed.”,”Empty Field Found”,1);
                 else if(FebruaryTF.getText().length()<=0)
                JOptionPane.showMessageDialog(this,”February Field Required”,”Empty Field Found”,1);
                        else if(valid.isValidNumber(FebruaryTF.getText()))
                JOptionPane.showMessageDialog(this,”February Field Must Be In Numeric!\nSpecial Characters (!,\\/. Etc) Are Not Allowed.”,”Empty Field Found”,1);
                        else if(MarchTF.getText().length()<=0)
                JOptionPane.showMessageDialog(this,”March Field Required”,”Empty Field Found”,1);
                        else if(valid.isValidNumber(MarchTF.getText()))
                JOptionPane.showMessageDialog(this,”March Field Must Be In Numeric!\nSpecial Characters (!,\\/. Etc) Are Not Allowed.”,”Empty Field Found”,1);
                             else if(AprilTF.getText().length()<=0)
                JOptionPane.showMessageDialog(this,”April Field Required”,”Empty Field Found”,1);
                        else if(valid.isValidNumber(AprilTF.getText()))
                JOptionPane.showMessageDialog(this,”April Field Must Be In Numeric!\nSpecial Characters (!,\\/. Etc) Are Not Allowed.”,”Empty Field Found”,1);
                           else if(MayTF.getText().length()<=0)
                JOptionPane.showMessageDialog(this,”May Field Required”,”Empty Field Found”,1);
                        else if(valid.isValidNumber(MayTF.getText()))
                JOptionPane.showMessageDialog(this,”May Field Must Be In Numeric!\nSpecial Characters (!,\\/. Etc) Are Not Allowed.”,”Empty Field Found”,1);
                else if(JuneTF.getText().length()<=0)
                JOptionPane.showMessageDialog(this,”June Field Required”,”Empty Field Found”,1);
                        else if(valid.isValidNumber(JuneTF.getText()))
                JOptionPane.showMessageDialog(this,”June Field Must Be In Numeric!\nSpecial Characters (!,\\/. Etc) Are Not Allowed.”,”Empty Field Found”,1);
                    else if(JulyTF.getText().length()<=0)
                JOptionPane.showMessageDialog(this,”July Field Required”,”Empty Field Found”,1);
                        else if(valid.isValidNumber(JulyTF.getText()))
                JOptionPane.showMessageDialog(this,”July Field Must Be In Numeric!\nSpecial Characters (!,\\/. Etc) Are Not Allowed.”,”Empty Field Found”,1);
                    else if(AugustTF.getText().length()<=0)
                JOptionPane.showMessageDialog(this,”August Field Required”,”Empty Field Found”,1);
                        else if(valid.isValidNumber(AugustTF.getText()))
                JOptionPane.showMessageDialog(this,”August Field Must Be In Numeric!\nSpecial Characters (!,\\/. Etc) Are Not Allowed.”,”Empty Field Found”,1);
                    else if(SeptemberTF.getText().length()<=0)
                JOptionPane.showMessageDialog(this,”September Field Required”,”Empty Field Found”,1);
                        else if(valid.isValidNumber(SeptemberTF.getText()))
                JOptionPane.showMessageDialog(this,”September Field Must Be In Numeric!\nSpecial Characters (!,\\/. Etc) Are Not Allowed.”,”Empty Field Found”,1);
            else if(OctoberTF.getText().length()<=0)
                JOptionPane.showMessageDialog(this,”October Field Required”,”Empty Field Found”,1);
                        else if(valid.isValidNumber(OctoberTF.getText()))
                JOptionPane.showMessageDialog(this,”October Field Must Be In Numeric!\nSpecial Characters (!,\\/. Etc) Are Not Allowed.”,”Empty Field Found”,1);
                    else if(NovemberTF.getText().length()<=0)
                JOptionPane.showMessageDialog(this,”November Field Required”,”Empty Field Found”,1);
                        else if(valid.isValidNumber(NovemberTF.getText()))
                JOptionPane.showMessageDialog(this,”November Field Must Be In Numeric!\nSpecial Characters (!,\\/. Etc) Are Not Allowed.”,”Empty Field Found”,1);
                    else if(DecemberTF.getText().length()<=0)
                JOptionPane.showMessageDialog(this,”December Field Required”,”Empty Field Found”,1);
                        else if(valid.isValidNumber(DecemberTF.getText()))
                JOptionPane.showMessageDialog(this,”December Field Must Be In Numeric!\nSpecial Characters (!,\\/. Etc) Are Not Allowed.”,”Empty Field Found”,1);
            else if(leavetype.getSelectedItem().equals(“Select Any”))
                JOptionPane.showMessageDialog(this,”Please Select Leave Type”,”Empty Field Found”,1);
            /*Validation ended here*/
            else
            {
                try
                {
                    /*Creating Connection between Back End and Front End*/
                                        /*Update Leave Entry Table here…*/                           
                    PreparedStatement ps = con.prepareStatement(“update LeaveEntry_Table set Jan_Absent=?,Feb_Absent=?,Mar_Absent=?,Apr_Absent=?,May_Absent=?,Jun_Absent=?,Jul_Absent=?,Aug_Absent=?,Sep_Absent=?,Oct_Absent=?,Nov_Absent=?,Dec_Absent=? where Leave_Type = ?”);
                   
                                ps.setInt(1,Integer.parseInt(JanuaryTF.getText()));
                                   ps.setInt(2,Integer.parseInt(FebruaryTF.getText()));
                                ps.setInt(3,Integer.parseInt(MarchTF.getText()));
                                   ps.setInt(4,Integer.parseInt(AprilTF.getText()));
                                   ps.setInt(5,Integer.parseInt(MayTF.getText()));
                            ps.setInt(6,Integer.parseInt(JuneTF.getText()));
                                ps.setInt(7,Integer.parseInt(JulyTF.getText()));
                                ps.setInt(8,Integer.parseInt(AugustTF.getText()));
                                ps.setInt(9,Integer.parseInt(SeptemberTF.getText()));
                        ps.setInt(10,Integer.parseInt(OctoberTF.getText()));
                                ps.setInt(11,Integer.parseInt(NovemberTF.getText()));
                                ps.setInt(12,Integer.parseInt(DecemberTF.getText()));
                    ps.setString(13,String.valueOf(leavetype.getSelectedItem()));
                    ps.executeUpdate();
   
                            ps = con.prepareStatement(“update AbsentLeave_Table set Jan_Absent=?,Feb_Absent=?,Mar_Absent=?,Apr_Absent=?,May_Absent=?,Jun_Absent=?,Jul_Absent=?,Aug_Absent=?,Sep_Absent=?,Oct_Absent=?,Nov_Absent=?,Dec_Absent=?,Total=?”);
               
                                ps.setInt(1,Integer.parseInt(JanuaryTF.getText()));
                                   ps.setInt(2,Integer.parseInt(FebruaryTF.getText()));
                                ps.setInt(3,Integer.parseInt(MarchTF.getText()));
                                   ps.setInt(4,Integer.parseInt(AprilTF.getText()));
                                   ps.setInt(5,Integer.parseInt(MayTF.getText()));
                            ps.setInt(6,Integer.parseInt(JuneTF.getText()));
                                ps.setInt(7,Integer.parseInt(JulyTF.getText()));
                                ps.setInt(8,Integer.parseInt(AugustTF.getText()));
                                ps.setInt(9,Integer.parseInt(SeptemberTF.getText()));
                        ps.setInt(10,Integer.parseInt(OctoberTF.getText()));
                                ps.setInt(11,Integer.parseInt(NovemberTF.getText()));
                                ps.setInt(12,Integer.parseInt(DecemberTF.getText()));
                    ps.setInt(13,Integer.parseInt(JanuaryTF.getText())+
                                Integer.parseInt(FebruaryTF.getText())+
                                Integer.parseInt(MarchTF.getText())+
                                Integer.parseInt(AprilTF.getText())+
                                Integer.parseInt(MayTF.getText())+
                            Integer.parseInt(JuneTF.getText())+
                                Integer.parseInt(JulyTF.getText())+
                                Integer.parseInt(AugustTF.getText())+
                            Integer.parseInt(SeptemberTF.getText())+
                                Integer.parseInt(OctoberTF.getText())+
                                Integer.parseInt(NovemberTF.getText())+
                                Integer.parseInt(DecemberTF.getText()));
                    ps.executeUpdate();

                            ps = con.prepareStatement(“update BreakLeave_Table set Jan_Absent=?,Feb_Absent=?,Mar_Absent=?,Apr_Absent=?,May_Absent=?,Jun_Absent=?,Jul_Absent=?,Aug_Absent=?,Sep_Absent=?,Oct_Absent=?,Nov_Absent=?,Dec_Absent=?,Total=?”);
               
                                ps.setInt(1,Integer.parseInt(JanuaryTF.getText()));
                                   ps.setInt(2,Integer.parseInt(FebruaryTF.getText()));
                                ps.setInt(3,Integer.parseInt(MarchTF.getText()));
                                   ps.setInt(4,Integer.parseInt(AprilTF.getText()));
                                   ps.setInt(5,Integer.parseInt(MayTF.getText()));
                            ps.setInt(6,Integer.parseInt(JuneTF.getText()));
                                ps.setInt(7,Integer.parseInt(JulyTF.getText()));
                                ps.setInt(8,Integer.parseInt(AugustTF.getText()));
                                ps.setInt(9,Integer.parseInt(SeptemberTF.getText()));
                        ps.setInt(10,Integer.parseInt(OctoberTF.getText()));
                                ps.setInt(11,Integer.parseInt(NovemberTF.getText()));
                                ps.setInt(12,Integer.parseInt(DecemberTF.getText()));
                    ps.setInt(13,Integer.parseInt(JanuaryTF.getText())+
                                Integer.parseInt(FebruaryTF.getText())+
                                   Integer.parseInt(MarchTF.getText())+
                                Integer.parseInt(AprilTF.getText())+
                                Integer.parseInt(MayTF.getText())+
                            Integer.parseInt(JuneTF.getText())+
                                Integer.parseInt(JulyTF.getText())+
                                Integer.parseInt(AugustTF.getText())+
                            Integer.parseInt(SeptemberTF.getText())+
                                Integer.parseInt(OctoberTF.getText())+
                                Integer.parseInt(NovemberTF.getText())+
                                Integer.parseInt(DecemberTF.getText()));
                    ps.executeUpdate();

                            ps = con.prepareStatement(“update CausalLeave_Table set Jan_Absent=?,Feb_Absent=?,Mar_Absent=?,Apr_Absent=?,May_Absent=?,Jun_Absent=?,Jul_Absent=?,Aug_Absent=?,Sep_Absent=?,Oct_Absent=?,Nov_Absent=?,Dec_Absent=?,Total=?”);
               
                                ps.setInt(1,Integer.parseInt(JanuaryTF.getText()));
                                   ps.setInt(2,Integer.parseInt(FebruaryTF.getText()));
                                ps.setInt(3,Integer.parseInt(MarchTF.getText()));
                                   ps.setInt(4,Integer.parseInt(AprilTF.getText()));
                                   ps.setInt(5,Integer.parseInt(MayTF.getText()));
                            ps.setInt(6,Integer.parseInt(JuneTF.getText()));
                                ps.setInt(7,Integer.parseInt(JulyTF.getText()));
                                ps.setInt(8,Integer.parseInt(AugustTF.getText()));
                                ps.setInt(9,Integer.parseInt(SeptemberTF.getText()));
                        ps.setInt(10,Integer.parseInt(OctoberTF.getText()));
                                ps.setInt(11,Integer.parseInt(NovemberTF.getText()));
                                ps.setInt(12,Integer.parseInt(DecemberTF.getText()));
                    ps.setInt(13,Integer.parseInt(JanuaryTF.getText())+
                            Integer.parseInt(FebruaryTF.getText())+
                                Integer.parseInt(MarchTF.getText())+
                                Integer.parseInt(AprilTF.getText())+
                                Integer.parseInt(MayTF.getText())+
                            Integer.parseInt(JuneTF.getText())+
                                Integer.parseInt(JulyTF.getText())+
                                Integer.parseInt(AugustTF.getText())+
                            Integer.parseInt(SeptemberTF.getText())+
                                Integer.parseInt(OctoberTF.getText())+
                                Integer.parseInt(NovemberTF.getText())+
                                Integer.parseInt(DecemberTF.getText()));
                    ps.executeUpdate();

                            ps = con.prepareStatement(“update SicknessLeave_Table set Jan_Absent=?,Feb_Absent=?,Mar_Absent=?,Apr_Absent=?,May_Absent=?,Jun_Absent=?,Jul_Absent=?,Aug_Absent=?,Sep_Absent=?,Oct_Absent=?,Nov_Absent=?,Dec_Absent=?,Total=?”);
               
                                ps.setInt(1,Integer.parseInt(JanuaryTF.getText()));
                                   ps.setInt(2,Integer.parseInt(FebruaryTF.getText()));
                                ps.setInt(3,Integer.parseInt(MarchTF.getText()));
                                   ps.setInt(4,Integer.parseInt(AprilTF.getText()));
                              ps.setInt(5,Integer.parseInt(MayTF.getText()));
                            ps.setInt(6,Integer.parseInt(JuneTF.getText()));
                                ps.setInt(7,Integer.parseInt(JulyTF.getText()));
                                ps.setInt(8,Integer.parseInt(AugustTF.getText()));
                                ps.setInt(9,Integer.parseInt(SeptemberTF.getText()));
                        ps.setInt(10,Integer.parseInt(OctoberTF.getText()));
                                ps.setInt(11,Integer.parseInt(NovemberTF.getText()));
                                ps.setInt(12,Integer.parseInt(DecemberTF.getText()));
                    ps.setInt(13,Integer.parseInt(JanuaryTF.getText())+
                                Integer.parseInt(FebruaryTF.getText())+
                                Integer.parseInt(MarchTF.getText())+
                                Integer.parseInt(AprilTF.getText())+
                                Integer.parseInt(MayTF.getText())+
                            Integer.parseInt(JuneTF.getText())+
                                Integer.parseInt(JulyTF.getText())+
                                Integer.parseInt(AugustTF.getText())+
                            Integer.parseInt(SeptemberTF.getText())+
                                Integer.parseInt(OctoberTF.getText())+
                                Integer.parseInt(NovemberTF.getText())+
                                Integer.parseInt(DecemberTF.getText()));
                      
                    ps.executeUpdate();
                    JOptionPane.showMessageDialog(this,”Record Successfully Updated”,”Operation Successfull”,1);
                }/*Leve Entry Tabel Updation ends here.*/
                catch(Exception e)
                {
                    JOptionPane.showMessageDialog(null,e,”Data Retrieve Error”,1);
                }
                    }//Else Part Closere here.
        }//Action Performed on Update Button ends here.
    }//Add Action Listenre ends here..
    /*Performing Item State Changed Operation on LeaveType ComboBox to get Leave Details*/
    public void itemStateChanged(ItemEvent e)
    {
        /*If Leave type selected is Select Any then leave fields will be empty*/
            String type = String.valueOf(leavetype.getSelectedItem());
            if(leavetype.getSelectedItem().equals(“Select Any”))
            {
                     JanuaryTF.setText(“”);
                    FebruaryTF.setText(“”);
                    MarchTF.setText(“”);
                    AprilTF.setText(“”);
                    MayTF.setText(“”);
                    JuneTF.setText(“”);
                    JulyTF.setText(“”);
                    AugustTF.setText(“”);
                    SeptemberTF.setText(“”);
                    OctoberTF.setText(“”);
                    NovemberTF.setText(“”);
                    DecemberTF.setText(“”);
            }
            /*If Leave type selected is Absent then leave fields will be filled*/
        if(leavetype.getSelectedItem().equals(“Absent”))
                {
                    try
                {
                                PreparedStatement ps = con.prepareStatement(“select * from LeaveEntry_Table where Leave_Type = ?”);
                ps.setString(1,type);
                            ResultSet rs = ps.executeQuery();
                            while(rs.next())
                            {
                                JanuaryTF.setText(rs.getString(“Jan_Absent”));
                                FebruaryTF.setText(rs.getString(“Feb_Absent”));
                                MarchTF.setText(rs.getString(“Mar_Absent”));
                                AprilTF.setText(rs.getString(“Apr_Absent”));
                                MayTF.setText(rs.getString(“May_Absent”));
                                JuneTF.setText(rs.getString(“Jun_Absent”));
                                JulyTF.setText(rs.getString(“Jul_Absent”));
                                AugustTF.setText(rs.getString(“Aug_Absent”));
                                SeptemberTF.setText(rs.getString(“Sep_Absent”));
                                OctoberTF.setText(rs.getString(“Oct_Absent”));
                                NovemberTF.setText(rs.getString(“Nov_Absent”));
                                DecemberTF.setText(rs.getString(“Dec_Absent”));
                            }
                    }
                    catch(Exception ex)
                    {
                        JOptionPane.showMessageDialog(null,ex,”Data Retrieve Error”,1);
                    }   
        }
        /*If Leave type selected is Sickness then leave fields will be filled*/
            if(leavetype.getSelectedItem().equals(“Sickness”))
            {
            try
                    {
                                PreparedStatement ps = con.prepareStatement(“select * from LeaveEntry_Table where Leave_Type = ?”);
                ps.setString(1,type);
                            ResultSet rs = ps.executeQuery();
                            while(rs.next())
                            {
                                JanuaryTF.setText(rs.getString(“Jan_Absent”));
                                FebruaryTF.setText(rs.getString(“Feb_Absent”));
                                MarchTF.setText(rs.getString(“Mar_Absent”));
                                AprilTF.setText(rs.getString(“Apr_Absent”));
                                MayTF.setText(rs.getString(“May_Absent”));
                                JuneTF.setText(rs.getString(“Jun_Absent”));
                                JulyTF.setText(rs.getString(“Jul_Absent”));
                                AugustTF.setText(rs.getString(“Aug_Absent”));
                                SeptemberTF.setText(rs.getString(“Sep_Absent”));
                                OctoberTF.setText(rs.getString(“Oct_Absent”));
                                NovemberTF.setText(rs.getString(“Nov_Absent”));
                                DecemberTF.setText(rs.getString(“Dec_Absent”));
                            }
                    }
                    catch(Exception ez)
                    {
                            JOptionPane.showMessageDialog(null,ez,”Data Retrieve Error”,1);
                    }
                }
                /*If Leave type selected is Casual then leave fields will be filed*/
                if(leavetype.getSelectedItem().equals(“Casual”))
                {
                    try
                    {
                                PreparedStatement ps = con.prepareStatement(“select * from LeaveEntry_Table where Leave_Type = ?”);
                    ps.setString(1,type);
                            ResultSet rs = ps.executeQuery();
                            while(rs.next())
                            {
                                JanuaryTF.setText(rs.getString(“Jan_Absent”));
                                FebruaryTF.setText(rs.getString(“Feb_Absent”));
                                MarchTF.setText(rs.getString(“Mar_Absent”));
                                AprilTF.setText(rs.getString(“Apr_Absent”));
                                MayTF.setText(rs.getString(“May_Absent”));
                                JuneTF.setText(rs.getString(“Jun_Absent”));
                                JulyTF.setText(rs.getString(“Jul_Absent”));
                                AugustTF.setText(rs.getString(“Aug_Absent”));
                                SeptemberTF.setText(rs.getString(“Sep_Absent”));
                                OctoberTF.setText(rs.getString(“Oct_Absent”));
                                NovemberTF.setText(rs.getString(“Nov_Absent”));
                                DecemberTF.setText(rs.getString(“Dec_Absent”));
                }
                    }
                    catch(Exception ez)
                    {
                JOptionPane.showMessageDialog(null,ez,”Data Retrieve Error”,1);
                    }
            }
            /*If Leave type selected is Break then leave fields will be filled*/
                if(leavetype.getSelectedItem().equals(“Break”))
                {
                    try
                    {
                                PreparedStatement ps = con.prepareStatement(“select * from LeaveEntry_Table where Leave_Type = ?”);
                ps.setString(1,type);
                            ResultSet rs = ps.executeQuery();       
                            while(rs.next())
                            {   
                                JanuaryTF.setText(rs.getString(“Jan_Absent”));
                                FebruaryTF.setText(rs.getString(“Feb_Absent”));
                                MarchTF.setText(rs.getString(“Mar_Absent”));
                                AprilTF.setText(rs.getString(“Apr_Absent”));
                                MayTF.setText(rs.getString(“May_Absent”));
                                JuneTF.setText(rs.getString(“Jun_Absent”));
                                JulyTF.setText(rs.getString(“Jul_Absent”));
                                AugustTF.setText(rs.getString(“Aug_Absent”));
                                SeptemberTF.setText(rs.getString(“Sep_Absent”));
                                OctoberTF.setText(rs.getString(“Oct_Absent”));
                                NovemberTF.setText(rs.getString(“Nov_Absent”));
                                DecemberTF.setText(rs.getString(“Dec_Absent”));
                }
                    }
                    catch(Exception ez)
                    {
                            JOptionPane.showMessageDialog(null,ez,”Data Retrieve Error”,1);
                    }
                }
        }//Item State Changed Operation ends here.
}

Leave a Comment

Leave a comment