?? frame3.java
字號:
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("置空"); jButton3.addActionListener(new Frame3_jButton3_actionAdapter(this)); 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("置空"); jButton5.addActionListener(new Frame3_jButton5_actionAdapter(this)); jTabbedPane1.setFont(new java.awt.Font("Dialog", 0, 12)); 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); /////////////查看該卡與俄和是否掛失 PreparedStatement stmt=con.prepareStatement("select card_money,card_state from card where card_number=?"); stmt.setString(1,card); ResultSet rs=stmt.executeQuery(); while(rs.next()) { int mon=rs.getInt(1); String state=rs.getString(2).trim(); if(mon<1) { JOptionPane.showMessageDialog(this,"對不起,余額不足一小時,請充值!!!","提示",JOptionPane.PLAIN_MESSAGE); return; } if(state.equals("掛失"))
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -