-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathIssue.java
More file actions
380 lines (324 loc) · 13.2 KB
/
Issue.java
File metadata and controls
380 lines (324 loc) · 13.2 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
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
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
/*
* 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 javax.swing.*;
import javax.swing.border.*;
import java.awt.event.*;
import javax.swing.event.*;
import java.awt.*;
import java.time.*;
import java.time.format.*;
import java.sql.*;
/**
*
* @author root
*/
public class Issue extends JFrame {
JLabel l1, l2, l3, l4, l5, l6, l11, l12, l13, l14, l15, l16, l17, l18;
JTextField t1, t2, t3, t4, t5, t6, t11, t12, t13, t14, t15, t16, t17;
JPanel p1, p2;
JButton search1, search2, issue, back;
String date;
Issue() {
getContentPane().setBackground(new Color(153, 170, 181));
setTitle("Issue Book");
date = LocalDate.now().format(DateTimeFormatter.ofPattern("dd-MM-yyyy"));
p1 = new JPanel();
TitledBorder title1;
title1 = BorderFactory.createTitledBorder("Book Details");
//BorderFactory.createTitledBorder(null, "text", TitledBorder.CENTER, TitledBorder.BOTTOM, new Font("times new roman",Font.PLAIN,12), Color.yellow)
title1.setTitleColor(Color.RED);
title1.setTitleFont(new Font("times new roman", Font.PLAIN, 20));
// title.setTitleJustification(TitledBorder.LEFT);
p1.setBorder(title1);
// p.setBackground();
p1.setBounds(0, 0, 600, 400);
p1.setLayout(null);
// p1.setSize(420, 350);
l1 = new JLabel("Book ID");
l1.setBounds(100, 60, 100, 30);
p1.add(l1);
l2 = new JLabel("Name");
l2.setBounds(100, 100, 100, 30);
p1.add(l2);
l3 = new JLabel("Edition");
l3.setBounds(100, 140, 100, 30);
p1.add(l3);
l4 = new JLabel("Publisher");
l4.setBounds(100, 180, 200, 30);
p1.add(l4);
l5 = new JLabel("Price");
l5.setBounds(100, 220, 100, 30);
p1.add(l5);
l6 = new JLabel("Pages");
l6.setBounds(100, 260, 100, 30);
p1.add(l6);
t1 = new JTextField();
t1.setBounds(280, 60, 200, 30);
t1.setText("0");
p1.add(t1);
t1.setEditable(true);
t2 = new JTextField();
t2.setBounds(280, 100, 200, 30);
p1.add(t2);
t2.setEditable(false);
t3 = new JTextField();
t3.setBounds(280, 140, 200, 30);
t3.setEditable(false);
p1.add(t3);
t4 = new JTextField();
t4.setBounds(280, 180, 200, 30);
t4.setEditable(false);
p1.add(t4);
t5 = new JTextField();
t5.setBounds(280, 220, 200, 30);
t5.setEditable(false);
p1.add(t5);
t6 = new JTextField();
t6.setBounds(280, 260, 200, 30);
t6.setEditable(false);
p1.add(t6);
search1 = new JButton("Search");
search1.setBounds(490, 60, 100, 30);
search1.setIcon(new ImageIcon(getClass().getResource("/17.png")));
search1.setHorizontalAlignment(SwingConstants.LEFT);
search1.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
search1();
}
});
p1.add(search1);
p1.setBackground(Color.white);
add(p1);
TitledBorder title;
title = BorderFactory.createTitledBorder("Member Details");
//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));
p2 = new JPanel();
// title.setTitleJustification(TitledBorder.LEFT);
p2.setBorder(title);
// p.setBackground();
p2.setBounds(600, 0, 620, 400);
p2.setLayout(null);
// p2.setSize(420, 450);
l11 = new JLabel("Member id");
l11.setBounds(100, 60, 100, 30);
p2.add(l11);
l12 = new JLabel("Name");
l12.setBounds(100, 100, 100, 30);
p2.add(l12);
l13 = new JLabel("Father Name");
l13.setBounds(100, 140, 100, 30);
p2.add(l13);
l14 = new JLabel("Department");
l14.setBounds(100, 180, 200, 30);
p2.add(l14);
l15 = new JLabel("Year");
l15.setBounds(100, 220, 100, 30);
p2.add(l15);
l16 = new JLabel("Sem");
l16.setBounds(100, 260, 100, 30);
p2.add(l16);
l17 = new JLabel("Member type");
l17.setBounds(100, 300, 100, 30);
p2.add(l17);
t11 = new JTextField();
t11.setBounds(280, 60, 200, 30);
t11.setText("0");
p2.add(t11);
t12 = new JTextField();
t12.setBounds(280, 100, 200, 30);
t12.setEditable(false);
p2.add(t12);
t13 = new JTextField();
t13.setBounds(280, 140, 200, 30);
t13.setEditable(false);
p2.add(t13);
t14 = new JTextField();
t14.setBounds(280, 180, 200, 30);
t14.setEditable(false);
p2.add(t14);
t15 = new JTextField();
t15.setBounds(280, 220, 200, 30);
t15.setEditable(false);
p2.add(t15);
t16 = new JTextField();
t16.setBounds(280, 260, 200, 30);
t16.setEditable(false);
p2.add(t16);
t17 = new JTextField();
t17.setBounds(280, 300, 200, 30);
t17.setEditable(false);
p2.add(t17);
search2 = new JButton("Search");
search2.setIcon(new ImageIcon(getClass().getResource("/18.png")));
search2.setHorizontalAlignment(SwingConstants.LEFT);
search2.setBounds(500, 60, 100, 30);
p2.add(search2);
l18 = new JLabel();
l18.setText("current date is : " + date);
l18.setBounds(600, 460, 200, 30);
add(l18);
p2.setBackground(Color.white);
search2.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
search2();
}
});
issue = new JButton(" Issue");
issue.setIcon(new ImageIcon(getClass().getResource("/14.png")));
issue.setHorizontalAlignment(SwingConstants.LEFT);
issue.setBounds(800, 460, 200, 30);
issue.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
issueStore();
}
});
add(issue);
add(p2);
back = new JButton("Back");
back.setBounds(200, 460, 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();
}
});
add(back);
//System.out.println(LocalDate.now().toString());
setLayout(null);
setVisible(true);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(400, 120, 1225, 600); // set where frame will be
}
void search1() {
String s1, s2;
s2 = "";
s1 = t1.getText();
JavaConnection dm = new JavaConnection();
dm.connection();
if (!s1.equals(s2)) {
try {
int i = Integer.parseInt(t1.getText());
String search = "select * from Book where bookid='" + i + "'";
ResultSet rs = dm.executeQuery(search);
// System.out.println("username:" + rs.getString(1) + " password " + rs.getString(2));
if (rs.next()) {
t2.setText(rs.getString(2));
t3.setText(rs.getString(3));
t4.setText(rs.getString(4));
t5.setText(rs.getString(5));
t6.setText(rs.getString(6));
} else {
JOptionPane.showMessageDialog(null, "Invalid Book ID");
}
} catch (Exception e) {
JOptionPane.showMessageDialog(null, e);
}
} else {
JOptionPane.showMessageDialog(null, "put something");
}
}
void search2() {
JavaConnection dm = new JavaConnection();
dm.connection();
String s1, s2;
s2 = "";
s1 = t11.getText();
if (s1.equals(s2)) {
JOptionPane.showMessageDialog(null, "put something");
} else {
try {
int i = Integer.parseInt(t11.getText());
String search = "select * from Member where memberid='" + i + "'";
ResultSet rs = dm.executeQuery(search);
// System.out.println("username:" + rs.getString(1) + " password " + rs.getString(2));
if (rs.next()) {
t12.setText(rs.getString(2));
t13.setText(rs.getString(3));
t14.setText(rs.getString(4));
t15.setText(rs.getString(5));
t16.setText(rs.getString(6));
t17.setText(rs.getString(7));
} else {
JOptionPane.showMessageDialog(null, "User Not Exists ");
}
} catch (Exception e) {
JOptionPane.showMessageDialog(null, e);
}
}
}
void issueStore() {
String membername, department, member_type;
int bookid, memberid;
membername = t12.getText();
department = t14.getText();
member_type = t17.getText();
String s1, s2, s3, s4;
s1 = s2 = s3 = s4 = "";
int i, j;
i = j = 0;
s3 = t1.getText();
s4 = t11.getText();
//JOptionPane.showMessageDialog(null, "s3 :" + s3 + "\ns4 :" + s4);
JavaConnection db = new JavaConnection();
db.connection();
if (s3.equals(s1) || s4.equals(s2)) {
JOptionPane.showMessageDialog(null, "Blank Character is not allowed");
} else {
memberid = Integer.parseInt(t11.getText());
bookid = Integer.parseInt(t1.getText());
if (bookid == i && memberid ==j) {
JOptionPane.showMessageDialog(null, "First input something");
} else {
String insert, check, check1, check2, check3, check4, check5;
check1 = "select memberid,bookid from Issue Where memberid=bookid AND memberid='" + memberid + "'";
check2 = "select memberid,bookid from Issue Where memberid='" + memberid + "' AND bookid='" + bookid + "'";
check3 = "select * from Issue Where bookid='" + bookid + "'";
check4 = "select * from Book where bookid='" + bookid + "'";
check5 = "select * from Member where memberid='" + memberid + "'";
try {
ResultSet rs1 = db.executeQuery(check1);
if (rs1.next()) {
JOptionPane.showMessageDialog(null, "The user that request for the book,he already have");
} else {
ResultSet rs2 = db.executeQuery(check2);
if (rs2.next()) {
JOptionPane.showMessageDialog(null, "The user that request for the book,he already have");
} else {
ResultSet rs3 = db.executeQuery(check3);
if (rs3.next()) {
JOptionPane.showMessageDialog(null, "book cant be distrubuted of same id");
} else {
ResultSet rs4, rs5;
rs4 = db.executeQuery(check4);
rs5 = db.executeQuery(check5);
if (rs4.next() && rs5.next()) {
insert = "INSERT INTO Issue (memberid,bookid,membername,department,member_type,date) VALUES('" + memberid + "','" + bookid + "','" + membername + "','" + department + "','" + member_type + "', STR_TO_DATE('" + date + "','%d-%m-%Y') )";
db.executeUpdate(insert);
JOptionPane.showMessageDialog(null, "Issued \n Bookid: "+bookid+" \n To Memberid : "+memberid);
db.connClose();
} else {
JOptionPane.showMessageDialog(null, "Invalid BookID or Member ID");
}
}
}
}
} catch (Exception e) {
JOptionPane.showMessageDialog(null, e);
}
}
}
}
}
class Sigsupe {
public static void main(String[] args) {
Issue s = new Issue();
s.setSize(1230, 600);
}
}