package com.gioppl.Windows;
import java.awt.EventQueue;
import java.awt.Font;
import java.awt.SystemColor;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.io.File;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JFileChooser;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.JTextPane;
import javax.swing.border.EmptyBorder;
import com.gioppl.Function.ChageDate;
import com.gioppl.Function.ChangeFilePath;
import com.gioppl.SQLOption.CarSQL;
import com.gioppl.SQLOption.CoachSQL;
import com.gioppl.SQLOption.StudentSQL;
import com.gioppl.Student.StudentBean;
import java.awt.Color;
public class StudentDetails extends JFrame {
/**
* 创建学员信息修改页面
*/
private static final long serialVersionUID = 1L;
private JPanel contentPane;
private JTextField txt_name;
private JTextField txt_idCard;
private JTextField txt_schooling;
private JTextField txt_phone;
private String filePath = "C:\\Users\\VULCAN\\Pictures\\Saved Pictures\\u=3165904173,190399370&fm=27&gp=0.jpg";// 图片的绝对路径
private JLabel lab_photo;
private JFileChooser fileChooser = new JFileChooser();
private JTextField txt_date;
private JTextField txt_time;
private JComboBox combox_progress;
private JComboBox combox_gender;
final JButton btn_upcar= new JButton("\u4E0A\u8F66");;
private String name;// 姓名
private int teacher;// 教练
private int car;// 车号
private int time;// 总时间
private int progress;// 考试进度
private StudentBean bean;
Thread thread = null;
private JComboBox comboBox_car;
private JComboBox comboBox_coach;
/**
* 运行页面
*/
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
AddStu frame = new AddStu();
frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
/**
* studentNumber是学员的ID,传给下一个界面的事件行数
*/
public StudentDetails(StudentBean bean, int studentNumber,int r) {
ImageIcon icon=new ImageIcon("C:\\Users\\VULCAN\\Pictures\\timgGDER3J711.jpg");
this.bean = bean;
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(500, 200, 888, 500);
contentPane = new JPanel();
contentPane.setBackground(SystemColor.menu);
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
setContentPane(contentPane);
contentPane.setLayout(null);
//添加背景图片
//将图片放入label中
JLabel label=new JLabel(icon);
//设置label的大小
label.setBounds(0,0,icon.getIconWidth(),icon.getIconHeight());
//获取窗口的第二层,将label放入
this.getLayeredPane().add(label,new Integer(Integer.MIN_VALUE));
JPanel j=(JPanel)this.getContentPane();
j.setOpaque(false);
JTextPane addText = new JTextPane();
addText.setBackground(SystemColor.menu);
addText.setFont(new Font("微软雅黑 Light", Font.BOLD, 40));
addText.setEnabled(false);
addText.setEditable(false);
addText.setText("详细信息");
addText.setOpaque(false);
addText.setBounds(258, 13, 215, 77);
contentPane.add(addText);
JTextPane nameT = new JTextPane();
nameT.setBackground(SystemColor.menu);
nameT.setFont(new Font("宋体", Font.PLAIN, 25));
nameT.setEnabled(false);
nameT.setEditable(false);
nameT.setText("姓名:");
nameT.setOpaque(false);
nameT.setBounds(10, 114, 93, 49);
contentPane.add(nameT);
JTextPane Tphone = new JTextPane();
Tphone.setBackground(SystemColor.menu);
Tphone.setText("电话:");
Tphone.setFont(new Font("宋体", Font.PLAIN, 25));
Tphone.setEnabled(false);
Tphone.setEditable(false);
Tphone.setOpaque(false);
Tphone.setBounds(10, 271, 93, 49);
contentPane.add(Tphone);
JTextPane TidCard = new JTextPane();
TidCard.setBackground(SystemColor.menu);
TidCard.setText("身份证号:");
TidCard.setFont(new Font("宋体", Font.PLAIN, 18));
TidCard.setEnabled(false);
TidCard.setEditable(false);
TidCard.setOpaque(false);
TidCard.setBounds(10, 222, 93, 36);
contentPane.add(TidCard);
JTextPane Tschooling = new JTextPane();
Tschooling.setBackground(SystemColor.menu);
Tschooling.setText("学费:");
Tschooling.setFont(new Font("宋体", Font.PLAIN, 25));
Tschooling.setEnabled(false);
Tschooling.setEditable(false);
Tschooling.setOpaque(false);
Tschooling.setBounds(10, 335, 93, 49);
contentPane.add(Tschooling);
// 图片加载控件
lab_photo = new JLabel("添加照片");
lab_photo.setForeground(SystemColor.textHighlight);
lab_photo.setFont(new Font("宋体", Font.PLAIN, 22));
lab_photo.setBackground(SystemColor.menu);
lab_photo.setBounds(578, 13, 272, 277);
lab_photo.setIcon(new ImageIcon(filePath));
lab_photo.addMouseListener(new onClick());
contentPane.add(lab_photo);
combox_gender = new JComboBox();
combox_gender.addItem("男");
combox_gender.addItem("女");
combox_gender.addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent e) {
}
});
combox_gender.setBounds(131, 174, 147, 35);
contentPane.add(combox_gender);
JTextPane textPane = new JTextPane();
textPane.setText("性别:");
textPane.setFont(new Font("宋体", Font.PLAIN, 25));
textPane.setEnabled(false);
textPane.setEditable(false);
textPane.setBackground(SystemColor.menu);
textPane.setOpaque(false);
textPane.setBounds(10, 168, 93, 49);
contentPane.add(textPane);
txt_name = new JTextField();
txt_name.setBounds(131, 114, 147, 41);
contentPane.add(txt_name);
txt_name.setColumns(10);
txt_idCard = new JTextField();
txt_idCard.setFont(new Font("宋体", Font.PLAIN, 13));
txt_idCard.setColumns(10);
txt_idCard.setBounds(131, 227, 147, 41);
contentPane.add(txt_idCard);
txt_schooling = new JTextField();
txt_schooling.setColumns(10);
txt_schooling.setBounds(131, 335, 147, 41);
contentPane.add(txt_schooling);
txt_phone = new JTextField();
txt_phone.setColumns(10);
txt_phone.setBounds(131, 271, 147, 41);
contentPane.add(txt_phone);
// 确定添加
JButton btn_update = new JButton("确认修改");
btn_update.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
name = txt_name.getText();
teacher = comboBox_coach.getSelectedIndex();
car = comboBox_car.getSelectedIndex();
java.util.Date date = new java.util.Date();
time = Integer.parseInt(txt_time.getText());
String ID = txt_idCard.getText();
String Schooling = txt_schooling.getText();
String phone = txt_phone.getText();
int gender = 2;// 默认为女
if (combox_gender.getSelectedItem().toString().equals("男"))
gender = 1;// 如果是男,则为1
switch (combox_progress.getSelectedItem().toString()) {
case "科目一":
progress = 1;
break;
case "科目二":
progress = 2;
break;
case "科目三":
progress = 3;
break;
case "科目四":
progress = 4;
break;
default:
break;
}
// 保存到Student文件中去
StudentBean newStudent = new StudentBean();
newStudent.setName(name);
newStudent.setGender(gender);
newStudent.setTeacher(teacher);
newStudent.setCar(car);
newStudent.setDate(date.toString());
newStudent.setTime(time);
newStudent.setPhonenumber(phone);
newStudent.setSchooling(Schooling);
newStudent.setProgress(progress);
newStudent.setIDcard(ID);
newStudent.setPhotoUrl(filePath);
new StudentSQL().UpdataStudent(studentNumber, newStudent);
// 关闭窗口
Students