📄 studentinfoframe.java
字号:
package com.sccp.StudentMS.baseFrame;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Font;
import java.awt.HeadlessException;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.border.EtchedBorder;
import javax.swing.border.LineBorder;
import javax.swing.border.MatteBorder;
import javax.swing.border.TitledBorder;
import com.sccp.StudentMS.DBtools.DBtool;
import com.swtdesigner.SwingResourceManager;
public class StudentInfoFrame extends JFrame {
public JTextField home;
public JTextField birth;
public JTextField cName;
public JTextField ethnic;
public JTextField sex;
public JTextField name;
public JTextField id;
public JButton modify;
public JButton add ;
public JButton delete;
public JButton save;
public JButton cancel;
public JButton see;
public JButton query;
public JButton sum;
public JButton markM;
JLabel a;
JLabel m;
JLabel d;
JLabel s;
JLabel c;
JLabel e;
JLabel tou;
JLabel label_15;
JLabel label_16;
static ResultSet rs,rs1;
String exeType="";
String sql;
/**
* Launch the application
* @param args
*/
public static void main(String args[]) {
try {
StudentInfoFrame frame = new StudentInfoFrame();
frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
/**
* Create the frame
*/
public StudentInfoFrame() {
super();
setResizable(false);
setTitle("个人信息管理");
setBounds(100, 100, 617, 462);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
final JPanel panel = new JPanel();
panel.setLayout(null);
getContentPane().add(panel, BorderLayout.CENTER);
PreparedStatement ps;
final DBtool db=new DBtool();
query = new JButton();
query.addActionListener(new ActionListener() {
public void actionPerformed(final ActionEvent e) {
PeopleQueryFrame1 fqf1=new PeopleQueryFrame1();
fqf1.setVisible(true);
fqf1.setLabelText("请选择查询方式:");
fqf1.t.setEnabled(false);
fqf1.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
}
});
query.setText("查询");
query.setBounds(10, 27, 99, 23);
panel.add(query);
see = new JButton();
see.addActionListener(new ActionListener() {
public void actionPerformed(final ActionEvent e) {
if(id.getText().equals(""))
{
JOptionPane.showMessageDialog(null,"请先输入学号!");//??????????????????????????
}
else{
sql="select * from grade where ID='"+id.getText()+"'";
rs=db.getResult(sql);
rs1=db.getResult(sql);
try {
if(rs.next())
{
seeGrade();
}
} catch (SQLException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
}
}
});
see.setText("查看成绩");
see.setBounds(132, 27, 99, 23);
panel.add(see);
sum = new JButton();
sum.addActionListener(new ActionListener() {
public void actionPerformed(final ActionEvent e) {
PeopleStatisticFrame pqf=new PeopleStatisticFrame ();
//StudentInfoFrame.this.dispose();
pqf.setVisible(true);
pqf.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
}
});
sum.setText("人员统计");
sum.setBounds(255, 27, 99, 23);
panel.add(sum);
markM = new JButton();
markM.addActionListener(new ActionListener() {
public void actionPerformed(final ActionEvent e) {
MarkInfoFrame mif=new MarkInfoFrame();
mif.setTextAbled(false);
mif.modify.setEnabled(false);
mif.delete.setEnabled(false);
mif.save.setEnabled(false);
StudentInfoFrame.this.dispose();
mif.setVisible(true);
mif.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
}
});
markM.setText("成绩管理");
markM.setBounds(361, 27, 99, 23);
panel.add(markM);
final JLabel label = new JLabel();
label.setText("学号");
label.setBounds(37, 129, 60, 15);
panel.add(label);
id = new JTextField();
id.setBackground(new Color(255, 255, 255));
id.setFont(new Font("", Font.BOLD, 12));
id.setBounds(132, 127, 95, 20);
panel.add(id);
final JLabel label_1 = new JLabel();
label_1.setText("姓名");
label_1.setBounds(37, 170, 60, 15);
panel.add(label_1);
name = new JTextField();
name.setFont(new Font("", Font.BOLD, 12));
name.setBounds(132, 168, 95, 20);
panel.add(name);
final JLabel label_2 = new JLabel();
label_2.setText("性别");
label_2.setBounds(37, 212, 60, 15);
panel.add(label_2);
sex = new JTextField();
sex.setFont(new Font("", Font.BOLD, 12));
sex.setBounds(132, 207, 95, 20);
panel.add(sex);
final JLabel label_3 = new JLabel();
label_3.setText("民族");
label_3.setBounds(284, 129, 60, 15);
panel.add(label_3);
ethnic = new JTextField();
ethnic.setFont(new Font("", Font.BOLD, 12));
ethnic.setBounds(361, 124, 95, 20);
panel.add(ethnic);
final JLabel label_4 = new JLabel();
label_4.setText("所在班级");
label_4.setBounds(295, 170, 60, 15);
panel.add(label_4);
cName = new JTextField();
cName.setFont(new Font("", Font.BOLD, 12));
cName.setBounds(361, 168, 95, 20);
panel.add(cName);
final JLabel label_5 = new JLabel();
label_5.setText("出生日期");
label_5.setBounds(295, 209, 60, 15);
panel.add(label_5);
birth = new JTextField();
birth.setFont(new Font("", Font.BOLD, 12));
birth.setBounds(361, 207, 95, 20);
panel.add(birth);
final JLabel label_6 = new JLabel();
label_6.setText("籍贯");
label_6.setBounds(37, 254, 60, 15);
panel.add(label_6);
home = new JTextField();
home.setFont(new Font("", Font.BOLD, 12));
home.setBounds(132, 252, 328, 17);
panel.add(home);
add= new JButton();
add.setFont(new Font("", Font.PLAIN, 5));
add.setIcon(SwingResourceManager.getIcon(StudentInfoFrame.class, "/images/1.png"));
add.setToolTipText("添加");
add.addActionListener(new ActionListener() {
public void actionPerformed(final ActionEvent e) {
setNull();
setExeType("add");
setTextAbled(true);
setButton(false,false,false,true,true);
}
});
add.setText("添加");
add.setBounds(10, 314, 66, 48);
panel.add(add);
modify = new JButton();
modify.setIcon(SwingResourceManager.getIcon(StudentInfoFrame.class, "/images/2.png"));
modify.setFont(new Font("", Font.PLAIN, 5));
modify.setToolTipText("修改");
modify.addActionListener(new ActionListener() {
public void actionPerformed(final ActionEvent e) {
setExeType("modify");
setTextAbled(true);
setButton(false,false,false,true,true);
}
});
modify.setText("修改");
modify.setBounds(118, 314, 66, 48);
panel.add(modify);
delete= new JButton();
delete.setIcon(SwingResourceManager.getIcon(StudentInfoFrame.class, "/images/3.png"));
delete.setFont(new Font("", Font.PLAIN, 5));
delete.setToolTipText("删除");
delete.addActionListener(new ActionListener() {
public void actionPerformed(final ActionEvent e) {
String sql="delete from grade where ID='"+id.getText()+"'";
if(db.executeSql(sql))
{
sql="delete from studentInfo where ID='"+id.getText()+"'";
if(db.executeSql(sql))
{
JOptionPane.showMessageDialog(null,"成功删除信息!");
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -