-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMember.java
More file actions
175 lines (141 loc) · 5.24 KB
/
Member.java
File metadata and controls
175 lines (141 loc) · 5.24 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
/*
* 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.
*/
import java.awt.Color;
import java.awt.Font;
import javax.swing.*;
import java.awt.event.*;
import javax.swing.border.TitledBorder;
/**
*
* @author root
*/
public class Member extends JFrame {
JLabel l1, l2, l3, l4, l5, l6, l7, l8;
JTextField t1, t2, t3;
JButton add, back;
String name, father, course, member;
int year, sem, roll = 1;
String yyear[], ssem[], ccourse[], mmember[];
JComboBox j1, j2, j3, j4;
JPanel p=new JPanel();
Member() {
setTitle("New Member");
setLayout(null);
TitledBorder title;
title = BorderFactory.createTitledBorder(" New Member");
//BorderFactory.createTitledBorder(null, "text", TitledBorder.CENTER, TitledBorder.BOTTOM, new Font("times new roman",Font.PLAIN,12), Color.yellow)
title.setTitleColor(Color.RED);
title.setTitleFont(new Font("times new roman", Font.PLAIN, 20));
// title.setTitleJustification(TitledBorder.LEFT);
p.setBorder(title);
// p.setBackground();
p.setBounds(0, 0, 600, 500);
p.setLayout(null);
p.setBackground(Color.white);
l1 = new JLabel("Member id");
l1.setBounds(100, 60, 100, 30);
p.add(l1);
l2 = new JLabel("Name");
l2.setBounds(100, 100, 100, 30);
p.add(l2);
l3 = new JLabel("Father Name");
l3.setBounds(100, 140, 100, 30);
p.add(l3);
l4 = new JLabel("Department");
l4.setBounds(100, 180, 200, 30);
p.add(l4);
l5 = new JLabel("Year");
l5.setBounds(100, 220, 100, 30);
p.add(l5);
l6 = new JLabel("Sem");
l6.setBounds(100, 260, 100, 30);
p.add(l6);
l7 = new JLabel("Member type");
l7.setBounds(100, 300, 100, 30);
p.add(l7);
t1 = new JTextField();
t1.setBounds(300, 60, 200, 30);
t1.setEditable(false);
t1.setText(" Automatic Generated");
p.add(t1);
t2 = new JTextField();
t2.setBounds(300, 100, 200, 30);
p.add(t2);
t3 = new JTextField();
t3.setBounds(300, 140, 200, 30);
p.add(t3);
ccourse = new String[]{"Mtech", "BTech", "MCA", "BCA", "BBA", "MBA", "BA", "BCom", "BSC"};
j1 = new JComboBox(ccourse);
j1.setBounds(300, 180, 200, 30);
p.add(j1);
yyear = new String[]{"1", "2", "3", "4"};
j2 = new JComboBox(yyear);
j2.setBounds(300, 220, 200, 30);
p.add(j2);
ssem = new String[]{"1", "2", "3", "4", "5", "6", "7", "8"};
j3 = new JComboBox(ssem);
j3.setBounds(300, 260, 200, 30);
p.add(j3);
mmember = new String[]{"Student", "Teacher"};
j4 = new JComboBox(mmember);
j4.setBounds(300, 300, 200, 30);
p.add(j4);
add = new JButton("Add");
add.setBounds(70, 400, 100, 30);
add.setIcon(new ImageIcon(getClass().getResource("/12.png")));
add.setHorizontalAlignment(SwingConstants.LEFT);
p.add(add);
back = new JButton("Back");
back.setBounds(400, 400, 100, 30);
back.setIcon(new ImageIcon(getClass().getResource("/11.png")));
back.setHorizontalAlignment(SwingConstants.LEFT);
back.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
setVisible(false);
WelcomePage w = new WelcomePage();
}
});
p.add(back);
add(p);
setSize(400, 400);
setVisible(true);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(700, 270, 610, 540);
add.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
add();
}
});
}
void add() {
JavaConnection db = new JavaConnection();
db.connection();
name = t2.getText();
father = t3.getText();
course = (String) j1.getSelectedItem();
year = Integer.parseInt((String) j2.getSelectedItem());
sem = Integer.parseInt((String) j3.getSelectedItem());
member = (String) j4.getSelectedItem();
String nam, fath, mem;
nam = fath = mem ="";
String insert;
if (name.equals(nam) || father.equals(fath)) {
JOptionPane.showMessageDialog(null, "This is an illegal input !");
} else {
insert = "INSERT INTO Member (name,father_name,department,year,sem,member_type) VALUES('" + name + "','" + father + "','" + course + "','" + year + "','" + sem + "','" + member + "')";
db.executeUpdate(insert);
JOptionPane.showMessageDialog(null,member +", is added as Member !");
t2.setText("");
t3.setText("");
}
db.connClose();
}
}
class Sig {
public static void main(String[] args) {
Member s = new Member();
}
}