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

📄 frmopenbook.java~31~

📁 此程序是用Java实现的一个图书管理系统,再加以可以做毕业设计用而,而且实现的工能相对效全.
💻 JAVA~31~
字号:
package bookmanager;

import java.awt.BorderLayout;
import javax.swing.JFrame;
import javax.swing.JPanel;
import java.awt.*;
import javax.swing.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.sql.Date;
import java.util.Calendar;
import java.util.ArrayList;

public class frmopenbook extends JFrame {
    Calendar c;
    public frmopenbook() {
        try {
            jbInit();
            c = Calendar.getInstance();
            Date d = new Date(c.getTimeInMillis());
            txtdatemodel.setText(d.toString());
        } catch (Exception exception) {
            exception.printStackTrace();
        }
    }

    private void jbInit() throws Exception {
        getContentPane().setLayout(null);
        pnlopenm.setBorder(BorderFactory.createEtchedBorder());
        pnlopenm.setBounds(new Rectangle(0, 0, 363, 299));
        pnlopenm.setLayout(null);
        pnla.setBorder(BorderFactory.createEtchedBorder());
        pnla.setBounds(new Rectangle(17, 14, 332, 95));
        pnla.setLayout(null);
        lblnumber.setText("借书证号码:");
        lblnumber.setBounds(new Rectangle(0, 6, 72, 24));
        txtnumb.setText("");
        txtnumb.setBounds(new Rectangle(68, 8, 98, 20));
        lblh.setText("姓名:");
        lblh.setBounds(new Rectangle(0, 52, 35, 25));
        txtu.setText("");
        txtu.setBounds(new Rectangle(68, 49, 100, 23));
        lblmage.setBorder(null);
        lblmage.setBounds(new Rectangle(240, 0, 90, 95));
        jPan.setBorder(BorderFactory.createEtchedBorder());
        jPan.setBounds(new Rectangle(17, 131, 332, 109));
        jPan.setLayout(null);
        lblsex.setText("性别:");
        lblsex.setBounds(new Rectangle(0, 9, 42, 24));
        cmbfal.setBounds(new Rectangle(51, 13, 80, 17));
        lbltele.setText("联系电话:");
        lbltele.setBounds(new Rectangle(0, 61, 61, 24));
        txttelep.setText("");
        txttelep.setBounds(new Rectangle(53, 63, 69, 19));
        lbladdr.setText("住址:");
        lbladdr.setBounds(new Rectangle(138, 13, 36, 21));
        txtaress.setText("");
        txtaress.setBounds(new Rectangle(178, 9, 149, 24));
        jPane.setBorder(BorderFactory.createEtchedBorder());
        jPane.setBounds(new Rectangle(17, 246, 85, 43));
        jPane.setLayout(null);
        jPanelexit.setBorder(BorderFactory.createEtchedBorder());
        jPanelexit.setBounds(new Rectangle(264, 246, 84, 43));
        jPanelexit.setLayout(null);
        btnop.setBounds(new Rectangle(6, 6, 71, 31));
        btnop.setText("确定");
        btnop.addActionListener(new frmopenbook_btnop_actionAdapter(this));
        btnexitok.setBounds(new Rectangle(7, 6, 71, 29));
        btnexitok.setText("退出");
        btnexitok.addActionListener(new frmopenbook_btnexitok_actionAdapter(this));
        lbldate.setText("有效期:");
        lbldate.setBounds(new Rectangle(125, 58, 44, 26));
        lb.setText("到");
        lb.setBounds(new Rectangle(243, 63, 18, 17));
        this.setTitle("开证");
        jP.setBorder(BorderFactory.createEtchedBorder());
        jP.setBounds(new Rectangle(132, 248, 98, 41));
        jP.setLayout(null);
        btnwrite.setBounds(new Rectangle(9, 5, 79, 32));
        btnwrite.setText("重置");
        btnwrite.addActionListener(new frmopenbook_btnwrite_actionAdapter(this));
        txtdatemodel.setText("");
        txtdatemodel.setBounds(new Rectangle(172, 62, 67, 18));
        txtmodeltime.setText("");
        txtmodeltime.setBounds(new Rectangle(260, 60, 68, 19));
        this.getContentPane().add(pnlopenm);
        pnlopenm.add(pnla);
        pnla.add(lblnumber);
        pnla.add(txtnumb);
        pnla.add(lblh);
        pnla.add(txtu);
        pnla.add(lblmage);
        pnlopenm.add(jPane);
        jPane.add(btnop);
        pnlopenm.add(jPanelexit);
        jPanelexit.add(btnexitok);
        pnlopenm.add(jPan);
        pnlopenm.add(jP);
        jP.add(btnwrite);
        jPan.add(lblsex);
        jPan.add(cmbfal);
        jPan.add(lbltele);
        jPan.add(txttelep);
        jPan.add(lbladdr);
        jPan.add(txtaress);
        jPan.add(lbldate);
        jPan.add(lb);
        jPan.add(txtdatemodel);
        jPan.add(txtmodeltime);
        cmbfal.addItem("男");
        cmbfal.addItem("女");
    }

