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

📄 borrowinfoupdate.java~11~

📁 这是一个图书管理系统
💻 JAVA~11~
字号:
package bookmanager;import javax.swing.*;import com.borland.jbcl.layout.*;import java.awt.*;import java.awt.event.*;import java.sql.*;/** * <p>Title: </p> * <p>Description: </p> * <p>Copyright: Copyright (c) 2003</p> * <p>Company: </p> * @author not attributable * @version 1.0 */public class borrowInfoUpdate extends JFrame {  ResultSet rs;    //定义结果集  private DBManager db =new DBManager();//定义数据库操作对象  XYLayout xYLayout1 = new XYLayout();  JButton jButtonupdate = new JButton();  JButton jButtonexit = new JButton();  JButton jButtondeciside = new JButton();  JButton jButtonClear = new JButton();  JLabel jLabel8 = new JLabel();  JLabel jLabel4 = new JLabel();  JTextField jTextbookname = new JTextField();  JTextField jTextborrowdate = new JTextField();  JLabel jLabel1 = new JLabel();  JLabel jLabel3 = new JLabel();  JLabel jLabel2 = new JLabel();  JTextField jTextcomment = new JTextField();  JTextField jTextstudentname = new JTextField();  public borrowInfoUpdate() {    try {      jbInit();    }    catch(Exception e) {      e.printStackTrace();    }  }  public static void main(String[] args) {    borrowInfoUpdate borrowInfoUpdate = new borrowInfoUpdate();  }  private void jbInit() throws Exception {    jButtonClear.setFont(new java.awt.Font("Dialog", 0, 16));    jButtonClear.setText("清空");    jButtonClear.addMouseListener(new borrowInfoUpdate_jButtonClear_mouseAdapter(this));    jButtondeciside.setFont(new java.awt.Font("Dialog", 0, 16));     jButtondeciside.setText("确定");    jButtondeciside.addMouseListener(new borrowInfoUpdate_jButtondeciside_mouseAdapter(this));     jButtonexit.setFont(new java.awt.Font("Dialog", 0, 16));     jButtonexit.setText("退出");    jButtonexit.addMouseListener(new borrowInfoUpdate_jButtonexit_mouseAdapter(this));    jButtonupdate.setFont(new java.awt.Font("Dialog", 0, 16));      jButtonupdate.setText("更新");    jButtonupdate.addMouseListener(new borrowInfoUpdate_jButtonupdate_mouseAdapter(this));    this.getContentPane().setLayout(xYLayout1);    jLabel8.setFont(new java.awt.Font("Dialog", 0, 16));    jLabel8.setText("输入借阅者姓名或书名点击确定,将调出此书相关信息");    jLabel4.setText("备注");    jLabel4.setFont(new java.awt.Font("Dialog", 0, 16));    jTextbookname.setText("");    jTextbookname.setFont(new java.awt.Font("Dialog", 0, 16));    jTextborrowdate.setText("");    jTextborrowdate.setFont(new java.awt.Font("Dialog", 0, 16));    jLabel1.setText("借阅者姓名");    jLabel1.setRequestFocusEnabled(true);    jLabel1.setFont(new java.awt.Font("Dialog", 0, 16));    jLabel3.setText("借阅日期");    jLabel3.setFont(new java.awt.Font("Dialog", 0, 16));    jLabel2.setText("书名");    jLabel2.setFont(new java.awt.Font("Dialog", 0, 16));    jTextcomment.setText("");    jTextcomment.setFont(new java.awt.Font("Dialog", 0, 16));    jTextstudentname.setText("");    jTextstudentname.setFont(new java.awt.Font("Dialog", 0, 16));    xYLayout1.setWidth(477);    xYLayout1.setHeight(386);    this.getContentPane().add(jTextstudentname,  new XYConstraints(219, 90, 150, 26));    this.getContentPane().add(jLabel4, new XYConstraints(90, 247, 63, 29));    this.getContentPane().add(jTextbookname, new XYConstraints(218, 144, 154, 23));    this.getContentPane().add(jTextborrowdate, new XYConstraints(218, 187, 153, -1));    this.getContentPane().add(jLabel1, new XYConstraints(91, 86, 88, 33));    this.getContentPane().add(jLabel3, new XYConstraints(88, 200, 87, 29));    this.getContentPane().add(jLabel2, new XYConstraints(88, 144, 89, 35));    this.getContentPane().add(jTextcomment, new XYConstraints(219, 236, 154, -1));    this.getContentPane().add(jLabel8,  new XYConstraints(17, 26, 435, 25));    this.getContentPane().add(jButtondeciside, new XYConstraints(166, 314, -1, 28));    this.getContentPane().add(jButtonupdate, new XYConstraints(232, 314, 74, 27));    this.getContentPane().add(jButtonexit, new XYConstraints(306, 314, 75, 28));    this.getContentPane().add(jButtonClear, new XYConstraints(99, 314, 66, 28));  }  void jButtondeciside_mouseClicked(MouseEvent e) {    String sql;    //定义变量,用来判断是否是第一个查询条件    boolean  isfirst =true;    sql="select * from BookBorrow ";      //如果款型的查询条件不为空    if (jTextstudentname.getText().trim().length() ==0)       {}       else       {          sql=sql+"  where  studentname='"+jTextstudentname.getText().trim()+"'";          isfirst=false;       }            //如果颜色的查询条件不为空      if (jTextbookname.getText().trim().length()==0)      {}      else      {    //如果是第一个查询条件        if (isfirst)        sql=sql+" where bookname='"+jTextbookname.getText().trim() +"'";          //如果是第二个查询条件        else         sql=sql+" and bookname='"+jTextbookname.getText().trim() +"'";      }    //执行数据库的查询操作    rs =db.getResult(sql);     try {            //判断返回的结果集是否为空,若不为空显示第一条记录       if(! rs.equals(null) )       {  rs.first();         jTextstudentname.setText(rs.getString("studentname"));        jTextbookname.setText(rs.getString("bookname"));        jTextborrowdate.setText(rs.getString("borrowdate"));        jTextcomment.setText(rs.getString("comment"));       }       else       {   JOptionPane.showMessageDialog(null,"无次纪录!");              }     }//若出现异常,弹出警告对话框     catch (SQLException ex) { JOptionPane.showMessageDialog(null,"发生错误!");     }  }   //清空文本框  void jButtonClear_mouseClicked(MouseEvent e) {          jTextstudentname.setText("");          jTextbookname.setText("");          jTextborrowdate.setText("");          jTextcomment.setText("");  }  void jButtonexit_mouseClicked(MouseEvent e) {               this.dispose();  }  void jButtonupdate_mouseClicked(MouseEvent e) {    String strSQL ;strSQL="update BookBorrow set  ";strSQL= strSQL+" borrowdate='"+jTextborrowdate.getText().trim()+"',";strSQL= strSQL+" comment='"+jTextcomment.getText().trim()+"'";strSQL= strSQL+  " where studentname='"+jTextstudentname.getText().trim() +"'";strSQL= strSQL+" and bookname='"+jTextbookname.getText().trim()+"'";if(db.executeSql(strSQL))       {JOptionPane.showMessageDialog(null,"成功更新!"); }    else       { JOptionPane.showMessageDialog(null," 更新失败,请重新操作!");      }  }}class borrowInfoUpdate_jButtondeciside_mouseAdapter extends java.awt.event.MouseAdapter {  borrowInfoUpdate adaptee;  borrowInfoUpdate_jButtondeciside_mouseAdapter(borrowInfoUpdate adaptee) {    this.adaptee = adaptee;  }  public void mouseClicked(MouseEvent e) {    adaptee.jButtondeciside_mouseClicked(e);  }}class borrowInfoUpdate_jButtonClear_mouseAdapter extends java.awt.event.MouseAdapter {  borrowInfoUpdate adaptee;  borrowInfoUpdate_jButtonClear_mouseAdapter(borrowInfoUpdate adaptee) {    this.adaptee = adaptee;  }  public void mouseClicked(MouseEvent e) {    adaptee.jButtonClear_mouseClicked(e);  }}class borrowInfoUpdate_jButtonexit_mouseAdapter extends java.awt.event.MouseAdapter {  borrowInfoUpdate adaptee;  borrowInfoUpdate_jButtonexit_mouseAdapter(borrowInfoUpdate adaptee) {    this.adaptee = adaptee;  }  public void mouseClicked(MouseEvent e) {    adaptee.jButtonexit_mouseClicked(e);  }}class borrowInfoUpdate_jButtonupdate_mouseAdapter extends java.awt.event.MouseAdapter {  borrowInfoUpdate adaptee;  borrowInfoUpdate_jButtonupdate_mouseAdapter(borrowInfoUpdate adaptee) {    this.adaptee = adaptee;  }  public void mouseClicked(MouseEvent e) {    adaptee.jButtonupdate_mouseClicked(e);  }}

⌨️ 快捷键说明

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