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

📄 addreader1.java

📁 基于Java的物流管理系统的开发与应用
💻 JAVA
字号:
package untitled5;import java.awt.*;import java.awt.event.*;import javax.swing.*;import com.borland.jbcl.layout.*;import java.io.*;import java.net.*;import java.sql.*;import java.lang.*;import javax.sql.*;import java.awt.*;import java.awt.event.*;import javax.swing.*;import com.borland.jbcl.layout.*;import javax.swing.event.*;/** * <p>Title: </p> * <p>Description: </p> * <p>Copyright: Copyright (c) 2003</p> * <p>Company: </p> * @author not attributable * @version 1.0 */public class addreader1 extends JFrame {  JPanel contentPane;  XYLayout xYLayout1 = new XYLayout();  JLabel jLabel1 = new JLabel();  JLabel jLabel2 = new JLabel();  JTextField name = new JTextField();  JLabel jLabel3 = new JLabel();  JTextField id = new JTextField();  JLabel jLabel4 = new JLabel();  JPasswordField password = new JPasswordField();  JLabel jLabel5 = new JLabel();  JTextField department = new JTextField();  JButton jButton1 = new JButton();  //Construct the frame  public addreader1() {    enableEvents(AWTEvent.WINDOW_EVENT_MASK);    try {      jbInit();    }    catch(Exception e) {      e.printStackTrace();    }  }  //Component initialization  private void jbInit() throws Exception  {    contentPane = (JPanel) this.getContentPane();    jLabel1.setFont(new java.awt.Font("SansSerif", 0, 20));    jLabel1.setForeground(Color.red);    jLabel1.setText("物流管理系统");    contentPane.setLayout(xYLayout1);    this.setSize(new Dimension(500, 500));    this.setTitle("Frame Title");    jLabel2.setFont(new java.awt.Font("SansSerif", 0, 15));    jLabel2.setText("姓名");    name.setText("");    jLabel3.setFont(new java.awt.Font("SansSerif", 0, 15));    jLabel3.setText("ID号");    id.setText("");    jLabel4.setFont(new java.awt.Font("SansSerif", 0, 15));    jLabel4.setRequestFocusEnabled(true);    jLabel4.setText("密码");    password.setText("");    jLabel5.setFont(new java.awt.Font("SansSerif", 0, 15));    jLabel5.setText("院系");    department.setText("");    jButton1.setFont(new java.awt.Font("SansSerif", 0, 15));    jButton1.setText("提交");    jButton1.addActionListener(new addreader1_jButton1_actionAdapter(this));    contentPane.setBackground(UIManager.getColor("Desktop.background"));    contentPane.add(jLabel1, new XYConstraints(180, 0, 140, 27));    contentPane.add(jLabel3,      new XYConstraints(87, 130, -1, 26));    contentPane.add(id,       new XYConstraints(118, 129, 120, 28));    contentPane.add(jLabel4,     new XYConstraints(88, 170, -1, 23));    contentPane.add(password,       new XYConstraints(118, 168, 120, 29));    contentPane.add(name,    new XYConstraints(118, 93, 120, 26));    contentPane.add(jLabel2, new XYConstraints(89, 95, -1, 28));    contentPane.add(jLabel5,       new XYConstraints(90, 210, 32, 28));    contentPane.add(department,      new XYConstraints(118, 209, 120, 29));    contentPane.add(jButton1,   new XYConstraints(118, 249, 106, 29));  }  //Overridden so we can exit when window is closed  protected void processWindowEvent(WindowEvent e) {    super.processWindowEvent(e);    if (e.getID() == WindowEvent.WINDOW_CLOSING) {      System.exit(0);    }  }  void jButton1_actionPerformed(ActionEvent e) {    validID();  }  void validID() {     System.out.println("JLKJLJLJLJL");    try {      String str1,str2,str3,str4;      str1 = name.getText();      str2=id.getText();      str3=password.getText();      str4=department.getText();      int number=Integer.parseInt(str1);     // int issn=Integer.parseInt(str1);      System.out.println(str1);     // str2 = jPasswordField1.getText();     // System.out.println(str1);      //System.out.println(str2);      //装载jdbc驱动程序      String driverName = "oracle.jdbc.OracleDriver";      Driver driver = (Driver) Class.forName(driverName).newInstance();      //连接数据库      Connection con = DriverManager.getConnection(          "jdbc:oracle:thin:@thsspc0791:1521:tongfang", "sa", "tongfang");      PreparedStatement pstmt = con.prepareStatement(          " insert into reader values(?)");      pstmt.setString(1, str1);      pstmt.setString(2,str2);      pstmt.setString(3,str3);      pstmt.setString(4,str4);      ResultSet res = pstmt.executeQuery();      System.out.println("ljljljljljljlj");      //String sa=res.getString(1);      //if ((!res.next()) || res.getString("issn")== null) {        //JOptionPane.showMessageDialog(this, "查无此书", "错误",                                    //JOptionPane.ERROR_MESSAGE);     // }else {        // { String outputarea="祝贺您!!!"+"\n"+"\n"+"您已经成功取消预定此书";          //System.out.println("aksdjflkajsdlf");         // do{          //System.out.println(res.getString(1)+":" + res.getLong(2) + ":" +res.getLong(3) +":"+res.getInt(4)+":"+res.getString(5)+":"+res.getString(6)+":"+res.getInt(7));          //outputarea+="  "+res.getString(1)+"  "+"  "+res.getString(2)+"  "+"  "+res.getLong(3)+"  "+"      "+res.getString(4)+"  "+"     "+res.getString(5)+"  "+"   "+res.getDate(6)+"      "+"    "+res.getInt(7)+"  "+"   "+res.getString(8)+"   "+"\n";          // showmessage.setText(outputarea);          //}while (res.next());     // }      pstmt.close();      con.close();    }catch (InstantiationException e) {      System.out.println(e.getMessage());    }catch (IllegalAccessException e) {      System.out.println(e.getMessage());    }catch (ClassNotFoundException e) {      System.out.println(e.getMessage());    }catch (SQLException edd) {      edd.printStackTrace() ;      System.out.println(edd.getMessage());    }  }}class addreader1_jButton1_actionAdapter implements java.awt.event.ActionListener {  addreader1 adaptee;  addreader1_jButton1_actionAdapter(addreader1 adaptee) {    this.adaptee = adaptee;  }  public void actionPerformed(ActionEvent e) {    adaptee.jButton1_actionPerformed(e);  }}

⌨️ 快捷键说明

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