    JPanel pnlopenm = new JPanel();
    JPanel pnla = new JPanel();
    JLabel lblnumber = new JLabel();
    JTextField txtnumb = new JTextField();
    JLabel lblh = new JLabel();
    JTextField txtu = new JTextField();
    JLabel lblmage = new JLabel(new ImageIcon("D:\\曾新焱\\P110.jpg"));
    JPanel jPan = new JPanel();
    JLabel lblsex = new JLabel();
    JComboBox cmbfal = new JComboBox();
    JLabel lbltele = new JLabel();
    JTextField txttelep = new JTextField();
    JLabel lbladdr = new JLabel();
    JTextField txtaress = new JTextField();
    JPanel jPane = new JPanel();
    JPanel jPanelexit = new JPanel();
    JButton btnop = new JButton();
    JButton btnexitok = new JButton();
    JLabel lbldate = new JLabel();
    JLabel lb = new JLabel();
    JPanel jP = new JPanel();
    JButton btnwrite = new JButton();
    JTextField txtdatemodel = new JTextField();
    JTextField txtmodeltime = new JTextField();
    public void btnexitok_actionPerformed(ActionEvent e) {
        this.dispose();
    }

    public void btnwrite_actionPerformed(ActionEvent e) {//重置
        txtnumb.setText("");
        txtu.setText("");
        txtaress.setText("");
        txttelep.setText("");
    }

    public void btnop_actionPerformed(ActionEvent e) {//办证功能
        int k = 0;
        readinfo r = new readinfo();
        borrowinfo b=new borrowinfo();
        killclass kill = new killclass();
        ArrayList nist = new ArrayList();
        nist = kill.checkreadinfo();
        if (txtnumb.getText().equals("")) {
            JOptionPane.showMessageDialog(this, "借书证号不能为空!", "请重输",
                                          JOptionPane.ERROR_MESSAGE);
        } else {
            for (int j = 0; j < nist.size(); j++) {
                readinfo book = (readinfo) nist.get(j);
                if (book.getreadid().equals(txtnumb.getText())) {
                    k++;
                    break;
                }
            }
            if(k>0){
               JOptionPane.showMessageDialog(this,"此借书证号已存在!","错误",
                                              JOptionPane.ERROR_MESSAGE);
           }
           else{
                r.setreadid(txtnumb.getText());
                if (txtu.getText().equals("")) {
                    JOptionPane.showMessageDialog(this, "姓名不能为空!", "请重输",
                                                  JOptionPane.ERROR_MESSAGE);
                } else {
                    r.setreadname(txtu.getText());
                    r.setreadsex(cmbfal.getSelectedItem().toString());
                    String s1 = txttelep.getText();
                    int cou = 0;
                    for (int i = 0; i < s1.length(); i++) {
                        if ((s1.charAt(i) >= '0' && s1.charAt(i) <= '9') == false) {
                            cou++;
                            break;
                        }
                    }
                    if (cou != 0) {
                        JOptionPane.showMessageDialog(this, "电话号码不能是0~9以外的字符!",
                                "请重输", JOptionPane.ERROR_MESSAGE);
                    } else {
                        r.setreadtelephone(txttelep.getText());
                        r.setreadaddress(txtaress.getText());
                        String st2 = (txtmodeltime.getText());
                        if (st2.equals("")) {
                            JOptionPane.showMessageDialog(this, "日期不能为空!",
                                    "请重输", JOptionPane.ERROR_MESSAGE);
                        } else {
                            if ((st2.substring(4, 5).equals("-") &&
                                 st2.substring(7, 8).equals("-")) == false) {
                                JOptionPane.showMessageDialog(this,
                                        "请输入正确的日期格式!",
                                        "请重输", JOptionPane.ERROR_MESSAGE);
                            } else {
                                int t1 = Integer.parseInt(txtdatemodel.getText().
                                        substring(0, 4));
                                int t2 = Integer.parseInt(txtdatemodel.getText().
                                        substring(5, 7));
                                int t3 = Integer.parseInt(txtdatemodel.getText().
                                        substring(8, 10));
                                int y1 = Integer.parseInt(txtmodeltime.getText().
                                        substring(0, 4));
                                int y2 = Integer.parseInt(txtmodeltime.getText().
                                        substring(5, 7));
                                int y3 = Integer.parseInt(txtmodeltime.getText().
                                        substring(8, 10));
                                int count = ((y1 - t1) * 365 + (y2 - t2) * 30 +
                                             (y3 - t3));
                                r.setreaddatetime(count);
                                int up = 0;
                                killclass dc = new killclass();
                                up = dc.readopen(r);
                                if (up == 1) {
                                    JOptionPane.showMessageDialog(this, "办证成功",
                                            "请继续", JOptionPane.OK_OPTION);
                                    b.setborrowid(txtnumb.getText());
                                    b.setborrowname(txtu.getText());
                                    b.setmoneyfee(100.00f);
                                    b.setboamount(10);
                                    b.setamount(0);
                                    kill.insertmodel(b);
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
class frmopenbook_btnop_actionAdapter implements ActionListener {
    private frmopenbook adaptee;
    frmopenbook_btnop_actionAdapter(frmopenbook adaptee) {
        this.adaptee = adaptee;
    }

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


class frmopenbook_btnwrite_actionAdapter implements ActionListener {
    private frmopenbook adaptee;
    frmopenbook_btnwrite_actionAdapter(frmopenbook adaptee) {
        this.adaptee = adaptee;
    }

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


class frmopenbook_btnexitok_actionAdapter implements ActionListener {
    private frmopenbook adaptee;
    frmopenbook_btnexitok_actionAdapter(frmopenbook adaptee) {
        this.adaptee = adaptee;
    }

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

⌨️ 快捷键说明

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