-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStudentFeeForm.java
More file actions
216 lines (180 loc) · 6.9 KB
/
Copy pathStudentFeeForm.java
File metadata and controls
216 lines (180 loc) · 6.9 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
/*
* 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 javax.swing.*;
import javax.swing.border.*;
import java.awt.event.*;
import java.sql.*;
import java.util.*;
public class StudentFeeForm extends JFrame implements ActionListener{
private JPanel contentPane;
private JTextField t1,t2,t3;
private JComboBox comboBox, comboBox_1, comboBox_2, comboBox_3;
JButton b1,b2;
Choice c1;
public static void main(String[] args) {
new StudentFeeForm().setVisible(true);
}
public StudentFeeForm() {
super("Student Fee Form");
setBounds(700, 200, 550, 450);
contentPane = new JPanel();
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
setContentPane(contentPane);
contentPane.setLayout(null);
c1 = new Choice();
c1.setForeground(new Color(47, 79, 79));
c1.setFont(new Font("Trebuchet MS", Font.BOLD, 14));
try{
connect c = new connect();
ResultSet rs = c.s.executeQuery("select * from student");
while(rs.next()){
c1.add(rs.getString("rollno"));
}
}catch(Exception e) { }
JLabel l1 = new JLabel("Select Roll No");
l1.setForeground(new Color(25, 25, 112));
l1.setFont(new Font("Tahoma", Font.BOLD, 14));
l1.setBounds(64, 63, 102, 22);
contentPane.add(l1);
JLabel l2 = new JLabel("Name");
l2.setForeground(new Color(25, 25, 112));
l2.setFont(new Font("Tahoma", Font.BOLD, 14));
l2.setBounds(64, 97, 102, 22);
contentPane.add(l2);
JLabel l3 = new JLabel("Father's Name");
l3.setForeground(new Color(25, 25, 112));
l3.setFont(new Font("Tahoma", Font.BOLD, 14));
l3.setBounds(64, 130, 102, 22);
contentPane.add(l3);
JLabel l4 = new JLabel("Branch");
l4.setForeground(new Color(25, 25, 112));
l4.setFont(new Font("Tahoma", Font.BOLD, 14));
l4.setBounds(64, 209, 102, 22);
contentPane.add(l4);
JLabel l5 = new JLabel("Semester");
l5.setForeground(new Color(25, 25, 112));
l5.setFont(new Font("Tahoma", Font.BOLD, 14));
l5.setBounds(64, 242, 102, 22);
contentPane.add(l5);
JLabel l6 = new JLabel("Total Payable");
l6.setForeground(new Color(25, 25, 112));
l6.setFont(new Font("Tahoma", Font.BOLD, 14));
l6.setBounds(64, 275, 102, 22);
contentPane.add(l6);
c1.setBounds(174, 66, 156, 20);
contentPane.add(c1);
t2 = new JTextField();
t2.setForeground(new Color(47, 79, 79));
t2.setFont(new Font("Trebuchet MS", Font.BOLD, 14));
t2.setColumns(10);
t2.setBounds(174, 100, 156, 20);
contentPane.add(t2);
t3 = new JTextField();
t3.setForeground(new Color(47, 79, 79));
t3.setFont(new Font("Trebuchet MS", Font.BOLD, 14));
t3.setColumns(10);
t3.setBounds(174, 133, 156, 20);
contentPane.add(t3);
try{
connect c = new connect();
ResultSet rs = c.s.executeQuery("select * from student where rollno = '"+c1.getSelectedItem()+"'");
while(rs.next()){
t2.setText(rs.getString("name"));
t3.setText(rs.getString("fathers_name"));
}
}catch(Exception e){}
comboBox = new JComboBox();
comboBox.setModel(new DefaultComboBoxModel(new String[] { "Mechanical", "CSE", "IT", "Civil", "Automobile", "Electronics", "Other" }));
comboBox.setForeground(new Color(47, 79, 79));
comboBox.setFont(new Font("Trebuchet MS", Font.BOLD, 14));
comboBox.setBounds(176, 211, 154, 20);
contentPane.add(comboBox);
comboBox_2 = new JComboBox();
comboBox_2.setModel(
new DefaultComboBoxModel(new String[] { "1st", "2nd", "3rd", "4th", "5th", "6th", "7th", "8th" }));
comboBox_2.setFont(new Font("Trebuchet MS", Font.BOLD, 14));
comboBox_2.setForeground(new Color(47, 79, 79));
comboBox_2.setBounds(176, 244, 154, 20);
contentPane.add(comboBox_2);
t1 = new JTextField();
t1.setForeground(new Color(47, 79, 79));
t1.setFont(new Font("Trebuchet MS", Font.BOLD, 14));
t1.setColumns(10);
t1.setBounds(176, 275, 154, 20);
add(t1);
b1 = new JButton("Pay");
b1.addActionListener(this);
b1.setFont(new Font("Trebuchet MS", Font.BOLD, 14));
b1.setBounds(64, 321, 111, 33);
b1.setBackground(Color.BLACK);
b1.setForeground(Color.WHITE);
contentPane.add(b1);
b2 = new JButton("Back");
b2.addActionListener(this);
b2.setFont(new Font("Trebuchet MS", Font.BOLD, 14));
b2.setBounds(198, 321, 111, 33);
b2.setBackground(Color.BLACK);
b2.setForeground(Color.WHITE);
contentPane.add(b2);
JLabel l7 = new JLabel("Course");
l7.setForeground(new Color(25, 25, 112));
l7.setFont(new Font("Tahoma", Font.BOLD, 14));
l7.setBounds(64, 173, 102, 22);
contentPane.add(l7);
comboBox_3 = new JComboBox();
comboBox_3.setModel(new DefaultComboBoxModel(
new String[] { "B.Tech", "M.Tech", "MBA", "BBA", "BCA", "B.Sc", "MCA" }));
comboBox_3.setForeground(new Color(47, 79, 79));
comboBox_3.setFont(new Font("Trebuchet MS", Font.BOLD, 14));
comboBox_3.setBounds(176, 176, 154, 20);
contentPane.add(comboBox_3);
JPanel panel = new JPanel();
panel.setBorder(new TitledBorder(new LineBorder(new Color(102, 205, 170), 2, true), "Fee-Form",
TitledBorder.LEADING, TitledBorder.TOP, null, new Color(30, 144, 255)));
panel.setBackground(new Color(211, 211, 211));
panel.setBounds(10, 38, 358, 348);
contentPane.setBackground(Color.WHITE);
panel.setBackground(Color.WHITE);
contentPane.add(panel);
}
public void actionPerformed(ActionEvent ae){
try{
if(ae.getSource() == b1){
try{
connect con = new connect();
String sql = "insert into fee(rollno, name, fathers_name, course, branch, semester, fee_paid) values(?, ?, ?, ?, ?, ?, ?)";
PreparedStatement st = con.c.prepareStatement(sql);
st.setString(1, c1.getSelectedItem());
st.setString(2, t2.getText());
st.setString(3, t3.getText());
st.setString(4, (String) comboBox_3.getSelectedItem());
st.setString(5, (String) comboBox.getSelectedItem());
st.setString(6, (String) comboBox_2.getSelectedItem());
st.setString(7, t1.getText());
int i = st.executeUpdate();
if (i > 0){
JOptionPane.showMessageDialog(null, "Successfully Paid");
this.setVisible(false);
}
else
JOptionPane.showMessageDialog(null, "error");
}catch(Exception e){
e.printStackTrace();
}
}
if(ae.getSource() == b2){
this.setVisible(false);
}
}catch(Exception e){
}
}
}