Project Code - TXT - Notepad
Project Code - TXT - Notepad
txt
package payroll;
import
import
import
import
import
import
import
import
java.awt.*;
java.awt.event.*;
java.sql.*;
java.io.*;
java.util.*;
java.net.*;
javax.swing.*;
java.util.Date;
SYSTEM");
project code.txt
exitBtn = new JButton("Quit");
exitBtn.addActionListener(this);
panel1.add(nameLbl);
panel1.setOpaque(true);
panel2.add(userLbl);
panel2.add(userTxt);
panel2.add(passwordLbl);
panel2.add(passwordTxt);
panel2.setOpaque(true);
panel3.add(loginBtn);
panel3.add(exitBtn);
panel3.setOpaque(true);
frame = new JFrame("LOGIN");
frame.setSize(300,200);
Container pane = frame.getContentPane();
pane.setLayout(new BoxLayout(pane, BoxLayout.Y_AXIS));
//pane.setLayout(new GridLayout(3,1));
pane.add(panel1);
pane.add(panel2);
pane.add(panel3);
frame.setLocation((screen.width - 500)/2,((screen.height-350)/2));
frame.setVisible(true);
frame.addWindowListener(new WindowAdapter()
{
public void windowClosing(WindowEvent e)
{
System.exit(0);
}
});
}
public void actionPerformed(ActionEvent event)
{
Object source = event.getSource();
if(source.equals(loginBtn))
{
login();
}
else if(source.equals(exitBtn))
{
System.exit(0);
}
}
public void login()
{
loginname = userTxt.getText().trim();
loginpass = passwordTxt.getText().trim();
try {
conn = connect.setConnection(conn,"","");
}
catch(Exception e)
{
}
try{
Statement stmt = conn.createStatement();
String query = "SELECT * FROM Login WHERE USERNAME='"+loginname
Page 2
project code.txt
+"' AND PASSWORD='"+loginpass +"'";
ResultSet rs = stmt.executeQuery(query);
boolean recordfound = rs.next();
if (recordfound)
{
dialogmessage = "Login Successful as "+loginname;
dialogtype = JOptionPane.INFORMATION_MESSAGE;
JOptionPane.showMessageDialog((Component)null, dialogmessage,
dialogs, dialogtype);
userTxt.setText("");
passwordTxt.setText("");
frame.setVisible(false);
frame.dispose();
MainMenu menu = new MainMenu(loginname,td);
}
else
{
dialogmessage = "ERROR!Login Failed!";
JOptionPane.showMessageDialog(null, "Bad Username and
Password Combination!",
"WARNING!!",JOptionPane.WARNING_MESSAGE);
userTxt.setText("");
passwordTxt.setText("");
}
conn.close();
}
catch(Exception ex)
{
JOptionPane.showMessageDialog(null,"DB Not Connected!",
"WARNING!!!",JOptionPane.INFORMATION_MESSAGE);
}
}
public static void main(String[] args)
{
try {
for (javax.swing.UIManager.LookAndFeelInfo info :
javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Windows".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (Exception ex) {}
LoginFrame frame1 = new LoginFrame();
frame1.addNotify();
frame1.pack();
}
package payroll;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
Page 3
import
import
import
import
import
import
import
import
import
project code.txt
java.awt.Toolkit;
java.io.*;
java.sql.*;
java.util.*;
java.text.DateFormat;
java.util.Date;
java.text.*;
java.lang.*;
java.beans.PropertyVetoException;
project code.txt
JTextField username = new JTextField();
username.setEditable(false);
JTextField logtime = new JTextField();
logtime.setEditable(false);
username.setText(sUser);
logtime.setText(sLogin);
panel_Bottom.setLayout(new FlowLayout());
panel_Bottom.setPreferredSize(new Dimension(10, 25));
// panel_Bottom.add(lblUserIcon);
panel_Bottom.add(lblUsername);
panel_Bottom.add(username);
panel_Bottom.add(lblLogDetails);
panel_Bottom.add(logtime);
//
panel_Top.setLayout(new BorderLayout());
// panel_Top.setPreferredSize(new Dimension(10, 65));
// panel_Top.add(createJToolBar(), BorderLayout.PAGE_START);
desktop.setBackground(Color.WHITE);
desktop.setAutoscrolls(true);
desktop.setBorder(BorderFactory.createLoweredBevelBorder());
desktop.setDragMode(JDesktopPane.OUTLINE_DRAG_MODE);
//
getContentPane().add(panel_Top, BorderLayout.PAGE_START);
getContentPane().add(desktop, BorderLayout.CENTER);
getContentPane().add(panel_Bottom, BorderLayout.PAGE_END);
addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
UnloadWindow();
}
});
setJMenuBar(CreateJMenuBar());
setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
// setIconImage(new ImageIcon("./src/images/Business.png").getImage());
setSize(700, 700);
setLocation(2, 2);
show();
}
protected JMenuBar CreateJMenuBar() {
// creating Submenu
// Menu File
menuFile.add(settings.setJMenuItem(itemExit,
"Quit","./src/images/exit.png"));
itemExit.addActionListener(this);
// MEnu Employee
menuEmployee.add(settings.setJMenuItem(itemAdd, "Add an Employee",
"./src/images/employee.png"));
menuEmployee.add(settings.setJMenuItem(itemEdit, "Edit an Existing
Employee", "./src/images/edit.png"));
menuEmployee.addSeparator();
menuEmployee.add(settings.setJMenuItem(itemDelete, "Delete an Existing
Employee", "./src/images/delete.png"));
itemAdd.addActionListener(this);
itemEdit.addActionListener(this);
Page 5
project code.txt
itemDelete.addActionListener(this);
// setting tool bar
menuTools.add(settings.setJMenuItem(itemSettings, "Payroll Parameters",
"./src/images/setting.png"));
//
menuTools.add(settings.setJMenuItem(itemCalculator, "Calculator",
"./src/images/calc.png"));
//
menuTools.addSeparator();
//
menuTools.add(settings.setJMenuItem(itemNotePad, "NotePad",
"./src/images/notepad.png"));
itemSettings.addActionListener(this);
itemCalculator.addActionListener(this);
itemNotePad.addActionListener(this);
// setting Reports bar
menuReports.add(settings.setJMenuItem(itemEmprpt, "Payroll Report",
"./src/images/emp_rpt.png"));
menuTools.addSeparator();
menuTools.addSeparator();
itemEmprpt.addActionListener(this);
// setting Help
menuHelp.add(settings.setJMenuItem(itemAuthor, "About Our Team",
"./src/images/xp.png"));
menuHelp.add(settings.setJMenuItem(itemHelp, "Help",
"./src/images/help.png"));
itemAuthor.addActionListener(this);
itemHelp.addActionListener(this);
// adding menuitem to menubar
menubar.add(settings.setJMenu(menuFile));
menubar.add(settings.setJMenu(menuEmployee));
menubar.add(settings.setJMenu(menuTools));
menubar.add(settings.setJMenu(menuReports));
menubar.add(settings.setJMenu(menuHelp));
return menubar;
}
/*
toolbar.add(settings.CreateJToolbarButton("Exit",
"./src/images/exit.png", "File_Exit",
JToolBarActionListener));
toolbar.addSeparator();
toolbar.addSeparator();
toolbar.add(settings.CreateJToolbarButton("Add - Employee",
"./src/images/employee.png", "Emp_Add",
JToolBarActionListener));
toolbar.add(settings.CreateJToolbarButton("Edit - Employee",
"./src/images/edit.png", "Emp_Edit",
JToolBarActionListener));
toolbar.addSeparator();
toolbar.add(settings.CreateJToolbarButton("Delete - Employee",
"./src/images/delete.png", "Emp_Delete",
JToolBarActionListener));
toolbar.addSeparator();
toolbar.addSeparator();
Page 6
project code.txt
toolbar.add(settings.CreateJToolbarButton("Help - Author",
"./src/images/xp.png", "Help_Author",
JToolBarActionListener));
toolbar.add(settings.CreateJToolbarButton("Help - Help",
"./src/images/help.png", "Help_Help",
JToolBarActionListener));
return toolbar;
}*/
ActionListener JToolBarActionListener = new ActionListener() {
public void actionPerformed(ActionEvent e) {
String source = e.getActionCommand();
if (source == "File_Exit") {
loadJInternalFrame(2);
} else if (source == "Emp_Add") {
loadJInternalFrame(3);
} else if (source == "Emp_Edit") {
loadJInternalFrame(4);
} else if (source == "Emp_Delete") {
loadJInternalFrame(5);
} else if (source == "Settings") {
loadJInternalFrame(6);
} else if (source == "Tools_Calculator") {
loadJInternalFrame(7);
} else if (source == "Tools_NotePad") {
loadJInternalFrame(8);
} else if (source == "Reports_Employee") {
loadJInternalFrame(9);
} else if (source == "Help_Author") {
loadJInternalFrame(11);
} else if (source == "Help_Help") {
loadJInternalFrame(12);
}
}
};
public void actionPerformed(ActionEvent event) {
Object object = event.getSource();
if (object == itemExit) {
loadJInternalFrame(2);
} else if (object == itemAdd) {
loadJInternalFrame(3);
} else if (object == itemEdit) {
Page 7
project code.txt
loadJInternalFrame(4);
} else if (object == itemDelete) {
loadJInternalFrame(5);
} else if (object == itemSettings) {
loadJInternalFrame(6);
} else if (object == itemCalculator) {
loadJInternalFrame(7);
} else if (object == itemNotePad) {
loadJInternalFrame(8);
} else if (object == itemEmprpt) {
loadJInternalFrame(9);
} else if (object == itemAuthor) {
loadJInternalFrame(12);
} else if (object == itemHelp) {
loadJInternalFrame(13);
}
}
private void loadJInternalFrame(int intWhich) {
switch (intWhich) {
case 2:
System.exit(0);
break;
case 3:
try {
FormAddwindow = new Addwindow(this);
loadForm("Add an Employee", FormAddwindow);
} catch (Exception e) {
System.out.println("\nError!");
}
break;
case 4:
try {
FormEditwindow = new Editwindow(this);
loadForm("Edit an Employee", FormEditwindow);
} catch (Exception e) {
System.out.println("\nError!");
}
break;
case 5:
try {
FormDeletewindow = new Deletewindow(this);
loadForm("Delete an Employee", FormDeletewindow);
} catch (Exception e) {
System.out.println("\nError!");
}
break;
case 6:
try {
FormSettingswindow = new Settingswindow(this);
loadForm("Payroll Parameters", FormSettingswindow);
} catch (Exception e) {
System.out.println("\nError!");
}
break;
case 7:
//
runComponents("Calc.exe");
break;
case 8:
//
runComponents("Notepad.exe");
Page 8
project code.txt
break;
case 9:
try {
FormEmprptwindow = new Emprptwindow(this);
loadForm("Employee PaySlip", FormEmprptwindow);
} catch (Exception e) {
System.out.println("\nError!" + e);
}
break;
case 12:
System.out.println("\"This project was developed by, \"\n" +
+ \"Eby Prasad\"\n" +
+ \"Greeshma Gilbert\"\n" +
+ \"Neethu Sudarshan\"\n" +
+ \"Nimmi N\"");
// try {
//FormAboutwindow = new Aboutwindow(this);
//loadForm("About Team", FormAboutwindow);
"
"
"
"
// }catch (Exception e) {
//
System.out.println("\nError!");
// }
break;
case 13:
System.out.println("\"Kindly Make the DB connection first and
Check whether all the fields are entered");
//try {
//FormAuthorwindow = new Helpwindow(this);
//loadForm("Help", FormHelpwindow);
//}catch (Exception e) {
//
System.out.println("\nError!");
// }
break;
}
}
protected void runComponents(String sComponents) {
Runtime rt = Runtime.getRuntime();
try {
rt.exec(sComponents);
} catch (IOException evt) {
JOptionPane.showMessageDialog(null, evt.getMessage(), "Error Found!",
JOptionPane.ERROR_MESSAGE);
}
}
protected void loadForm(String Title, JInternalFrame clsForm) {
boolean xForm = isLoaded(Title);
if (xForm == false) {
desktop.add(clsForm);
clsForm.setVisible(true);
clsForm.show();
} else {
try {
clsForm.setIcon(false);
clsForm.setSelected(true);
Page 9
project code.txt
} catch (PropertyVetoException e) {
}
}
} // Complete Load Form methode
protected boolean isLoaded(String FormTitle) {
JInternalFrame Form[] = desktop.getAllFrames();
for (int i = 0; i < Form.length; i++) {
if (Form[i].getTitle().equalsIgnoreCase(FormTitle)) {
Form[i].show();
try {
Form[i].setIcon(false);
Form[i].setSelected(true);
} catch (PropertyVetoException e) {
}
return true;
}
}
return false;
} // Complete to Verify Form loaded or not
protected void UnloadWindow() {
try {
int reply = JOptionPane.showConfirmDialog(this, "Really Exit?",
sMSGBOX_TITLE, JOptionPane.YES_NO_OPTION,
JOptionPane.WARNING_MESSAGE);
if (reply == JOptionPane.YES_OPTION) {
setVisible(false);
System.exit(0);
}
} catch (Exception e) {
}
}// Close the Windows
public static void setlogin(String sUsername, Date sDate) {
sUser = sUsername;
td = sDate;
}//Set Login
}
package payroll;
import
import
import
import
import
import
import
import
java.awt.*;
java.awt.event.*;
javax.swing.*;
javax.swing.event.*;
java.sql.*;
java.io.*;
java.util.*;
java.net.*;
project code.txt
private JPanel panel8;
private
private
private
private
private
JButton AddBtn;
JButton ChangeBtn;
JButton ExitBtn;
JButton DeleteBtn;
JLabel LblHeading, LblBasic_Salary, LblAllowance, LblPercent1,
LblRs1;
private JLabel LblDeduction, LblPercent2, LblRs2;
private JLabel LblDA, LblHRA, LblWA, LblGPF, LblIT,LblGIS,LblPF, LblLIC;
private JLabel Emp_Type, SELECT1, SELECT2,pos;
private JTextField
TxtBasic, TxtDA1, TxtHRA1, TxtWA1, TxtGPF1, TxtIT1,
TxtGIS1, TxtPF1, TxtLIC1;
private JTextField TxtCategory_Name,TxtDA2, TxtHRA2, TxtWA2;
private JTextField TxtGPF2,TxtIT2, TxtGIS2, TxtPF2, TxtLIC2;
private JComboBox Cat_Name;
private JCheckBox chDA,chHRA,chWA, chGPF, chIT, chGIS, chPF, chLIC;
String dialogmessage;
String dialogs;
int dialogtype = JOptionPane.PLAIN_MESSAGE;
public static int record;
// Class Variables
clsSettings settings = new clsSettings();
clsConnection connect = new clsConnection();
// Connection
Connection conn;
/*Connection conn;
String url = "jdbc:mysql://localhost:3306/Payroll";
String dbName = "Payroll";
String driver = "com.mysql.jdbc.Driver";
String userName = "root";
String password = "root";
//url = url + dbName;
//Class.forName(driver).newInstance();
conn = DriverManager.getConnection(url+dbName,userName,password);
*/
private String sCategory_Type = "";
private String sCategory_Name = "";
private String 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";
private String sDA_Allow = "";
private String sHRA_Allow = "";
private String sWA_Allow = "";
private String sGPF_Dedu = "";
private String sIT_Dedu = "";
private String sGIS_Dedu = "";
private String sPF_Dedu = "";
private String sLIC_Dedu = "";
public static boolean s;
Page 11
project code.txt
public Settingswindow(JFrame getParentFrame)
{
super("Employee - Settings",true,true,true,true);
setSize(800,850);
JFParentFrame = getParentFrame;
panel2 = new JPanel();
panel2.setLayout(new FlowLayout());
Emp_Type = new JLabel("Employee Type :");
Cat_Name = new JComboBox();
Cat_Name.addActionListener(this);
Cat_Name.setEditable(false);
add_Cat_combo(Cat_Name);
pos = new JLabel(" Current Position:");
TxtCategory_Name = new JTextField(10);
TxtCategory_Name.setText(null);
String cat_Name = (String)Cat_Name.getSelectedItem();
panel2.add(Emp_Type,"LEFT");
panel2.add(Cat_Name,"CENTER");
panel2.add(pos,"RIGHT");
panel2.add(TxtCategory_Name,"RIGHT");
panel3 = new JPanel();
panel3.setLayout(new FlowLayout());
LblBasic_Salary = new JLabel("Basic Salary : ");
TxtBasic = new JTextField(10);
panel3.add(LblBasic_Salary,"LEFT");
panel3.add(TxtBasic,"RIGHT");
panel4 = new JPanel();
panel4.setLayout(new GridLayout(1,4,5,5));
SELECT1 = new JLabel("");
LblAllowance = new JLabel("Allowance");
LblPercent1 = new JLabel(" Allowance Value");
LblRs1 = new JLabel("");
panel4.add(SELECT1,"CENTER");
panel4.add(LblAllowance, "CENTER");
panel4.add(LblPercent1, "CENTER");
panel4.add(LblRs1, "CENTER");
panel5 = new JPanel();
panel5.setLayout(new GridLayout(3,4,5,5));
LblDA = new JLabel("DA Allowance
:");
LblHRA = new JLabel("HRA Allowance :");
LblWA = new JLabel("WA Allowane
:");
TxtDA1 = new JTextField();
TxtDA2 = new JTextField("");
TxtHRA1 = new JTextField();
TxtHRA2 = new JTextField("");
TxtWA1 = new JTextField();
TxtWA2 = new JTextField("");
chDA = new JCheckBox("DA",false);
Page 12
project code.txt
chDA.addItemListener(this);
chHRA = new JCheckBox("HRA",false);
chHRA.addItemListener(this);
chWA = new JCheckBox("WA",false);
chWA.addItemListener(this);
panel5.add(LblDA);
panel5.add(chDA);
panel5.add(TxtDA1);
panel5.add(TxtDA2);
panel5.add(LblHRA);
panel5.add(chHRA);
panel5.add(TxtHRA1);
panel5.add(TxtHRA2);
panel5.add(LblWA);
panel5.add(chWA);
panel5.add(TxtWA1);
panel5.add(TxtWA2);
project code.txt
chPF.addItemListener(this);
chLIC = new JCheckBox("LIC",false);
chLIC.addItemListener(this);
panel7.add(LblGPF);
panel7.add(chGPF);
panel7.add(TxtGPF1);
panel7.add(TxtGPF2);
panel7.add(LblIT);
panel7.add(chIT);
panel7.add(TxtIT1);
panel7.add(TxtIT2);
panel7.add(LblGIS);
panel7.add(chGIS);
panel7.add(TxtGIS1);
panel7.add(TxtGIS2);
panel7.add(LblPF);
panel7.add(chPF);
panel7.add(TxtPF1);
panel7.add(TxtPF2);
panel7.add(LblLIC);
panel7.add(chLIC);
panel7.add(TxtLIC1);
panel7.add(TxtLIC2);
panel7.setOpaque(true);
project code.txt
settings.Numvalidator(TxtDA1);
settings.Numvalidator(TxtDA2);
settings.Numvalidator(TxtHRA1);
settings.Numvalidator(TxtHRA2);
settings.Numvalidator(TxtWA1);
settings.Numvalidator(TxtWA2);
settings.Numvalidator(TxtGPF1);
settings.Numvalidator(TxtGPF2);
settings.Numvalidator(TxtIT1);
settings.Numvalidator(TxtIT2);
settings.Numvalidator(TxtGIS1);
settings.Numvalidator(TxtGIS2);
settings.Numvalidator(TxtPF1);
settings.Numvalidator(TxtPF2);
settings.Numvalidator(TxtLIC1);
settings.Numvalidator(TxtLIC2);
fill_form(cat_Name);
}
public void actionPerformed(ActionEvent event)
{
Object source = event.getSource();
if ( source
== Cat_Name)
{
String cat_Name = (String)Cat_Name.getSelectedItem();
fill_form(cat_Name);
}
if (source == AddBtn)
{
add_record();
}
if (source == ChangeBtn)
{
edit_record();
}
if (source == DeleteBtn)
{
delete_record();
}
if (source == ExitBtn)
{
setVisible (false);
dispose();
}
}
public void itemStateChanged(ItemEvent event)
{
Object item = event.getItemSelectable();
if (item == chDA)
{
if (event.getStateChange() == ItemEvent.SELECTED) {
sDA = "true";
Page 15
project code.txt
TxtDA2.setText("");
}
else if (event.getStateChange() == ItemEvent.DESELECTED)
{
sDA = "false";
TxtDA2.setText("");
}
}
else if (item == chHRA)
{
if (event.getStateChange() == ItemEvent.SELECTED) {
sHRA = "true";
TxtHRA2.setText("");
}
else if (event.getStateChange() == ItemEvent.DESELECTED)
{
sHRA = "false";
TxtHRA2.setText("");
}
}
else if (item == chWA)
{
if (event.getStateChange() == ItemEvent.SELECTED) {
sWA = "true";
TxtWA2.setText("");
}
else if (event.getStateChange() == ItemEvent.DESELECTED)
{
sWA = "false";
TxtWA2.setText("");
}
}
else if (item == chGPF)
{
if (event.getStateChange() == ItemEvent.SELECTED) {
sGPF = "true";
TxtGPF2.setText("");
}
else if (event.getStateChange() == ItemEvent.DESELECTED)
{
sGPF = "false";
TxtGPF2.setText("");
}
}
else if (item == chIT)
{
if (event.getStateChange() == ItemEvent.SELECTED) {
sIT = "true";
TxtIT2.setText("");
}
else if (event.getStateChange() == ItemEvent.DESELECTED)
{
sIT = "false";
TxtIT2.setText("");
Page 16
project code.txt
}
}
else if (item == chGIS)
{
if (event.getStateChange() == ItemEvent.SELECTED) {
sGIS = "true";
TxtGIS2.setText("");
}
else if (event.getStateChange() == ItemEvent.DESELECTED)
{
sGIS = "false";
TxtGIS2.setText("");
}
}
else if (item == chPF)
{
if (event.getStateChange() == ItemEvent.SELECTED) {
sPF = "true";
TxtPF2.setText("");
}
else if (event.getStateChange() == ItemEvent.DESELECTED)
{
sPF = "false";
TxtPF2.setText("");
}
}
else if (item == chLIC)
{
if (event.getStateChange() == ItemEvent.SELECTED) {
sLIC = "true";
TxtLIC2.setText("");
}
else if (event.getStateChange() == ItemEvent.DESELECTED)
{
sLIC = "false";
TxtLIC2.setText("");
}
}
}
public void check_false()
{
TxtDA1.setEditable(true);
TxtHRA1.setEditable(true);
TxtWA1.setEditable(true);
TxtGPF1.setEditable(true);
TxtIT1.setEditable(true);
TxtGIS1.setEditable(true);
TxtPF1.setEditable(true);
TxtLIC1.setEditable(true);
}
Page 17
project code.txt
public void uncheck_true()
{
TxtDA2.setEditable(false);
TxtHRA2.setEditable(false);
TxtWA2.setEditable(false);
TxtGPF2.setEditable(false);
TxtIT2.setEditable(false);
TxtGIS2.setEditable(false);
TxtPF2.setEditable(false);
TxtLIC2.setEditable(false);
}
public void seteditable_true(JTextField chtxt )
{
chtxt.setEditable(true);
}
public void seteditable_false(JTextField chtxt)
{
chtxt.setEditable(false);
}
public void checkbox_state( JCheckBox chbox, String opt)
{
s = Boolean.valueOf(opt);
chbox.setSelected(s);
}
public void txtbox_fill(JTextField txt1, String value)
{
//s = Boolean.valueOf(option);
txt1.setText(value);
}
public void add_Cat_combo(JComboBox cmb)
{
try {
// Reset with mysql query.
conn = connect.setConnection(conn,"","");
}
catch(Exception e)
{
}
try{
Statement stmt = conn.createStatement();
String query = "SELECT * FROM Settings";
ResultSet rs = stmt.executeQuery(query);
while (rs.next())
{
String Txtcmb = rs.getString(2).trim();
Page 18
project code.txt
record = rs.getInt("Category_Type");
cmb.addItem(Txtcmb);
}
conn.close();
}
catch(Exception ex)
{
}
}
/////////////////////////////////
public void add_record()
{
try {
conn = connect.setConnection(conn,"","");
}
catch(Exception e)
{
}
try{
record = record +1;
sCategory_Type = ""+record;
sCategory_Name
=
TxtCategory_Name.getText().trim();
sBasic_Pay = TxtBasic.getText().trim();
sDA_Allow = TxtDA1.getText().trim();
sHRA_Allow =TxtHRA1.getText().trim();
sWA_Allow = TxtWA1.getText().trim();
sGPF_Dedu = TxtGPF1.getText().trim();
sIT_Dedu = TxtIT1.getText().trim();
sGIS_Dedu = TxtGIS1.getText().trim();
sPF_Dedu = TxtPF1.getText().trim();
sLIC_Dedu = TxtLIC1.getText().trim();
if (!sCategory_Type.equals("") &&
!sCategory_Name.equals("")&&
!sBasic_Pay.equals("")&&
!sDA_Allow.equals("") &&
!sHRA_Allow.equals("")&&
!sWA_Allow.equals("") &&
!sGPF_Dedu.equals("") &&
!sIT_Dedu.equals("")&&
!sGIS_Dedu.equals("")&&
!sPF_Dedu.equals("") &&
!sLIC_Dedu.equals(""))
{
System.out.println("Category Name :" +sCategory_Name);
Statement stmt = conn.createStatement();
String query = "SELECT * FROM Settings WHERE Category_Name='"
+sCategory_Name+ "'";
ResultSet rs = stmt.executeQuery(query);
Page 19
project code.txt
int foundrec=0;
while (rs.next())
{
dialogmessage = "Record Already Exists in DataBase!!!";
dialogtype = JOptionPane.WARNING_MESSAGE;
JOptionPane.showMessageDialog((Component)null, dialogmessage,
dialogs, dialogtype);
foundrec = 1;
}
if (foundrec == 0)
{
String temp = "INSERT INTO Settings VALUES (" + sCategory_Type
+",'" +
sCategory_Name
sBasic_Pay
sDA
+"'," +
+",'"
+"','" +
sHRA
+"','" +
sWA
+ "','" +
sGPF
+"','"+
sIT
+"','"+
sGIS
+"','"+
sPF
+"','"+
sLIC
+"',"+
sDA_Allow
+","+
sHRA_Allow
+","+
sWA_Allow
sGPF_Dedu
+","+
+","+
sIT_Dedu
sGIS_Dedu
sPF_Dedu
sLIC_Dedu
+","+
+","+
+","+
+")";
project code.txt
}
else {
dialogmessage = "Failed To
Insert";
JOptionPane.showMessageDialog(null, dialogmessage,
"WARNING!!",JOptionPane.WARNING_MESSAGE);
}
}
}
else
{
dialogmessage = "EMPTY VALUE
FOUND";
JOptionPane.showMessageDialog(null, dialogmessage,
"WARNING!!",JOptionPane.WARNING_MESSAGE);
}
conn.close();
}
catch(Exception ex)
{
System.out.println("Unknown Error" +ex);
}
}
public void fill_form(String name)
{
try {
conn = connect.setConnection(conn,"","");
}
catch(Exception e)
{
}
try{
Statement stmt = conn.createStatement();
String query = "SELECT * FROM Settings WHERE Category_Name='"
+name+ "'";
ResultSet rs = stmt.executeQuery(query);
while (rs.next())
{
sCategory_Type = "";
sCategory_Name = "";
sBasic_Pay = "";
sDA = "";
sHRA = "";
sWA = "";
sGPF = "";
sIT = "";
Page 21
project code.txt
sGIS = "";
sPF = "";
sLIC = "";
sDA_Allow = "";
sHRA_Allow = "";
sWA_Allow = "";
sGPF_Dedu = "";
sIT_Dedu = "";
sGIS_Dedu = "";
sPF_Dedu = "";
sLIC_Dedu = "";
sCategory_Type += rs.getString(1).trim();
sCategory_Name = rs.getString(2).trim();
sBasic_Pay = rs.getString(3).trim();
sDA = rs.getString(4).trim();
sHRA = rs.getString(5).trim();
sWA = rs.getString(6).trim();
sGPF = rs.getString(7).trim();
sIT = rs.getString(8).trim();
sGIS = rs.getString(9).trim();
sPF = rs.getString(10).trim();
sLIC = rs.getString(11).trim();
sDA_Allow = rs.getString(12).trim();
sHRA_Allow = rs.getString(13).trim();
sWA_Allow = rs.getString(14).trim();
sGPF_Dedu = rs.getString(15).trim();
sIT_Dedu = rs.getString(16).trim();
sGIS_Dedu = rs.getString(17).trim();
sPF_Dedu = rs.getString(18).trim();
sLIC_Dedu = rs.getString(19).trim();
TxtBasic.setText(sBasic_Pay);
checkbox_state(
checkbox_state(
checkbox_state(
checkbox_state(
checkbox_state(
checkbox_state(
checkbox_state(
checkbox_state(
chDA, sDA );
chHRA, sHRA );
chWA, sWA );
chGPF, sGPF );
chIT, sIT );
chGIS, sGIS );
chPF, sPF );
chLIC, sLIC );
txtbox_fill(TxtDA1,sDA_Allow);
txtbox_fill(TxtHRA1,sHRA_Allow);
txtbox_fill(TxtWA1,sWA_Allow);
txtbox_fill(TxtGPF1,sGPF_Dedu);
txtbox_fill(TxtIT1,sIT_Dedu);
txtbox_fill(TxtGIS1,sGIS_Dedu);
txtbox_fill(TxtPF1, sPF_Dedu);
txtbox_fill(TxtLIC1, sLIC_Dedu);
rs = null;
}
conn.close();
}
catch(Exception ex)
{
}
}
Page 22
project code.txt
public void edit_record()
{
try {
conn = connect.setConnection(conn,"","");
}
catch(Exception e)
{
}
try{
sCategory_Name = (String)Cat_Name.getSelectedItem();
sBasic_Pay = TxtBasic.getText().trim();
sDA_Allow = TxtDA1.getText().trim();
sHRA_Allow =TxtHRA1.getText().trim();
sWA_Allow = TxtWA1.getText().trim();
sGPF_Dedu = TxtGPF1.getText().trim();
sIT_Dedu = TxtIT1.getText().trim();
sGIS_Dedu = TxtGIS1.getText().trim();
sPF_Dedu = TxtPF1.getText().trim();
sLIC_Dedu = TxtLIC1.getText().trim();
if (!sCategory_Name.equals("")&&
!sBasic_Pay.equals("")&&
!sDA_Allow.equals("") &&
!sHRA_Allow.equals("")&&
!sWA_Allow.equals("") &&
!sGPF_Dedu.equals("") &&
!sIT_Dedu.equals("")&&
!sGIS_Dedu.equals("")&&
!sPF_Dedu.equals("") &&
!sLIC_Dedu.equals(""))
{
Statement stmt = conn.createStatement();
String temp = "UPDATE Settings SET " +
"Category_Type= " +sCategory_Type+
", Category_Name= '" + sCategory_Name +
"',Basic_Pay= " + sBasic_Pay +
", DA='" + sDA +
"',HRA= '" + sHRA +
"',WA= '" + sWA +
"',GPF = '" + sGPF +
"',IT = '" + sIT +
"',GIS = '" + sGIS +
"',PF = '" + sPF +
"',LIC = '" + sLIC +
"',DA_Allow = " + sDA_Allow +
",HRA_Allow = " + sHRA_Allow +
",WA_Allow = " + sWA_Allow +
",GPF_Dedu = " + sGPF_Dedu +
",IT_Dedu = " + sIT_Dedu +
",GIS_Dedu = " + sGIS_Dedu +
",PF_Dedu = " + sPF_Dedu +
",LIC_Dedu = " + sLIC_Dedu +
" WHERE Category_Type= " +
sCategory_Type;
int result = stmt.executeUpdate( temp );
if ( result == 1 )
{
dialogmessage = "Record Altered into DataBase!!!";
dialogtype = JOptionPane.INFORMATION_MESSAGE;
Page 23
project code.txt
JOptionPane.showMessageDialog((Component)null, dialogmessage,
dialogs, dialogtype);
}
else
{
dialogmessage = "NO SUCH POSITION FOUND!!!";
dialogtype = JOptionPane.WARNING_MESSAGE;
JOptionPane.showMessageDialog((Component)null, dialogmessage,
dialogs, dialogtype);
}
}
else
{
dialogmessage = "NULL VALUES IN TEXTFIELD
OCCURED!!!";
dialogtype = JOptionPane.WARNING_MESSAGE;
JOptionPane.showMessageDialog((Component)null, dialogmessage,
dialogs, dialogtype);
}
conn.close();
}
catch(Exception ex)
{
JOptionPane.showMessageDialog(null,"GENERAL EXCEPTION",
"WARNING!!!",JOptionPane.INFORMATION_MESSAGE);
}
}
//////////////////////////////////
public void delete_record()
{
sCategory_Name = (String)Cat_Name.getSelectedItem();
int DResult = JOptionPane.showConfirmDialog(null,"Are you sure you want to
delete Record?");
if (DResult == JOptionPane.NO_OPTION || DResult ==
JOptionPane.CANCEL_OPTION) {
dialogmessage = "Operation Calceld By
User!!!";
dialogtype = JOptionPane.INFORMATION_MESSAGE;
JOptionPane.showMessageDialog((Component)null, dialogmessage,
dialogs, dialogtype);
}
if (DResult == JOptionPane.YES_OPTION)
{
try {
conn = connect.setConnection(conn,"","");
}
catch(Exception e)
{
}
try{
Page 24
project code.txt
if (!sCategory_Name.equals(""))
{
Statement stmt = conn.createStatement();
String temp = "DELETE from Settings " +
" WHERE Category_Name = '" + sCategory_Name
+ "'";
int result = stmt.executeUpdate( temp );
if ( result == 1 )
{
dialogmessage = "Record Deleted From DataBase!!!";
dialogtype = JOptionPane.INFORMATION_MESSAGE;
JOptionPane.showMessageDialog((Component)null, dialogmessage,
dialogs, dialogtype);
}
else
{
dialogmessage = "No Such Record Found!!!";
dialogtype = JOptionPane.WARNING_MESSAGE;
JOptionPane.showMessageDialog((Component)null, dialogmessage,
dialogs, dialogtype);
}
}
else
{
dialogmessage = "Empty Record Found!!!";
dialogtype = JOptionPane.WARNING_MESSAGE;
JOptionPane.showMessageDialog((Component)null, dialogmessage,
dialogs, dialogtype);
}
conn.close();
}
catch(Exception ex)
{
JOptionPane.showMessageDialog(null,"GENERAL EXCEPTION",
"WARNING!!!",JOptionPane.INFORMATION_MESSAGE);
}
}
}
///////////////////////////////
}
package payroll;
Page 25
project code.txt
import java.sql.*;
public class clsConnection {
String url = "";
String username = "";
String password = "";
public Connection setConnection(Connection conn, String username, String
password) {
try {
Class.forName("com.mysql.jdbc.Driver").newInstance();
conn=DriverManager.getConnection("jdbc:mysql://localhost:3306/payroll", "root",
"root");
} catch (Exception e) {
System.err.println("SQl Exception");
e.printStackTrace();
}
return conn;
}
}
package payroll;
import
import
import
import
import
import
import
import
import
import
import
java.awt.*;
java.awt.event.*;
javax.swing.*;
java.sql.*;
java.io.*;
java.util.*;
java.net.*;
java.lang.String;
java.awt.print.*;
java.text.DateFormat;
java.util.Date;
project code.txt
private JButton ExitBtn;
private JTextField TxtCategory_Type, TxtCategory_Name;
private JComboBox MonthCombo;
private JTextField TxtYear;
private JLabel LblMonth,aa;
private String[] Month_Name = {"JAN",
"FEB",
"MAR",
"APR",
"MAY",
"JUN",
"JUL",
"AUG",
"SEP",
"OCT",
"NOV",
"DEC"};
String dialogmessage;
String s="";
String dialogs;
int dialogtype = JOptionPane.PLAIN_MESSAGE;
public static int record;
// Class Variables
clsSettings settings = new clsSettings();
clsConnection connect = new clsConnection();
// Connection
Connection conn;
////// Report Variables
private JLabel Lblcollege1, Lblcollege2, Lblcollege3, Lbldate,
LblSalary_Slip;
private JLabel LblEmp_Name, LblEmp_Code, LblEmp_Desi, LblBasic_Pay,
LblAllowance, LblDeduction;
private JLabel LblDA, LblHRA, LblWA, LblGPF, LblIT, LblGIS, LblPF, LblLIC;
private JLabel LblTot_Allowance, LblTot_Deduction, LblNet_Salary;
private JTextField TxtDate, TxtEmp_Name1, TxtEmp_Name2, TxtEmp_Code,
TxtSalary_Month, TxtEmp_Desi, TxtBasic_Pay;
private JTextField TxtDA, TxtHRA, TxtWA, TxtGPF, TxtIT, TxtGIS, TxtPF,
TxtLIC;
private JTextField TxtTot_Allowance, TxtTot_Deduction, TxtNet_Salary;
public String sEmp_Code = "";
public String sEmp_Name1 = "";
public String sEmp_Name2 = "";
public String sEmp_Desi = "";
public String sCategory_Type = "";
public String sCategory_Name = "";
public String sBasic_Pay = "";
public String sDA = "";
public String sHRA = "";
public String sWA = "";
public String sGPF = "";
public String sIT = "";
public String sGIS = "";
public String sPF = "";
public String sLIC = "";
public String sDA_Allow = "";
public String sHRA_Allow = "";
public String sWA_Allow = "";
public String sGPF_Dedu = "";
public String sIT_Dedu = "";
public String sGIS_Dedu = "";
public String sPF_Dedu = "";
public String sLIC_Dedu = "";
public String sAllow = "";
public String sDedu = "";
public String sNet_Salary = "";
public String Emp_Month;
public String Emp_Year;
public static int vBasic_Pay, DA_Rs, HRA_Rs, WA_Rs, GPF_Rs, IT_Rs, GIS_Rs,
Page 27
project code.txt
PF_Rs, LIC_Rs;
public static int DA_Value, HRA_Value, WA_Value, GPF_Value, IT_Value,
GIS_Value, PF_Value, LIC_Value;
public static int Allow, Dedu, Net_Salary,ss;
public Emprptwindow(JFrame getParentFrame) {
super("Payroll Report", true, true, true, true);
setSize(600, 700);
JFParentFrame = getParentFrame;
Page 28
project code.txt
panel4 = new JPanel();
panel4.setLayout(new FlowLayout());
GenerateBtn = new JButton("Get Report");
GenerateBtn.addActionListener(this);
panel4.add(GenerateBtn);
Page 29
project code.txt
panel5 = new JPanel();
panel5.setLayout(new FlowLayout());
panel5.add(Lblcollege2, BorderLayout.CENTER);
panel5_1 = new JPanel();
panel5_1.setLayout(new GridLayout(3, 3));
panel5_1.add(Lbldate);
panel5_1.add(TxtDate);
panel5_1.add(LblSalary_Slip, "CENTER");
panel5_1.add(TxtSalary_Month, "RIGHT");
panel5_1.add(LblBasic_Pay, "LEFT");
panel5_1.add(TxtBasic_Pay, "CENTER");
panel7 = new JPanel();
panel7.setLayout(new FlowLayout());
panel7.add(LblAllowance, "CENTER");
panel8_1 = new JPanel();
panel8_1.setLayout(new GridLayout(3, 2));
panel8_1.add(LblDA);
panel8_1.add(TxtDA);
panel8_1.add(LblHRA);
panel8_1.add(TxtHRA);
panel8_1.add(LblWA);
panel8_1.add(TxtWA);
panel9 = new JPanel();
panel9.setLayout(new GridLayout(1, 3));
panel9.add(LblTot_Allowance, "EAST");
panel9.add(TxtTot_Allowance, "EAST");
panel10 = new JPanel();
panel10.setLayout(new FlowLayout());
panel10.add(LblDeduction, "CENTER");
panel11 = new JPanel();
panel11.setLayout(new GridLayout(5, 5));
panel11.add(LblGPF);
panel11.add(TxtGPF);
panel11.add(LblIT);
panel11.add(TxtIT);
panel11.add(LblGIS);
panel11.add(TxtGIS);
panel11.add(LblPF);
panel11.add(TxtPF);
panel11.add(LblLIC);
panel11.add(TxtLIC);
panel12 = new JPanel();
panel12.setLayout(new GridLayout(1, 3));
panel12.add(LblTot_Deduction);
panel12.add(TxtTot_Deduction);
panel13 = new JPanel();
panel13.setLayout(new FlowLayout());
panel13.add(LblNet_Salary);
panel13.add(TxtNet_Salary);
Page 30
project code.txt
panel14 = new JPanel();
panel14.setLayout(new FlowLayout());
PrintBtn = new JButton("Preview", new
ImageIcon("./src/images/prints.png"));
PrintBtn.addActionListener(this);
ExitBtn = new JButton("Exit", new ImageIcon("./src/images/exit.png"));
ExitBtn.addActionListener(this);
panel14.add(PrintBtn);
panel14.add(ExitBtn);
Container pane = getContentPane();
pane.setLayout(new BoxLayout(pane, BoxLayout.Y_AXIS));
pane.add(panel1);
pane.add(panel2);
pane.add(panel3);
pane.add(panel4);
pane.add(panel5);
pane.add(panel5_1);
pane.add(panel7);
pane.add(panel8_1);
pane.add(panel9);
pane.add(panel10);
pane.add(panel11);
pane.add(panel12);
pane.add(panel13);
pane.add(panel14);
setFrameIcon(new ImageIcon("images/New.gif"));
setDefaultCloseOperation(DISPOSE_ON_CLOSE);
pack();
}
public void actionPerformed(ActionEvent event) {
Object source = event.getSource();
if (source == MonthCombo) {
String Emp_Month = (String) MonthCombo.getSelectedItem();
}
if (source == PrintBtn) {
printwindow prn = new printwindow();
prn.fill_data(sEmp_Name1, sEmp_Name2, Emp_Month, Emp_Year, sEmp_Code,
sDate,
sEmp_Desi, sBasic_Pay, sDA_Allow, sHRA_Allow, sWA_Allow,
sGPF_Dedu, sIT_Dedu, sGIS_Dedu, sPF_Dedu, sLIC_Dedu, sAllow,
sDedu, sNet_Salary);
}
if (source == GenerateBtn) {
sEmp_Code = TxtEmp_Code.getText().trim();
s = TxtYear.getText();
Page 31
project code.txt
ss=Integer.parseInt(s)*500;
// ss=Integer.parseInt(s);
System.out.println(s);
Get_Data(sEmp_Code);
Generate_Report(sEmp_Desi);
}
if (source == ExitBtn) {
setVisible(false);
dispose();
}
}
public void Get_Data(String code) {
try {
conn = connect.setConnection(conn, "", "");
} catch (Exception e) {
}
try {
Statement stmt = conn.createStatement();
if (!code.equals("")) {
String query = "SELECT * FROM EMPLOYEE WHERE Emp_Code = '" + code
+ "'";
ResultSet rs = stmt.executeQuery(query);
int foundrec = 0;
while (rs.next()) {
sEmp_Code = code;
sEmp_Name1 = rs.getString(2).trim();
sEmp_Name2 = rs.getString(3).trim();
sEmp_Desi = rs.getString(4).trim();
Emp_Month = (String) MonthCombo.getSelectedItem();
Emp_Year = TxtYear.getText().trim();
foundrec = 1;
}
if (foundrec == 0) {
dialogmessage = "No Such Employuee";
dialogtype = JOptionPane.WARNING_MESSAGE;
JOptionPane.showMessageDialog((Component) null,
dialogmessage, dialogs, dialogtype);
}
} else {
dialogmessage = "No Blank Field Allowed";
dialogtype = JOptionPane.WARNING_MESSAGE;
JOptionPane.showMessageDialog((Component) null, dialogmessage,
Page 32
project code.txt
dialogs, dialogtype);
}
} catch (Exception e) {
System.out.println("\nUnknown Error at Genrate_Data");
}
}
public void Generate_Report(String Desi) {
try {
conn = connect.setConnection(conn, "", "");
} catch (Exception e) {
}
try {
Statement stmt = conn.createStatement();
if (!Desi.equals("")) {
String query = "SELECT * FROM Settings WHERE Category_Name = '" +
Desi + "'";
ResultSet rs = stmt.executeQuery(query);
int foundrec = 0;
while (rs.next()) {
sCategory_Type = rs.getString(1).trim();
sCategory_Name = rs.getString(2).trim();
vBasic_Pay = rs.getInt(3);
sDA = rs.getString(4).trim();
sHRA = rs.getString(5).trim();
sWA = rs.getString(6).trim();
sGPF = rs.getString(7).trim();
sIT = rs.getString(8).trim();
sGIS = rs.getString(9).trim();
sPF = rs.getString(10).trim();
sLIC = rs.getString(11).trim();
DA_Value = rs.getInt(12);
HRA_Value = rs.getInt(13);
WA_Value = rs.getInt(14);
GPF_Value = rs.getInt(15);
IT_Value = rs.getInt(16);
GIS_Value = rs.getInt(17);
PF_Value = rs.getInt(18);
LIC_Value = rs.getInt(19);
if (sDA.equals("true")) {
DA_Rs = vBasic_Pay * DA_Value / 100;
} else {
DA_Rs = DA_Value;
}
Page 33
project code.txt
if (sHRA.equals("true")) {
HRA_Rs = (vBasic_Pay * HRA_Value) / 100;
} else {
HRA_Rs = HRA_Value;
}
if (sWA.equals("true")) {
WA_Rs = (vBasic_Pay * WA_Value) / 100;
} else {
WA_Rs = WA_Value;
}
if (sGPF.equals("true")) {
GPF_Rs = (vBasic_Pay * GPF_Value) / 100;
} else {
GPF_Rs = GPF_Value;
}
if (sIT.equals("true")) {
IT_Rs = (vBasic_Pay * IT_Value) / 100;
} else {
IT_Rs = IT_Value;
}
if (sGIS.equals("true")) {
GIS_Rs = (vBasic_Pay * GIS_Value) / 100;
} else {
GIS_Rs = GIS_Value;
}
if (sPF.equals("true")) {
PF_Rs = (vBasic_Pay * PF_Value) / 100;
} else {
PF_Rs = PF_Value;
}
if (sLIC.equals("true")) {
LIC_Rs = (vBasic_Pay * LIC_Value) / 100;
} else {
LIC_Rs = LIC_Value;
}
project code.txt
" + Emp_Year);
TxtEmp_Code.setText(sEmp_Code);
TxtEmp_Desi.setText(sEmp_Desi);
TxtBasic_Pay.setText(sBasic_Pay);
TxtDA.setText(sDA_Allow);
TxtHRA.setText(sHRA_Allow);
TxtWA.setText(sWA_Allow);
TxtTot_Allowance.setText(sAllow);
TxtGPF.setText(sGPF_Dedu);
TxtIT.setText(sIT_Dedu);
TxtGIS.setText(sGIS_Dedu);
TxtPF.setText(sPF_Dedu);
TxtLIC.setText(sLIC_Dedu);
TxtTot_Deduction.setText(sDedu);
TxtNet_Salary.setText(sNet_Salary);
foundrec = 1;
}
if (foundrec == 0) {
dialogmessage = "No Such Employuee";
dialogtype = JOptionPane.WARNING_MESSAGE;
JOptionPane.showMessageDialog((Component) null,
dialogmessage, dialogs, dialogtype);
}
} else {
dialogmessage = "No Blank Field Allowed";
dialogtype = JOptionPane.WARNING_MESSAGE;
JOptionPane.showMessageDialog((Component) null, dialogmessage,
dialogs, dialogtype);
}
conn.close();
} catch (Exception e) {
System.out.println("\nUnknown Errorat Generate -report");
}
}
}
Page 35