-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCourseOfAction.java
More file actions
130 lines (107 loc) · 3.01 KB
/
Copy pathCourseOfAction.java
File metadata and controls
130 lines (107 loc) · 3.01 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
import java.awt.BorderLayout;
import java.awt.EventQueue;
import java.awt.GraphicsConfiguration;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JTextArea;
import javax.swing.JTextField;
import javax.swing.text.*;
import javax.swing.JButton;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import java.sql.*;
public class CourseOfAction extends JFrame {
private JPanel contentPane;
private DefaultStyledDocument doc;
private JTextArea textArea;
private JTextArea txtrF;
private JButton btnSubmit;
/**
* Launch the application.
*/
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
int a = 0;
CourseOfAction frame = new CourseOfAction(a);
frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
Connection conn = null;
/**
* Create the frame.
*/
public CourseOfAction(int fromBrowser) {
conn = db.dbConnector();
final int fromTheBrowser = fromBrowser; //data from the Browser
setTitle("Course of Action");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(100, 100, 450, 300);
contentPane = new JPanel();
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
setContentPane(contentPane);
contentPane.setLayout(null);
JLabel lblRecommend = new JLabel("Recommend");
lblRecommend.setBounds(48, 32, 91, 19);
contentPane.add(lblRecommend);
txtrF = new JTextArea();
txtrF.setText("Enter Here");
txtrF.setBounds(48, 67, 354, 114);
contentPane.add(txtrF);
btnSubmit = new JButton("Submit");
btnSubmit.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e)
{
if (fromTheBrowser == 0)
{
JOptionPane.showMessageDialog(null,"You did not launch from the Browser");
}
try
{
if (txtrF.getText().equals(""))
{
JOptionPane.showMessageDialog(null,"Necessary Data was not entered.");
}
else
{
int reviewID = 0;
String query = "SELECT ReviewID FROM review";
PreparedStatement ps = conn.prepareStatement(query);
ResultSet rs = ps.executeQuery();
while(rs.next())
{
reviewID = rs.getInt(1) + 1;
}
rs.close();
query = "INSERT INTO review (ReviewID, CaseID, ReviewDetails, HREmployee_EmployeeID) VALUES (?,?,?,?)";
ps = conn.prepareStatement(query);
ps.setInt(1, reviewID);
ps.setInt(2, fromTheBrowser);
ps.setString(3, txtrF.getText());
ps.setInt(4, 1);
ps.execute();
JOptionPane.showMessageDialog(null,"Data Saved");
ps.close();
System.exit(0);
}
}
catch (Exception ee)
{
JOptionPane.showMessageDialog(null, e);
}
}
});
btnSubmit.setBounds(295, 192, 107, 35);
contentPane.add(btnSubmit);
}
}