-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAddStudent.java
More file actions
234 lines (185 loc) · 6.92 KB
/
Copy pathAddStudent.java
File metadata and controls
234 lines (185 loc) · 6.92 KB
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
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package university.management.systems;
/**
*
* @author R.SHANMUKH
*/
import java.awt.*;
import java.awt.event.*;
import java.util.Random;
import javax.swing.*;
class AddStudent implements ActionListener{
JFrame f;
JLabel id,id1,id2,id3,id4,id5,id6,id7,id8,id9,id10,id11,id12,id15,id16,id17,lab,lab1,lab2;
JTextField t,t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12,t13;
JButton b,b1,b2,b3;
JComboBox c1,c2;
Random ran = new Random();
long first4 = (ran.nextLong() % 9000L) + 1000L;
long first = Math.abs(first4);
public AddStudent(){
f = new JFrame("Add Student");
f.setBackground(Color.white);
f.setLayout(null);
id15=new JLabel();
id15.setBounds(0,0,900,700);
id15.setLayout(null);
ImageIcon img = new ImageIcon(ClassLoader.getSystemResource("university/management/systems/icons/fourth.jpg"));
Image i3 = img.getImage().getScaledInstance(1220, 700,Image.SCALE_DEFAULT);
ImageIcon icc3 = new ImageIcon(i3);
id15.setIcon(icc3);
id8 = new JLabel("New Student Details");
id8.setBounds(320,30,500,50);
id8.setFont(new Font("serif",Font.ITALIC,25));
id8.setForeground(Color.black);
id15.add(id8);
f.add(id15);
id1 = new JLabel("Name");
id1.setBounds(50,150,100,30);
id1.setFont(new Font("serif",Font.BOLD,20));
id15.add(id1);
t1=new JTextField();
t1.setBounds(200,150,150,30);
id15.add(t1);
id2 = new JLabel("Father's Name");
id2.setBounds(400,150,200,30);
id2.setFont(new Font("serif",Font.BOLD,20));
id15.add(id2);
t2=new JTextField();
t2.setBounds(600,150,150,30);
id15.add(t2);
id3= new JLabel("Age");
id3.setBounds(50,200,100,30);
id3.setFont(new Font("serif",Font.BOLD,20));
id15.add(id3);
t3=new JTextField();
t3.setBounds(200,200,150,30);
id15.add(t3);
id4= new JLabel("DOB (dd/mm/yyyy)");
id4.setBounds(400,200,200,30);
id4.setFont(new Font("serif",Font.BOLD,20));
id15.add(id4);
t4=new JTextField();
t4.setBounds(600,200,150,30);
id15.add(t4);
id5= new JLabel("Address");
id5.setBounds(50,250,100,30);
id5.setFont(new Font("serif",Font.BOLD,20));
id15.add(id5);
t5=new JTextField();
t5.setBounds(200,250,150,30);
id15.add(t5);
id6= new JLabel("Phone");
id6.setBounds(400,250,100,30);
id6.setFont(new Font("serif",Font.BOLD,20));
id15.add(id6);
t6=new JTextField();
t6.setBounds(600,250,150,30);
id15.add(t6);
id7= new JLabel("Email Id");
id7.setBounds(50,300,100,30);
id7.setFont(new Font("serif",Font.BOLD,20));
id15.add(id7);
t7=new JTextField();
t7.setBounds(200,300,150,30);
id15.add(t7);
id9= new JLabel("Class X(%)");
id9.setBounds(400,300,130,30);
id9.setFont(new Font("serif",Font.BOLD,20));
id15.add(id9);
t8=new JTextField();
t8.setBounds(600,300,150,30);
id15.add(t8);
id10= new JLabel("Class XII(%)");
id10.setBounds(50,350,130,30);
id10.setFont(new Font("serif",Font.BOLD,20));
id15.add(id10);
t9=new JTextField();
t9.setBounds(200,350,150,30);
id15.add(t9);
id11= new JLabel("Aadhar No");
id11.setBounds(400,350,100,30);
id11.setFont(new Font("serif",Font.BOLD,20));
id15.add(id11);
t10=new JTextField();
t10.setBounds(600,350,150,30);
id15.add(t10);
id12= new JLabel("Roll No");
id12.setBounds(50,400,150,30);
id12.setFont(new Font("serif",Font.BOLD,20));
id15.add(id12);
t11=new JTextField();
t11.setBounds(200,400,150,30);
t11.setText("1533"+first);
id15.add(t11);
lab=new JLabel("Course");
lab.setBounds(400,400,150,30);
lab.setFont(new Font("serif",Font.BOLD,20));
id15.add(lab);
String course[] = {"B.Tech","BBA","BCA","Bsc","Msc","MBA","MCA","BA","BCom"};
c1 = new JComboBox(course);
c1.setBackground(Color.WHITE);
c1.setBounds(600,400,150,30);
id15.add(c1);
lab2=new JLabel("Branch");
lab2.setBounds(50,450,150,30);
lab2.setFont(new Font("serif",Font.BOLD,20));
id15.add(lab2);
String branch[] = {"Computer Science","Electronics","Electrical","Mechanical","Civil"};
c2 = new JComboBox(branch);
c2.setBackground(Color.WHITE);
c2.setBounds(200,450,150,30);
id15.add(c2);
b = new JButton("Submit");
b.setBackground(Color.BLACK);
b.setForeground(Color.WHITE);
b.setBounds(250,550,150,40);
id15.add(b);
b1=new JButton("Cancel");
b1.setBackground(Color.BLACK);
b1.setForeground(Color.WHITE);
b1.setBounds(450,550,150,40);
id15.add(b1);
b.addActionListener(this);
b1.addActionListener(this);
f.setVisible(true);
f.setSize(900,700);
f.setLocation(400,150);
}
public void actionPerformed(ActionEvent ae){
String a = t1.getText();
String bb = t2.getText();
String c = t3.getText();
String d = t4.getText();
String e = t5.getText();
String ff = t6.getText();
String g = t7.getText();
String h = t8.getText();
String i = t9.getText();
String j = t10.getText();
String k = t11.getText();
String l = (String)c1.getSelectedItem();
String m = (String)c2.getSelectedItem();
if(ae.getSource() == b){
try{
connect cc = new connect();
String q = "insert into student values('"+a+"','"+bb+"','"+c+"','"+d+"','"+e+"','"+ff+"','"+g+"','"+h+"','"+i+"','"+j+"','"+k+"','"+l+"','"+m+"')";
cc.s.executeUpdate(q);
JOptionPane.showMessageDialog(null,"Student Details Inserted Successfully");
f.setVisible(false);
}catch(Exception ee){
System.out.println("The error is:"+ee);
}
}else if(ae.getSource() == b1){
f.setVisible(false);
new Project().setVisible(true);
}
}
public static void main(String[ ] arg){
new AddStudent().f.setVisible(true);
}
}