informpanel.java~93~
来自「银行信用评估系统」· JAVA~93~ 代码 · 共 208 行
JAVA~93~
208 行
package management;import java.awt.*;import javax.swing.*;import com.borland.dx.sql.dataset.*;import com.borland.dbswing.*;import java.awt.event.*;import java.sql.*;import com.borland.dx.dataset.*;import com.borland.jbcl.layout.*;/** * <p>Title: </p> * <p>Description: </p> * <p>Copyright: Copyright (c) 2004</p> * <p>Company: </p> * @author not attributable * @version 1.0 */public class informPanel extends JPanel { JLabel jLabel2 = new JLabel(); JTextField jTextField1 = new JTextField(); JButton jButton1 = new JButton(); JButton jButton2 = new JButton(); Database database1 = new Database(); JdbNavToolBar jdbNavToolBar1 = new JdbNavToolBar(); JdbStatusLabel jdbStatusLabel1 = new JdbStatusLabel(); TableScrollPane tableScrollPane1 = new TableScrollPane(); JdbTable jdbTable1 = new JdbTable(); PreparedStatement pstmt; Connection con; String query; ResultSet rs; String str; JLabel jLabel3 = new JLabel(); GridBagLayout gridBagLayout1 = new GridBagLayout(); JLabel jLabel4 = new JLabel(); JButton jButton3 = new JButton(); QueryDataSet queryDataSet1 = new QueryDataSet(); QueryResolver queryResolver1 = new QueryResolver(); public informPanel() { try { jbInit(); } catch(Exception ex) { ex.printStackTrace(); } } void jbInit() throws Exception { this.setLayout(gridBagLayout1); jLabel2.setFont(new java.awt.Font("Dialog", 1, 22)); jLabel2.setText("输入学号:"); jTextField1.setText(""); jButton1.setText("信息管理"); jButton1.addActionListener(new informPanel_jButton1_actionAdapter(this)); jButton2.setText("重置"); jButton2.addActionListener(new informPanel_jButton2_actionAdapter(this)); database1.setConnection(new com.borland.dx.sql.dataset.ConnectionDescriptor("jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=student", "sa", "lomf8244", false, "com.microsoft.jdbc.sqlserver.SQLServerDriver")); database1.setUseTransactions(false); jdbNavToolBar1.setFont(new java.awt.Font("Dialog", 0, 10)); jdbStatusLabel1.setText(" "); tableScrollPane1.getViewport().setBackground(SystemColor.info); tableScrollPane1.setAutoscrolls(true); jdbTable1.setBackground(Color.cyan); jdbTable1.setAutoResizeMode(JTable.AUTO_RESIZE_LAST_COLUMN); jdbTable1.setSelectionBackground(SystemColor.info); jdbTable1.setSelectionForeground(UIManager.getColor("CheckBox.foreground")); jdbTable1.setDataSet(queryDataSet1); jLabel3.setText(""); jLabel4.setFont(new java.awt.Font("Dialog", 1, 40)); jLabel4.setForeground(Color.pink); jLabel4.setText(" 学 生 信 息 管 理"); jButton3.setText("密码管理"); jButton3.addActionListener(new informPanel_jButton3_actionAdapter(this)); queryDataSet1.setResolver(queryResolver1); queryResolver1.setDatabase(database1); queryResolver1.setUpdateMode(com.borland.dx.dataset.UpdateMode.KEY_COLUMNS); this.add(jTextField1, new GridBagConstraints(2, 1, 2, 1, 1.0, 0.0 ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(19, 7, 0, 108), 130, 3)); this.add(jLabel2, new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0 ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(16, 84, 0, 17), 5, -1)); this.add(tableScrollPane1, new GridBagConstraints(1, 4, 3, 1, 1.0, 1.0 ,GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), -17, -249)); tableScrollPane1.getViewport().add(jdbTable1, null); this.add(jButton1, new GridBagConstraints(1, 2, 1, 1, 0.0, 0.0 ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(10, 138, 0, 0), 11, 2)); this.add(jButton2, new GridBagConstraints(2, 2, 1, 1, 0.0, 0.0 ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(8, 39, 0, 0), 15, 2)); this.add(jdbStatusLabel1, new GridBagConstraints(1, 3, 3, 1, 0.0, 0.0 ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(32, 60, 0, 53), 268, -2)); this.add(jdbNavToolBar1, new GridBagConstraints(0, 3, 4, 1, 1.0, 0.0 ,GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, -7, 15, 18), 79, 0)); this.add(jLabel3, new GridBagConstraints(1, 1, GridBagConstraints.REMAINDER, GridBagConstraints.REMAINDER, 0.0, 0.0 ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); this.add(jLabel4, new GridBagConstraints(1, 0, 3, 1, 0.0, 0.0 ,GridBagConstraints.SOUTHEAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 223, 0)); this.add(jButton3, new GridBagConstraints(3, 2, 1, 1, 0.0, 0.0 ,GridBagConstraints.SOUTH, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 1, 0)); Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver"); String url = "jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=student"; String username= "sa"; String password= "lomf8244"; con = DriverManager.getConnection(url,username,password); query="select * from student where STUDENTNO=?"; pstmt = con.prepareStatement(query); jLabel3.setVisible(false); } void jButton2_actionPerformed(ActionEvent e) { jTextField1.setText(""); queryDataSet1.close(); queryDataSet1.setQuery(new com.borland.dx.sql.dataset.QueryDescriptor(database1, "select STUDENTNO as"+ "\'"+"学号" +"\'"+",STUDENTNAME as"+ "\'"+"姓名" +"\'"+",STUDENTAGE as"+ "\'"+"年龄" +"\'"+",STUDENTSEX as"+ "\'"+"性别" +"\'"+",STUENTRACE as"+ "\'"+"民族" +"\'"+",STUDENTSPECIATION as"+ "\'"+"专业" +"\'"+"from student", null, true, Load.ALL)); queryDataSet1.refresh(); jdbNavToolBar1.setDataSet(queryDataSet1); jdbStatusLabel1.setDataSet(queryDataSet1); jdbTable1.setDataSet(queryDataSet1); jdbTable1.repaint(); } void jButton1_actionPerformed(ActionEvent e) { try{ str=jTextField1.getText(); pstmt.setString(1,str); rs=pstmt.executeQuery(); if(jTextField1.getText().length()==0 || str.equals("学号不存在!")) { jTextField1.setText("请输入学号!"); } else { if(rs.next()){ queryDataSet1.close(); jLabel3.setText(rs.getString("STUDENTNO")); str=jLabel3.getText(); queryDataSet1.setQuery(new com.borland.dx.sql.dataset.QueryDescriptor(database1, "select STUDENTNO as"+ "\'"+"学号" +"\'"+",STUDENTNAME as"+ "\'"+"姓名" +"\'"+",STUDENTAGE as"+ "\'"+"年龄" +"\'"+",STUDENTSEX as"+ "\'"+"性别" +"\'"+",STUENTRACE as"+ "\'"+"民族" +"\'"+",STUDENTSPECIATION as"+ "\'"+"专业" +"\'"+"from STUDENTNO="+str, null, true, Load.ALL)); queryDataSet1.refresh(); jdbNavToolBar1.setDataSet(queryDataSet1); jdbStatusLabel1.setDataSet(queryDataSet1); jdbTable1.setDataSet(queryDataSet1); jdbTable1.repaint(); } else{ jTextField1.setText("学号不存在!"); queryDataSet1.close(); queryDataSet1.refresh(); jdbTable1.setDataSet(null); jdbTable1.repaint(); } } } catch(SQLException ex) { System.out.print("系统错误,请重新运行。"); } } void jButton3_actionPerformed(ActionEvent e) { queryDataSet1.close(); queryDataSet1.setQuery(new com.borland.dx.sql.dataset.QueryDescriptor(database1, "select STUDENTNO as"+ "\'"+"学号" +"\'"+",PASSWORDS as"+ "\'"+"密码" +"\'"+"from usercheck" , null, true, Load.ALL)); queryDataSet1.refresh(); jdbNavToolBar1.setDataSet(queryDataSet1); jdbStatusLabel1.setDataSet(queryDataSet1); jdbTable1.setDataSet(queryDataSet1); jdbTable1.repaint(); }}class informPanel_jButton2_actionAdapter implements java.awt.event.ActionListener { informPanel adaptee; informPanel_jButton2_actionAdapter(informPanel adaptee) { this.adaptee = adaptee; } public void actionPerformed(ActionEvent e) { adaptee.jButton2_actionPerformed(e); }}class informPanel_jButton1_actionAdapter implements java.awt.event.ActionListener { informPanel adaptee; informPanel_jButton1_actionAdapter(informPanel adaptee) { this.adaptee = adaptee; } public void actionPerformed(ActionEvent e) { adaptee.jButton1_actionPerformed(e); }}class informPanel_jButton3_actionAdapter implements java.awt.event.ActionListener { informPanel adaptee; informPanel_jButton3_actionAdapter(informPanel adaptee) { this.adaptee = adaptee; } public void actionPerformed(ActionEvent e) { adaptee.jButton3_actionPerformed(e); }}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?