frame3.java~31~

来自「学生上机系统,请大家多多指教.以后会发」· JAVA~31~ 代码 · 共 479 行 · 第 1/2 页

JAVA~31~
479
字号
package student_computer;import javax.swing.*;import java.awt.*;import com.borland.dbswing.*;import com.borland.dx.sql.dataset.*;import com.borland.dx.dataset.*;import java.awt.event.*;import java.sql.*;import java.util.Date;/** * <p>Title: </p> * <p>Description: </p> * <p>Copyright: Copyright (c) 2006</p> * <p>Company: </p> * @author not attributable * @version 1.0 */public class Frame3 extends JFrame {  BorderLayout borderLayout1 = new BorderLayout();  JTabbedPane jTabbedPane1 = new JTabbedPane();  JPanel jPanel1 = new JPanel();  JPanel jPanel2 = new JPanel();  JPanel jPanel3 = new JPanel();  BorderLayout borderLayout2 = new BorderLayout();  JPanel jPanel4 = new JPanel();  JLabel jLabel1 = new JLabel();  JPanel jPanel5 = new JPanel();  JdbNavToolBar jdbNavToolBar1 = new JdbNavToolBar();  BorderLayout borderLayout3 = new BorderLayout();  TableScrollPane tableScrollPane1 = new TableScrollPane();  JdbTable jdbTable1 = new JdbTable();  JdbStatusLabel jdbStatusLabel1 = new JdbStatusLabel();  JdbLabel jdbLabel1 = new JdbLabel();  JButton jButton1 = new JButton();  JLabel jLabel2 = new JLabel();  JLabel jLabel4 = new JLabel();  Database database1 = new Database();  QueryDataSet queryDataSet1 = new QueryDataSet();  ParameterRow parameterRow1 = new ParameterRow();  Column column1 = new Column();  Column column2 = new Column();  QueryDataSet queryDataSet2 = new QueryDataSet();  ButtonGroup buttonGroup1 = new ButtonGroup();  JPanel jPanel6 = new JPanel();  JRadioButton jRadioButton1 = new JRadioButton();  JRadioButton jRadioButton2 = new JRadioButton();  JLabel jLabel3 = new JLabel();  JTextField jTextField1 = new JTextField();  JLabel jLabel5 = new JLabel();  JTextField jTextField2 = new JTextField();  JButton jButton2 = new JButton();  JButton jButton3 = new JButton();  JLabel jLabel6 = new JLabel();  JTextField jTextField3 = new JTextField();  JLabel jLabel7 = new JLabel();  JTextField jTextField4 = new JTextField();  JButton jButton4 = new JButton();  JButton jButton5 = new JButton();  public Frame3() {    try {      jbInit();    }    catch(Exception e) {      e.printStackTrace();    }  }  private void jbInit() throws Exception {    this.getContentPane().setLayout(borderLayout1);    jPanel1.setLayout(borderLayout2);    jLabel1.setFont(new java.awt.Font("Dialog", 0, 16));    jLabel1.setText("               ");    jPanel5.setLayout(borderLayout3);    jdbStatusLabel1.setText("jdbStatusLabel1");    jdbStatusLabel1.setDataSet(queryDataSet1);    jButton1.setText("查询");    jButton1.addActionListener(new Frame3_jButton1_actionAdapter(this));    jLabel2.setText("            ");    jLabel4.setText("             ");    database1.setConnection(new com.borland.dx.sql.dataset.ConnectionDescriptor("jdbc:microsoft:sqlserver://210.30.104.11:1433;DatabaseName=student_computer", "xueli", "gejingguo", false, "com.microsoft.jdbc.sqlserver.SQLServerDriver"));    queryDataSet1.setQuery(new com.borland.dx.sql.dataset.QueryDescriptor(database1, "select computer_number as \'机号\',computer_state as \'目前状态\',computer_status " +      "as \'机器状态\' from computer;", null, true, Load.ALL));    jdbTable1.setDataSet(queryDataSet1);    jdbNavToolBar1.setButtonStateInsert(JdbNavToolBar.DISABLED);    jdbNavToolBar1.setButtonStateDelete(JdbNavToolBar.DISABLED);    jdbNavToolBar1.setDataSet(queryDataSet1);    column1.setColumnName("com_state");    column1.setDataType(com.borland.dx.dataset.Variant.STRING);    column1.setPreferredOrdinal(0);    column1.setServerColumnName("NewColumn1");    column1.setSqlType(0);    column2.setColumnName("com_status");    column2.setDataType(com.borland.dx.dataset.Variant.STRING);    column2.setPreferredOrdinal(1);    column2.setServerColumnName("NewColumn2");    column2.setSqlType(0);    parameterRow1.setColumns(new Column[] {column1, column2});    queryDataSet2.setQuery(new com.borland.dx.sql.dataset.QueryDescriptor(database1, "select computer_number as \'机号\',computer_state as \'目前状态\',computer_status " +      "as \'机器状态\' from computer where computer_state=\'空闲\' and \ncomputer_status=\'正常\'", null, true, Load.ALL));    jdbLabel1.setText("");    jRadioButton1.setText("可  用");    jRadioButton2.setSelected(true);    jRadioButton2.setText("全   部");    jPanel2.setLayout(null);    jLabel3.setFont(new java.awt.Font("Dialog", 0, 16));    jLabel3.setText("卡号:");    jLabel3.setBounds(new Rectangle(96, 94, 94, 31));    jTextField1.setText("");    jTextField1.setBounds(new Rectangle(196, 97, 115, 25));    jLabel5.setFont(new java.awt.Font("Dialog", 0, 16));    jLabel5.setText("机号:");    jLabel5.setBounds(new Rectangle(96, 157, 94, 33));    jTextField2.setText("");    jTextField2.setBounds(new Rectangle(196, 161, 115, 25));    jButton2.setBounds(new Rectangle(96, 238, 87, 29));    jButton2.setFont(new java.awt.Font("Dialog", 0, 16));    jButton2.setText("上机");    jButton2.addActionListener(new Frame3_jButton2_actionAdapter(this));    jButton3.setBounds(new Rectangle(235, 239, 87, 29));    jButton3.setFont(new java.awt.Font("Dialog", 0, 16));    jButton3.setText("置空");    jPanel3.setLayout(null);    jPanel3.setFont(new java.awt.Font("Dialog", 0, 16));    jLabel6.setFont(new java.awt.Font("Dialog", 0, 16));    jLabel6.setText("卡   号:");    jLabel6.setBounds(new Rectangle(110, 114, 75, 38));    jTextField3.setText("");    jTextField3.setBounds(new Rectangle(233, 119, 124, 29));    jLabel7.setFont(new java.awt.Font("Dialog", 0, 16));    jLabel7.setText("机  号:");    jLabel7.setBounds(new Rectangle(110, 183, 91, 39));    jTextField4.setText("");    jTextField4.setBounds(new Rectangle(233, 188, 124, 29));    jButton4.setBounds(new Rectangle(109, 260, 98, 31));    jButton4.setFont(new java.awt.Font("Dialog", 0, 16));    jButton4.setText("下机");    jButton4.addActionListener(new Frame3_jButton4_actionAdapter(this));    jButton5.setBounds(new Rectangle(258, 262, 98, 31));    jButton5.setFont(new java.awt.Font("Dialog", 0, 16));    jButton5.setText("退出");    this.getContentPane().add(jTabbedPane1, BorderLayout.CENTER);    jTabbedPane1.add(jPanel1,    "机器状态查询");    jTabbedPane1.add(jPanel2,   "上机登记");    jPanel2.add(jLabel3, null);    jPanel2.add(jTextField1, null);    jPanel2.add(jLabel5, null);    jPanel2.add(jTextField2, null);    jPanel2.add(jButton2, null);    jPanel2.add(jButton3, null);    jTabbedPane1.add(jPanel3,   "下机登记");    jPanel3.add(jTextField3, null);    jPanel3.add(jTextField4, null);    jPanel3.add(jLabel6, null);    jPanel3.add(jLabel7, null);    jPanel3.add(jButton4, null);    jPanel3.add(jButton5, null);    jPanel1.add(jPanel4,  BorderLayout.NORTH);    jPanel4.add(jLabel2, null);    jPanel4.add(jdbLabel1, null);    jPanel4.add(jPanel6, null);    jPanel6.add(jRadioButton2, null);    jPanel6.add(jRadioButton1, null);    jPanel4.add(jLabel1, null);    jPanel4.add(jButton1, null);    jPanel4.add(jLabel4, null);    jPanel1.add(jPanel5, BorderLayout.CENTER);    jPanel5.add(jdbNavToolBar1, BorderLayout.NORTH);    jPanel5.add(tableScrollPane1, BorderLayout.CENTER);    jPanel5.add(jdbStatusLabel1,  BorderLayout.SOUTH);    tableScrollPane1.getViewport().add(jdbTable1, null);    buttonGroup1.add(jRadioButton2);    buttonGroup1.add(jRadioButton1);    this.setSize(500,400);    this.setLocation(200,180);    jTabbedPane1.setSelectedIndex(0);    //this.setSize();  }//////////////////机器状态查询  void jButton1_actionPerformed(ActionEvent e) {     boolean select=jRadioButton1.isSelected();     String t="";     if(select)     {       jdbTable1.setDataSet(queryDataSet2);       jdbNavToolBar1.setDataSet(queryDataSet2);       jdbStatusLabel1.setDataSet(queryDataSet2);       queryDataSet2.refresh();     }     else     {       jdbTable1.setDataSet(queryDataSet1);       jdbNavToolBar1.setDataSet(queryDataSet1);       jdbStatusLabel1.setDataSet(queryDataSet1);       queryDataSet1.refresh();     }  }////////////////////上机登记  void jButton2_actionPerformed(ActionEvent e) {   String card=jTextField1.getText().trim();   String computer=jTextField2.getText().trim();   if(card.equals("")||computer.equals(""))   {     JOptionPane.showMessageDialog(this,"卡号或者机号!!!","提示",JOptionPane.PLAIN_MESSAGE);      return;   }   ////////////对上机卡进行检验,看是否符合标准   try{      String driverName = "com.microsoft.jdbc.sqlserver.SQLServerDriver";       String dbURL = "jdbc:microsoft:sqlserver://210.30.104.11:1433; DatabaseName=student_computer";        String userName = "xueli";       String userPwd = "gejingguo";       Class.forName(driverName);       Connection con = DriverManager.getConnection(dbURL, userName, userPwd);        //System.out.println(apartid+dom_id+date);        ////////查看是否有该卡的记录        Statement stmt0=con.createStatement();        ResultSet rs0=stmt0.executeQuery("select card_number from card");        int m=0;        while(rs0.next())        {          String cid=rs0.getString("card_number").trim();          //System.out.print(cid);          if(cid.equals(card))          {            m=1;           break;          }          //System.out.print("here");        }        if(m!=1)        {          JOptionPane.showMessageDialog(this,"没有该卡记录,可能已被注销!!!","提示",JOptionPane.PLAIN_MESSAGE);             return;        }        //stmt.setString(1,card);

⌨️ 快捷键说明

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