📄 servicejudge.java
字号:
package GraphicsUI;
import java.awt.*;
import java.awt.event.*;
import java.sql.*;
import javax.swing.*;
public class ServiceJudge implements ActionListener {
JInternalFrame jif;
JLabel id;
JLabel name;
JLabel popur;
JLabel pic;
JTextField jtf;
JButton first;
JButton next;
JButton select;
JPanel westup;
JPanel temp;
JPanel westdown;
JPanel tempbtn;
JPanel west;
JPanel westtemp;
JPanel center;
JPanel centerup;
JPanel centerdown;
CheckboxGroup q1;// 问卷模块
JLabel l1;
JPanel p1;
Checkbox q11;
Checkbox q12;
Checkbox q13;
Checkbox q14;
Checkbox q15;
CheckboxGroup q2;
JLabel l2;
JPanel p2;
Checkbox q21;
Checkbox q22;
Checkbox q23;
Checkbox q24;
Checkbox q25;
CheckboxGroup q3;
JLabel l3;
JPanel p3;
Checkbox q31;
Checkbox q32;
Checkbox q33;
Checkbox q34;
Checkbox q35;
CheckboxGroup q4;
JLabel l4;
JPanel p4;
Checkbox q41;
Checkbox q42;
Checkbox q43;
Checkbox q44;
Checkbox q45;
CheckboxGroup q5;
JLabel l5;
JPanel p5;
Checkbox q51;
Checkbox q52;
Checkbox q53;
Checkbox q54;
Checkbox q55;
JLabel sl;
JTextArea suggest;
JButton ok;
JLabel nul;// 占空间让布局美观
JLabel nul2;// 同上
JButton clear;
JPanel jbtn;
JScrollPane js;
MainFrame mf;
Connection conn;
Statement stmt;
ResultSet rs;
String[] file = { "con001.jpg", "con002.jpg", "con003.jpg", "con004.jpg",
"con005.jpg", "con101.jpg", "con102.jpg", "con103.jpg",
"con104.jpg", "con105.jpg" };
int count = 0;
public ServiceJudge(MainFrame m) {
mf = m;
jif = new JInternalFrame("服务评价", false, true, false, true);
pic = new JLabel();
pic.setIcon(new ImageIcon("ServicePeople/con001.jpg"));
id = new JLabel("员工号:" + " " + "con001");
name = new JLabel("姓名:" + " " + "胡月");
popur = new JLabel("好评度:" + " " + "100%");
temp = new JPanel();
jtf = new JTextField("输入员工号");
select = new JButton("根据员工号查找");
temp.setLayout(new GridLayout(3, 1));
temp.add(id);
temp.add(name);
temp.add(popur);
tempbtn = new JPanel();
tempbtn.setLayout(new GridLayout(2, 1));
tempbtn.add(jtf);
tempbtn.add(select);
westup = new JPanel();
westup.setLayout(new GridLayout(2, 1));
westup.add(pic);
westup.add(temp);
westdown = new JPanel();
westdown.setLayout(new FlowLayout());
first = new JButton("第一位员工");
next = new JButton("下一位员工");
westdown.add(first);
westdown.add(next);
westtemp = new JPanel();
westtemp.setLayout(new GridLayout(2, 1));
westtemp.add(tempbtn);
westtemp.add(westdown);
west = new JPanel();
west.setLayout(new BorderLayout());
west.add(westup, BorderLayout.CENTER);
west.add(westtemp, BorderLayout.SOUTH);
jif.add(west, BorderLayout.WEST);
l1 = new JLabel("1.您对这位票务员的工作效率如何评价? ");
q1 = new CheckboxGroup();
q11 = new Checkbox("太低", q1, false);
q12 = new Checkbox("一般", q1, true);
q13 = new Checkbox("不错", q1, false);
p1 = new JPanel();
p1.setLayout(new FlowLayout());
p1.add(l1);
p1.add(q11);
p1.add(q12);
p1.add(q13);
l2 = new JLabel("2.您对这位票务员的服务态度如何评价? ");
q2 = new CheckboxGroup();
q21 = new Checkbox("太差", q2, false);
q22 = new Checkbox("一般", q2, true);
q23 = new Checkbox("不错", q2, false);
p2 = new JPanel();
p2.setLayout(new FlowLayout());
p2.add(l2);
p2.add(q21);
p2.add(q22);
p2.add(q23);
l3 = new JLabel("3.您对本航空公司的机票定价看法如何? ");
q3 = new CheckboxGroup();
q31 = new Checkbox("太贵", q3, false);
q32 = new Checkbox("一般", q3, true);
q33 = new Checkbox("便宜", q3, false);
p3 = new JPanel();
p3.setLayout(new FlowLayout());
p3.add(l3);
p3.add(q31);
p3.add(q32);
p3.add(q33);
l4 = new JLabel("4.您对本航空公司的整体水平看法如何? ");
q4 = new CheckboxGroup();
q41 = new Checkbox("太差", q4, false);
q42 = new Checkbox("一般", q4, true);
q43 = new Checkbox("不错", q4, false);
p4 = new JPanel();
p4.setLayout(new FlowLayout());
p4.add(l4);
p4.add(q41);
p4.add(q42);
p4.add(q43);
l5 = new JLabel("5.你对使用此飞机订票系统的感觉如何? ");
q5 = new CheckboxGroup();
q51 = new Checkbox("不好", q5, false);
q52 = new Checkbox("一般", q5, true);
q53 = new Checkbox("满意", q5, false);
p5 = new JPanel();
p5.setLayout(new FlowLayout());
p5.add(l5);
p5.add(q51);
p5.add(q52);
p5.add(q53);
centerup = new JPanel();
centerup.setLayout(new GridLayout(5, 1));
centerup.add(p1);
centerup.add(p2);
centerup.add(p3);
centerup.add(p4);
centerup.add(p5);
center = new JPanel();
center.setLayout(new GridLayout(2, 1));
center.add(centerup);
centerdown = new JPanel();
sl = new JLabel(" 您对本航空公司还有什么意见?");
suggest = new JTextArea();
js = new JScrollPane(suggest);
nul = new JLabel(" ");
centerdown.setLayout(new BorderLayout());
centerdown.add(nul, BorderLayout.WEST);
centerdown.add(sl, BorderLayout.NORTH);
centerdown.add(js, BorderLayout.CENTER);
// nul2 = new JLabel(" ");
ok = new JButton("提交");
clear = new JButton("清空");
clear.addActionListener(this);
jbtn = new JPanel();
jbtn.setLayout(new FlowLayout());
// jbtn.add(nul2);
jbtn.add(clear);
jbtn.add(ok);
centerdown.add(jbtn, BorderLayout.SOUTH);
center.add(centerdown);
jif.add(center, BorderLayout.CENTER);
jif.setVisible(true);
// mf.mf.add(jif, BorderLayout.CENTER);
next.addActionListener(this);
first.addActionListener(this);
try {
conn = DriverManager.getConnection(
"jdbc:microsoft:sqlserver://localhost:1433", "sa", "");
stmt = conn.createStatement();
rs = stmt.executeQuery("select * from administrator");
rs.next();
rs.next();
System.out.println(rs.getString(2));
} catch (SQLException e) {
e.printStackTrace();
}
}
public void actionPerformed(ActionEvent arg0) {
if (arg0.getSource() == next) {
try {
rs.next();
count++;
pic.setIcon(new ImageIcon("ServicePeople/" + file[count]));
id.setText("员工号:" + " " + rs.getString(1));
name.setText("姓名:" + " " + rs.getString(2));
popur.setText("好评度:" + " " + rs.getString(7) + "%");// 没有完成===
System.out.println("next is ok");
} catch (SQLException e) {
// TODO 自动生成 catch 块
e.printStackTrace();
}
}
if (arg0.getSource() == first) {// prior改成first
try {
rs.close();
count = 0;
rs = stmt.executeQuery("select * from administrator");
rs.next();
pic.setIcon(new ImageIcon("ServicePeople/con001.jpg"));
id.setText("员工号:" + " " + rs.getString(1));
name.setText("姓名:" + " " + rs.getString(2));
popur.setText("好评度:" + " " + rs.getString(7) + "%");// 没有完成===
System.out.println("first is ok");
} catch (SQLException e) {
// TODO 自动生成 catch 块
e.printStackTrace();
}
}
if (arg0.getSource() == clear) {
jtf.setText("");
suggest.setText("");
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -