-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathIssueBook.java
363 lines (312 loc) · 11.5 KB
/
IssueBook.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
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
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
package library1;
import java.awt.*;
import javax.swing.*;
import javax.swing.border.*;
import com.toedter.calendar.JDateChooser;
import java.awt.event.*;
import java.sql.*;
public class IssueBook extends JFrame implements ActionListener{
/**
*
*/
private static final long serialVersionUID = 1L;
private JPanel contentPane;
JDateChooser dateChooser;
private JTextField t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12,t13,t14;
private JButton b1,b2,b3,b4;
public static void main(String[] args) {
new IssueBook().setVisible(true);
}
public IssueBook() {
setBounds(300, 200, 900, 500);
contentPane = new JPanel();
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
setContentPane(contentPane);
contentPane.setBackground(Color.WHITE);
contentPane.setLayout(null);
JLabel l1 = new JLabel("Book_id");
l1.setFont(new Font("Tahoma", Font.BOLD, 14));
l1.setForeground(new Color(47, 79, 79));
l1.setBounds(47, 63, 100, 23);
contentPane.add(l1);
JLabel l2 = new JLabel("Name");
l2.setForeground(new Color(47, 79, 79));
l2.setFont(new Font("Tahoma", Font.BOLD, 14));
l2.setBounds(47, 97, 100, 23);
contentPane.add(l2);
JLabel l3 = new JLabel("ISBN");
l3.setForeground(new Color(47, 79, 79));
l3.setFont(new Font("Tahoma", Font.BOLD, 14));
l3.setBounds(47, 131, 100, 23);
contentPane.add(l3);
JLabel l4 = new JLabel("Publisher");
l4.setForeground(new Color(47, 79, 79));
l4.setFont(new Font("Tahoma", Font.BOLD, 14));
l4.setBounds(47, 165, 100, 23);
contentPane.add(l4);
JLabel l5 = new JLabel("Edition");
l5.setForeground(new Color(47, 79, 79));
l5.setFont(new Font("Tahoma", Font.BOLD, 14));
l5.setBounds(47, 199, 100, 23);
contentPane.add(l5);
JLabel l6 = new JLabel("Price");
l6.setForeground(new Color(47, 79, 79));
l6.setFont(new Font("Tahoma", Font.BOLD, 14));
l6.setBounds(47, 233, 100, 23);
contentPane.add(l6);
JLabel l7 = new JLabel("Pages");
l7.setForeground(new Color(47, 79, 79));
l7.setFont(new Font("Tahoma", Font.BOLD, 14));
l7.setBounds(47, 267, 100, 23);
contentPane.add(l7);
t1 = new JTextField();
t1.setForeground(new Color(47, 79, 79));
t1.setFont(new Font("Trebuchet MS", Font.BOLD, 14));
t1.setBounds(126, 66, 86, 20);
contentPane.add(t1);
b1 = new JButton("Search");
b1.addActionListener(this);
b1.setBorder(new LineBorder(new Color(192, 192, 192), 1, true));
b1.setBackground(Color.BLACK);
b1.setForeground(Color.WHITE);
b1.setFont(new Font("Trebuchet MS", Font.BOLD, 14));
b1.setBounds(234, 59, 100, 30);
contentPane.add(b1);
t2 = new JTextField();
t2.setEditable(false);
t2.setForeground(new Color(47, 79, 79));
t2.setFont(new Font("Trebuchet MS", Font.BOLD, 14));
t2.setBounds(126, 100, 208, 20);
contentPane.add(t2);
t2.setColumns(10);
t3 = new JTextField();
t3.setEditable(false);
t3.setForeground(new Color(47, 79, 79));
t3.setFont(new Font("Trebuchet MS", Font.BOLD, 14));
t3.setColumns(10);
t3.setBounds(126, 131, 208, 20);
contentPane.add(t3);
t4 = new JTextField();
t4.setEditable(false);
t4.setForeground(new Color(47, 79, 79));
t4.setFont(new Font("Trebuchet MS", Font.BOLD, 14));
t4.setColumns(10);
t4.setBounds(126, 168, 208, 20);
contentPane.add(t4);
t5 = new JTextField();
t5.setEditable(false);
t5.setForeground(new Color(47, 79, 79));
t5.setFont(new Font("Trebuchet MS", Font.BOLD, 14));
t5.setColumns(10);
t5.setBounds(126, 202, 208, 20);
contentPane.add(t5);
t6 = new JTextField();
t6.setEditable(false);
t6.setForeground(new Color(47, 79, 79));
t6.setFont(new Font("Trebuchet MS", Font.BOLD, 14));
t6.setColumns(10);
t6.setBounds(126, 236, 208, 20);
contentPane.add(t6);
t7 = new JTextField();
t7.setEditable(false);
t7.setForeground(new Color(47, 79, 79));
t7.setFont(new Font("Trebuchet MS", Font.BOLD, 14));
t7.setColumns(10);
t7.setBounds(126, 270, 208, 20);
contentPane.add(t7);
JPanel panel = new JPanel();
panel.setBorder(new TitledBorder(new LineBorder(new Color(47, 79, 79), 2, true), "Issue-Book",
TitledBorder.LEADING, TitledBorder.TOP, null, new Color(34, 139, 34)));
panel.setFont(new Font("Tahoma", Font.BOLD, 14));
panel.setBounds(10, 38, 345, 288);
panel.setBackground(Color.WHITE);
contentPane.add(panel);
JLabel l8 = new JLabel("Student_id");
l8.setForeground(new Color(47, 79, 79));
l8.setFont(new Font("Tahoma", Font.BOLD, 14));
l8.setBounds(384, 63, 100, 23);
contentPane.add(l8);
JLabel l9 = new JLabel("Name");
l9.setForeground(new Color(47, 79, 79));
l9.setFont(new Font("Tahoma", Font.BOLD, 14));
l9.setBounds(384, 103, 100, 23);
contentPane.add(l9);
JLabel l10 = new JLabel("Father's Name");
l10.setForeground(new Color(47, 79, 79));
l10.setFont(new Font("Tahoma", Font.BOLD, 14));
l10.setBounds(384, 147, 100, 23);
contentPane.add(l10);
JLabel l11 = new JLabel("Course");
l11.setForeground(new Color(47, 79, 79));
l11.setFont(new Font("Tahoma", Font.BOLD, 14));
l11.setBounds(384, 187, 100, 23);
contentPane.add(l11);
JLabel l12 = new JLabel("Branch");
l12.setForeground(new Color(47, 79, 79));
l12.setFont(new Font("Tahoma", Font.BOLD, 14));
l12.setBounds(384, 233, 100, 23);
contentPane.add(l12);
JLabel l13 = new JLabel("Year");
l13.setForeground(new Color(47, 79, 79));
l13.setFont(new Font("Tahoma", Font.BOLD, 14));
l13.setBounds(384, 284, 100, 23);
contentPane.add(l13);
JLabel l14 = new JLabel("Semester");
l14.setForeground(new Color(47, 79, 79));
l14.setFont(new Font("Tahoma", Font.BOLD, 14));
l14.setBounds(384, 336, 100, 23);
contentPane.add(l14);
t8 = new JTextField();
t8.setForeground(new Color(47, 79, 79));
t8.setFont(new Font("Trebuchet MS", Font.BOLD, 14));
t8.setColumns(10);
t8.setBounds(508, 66, 86, 20);
contentPane.add(t8);
b2 = new JButton("Search");
b2.addActionListener(this);
b2.setFont(new Font("Trebuchet MS", Font.BOLD, 14));
b2.setBorder(new LineBorder(new Color(192, 192, 192), 1, true));
b2.setBounds(604, 59, 100, 30);
b2.setBackground(Color.BLACK);
b2.setForeground(Color.WHITE);
contentPane.add(b2);
t9 = new JTextField();
t9.setForeground(new Color(47, 79, 79));
t9.setFont(new Font("Trebuchet MS", Font.BOLD, 14));
t9.setEditable(false);
t9.setColumns(10);
t9.setBounds(508, 106, 208, 20);
contentPane.add(t9);
t10 = new JTextField();
t10.setForeground(new Color(47, 79, 79));
t10.setFont(new Font("Trebuchet MS", Font.BOLD, 14));
t10.setEditable(false);
t10.setColumns(10);
t10.setBounds(508, 150, 208, 20);
contentPane.add(t10);
t11 = new JTextField();
t11.setForeground(new Color(47, 79, 79));
t11.setFont(new Font("Trebuchet MS", Font.BOLD, 14));
t11.setEditable(false);
t11.setColumns(10);
t11.setBounds(508, 190, 208, 20);
contentPane.add(t11);
t12 = new JTextField();
t12.setForeground(new Color(47, 79, 79));
t12.setFont(new Font("Trebuchet MS", Font.BOLD, 14));
t12.setEditable(false);
t12.setColumns(10);
t12.setBounds(508, 236, 208, 20);
contentPane.add(t12);
t13 = new JTextField();
t13.setForeground(new Color(47, 79, 79));
t13.setFont(new Font("Trebuchet MS", Font.BOLD, 14));
t13.setEditable(false);
t13.setColumns(10);
t13.setBounds(508, 286, 208, 20);
contentPane.add(t13);
t14 = new JTextField();
t14.setForeground(new Color(47, 79, 79));
t14.setFont(new Font("Trebuchet MS", Font.BOLD, 14));
t14.setEditable(false);
t14.setColumns(10);
t14.setBounds(508, 338, 208, 20);
contentPane.add(t14);
JPanel panel_1 = new JPanel();
panel_1.setBorder(new TitledBorder(new LineBorder(new Color(70, 130, 180), 2, true), "Student-Deatails",
TitledBorder.LEADING, TitledBorder.TOP, null, new Color(100, 149, 237)));
panel_1.setForeground(new Color(0, 100, 0));
panel_1.setBounds(360, 38, 378, 372);
panel_1.setBackground(Color.WHITE);
contentPane.add(panel_1);
JLabel l15 = new JLabel(" Date of Issue :");
l15.setForeground(new Color(105, 105, 105));
l15.setFont(new Font("Trebuchet MS", Font.BOLD, 15));
l15.setBounds(20, 340, 118, 26);
contentPane.add(l15);
dateChooser = new JDateChooser();
dateChooser.setBorder(new LineBorder(new Color(0, 0, 0), 1, true));
dateChooser.setForeground(new Color(105, 105, 105));
dateChooser.setBounds(137, 337, 200, 29);
contentPane.add(dateChooser);
b3 = new JButton("Issue");
b3.addActionListener(this);
b3.setFont(new Font("Trebuchet MS", Font.BOLD, 14));
b3.setBorder(new LineBorder(new Color(192, 192, 192), 1, true));
b3.setBounds(47, 377, 118, 33);
b3.setBackground(Color.BLACK);
b3.setForeground(Color.WHITE);
contentPane.add(b3);
b4 = new JButton("Back");
b4.addActionListener(this);
b4.setFont(new Font("Trebuchet MS", Font.BOLD, 14));
b4.setBorder(new LineBorder(new Color(192, 192, 192), 1, true));
b4.setBounds(199, 377, 100, 33);
b4.setBackground(Color.BLACK);
b4.setForeground(Color.WHITE);
contentPane.add(b4);
}
public void actionPerformed(ActionEvent ae){
try{
conn con = new conn();
if(ae.getSource() == b1){
String sql = "select * from book where book_id = ?";
PreparedStatement st = con.c.prepareStatement(sql);
st.setString(1, t1.getText());
ResultSet rs = st.executeQuery();
while (rs.next()) {
t2.setText(rs.getString("name"));
t3.setText(rs.getString("isbn"));
t4.setText(rs.getString("publisher"));
t5.setText(rs.getString("edition"));
t6.setText(rs.getString("price"));
t7.setText(rs.getString("pages"));
}
st.close();
rs.close();
}
if(ae.getSource() == b2){
String sql = "select * from student where student_id = ?";
PreparedStatement st = con.c.prepareStatement(sql);
st.setString(1, t8.getText());
ResultSet rs = st.executeQuery();
while (rs.next()) {
t9.setText(rs.getString("name"));
t10.setText(rs.getString("father"));
t11.setText(rs.getString("course"));
t12.setText(rs.getString("branch"));
t13.setText(rs.getString("year"));
t14.setText(rs.getString("semester"));
}
st.close();
rs.close();
}
if(ae.getSource() == b3){
try{
String sql = "insert into issueBook(book_id, student_id, bname, sname, course, branch, dateOfIssue) values(?, ?, ?, ?, ?, ?, ?)";
PreparedStatement st = con.c.prepareStatement(sql);
st.setString(1, t1.getText());
st.setString(2, t8.getText());
st.setString(3, t2.getText());
st.setString(4, t9.getText());
st.setString(5, t11.getText());
st.setString(6, t12.getText());
st.setString(7, ((JTextField) dateChooser.getDateEditor().getUiComponent()).getText());
int i = st.executeUpdate();
if (i > 0)
JOptionPane.showMessageDialog(null, "Successfully Book Issued..!");
else
JOptionPane.showMessageDialog(null, "error");
}catch(Exception e){
e.printStackTrace();
}
}
if(ae.getSource() == b4){
this.setVisible(false);
new home().setVisible(true);
}
con.c.close();
}catch(Exception e){
}
}
}