sendnotice.java~6~

来自「银行信用评估系统」· JAVA~6~ 代码 · 共 130 行

JAVA~6~
130
字号
package management;import java.awt.*;import java.awt.event.*;import javax.swing.*;import com.borland.jbcl.layout.*;import java.sql.*;import com.borland.dx.dataset.*;import com.borland.dx.sql.dataset.*;import com.borland.dbswing.*;/** * <p>Title: </p> * <p>Description: </p> * <p>Copyright: Copyright (c) 2004</p> * <p>Company: </p> * @author not attributable * @version 1.0 */public class sendNotice extends JPanel {  PreparedStatement pstmt2;String query2;Connection con;ResultSet rrs;  JLabel jLabel1 = new JLabel();  JTextField jTextField1 = new JTextField();  JTextArea jTextArea1 = new JTextArea();  JButton jButton1 = new JButton();  JButton jButton2 = new JButton();  public sendNotice() {    try {      jbInit();    }    catch(Exception ex) {      ex.printStackTrace();    }  }  void jbInit() throws Exception {    jLabel1.setFont(new java.awt.Font("Dialog", 0, 14));    jLabel1.setPreferredSize(new Dimension(0, 0));    jLabel1.setRequestFocusEnabled(true);    jLabel1.setText("信用卡号:");    jLabel1.setBounds(new Rectangle(28, 37, 106, 35));    this.setLayout(null);    this.setForeground(Color.black);    jTextField1.setFont(new java.awt.Font("Dialog", 0, 14));    jTextField1.setText("");    jTextField1.setBounds(new Rectangle(154, 40, 141, 34));    jTextArea1.setSelectionStart(0);    jTextArea1.setText("");    jTextArea1.setBounds(new Rectangle(37, 113, 317, 144));    jButton1.setBounds(new Rectangle(43, 282, 85, 28));    jButton1.setFont(new java.awt.Font("Dialog", 0, 14));    jButton1.setText("发送");    jButton1.addActionListener(new sendNotice_jButton1_actionAdapter(this));    jButton2.setBounds(new Rectangle(183, 281, 80, 29));    jButton2.setFont(new java.awt.Font("Dialog", 0, 14));    jButton2.setText("取消");    jButton2.addActionListener(new sendNotice_jButton2_actionAdapter(this));    try {    String url =        "jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=CCES";    String username = "sa";    String password = "";    con = DriverManager.getConnection(url, username, password);  }  catch (Exception ep) {System.out.print("系统错误,请重新运行。2");    ep.printStackTrace() ;}    this.add(jLabel1, null);    this.add(jTextField1, null);    this.add(jTextArea1, null);    this.add(jButton1, null);    this.add(jButton2, null);  }  void jButton1_actionPerformed(ActionEvent e) {    try{      query2 =          "insert into Notice(CreditcardId,Content) values('"+jTextField1.getText()+"','"+jTextArea1.getText()+"')";    //   query2 = "insert into Notice(CreditcardId,Content) Values("+"\'"+Integer.parseInt(jTextField1.getText())+"\'"+ ","+"\'"+jTextArea1.getText()+"\'"+")";      pstmt2 = con.prepareStatement(query2);      rrs = pstmt2.executeQuery();      jTextField1.setText("");    jTextArea1.setText("");    }    catch (Exception eep) {      System.out.print("系统错误,请重新运行。3");      eep.printStackTrace();    }  }  void jButton2_actionPerformed(ActionEvent e) {    jTextField1.setText("");    jTextArea1.setText("");  }}class sendNotice_jButton1_actionAdapter implements java.awt.event.ActionListener {  sendNotice adaptee;  sendNotice_jButton1_actionAdapter(sendNotice adaptee) {    this.adaptee = adaptee;  }  public void actionPerformed(ActionEvent e) {    adaptee.jButton1_actionPerformed(e);  }}class sendNotice_jButton2_actionAdapter implements java.awt.event.ActionListener {  sendNotice adaptee;  sendNotice_jButton2_actionAdapter(sendNotice adaptee) {    this.adaptee = adaptee;  }  public void actionPerformed(ActionEvent e) {    adaptee.jButton2_actionPerformed(e);  }}

⌨️ 快捷键说明

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