import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.sql.*;
public class Setting extends JFrame implements ActionListener,ItemListener
{
JLabel l1,l2,l3,l4,l5,l6,l7,l8,l9,l10,l11,l12,l13,l14,l15,l16,l17,l18,l19,l20;
JTextField bs,da,hra,wa,gpf,it,gis,pf,lic,tf1,tf2,tf3,tf4,tf5,tf6,tf7,tf8;
JButton add,edit,delete,exit;
JComboBox etype;
JCheckBox dr,hr,w,gpfd,itd,gisd,pfd,licd;
JFrame jp;
String dialogmessage;
String dialogs;
static int record;
int dialogtype = JOptionPane.PLAIN_MESSAGE;
clsConnection connect = new clsConnection();
Connection conn;
private String sCategory_Type = "";
private String sCategory_Name = "";
private float sBasic_Pay;
private String sDA = "false";
private String sHRA = "false";
private String sWA = "false";
private String sGPF = "false";
private String sIT = "false";
private String sGIS = "false";
private String sPF = "false";
private String sLIC = "false";
float sDA_Allow,sHRA_Allow,sWA_Allow,sGPF_Dedu,sIT_Dedu,sGIS_Dedu,sPF_Dedu,sLIC_Dedu;
public static boolean s;
public Setting()
{
jp=new JFrame("SETTING");
jp.setLayout(null);
jp.setResizable(false);
jp.setBounds(350,80,620,600);
l1=new JLabel("Employee Type:");
l1.setBounds(70,20,100,20);
jp.add(l1);
etype=new JComboBox();
etype.setBounds(170,20,130,20);
jp.add(etype);
etype.addActionListener(this);
etype.setEditable(false);
add_Cat_combo(etype);
String cat_Name = (String)etype.getSelectedItem();
l2=new JLabel("Basic Salary:");
l2.setBounds(70,60,100,20);
jp.add(l2);
bs=new JTextField();
bs.setBounds(170,60,100,20);
jp.add(bs);
l3=new JLabel("ALLOWANCE VALUE INFORMATION (CHECK FOR %)");
l3.setBounds(150,100,350,40);
jp.add(l3);
l4=new JLabel("DA Allowance:");
l4.setBounds(70,150,100,25);
jp.add(l4);
l5=new JLabel("HRA Allowance:");
l5.setBounds(70,170,100,25);
jp.add(l5);
l6=new JLabel("TA Allowance:");
l6.setBounds(70,190,100,25);
jp.add(l6);
dr=new JCheckBox(" DA",false);
dr.setBounds(200,150,60,25);
dr.addItemListener(this);
jp.add(dr);
hr=new JCheckBox(" HRA",false);
hr.setBounds(200,170,60,25);
hr.addItemListener(this);
jp.add(hr);
w=new JCheckBox(" TA",false);
w.setBounds(200,190,60,25);
w.addItemListener(this);
jp.add(w);
l7=new JLabel("DEDUCTION VALUE INFORMATION (CHECK FOR %)");
l7.setBounds(150,230,350,40);
jp.add(l7);
l8=new JLabel("TDS Deduction:");
l8.setBounds(70,280,100,25);
jp.add(l8);
gpfd=new JCheckBox(" TDS",false);
gpfd.setBounds(200,280,60,25);
gpfd.addItemListener(this);
jp.add(gpfd);
l9=new JLabel("PT Deduction:");
l9.setBounds(70,300,100,25);
jp.add(l9);
itd=new JCheckBox(" PT",false);
itd.setBounds(200,300,60,25);
itd.addItemListener(this);
jp.add(itd);
l10=new JLabel("ESI Deduction:");
l10.setBounds(70,320,100,25);
jp.add(l10);
gisd=new JCheckBox(" ESI",false);
gisd.setBounds(200,320,60,25);
gisd.addItemListener(this);
jp.add(gisd);
l11=new JLabel("PF Deduction:");
l11.setBounds(70,340,100,25);
jp.add(l11);
pfd=new JCheckBox(" PF",false);
pfd.setBounds(200,340,60,25);
pfd.addItemListener(this);
jp.add(pfd);
l12=new JLabel("LIC Deduction:");
l12.setBounds(70,360,100,25);
jp.add(l12);
licd=new JCheckBox(" LIC",false);
licd.setBounds(200,360,60,25);
licd.addItemListener(this);
jp.add(licd);
da=new JTextField();
da.setBounds(280,150,50,20);
jp.add(da);
hra=new JTextField();
hra.setBounds(280,170,50,20);
jp.add(hra);
wa=new JTextField();
wa.setBounds(280,190,50,20);
jp.add(wa);
gpf=new JTextField();
gpf.setBounds(280,280,50,20);
jp.add(gpf);
it=new JTextField();
it.setBounds(280,300,50,20);
jp.add(it);
gis=new JTextField();
gis.setBounds(280,320,50,20);
jp.add(gis);
pf=new JTextField();
pf.setBounds(280,340,50,20);
jp.add(pf);
lic=new JTextField();
lic.setBounds(280,360,50,20);
jp.add(lic);
tf1=new JTextField("Enter in Rupees");
tf1.setBounds(370,150,200,20);
jp.add(tf1);
tf2=new JTextField("Enter in Rupees");
tf2.setBounds(370,170,200,20);
jp.add(tf2);
tf3=new JTextField("Enter in Rupees");
tf3.setBounds(370,190,200,20);
jp.add(tf3);
tf4=new JTextField("Enter in Rupees");
tf4.setBounds(370,280,200,20);
jp.add(tf4);
tf5=new JTextField("Enter in Rupees");
tf5.setBounds(370,300,200,20);
jp.add(tf5);
tf6=new JTextField("Enter in Rupees");
tf6.setBounds(370,320,200,20);
jp.add(tf6);
tf7=new JTextField("Enter in Rupees");
tf7.setBounds(370,340,200,20);
jp.add(tf7);
tf8=new JTextField("Enter in Rupees");
tf8.setBounds(370,360,200,20);
jp.add(tf8);
add=new JButton("Add New");
add.setBounds(80,470,90,25);
jp.add(add);
add.addActionListener(this);
edit=new JButton("Edit");
edit.setBounds(210,470,90,25);
jp.add(edit);
edit.addActionListener(this);
delete=new JButton("Delete");
delete.setBounds(340,470,90,25);
jp.add(delete);
delete.addActionListener(this);
exit=new JButton("Exit");
exit.setBounds(470,470,90,25);
jp.add(exit);
exit.addActionListener(this);
jp.setVisible(true);
check_false();
uncheck_true();
Numvalidator(bs);
Numvalidator(da);
Numvalidator(hra);
Numvalidator(wa);
Numvalidator(gpf);
Numvalidator(it);
Numvalidator(gis);
Numvalidator(pf);
Numvalidator(lic);
// NumCounter(bs,10);
}
public void Numvalidator(JTextField txtField)
{
txtField.addKeyListener(new KeyAdapter() {
public void keyTyped(KeyEvent e) {
char c = e.getKeyChar();
if (!(Character.isDigit(c) ||
(c == KeyEvent.VK_BACK_SPACE) ||
(c == KeyEvent.VK_DELETE))) {
e.consume();
}
}
});
}
public void check(final JTextField txtField)
{
txtField.addFocusListener(new FocusAdapter() {
public void focusLost(FocusEvent e) {
if (Integer.parseInt(txtField.getText())>100) {
txtField.setText("");
}
}
});
}
public void actionPerformed(ActionEvent event)
{ Object source = event.getSource();
if ( source == etype)
{
String etype1 = (String)etype.getSelectedItem();
fill_form(etype1);
}
if (source == add)
add_record();
if (source == edit)
edit_record();
if (source == delete)
delete_record();
if (source == exit)
{
jp.setVisible(false);
dispose();
}
}
public void itemStateChanged(ItemEvent event)
{
Object item = event.getItemSelectable();
if (item == dr)
{
if (event.getStateChange() == ItemEvent.SELECTED)
{
sDA = "true";
tf1.setText("Enter in % of Basic");
check(da);
da.setText("0");
}
else if (event.getStateChange() == ItemEvent.DESELECTED)
{
sDA = "false";
tf1.setText("Enter in Rupees");
}
}
else if (item == hr)
{
if (event.getStateChange() == ItemEvent.SELECTED)
{
sHRA = "true";
tf2.setText("Enter in % of Basic");
check(hra);
hra.setText("0");
}
else if (event.getStateChange() == ItemEvent.DESELECTED)
{
sHRA = "false";
tf2.setText("Enter in Rupees");
}
}
else if (item == w)
{
if (event.getStateChange() == ItemEvent.SELECTED)