?? artsquery.java~7~
字號:
package infomanagement;import java.awt.*;import javax.swing.*;import com.borland.jbcl.layout.*;import com.borland.dbswing.*;import com.borland.dx.sql.dataset.*;import com.borland.dx.dataset.*;import java.awt.event.*;/** * <p>Title: </p> * <p>Description: </p> * <p>Copyright: Copyright (c) 2003</p> * <p>Company: </p> * @author unascribed * @version 1.0 */public class ArtsQuery extends JDialog { private JPanel jPanel1 = new JPanel(); private XYLayout xYLayout1 = new XYLayout(); private JLabel jLabel1 = new JLabel(); private JLabel jLabel2 = new JLabel(); private JLabel jLabel3 = new JLabel(); private JTextField jTextField1 = new JTextField(); private JButton jButton1 = new JButton(); private JLabel jLabel4 = new JLabel(); private JdbTable jdbTable1 = new JdbTable(); private JLabel jLabel5 = new JLabel(); private JButton jButton2 = new JButton(); private JdbTextField jdbTextField1 = new JdbTextField(); private QueryDataSet queryDataSet1 = new QueryDataSet(); private Database database1 = new Database(); private QueryDataSet queryDataSet2 = new QueryDataSet(); private Column column1 = new Column(); public ArtsQuery(Frame frame, String title, boolean modal) { super(frame, title, modal); try { jbInit(); pack(); } catch(Exception ex) { ex.printStackTrace(); } } public ArtsQuery() { this(null, "", false); } private void jbInit() throws Exception { jPanel1.setLayout(xYLayout1); jLabel1.setFont(new java.awt.Font("Dialog", 0, 23)); jLabel1.setForeground(Color.magenta); jLabel1.setBorder(BorderFactory.createEtchedBorder()); jLabel1.setText(" 文科科成績查詢"); jLabel2.setBorder(BorderFactory.createEtchedBorder()); jLabel3.setText("準考證號"); jButton1.setText("執(zhí)行查詢"); jButton1.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { jButton1_actionPerformed(e); } }); jLabel4.setBorder(BorderFactory.createEtchedBorder()); jdbTable1.setBorder(BorderFactory.createEtchedBorder()); jLabel5.setText("總成績"); jButton2.setText("退出"); jButton2.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { jButton2_actionPerformed(e); } }); database1.setConnection(new com.borland.dx.sql.dataset.ConnectionDescriptor("jdbc:odbc:local", "sa", "", false, "sun.jdbc.odbc.JdbcOdbcDriver")); column1.setColumnName("NewColumn1"); column1.setDataType(com.borland.dx.dataset.Variant.STRING); column1.setPreferredOrdinal(0); column1.setServerColumnName("NewColumn1"); column1.setSqlType(0); this.getContentPane().add(jPanel1, BorderLayout.CENTER); jPanel1.add(jLabel1, new XYConstraints(0, 1, 399, 53)); jPanel1.add(jLabel3, new XYConstraints(10, 68, 90, 20)); jPanel1.add(jTextField1, new XYConstraints(110, 68, 90, 20)); jPanel1.add(jLabel2, new XYConstraints(0, 53, 398, 49)); jPanel1.add(jButton1, new XYConstraints(290, 68, 90, 20)); jPanel1.add(jdbTable1, new XYConstraints(1, 104, 394, 153)); jPanel1.add(jLabel5, new XYConstraints(20, 270, 90, 20)); jPanel1.add(jButton2, new XYConstraints(290, 270, 90, 20)); jPanel1.add(jdbTextField1, new XYConstraints(110, 270, 90, 20)); jPanel1.add(jLabel4, new XYConstraints(-2, 105, 397, 202)); } void cancel(){ dispose() ; } void jButton2_actionPerformed(ActionEvent e) { cancel() ; } void jButton1_actionPerformed(ActionEvent e) { //進行數(shù)據(jù)查詢 try{ //獲得準考證號 int cardID1 = Integer.parseInt(jTextField1.getText().trim()); //查詢學(xué)習成績 queryDataSet1.setQuery(new com.borland.dx.sql.dataset.QueryDescriptor(database1, "SELECT science2.cardID,science2.subject,science2.achievement,science2.subjectNameID " + "FROM info.dbo.science2 where science2.cardID = '"+cardID1+"'", null, true, Load.ALL)); //加入到j(luò)dbTable1中 queryDataSet1.setColumns(new Column[] {column1}); jdbTable1.setDataSet(queryDataSet1); //執(zhí)行sum語句,獲得成績總分 queryDataSet2.setQuery(new com.borland.dx.sql.dataset.QueryDescriptor(database1, "SELECT SUM(achievement) AS SUM_achievement FROM info.dbo.science2\n" + "where science2.cardID = 10000001", null, true, Load.ALL)); //在jdbTextField1中加入一列 jdbTextField1.setColumnName("SUM_achievement"); //把數(shù)據(jù)集加入到j(luò)dbTextField1中 jdbTextField1.setDataSet(queryDataSet2); } catch(Exception www){} }}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -