⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 addeditframe.java~68~

📁 考试管理系统:实现学生信息的注册、修改、查询、删除;以及对试题进行管理:增加试题、修改试题、删除试题、查询试题
💻 JAVA~68~
字号:
package edu.sccp.examManager.client;

import java.awt.*;
import javax.swing.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.sql.Date;
import edu.sccp.examManager.VO.ExamineeVO;
import edu.sccp.examManager.tools.Tools;
import edu.sccp.examManager.business.StudentBO;
import java.text.SimpleDateFormat;

/**
 * <p>Title: </p>
 *
 * <p>Description: </p>
 *
 * <p>Copyright: Copyright (c) 2006</p>
 *
 * <p>Company: </p>
 *
 * @author not attributable
 * @version 1.0
 */
public class AddEditFrame extends JFrame {
    public AddEditFrame() {
        try {
            jbInit();
        } catch (Exception exception) {
            exception.printStackTrace();
        }
    }

    public void setRegButton(boolean bl) {
        regButton.setEnabled(bl);
    }

    public void setEditButton(boolean bl) {
        editButton.setEnabled(bl);
    }

    public void setId(String id){//设置id
        textNo.setText(id);

    }

    private void jbInit() throws Exception {
        getContentPane().setLayout(null);
        this.setResizable(false);
        this.setSize(new Dimension(459, 539));
        jPanel1.setBounds(new Rectangle(1, 2, 435, 538));
        jPanel1.setLayout(null);
        jTextField1.setText("jTextField1");
        textNo.setEditable(false);
        textNo.setBounds(new Rectangle(187, 35, 155, 26));
        jLabel1.setFont(new java.awt.Font("Dialog", Font.PLAIN, 14));
        jLabel1.setText("姓名");
        jLabel1.setBounds(new Rectangle(82, 176, 37, 17));
        editButton.setBounds(new Rectangle(271, 429, 66, 26));
        editButton.setEnabled(false);
        editButton.setFont(new java.awt.Font("Dialog", Font.PLAIN, 14));
        editButton.setText("修改");
        editButton.addActionListener(new AddEditFrame_editButton_actionAdapter(this));
        regButton.setBounds(new Rectangle(172, 429, 66, 26));
        regButton.setEnabled(false);
        regButton.setFont(new java.awt.Font("Dialog", Font.PLAIN, 14));
        regButton.setText("注册");
        regButton.addActionListener(new AddEditFrame_jButton2_actionAdapter(this));
        textPassword1.setText("");
        textPassword1.setBounds(new Rectangle(187, 78, 155, 26));
        jLabel2.setFont(new java.awt.Font("Dialog", Font.PLAIN, 14));
        jLabel2.setText("考号");
        jLabel2.setBounds(new Rectangle(81, 33, 37, 28));
        jLabel3.setFont(new java.awt.Font("Dialog", Font.PLAIN, 14));
        jLabel3.setText("重输密码");
        jLabel3.setBounds(new Rectangle(82, 129, 59, 26));
        textName.setBounds(new Rectangle(187, 168, 155, 26));
        jLabel5.setFont(new java.awt.Font("Dialog", Font.PLAIN, 14));
        jLabel5.setText("密码");
        jLabel5.setBounds(new Rectangle(83, 81, 40, 23));
        resetButton.setBounds(new Rectangle(73, 427, 66, 26));
        resetButton.setFont(new java.awt.Font("Dialog", Font.PLAIN, 14));
        resetButton.setText("重置");
        resetButton.addActionListener(new
                                      AddEditFrame_resetButton_actionAdapter(this));
        jLabel6.setFont(new java.awt.Font("Dialog", Font.PLAIN, 14));
        jLabel6.setText("注册日期");
        jLabel6.setBounds(new Rectangle(82, 264, 104, 25));
        jPasswordField2.setText("");
        textDate.setEditable(false);
        textDate.setBounds(new Rectangle(187, 258, 155, 26));
        jLabel7.setFont(new java.awt.Font("Dialog", Font.PLAIN, 14));
        jLabel7.setText("班级");
        jLabel7.setBounds(new Rectangle(85, 214, 53, 24));
        textClass.setBounds(new Rectangle(187, 212, 155, 26));
        textPassword2.setBounds(new Rectangle(187, 127, 155, 26));
        jPanel2.setBorder(BorderFactory.createEtchedBorder());
        jPanel2.setBounds(new Rectangle(54, 316, 327, 88));
        jPanel2.setLayout(null);
        jLabel4.setFont(new java.awt.Font("Dialog", Font.PLAIN, 14));
        jLabel4.setText("备注");
        jLabel4.setBounds(new Rectangle(36, 26, 60, 31));
        textMemo.setBounds(new Rectangle(118, 7, 198, 71));
        jLabel8.setFont(new java.awt.Font("Dialog", Font.PLAIN, 14));
        jLabel8.setText("(yyyy-mm-dd)");
        jLabel8.setBounds(new Rectangle(348, 265, 99, 15));
        this.getContentPane().add(jTextArea1);
        this.getContentPane().add(jPanel1);
        jPanel1.add(jLabel1);
        jPanel1.add(editButton);
        jPanel1.add(regButton);
        jPanel1.add(jLabel3);
        jPanel1.add(jLabel6);
        jPanel1.add(jPasswordField2);
        jPanel1.add(jLabel7);
        jPanel1.add(resetButton);
        jPanel1.add(jLabel2);
        jPanel1.add(jLabel5);
        jPanel1.add(jPanel2);
        jPanel2.add(jLabel4);
        jPanel2.add(textMemo);
        jPanel1.add(textPassword1);
        jPanel1.add(textPassword2);
        jPanel1.add(textName);
        jPanel1.add(textClass);
        jPanel1.add(textDate);
        jPanel1.add(textNo);
        jPanel1.add(jLabel8);
    }

    JTextArea jTextArea1 = new JTextArea();
    JPanel jPanel1 = new JPanel();
    JTextField jTextField1 = new JTextField();
    JTextField textNo = new JTextField();
    JLabel jLabel1 = new JLabel();
    JButton editButton = new JButton();
    JButton regButton = new JButton();
    JPasswordField textPassword1 = new JPasswordField();
    JLabel jLabel2 = new JLabel();
    JLabel jLabel3 = new JLabel();
    JTextField textName = new JTextField();
    JLabel jLabel5 = new JLabel();
    JButton resetButton = new JButton();
    JLabel jLabel6 = new JLabel();
    JPasswordField jPasswordField2 = new JPasswordField();
    JTextField textDate = new JTextField();
    JLabel jLabel7 = new JLabel();
    JTextField textClass = new JTextField();
    JPasswordField textPassword2 = new JPasswordField();
    JPanel jPanel2 = new JPanel();
    JLabel jLabel4 = new JLabel();
    JTextArea textMemo = new JTextArea();
    JLabel jLabel8 = new JLabel();
    public void initComponent(){
        textPassword1.setText("");
        textPassword2.setText("");
        textName.setText("");
        textClass.setText("");
        textDate.setText("");
        textMemo.setText("");
    }
    public void regButton_actionPerformed(ActionEvent e) {
        String id=Tools.examineeNoGenerator();//生成考号!
        textNo.setText(id);
        String password1=String.valueOf(textPassword1.getPassword());
        if(password1.length()<6){
            Tools.showDialog("密码最低为六位!");
            return;
        }
        String password2=String.valueOf(textPassword2.getPassword());
        String password=null;
        if(!password1.equals(password2)){
            Tools.showDialog("两次密码输入不一致!");
            return;
        }else{
        password=password1;
        }
        String name=textName.getText();
        String sClass=textClass.getText();
        String memo = textMemo.getText();
        boolean bl=false;
        //try{
            //Date date = Date.valueOf(textDate.getText()); //attention!!
            SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
            String date=sdf.format(new java.util.Date());
            textDate.setText(date);
            ExamineeVO stuVo = new ExamineeVO(id, password, name, sClass, date, memo); //###
            StudentBO sbo = new StudentBO();
            bl = sbo.addExaminee(stuVo); //将封装后的stuVo对象传到StudentBO类的addExaminee()方法
        //}catch(IllegalArgumentException ee){
        //    Tools.showDialog("日期格式不正确!");
        //}
        if(bl){
            Tools.showDialog("恭喜您!注册成功!您的考号为: "+id); //注册成功后输出显示考生学号
            this.dispose();
        }
        else
            Tools.showDialog("注册失败!!!");
    }

    public void editButton_actionPerformed(ActionEvent e) {
        String id=textNo.getText();
        boolean bl=false;
        String password1=String.valueOf(textPassword1.getPassword());
        if(password1.length()<6){
            Tools.showDialog("密码最低为六位!");
            return;
        }
        String password2=String.valueOf(textPassword2.getPassword());
        String password=null;
        if(!password1.equals(password2)){
            Tools.showDialog("两次密码输入不一致!");
            return;
        }else{
        password=password1;
        }
        String name=textName.getText();
        String sClass=textClass.getText();
        String memo = textMemo.getText();
        //try{
            //Date date = Date.valueOf(textDate.getText()); //attention!!
            String date=textDate.getText();
            ExamineeVO stuVo = new ExamineeVO(id, password, name, sClass, date, memo); //###
            StudentBO sbo = new StudentBO();
            bl = sbo.editExaminee(stuVo); //将封装后的stuVo对象传到StudentBO类的addExaminee()方法
        //}catch(IllegalArgumentException ee){
        //    Tools.showDialog("日期格式不正确!");
        //}
        if(bl){
            Tools.showDialog("修改成功!!!"); //注册成功后输出显示考生学号
            this.dispose();
        }
        else
            Tools.showDialog("修改失败!!!");
  }


    public void resetButton_actionPerformed(ActionEvent e) {
        initComponent();
    }
}


    class AddEditFrame_resetButton_actionAdapter implements ActionListener {
        private AddEditFrame adaptee;
        AddEditFrame_resetButton_actionAdapter(AddEditFrame adaptee) {
            this.adaptee = adaptee;
        }

        public void actionPerformed(ActionEvent e) {
            adaptee.resetButton_actionPerformed(e);
        }
    }


    class AddEditFrame_editButton_actionAdapter implements ActionListener {
        private AddEditFrame adaptee;
        AddEditFrame_editButton_actionAdapter(AddEditFrame adaptee) {
            this.adaptee = adaptee;
        }

        public void actionPerformed(ActionEvent e) {
            adaptee.editButton_actionPerformed(e);
        }
    }


    class AddEditFrame_jButton2_actionAdapter implements ActionListener {
        private AddEditFrame adaptee;
        AddEditFrame_jButton2_actionAdapter(AddEditFrame adaptee) {
            this.adaptee = adaptee;
        }

        public void actionPerformed(ActionEvent e) {
            adaptee.regButton_actionPerformed(e);
        }
    }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -