📄 employeeinfo.java
字号:
package viewtuba1;
import java.awt.ComponentOrientation;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JPasswordField;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.JTextField;
import javax.swing.JToolBar;
import control.Console;
public class EmployeeInfo extends JFrame {
private JTextField textField_6;
private JTextField textField_5;
private JTextField textField_4;
private JTextField textField_3;
private JTextField textField_1;
private JTextField textField;
private JTextArea textArea;
private JComboBox comboBox;
final JLabel lblNumber;
final JButton button;
final JButton button_1;
String str1, str2, str3 = new String();
String[] memberInfo;
/**
* Launch the application
*
* @param args
*/
public static void main(String args[]) {
try {
EmployeeInfo frame = new EmployeeInfo();
frame.setVisible(true);
// frame.setResizable(false);
} catch (Exception e) {
e.printStackTrace();
}
}
/**
* Create the frame
*/
public EmployeeInfo() {
super();
setResizable(false);
getContentPane().setLayout(null);
setTitle("公司职员资料");
setBounds(100, 100, 442, 538);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
BufferedReader in;
try {
in = new BufferedReader(new FileReader("TempLoginInfo.csv"));
String[] temp = new String[3];
String sq = new String();
sq = in.readLine();
temp = sq.split(",", 3);
str1 = temp[0];
str2 = temp[1];
str3 = temp[2];
in.close();
} catch (IOException e) {
e.printStackTrace();
}
JLabel label_1 = new JLabel();
label_1.setBounds(65, 65, 91, 28);
label_1.setText("当前登录用户:");
getContentPane().add(label_1);
JLabel label_2 = new JLabel();
memberInfo = new String[7];
Console cos = new Console(str1);
memberInfo = cos.MemberLoad();
label_2.setText(memberInfo[1]);
label_2.setBounds(243, 65, 131, 28);
getContentPane().add(label_2);
final JToolBar toolBar = new JToolBar();
toolBar.setBounds(0, 0, 434, 53);
getContentPane().add(toolBar);
final JPanel panel = new JPanel();
panel.setLayout(null);
toolBar.add(panel);
final JLabel label = new JLabel();
label.setBounds(10, 10, 161, 37);
panel.add(label);
label.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT);
label.setText("工号检索查询:");
comboBox = new JComboBox();
BufferedReader inn;
try {
inn = new BufferedReader(new FileReader("Info.csv"));
String[] bump = new String[2];
String sqq = new String();
sqq = inn.readLine();
while (sqq != null) {
bump = sqq.split(",", 2);
comboBox.addItem(bump[0]);
sqq = inn.readLine();
}
inn.close();
} catch (IOException ee) {
ee.printStackTrace();
}
comboBox.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
for (int i = 0; i < comboBox.getItemCount(); i++) {
if (str1.equals("1000")) {
String[] memberElseInfo = new String[7];
Console cos1 = new Console(comboBox.getSelectedItem()
.toString());
memberElseInfo = cos1.MemberLoad();
textField_5.setText(memberElseInfo[0]);
textField_5.setEditable(false);
textField.setText(memberElseInfo[1]);
textField.setEditable(true);
textField_1.setText(memberElseInfo[5]);
textField_1.setEditable(true);
textField_3.setText(memberElseInfo[3]);
textField_3.setEditable(true);
textField_4.setText(memberElseInfo[2]);
textField_4.setEditable(true);
textField_6.setText(memberElseInfo[4]);
textField_6.setEditable(true);
textArea.setText(memberElseInfo[6]);
textArea.setLineWrap(true);
textArea.setWrapStyleWord(true);
textArea.setEditable(true);
button.setEnabled(true);
button_1.setEnabled(true);
} else {
if (comboBox.getSelectedItem().toString()
.equals("1000")) {
textField_5.setText("1000");
textField.setText("***");
textField.setEditable(false);
textField_1.setText("*****");
textField_3.setText("*****");
textField_4.setText("*****");
textField_4.setEditable(false);
textField_6.setText("*****");
textArea.setText("**********************" + "\n"
+ "**********************" + "\n"
+ "**********************");
button.setEnabled(false);
button_1.setEnabled(false);
} else {
if (comboBox.getSelectedItem().toString().equals(
memberInfo[0])) {
textField_5.setText(memberInfo[0]);
textField.setText(memberInfo[1]);
textField_1.setText(memberInfo[5]);
textField_3.setText(memberInfo[3]);
textField_4.setText(memberInfo[2]);
textField_6.setText(memberInfo[4]);
textArea.setText(memberInfo[6]);
button.setEnabled(true);
} else {
String[] memberElseInfo1 = new String[7];
Console cos2 = new Console(comboBox
.getSelectedItem().toString());
memberElseInfo1 = cos2.MemberLoad();
textField_5.setText(memberElseInfo1[0]);
textField.setText(memberElseInfo1[1]);
textField_1.setText(memberElseInfo1[5]);
textField_3.setText("*****");
textField_4.setText(memberElseInfo1[2]);
textField_4.setEditable(false);
textField_6.setText(memberElseInfo1[4]);
textArea.setText("**********************"
+ "\n" + "**********************"
+ "\n" + "**********************");
textArea.setEditable(false);
button.setEnabled(false);
button_1.setEnabled(false);
}
}
}
}
}
});
comboBox.setBounds(177, 10, 131, 31);
panel.add(comboBox);
final JLabel label_3 = new JLabel();
label_3.setText("工号");
label_3.setBounds(161, 65, 33, 28);
getContentPane().add(label_3);
lblNumber = new JLabel();
lblNumber.setText(str1);
lblNumber.setBounds(193, 65, 33, 28);
getContentPane().add(lblNumber);
final JLabel label_4 = new JLabel();
label_4.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT);
label_4.setText("工号:");
label_4.setBounds(61, 99, 60, 28);
getContentPane().add(label_4);
final JLabel label_4_2 = new JLabel();
label_4_2.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT);
label_4_2.setText("姓名:");
label_4_2.setBounds(203, 99, 60, 28);
getContentPane().add(label_4_2);
final JLabel label_4_3 = new JLabel();
label_4_3.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT);
label_4_3.setText("性别:");
label_4_3.setBounds(61, 141, 60, 28);
getContentPane().add(label_4_3);
final JLabel label_4_4 = new JLabel();
label_4_4.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT);
label_4_4.setText("工资:");
label_4_4.setBounds(203, 141, 60, 28);
getContentPane().add(label_4_4);
final JLabel label_4_5 = new JLabel();
label_4_5.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT);
label_4_5.setText("部门:");
label_4_5.setBounds(61, 185, 60, 28);
getContentPane().add(label_4_5);
final JLabel label_4_8 = new JLabel();
label_4_8.setText("基本信息:");
label_4_8.setBounds(63, 232, 75, 28);
getContentPane().add(label_4_8);
final JScrollPane scrollPane = new JScrollPane();
scrollPane.setBounds(77, 276, 284, 122);
getContentPane().add(scrollPane);
textArea = new JTextArea(1, 5);
textArea.setEditable(false);
scrollPane.setViewportView(textArea);
textField = new JTextField();
textField.setEditable(false);
textField.setBounds(265, 99, 91, 28);
getContentPane().add(textField);
textField_1 = new JTextField();
textField_1.setEditable(false);
textField_1.setBounds(118, 141, 75, 28);
getContentPane().add(textField_1);
textField_3 = new JTextField();
textField_3.setEditable(false);
textField_3.setBounds(269, 141, 87, 28);
getContentPane().add(textField_3);
textField_4 = new JTextField();
textField_4.setEditable(false);
textField_4.setBounds(119, 185, 75, 28);
getContentPane().add(textField_4);
textField_5 = new JTextField();
textField_5.setEditable(false);
textField_5.setBounds(118, 99, 75, 28);
getContentPane().add(textField_5);
button = new JButton();
button.setText("修改");
button.setEnabled(false);
button.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
textField_4.setEditable(true);
textArea.setEditable(true);
button_1.setEnabled(true);
}
});
button.setBounds(77, 426, 75, 35);
getContentPane().add(button);
button_1 = new JButton();
button_1.setText("确认");
button_1.setEnabled(false);
button_1.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
Console co = new Console();
String[] s1 = new String[7];
s1 = co.MemberLoad();
if (s1[0].equalsIgnoreCase(comboBox.getSelectedItem()
.toString())) {
s1[1] = textField.getText();
s1[2] = textField_4.getText();
s1[3] = textField_3.getText();
s1[4] = textField_6.getText();
s1[5] = textField_1.getText();
s1[6] = textArea.getText();
}
}
});
button_1.setBounds(177, 426, 75, 35);
getContentPane().add(button_1);
final JButton button_2 = new JButton();
button_2.setText("退出");
button_2.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
dispose();
}
});
button_2.setBounds(274, 426, 75, 35);
getContentPane().add(button_2);
final JPanel panel_1 = new JPanel();
panel_1.setLayout(null);
panel_1.setBounds(202, 185, 186, 26);
getContentPane().add(panel_1);
final JLabel label_4_6 = new JLabel();
label_4_6.setBounds(10, 0, 77, 30);
panel_1.add(label_4_6);
label_4_6.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT);
label_4_6.setText("纪校考勤:");
final JLabel label_4_7 = new JLabel();
label_4_7.setBounds(75, 0, 84, 30);
panel_1.add(label_4_7);
label_4_7.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT);
label_4_7.setText("迟到 次");
textField_6 = new JTextField();
textField_6.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT);
textField_6.setBounds(126, 1, 18, 25);
panel_1.add(textField_6);
textField_6.setEditable(false);
//
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -