-
Notifications
You must be signed in to change notification settings - Fork 0
/
StDetails.java
140 lines (121 loc) · 3.81 KB
/
StDetails.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
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
import javax.swing.border.EmptyBorder;
public class StDetails implements ActionListener{
JFrame jf;
JPanel jp;
JTextField info;
JLabel labname, labid, labrno, labcrs, labyr,issuc;
JButton issue, status, issub,cancel;
long sid=0;
int temp;
StDetails(String data[]) {
sid=Long.parseLong(data[0]);
issuc=new JLabel("Book has been Issued to "+data[0]+" - "+data[1]+" Successfully!!!", null, 0);
issub=new JButton("Issue Book", null);
cancel=new JButton("CANCEL", null);
info=new JTextField(20);
labname = new JLabel("Name: " + data[1]);
labrno = new JLabel("University Roll Number: " + data[2]);
labcrs = new JLabel("Course: " + data[3]);
labyr = new JLabel("Year: " + data[4]);
temp=Integer.parseInt(data[4]);
jp = new JPanel(new GridBagLayout());
jp.setBorder(new EmptyBorder(100, 100, 100, 100));
issue = new JButton("ISSUE");
status = new JButton("STATUS");
issue.addActionListener(this);
status.addActionListener(this);
cancel.addActionListener(this);
issub.addActionListener(this);
GridBagConstraints gbc = new GridBagConstraints();
gbc.fill = GridBagConstraints.BOTH;
gbc.insets = new Insets(5, 5, 5, 5);
gbc.ipadx=50;
gbc.ipady=30;
gbc.gridx = 0;
gbc.gridy = 0;
gbc.gridwidth = 3;
jp.add(labname, gbc);
gbc.gridx = 0;
gbc.gridy = 1;
jp.add(labrno, gbc);
gbc.gridx = 0;
gbc.gridy = 2;
jp.add(labcrs, gbc);
gbc.gridwidth = 1;
gbc.gridx = 0;
gbc.gridy = 3;
jp.add(labyr, gbc);
gbc.gridx = 1;
gbc.gridy = 3;
jp.add(info, gbc);
info.setVisible(false);
gbc.gridx = 0;
gbc.gridy = 4;
jp.add(cancel,gbc);
jp.add(issue, gbc);
cancel.setVisible(false);
gbc.gridx = 1;
gbc.gridy = 4;
jp.add(status, gbc);
jp.add(issub, gbc);
issub.setVisible(false);
gbc.gridwidth=3;
gbc.gridx = 0;
gbc.gridy = 5;
jp.add(issuc, gbc);
issuc.setVisible(false);
jf = new JFrame("Student Details");
jf.add(jp);
jf.pack();
jf.setVisible(true);
jf.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
jf.setSize(900, 500);
}
public void actionPerformed(ActionEvent ae)
{
String s=ae.getActionCommand();
if(s=="ISSUE")
{
labname.setVisible(false);
labcrs.setVisible(false);
labrno.setVisible(false);
issue.setVisible(false);
status.setVisible(false);
cancel.setVisible(true);
issub.setVisible(true);
labyr.setText("Enter Book ID : ");
info.setVisible(true);
}
else if(s=="Issue Book")
{
String x=info.getText();
String[] books = x.split(" ");
long[] ids = new long[books.length];
for (int i = 0; i < books.length; i++) {
ids[i] = Long.parseLong(books[i]);
}
Main.obj.issueBook(ids,sid);
issuc.setVisible(true);
}
else if(s=="STATUS")
{
new St_Status(sid);
}
else if(s=="CANCEL")
{
labname.setVisible(true);
labcrs.setVisible(true);
labrno.setVisible(true);
issue.setVisible(true);
status.setVisible(true);
cancel.setVisible(false);
issub.setVisible(false);
labyr.setText("Year : "+temp);
info.setVisible(false);
issuc.setVisible(false);
}
}
}