-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathapp.java
186 lines (141 loc) · 4.24 KB
/
app.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
import java.sql.*;
public class app extends JFrame implements ActionListener
{
JPanel p=new JPanel();
JPanel q=new JPanel();
JTextField tname,tage,textra,tusr,tpwd;
JLabel lname,lage,lsex,ledu,lextra,lexpect,lsal,Blank,Blank1,Blank2,Blank3,Blank4,lusr,lpwd;
JRadioButton rbml,rbfml;
JComboBox cbedu,cbsal;
JRadioButton it,civil,mech;
JButton bSub,bRes;
String sex=new String();
int field;
public static void main(String args[]){
new app();
}
public app()
{
getContentPane().add(p,BorderLayout.CENTER);
getContentPane().add(q,BorderLayout.SOUTH);
setTitle("Placement Office");
lusr=new JLabel("Login Name: ");
lpwd=new JLabel("Password: ");
lname=new JLabel("Name: ");
lage=new JLabel("Age: ");
lsex=new JLabel("Sex: ");
ledu=new JLabel("Education: ");
lextra=new JLabel("Extra: ");
lexpect=new JLabel("Field: ");
lsal=new JLabel("Minimum Expected Salary: ");
tusr=new JTextField(10);
tpwd=new JTextField(10);
tname=new JTextField(20);
tage=new JTextField(2);
textra=new JTextField(15);
rbml=new JRadioButton("Male");
rbfml=new JRadioButton("Female");
ButtonGroup bgrp=new ButtonGroup();
bgrp.add(rbml);
bgrp.add(rbfml);
cbedu=new JComboBox();
cbedu.addItem("Diploma");
cbedu.addItem("Degree");
cbedu.addItem("Post-Graduate");
cbsal=new JComboBox();
cbsal.addItem("5,000");
cbsal.addItem("10,000");
cbsal.addItem("15,000");
cbsal.addItem("20,000");
it=new JRadioButton("Software Engg.");
civil=new JRadioButton("Civil Engg.");
mech=new JRadioButton("Mechanical Engg.");
ButtonGroup bg2=new ButtonGroup();
bg2.add(it);
bg2.add(civil);
bg2.add(mech);
bSub=new JButton("Submit");
bRes=new JButton("Reset");
p.setLayout(new GridLayout(12,2));
Blank=new JLabel("");
Blank1=new JLabel("");
Blank2=new JLabel("");
Blank3=new JLabel("");
Blank4=new JLabel("");
p.add(lusr);
p.add(tusr);
p.add(lpwd);
p.add(tpwd);
p.add(lname);
p.add(tname);
p.add(lage);
p.add(tage);
p.add(lsex);
p.add(rbml);
p.add(Blank);
p.add(rbfml);
p.add(ledu);
p.add(cbedu);
p.add(lextra);
p.add(textra);
p.add(lexpect);
p.add(it);
p.add(Blank4);
p.add(civil);
p.add(Blank1);
p.add(mech);
p.add(lsal);
p.add(cbsal);
q.add(bSub);
q.add(bRes);
bSub.addActionListener(this);
bRes.addActionListener(this);
setVisible(true);
setBounds(200,200,500,500);
setDefaultCloseOperation(EXIT_ON_CLOSE);
}
public void actionPerformed(ActionEvent e){
Object source=e.getSource();
if(source==bRes){
tname.setText("");
tage.setText("");
cbedu.setSelectedItem("Diploma");
textra.setText("");
tusr.setText("");
tpwd.setText("");
}
else{
if(it.isSelected())field=1;
else if(civil.isSelected())field=2;
else if(mech.isSelected())field=3;
if(rbml.isSelected())sex="MALE";
else if(rbfml.isSelected())sex="FEMALE";
try{
int age=Integer.parseInt(tage.getText());}
catch(Exception ex){tage.setText("");}
if(tname.getText().equals("") | textra.getText().equals("") | tage.getText().equals("") | sex.equals("") | field==0 ) JOptionPane.showMessageDialog(null,"Please Fill in All Valid Entries!!");
else{
String sal=(String)cbsal.getSelectedItem();
String edu=(String)cbedu.getSelectedItem();
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection conn=DriverManager.getConnection("jdbc:odbc:go");
Statement st=conn.createStatement();
st.executeUpdate("INSERT INTO Applicant VALUES('" + tname.getText() + "','" + tage.getText() + "','" + sex + "','" + edu + "','" + textra.getText() + "','" + sal + "','" + field + "','" + tusr.getText() + "','" + tpwd.getText() + "')");
conn.close();
String msg="Your Details are Stored. Login again to View Related Companies! Thank You!!";
JOptionPane.showMessageDialog(null,msg);
new login();
setVisible(false);
}
catch(Exception exc){
JOptionPane.showMessageDialog(null,tname.getText()+" : "+exc);
System.exit(0);
}
}
}
}
}