📄 mzxxadd.java~20~
字号:
package mygui;/** * <p>Title: </p> * <p>Description: </p> * <p>Copyright: Copyright (c) 2005</p> * <p>Company: </p> * @author not attributable * @version 1.0 */import com.zdsoft.gui.*;import java.awt.*;import javax.swing.*;import java.awt.event.*;import com.zdsoft.datacenter.ASDatacenter;import com.zdsoft.datastore.ASDatastore;public class mzxxadd extends ASDialog{ BorderLayout borderLayout1 = new BorderLayout(); JPanel jPanel1 = new JPanel(); JPanel jPanel2 = new JPanel(); JPanel jPanel3 = new JPanel(); JLabel jLabel1 = new JLabel(); JButton jButton1 = new JButton(); JButton jButton2 = new JButton(); GridBagLayout gridBagLayout1 = new GridBagLayout(); JLabel jLabel2 = new JLabel(); JTextField bh = new JTextField(); JLabel jLabel3 = new JLabel(); JTextField name = new JTextField(); mzdmshow ms1; JLabel jLabel4 = new JLabel(); JTextField sex = new JTextField(); JLabel jLabel5 = new JLabel(); JTextField jTextField2 = new JTextField(); public mzxxadd(mzdmshow ms) { ms1=ms; try { jbInit(); } catch(Exception e) { e.printStackTrace(); } } private void jbInit() throws Exception { this.setSize(new Dimension(304, 208)); this.getContentPane().setLayout(borderLayout1); jLabel1.setFont(new java.awt.Font("Serif", 0, 15)); jLabel1.setText("增加学生信息"); jButton1.setFont(new java.awt.Font("Serif", 0, 12)); jButton1.setText("取消"); jButton1.addActionListener(new mzxxadd_jButton1_actionAdapter(this)); jButton2.setFont(new java.awt.Font("Serif", 0, 12)); jButton2.setText("确定"); jButton2.addActionListener(new mzxxadd_jButton2_actionAdapter(this)); jPanel1.setLayout(gridBagLayout1); jLabel2.setFont(new java.awt.Font("Serif", 0, 12)); jLabel2.setText("学号:"); bh.setPreferredSize(new Dimension(80, 22)); bh.setText(""); jLabel3.setFont(new java.awt.Font("Serif", 0, 12)); jLabel3.setText("姓名"); name.setPreferredSize(new Dimension(80, 22)); name.setText(""); jLabel4.setFont(new java.awt.Font("Serif", 0, 12)); jLabel4.setText("性别"); jLabel5.setFont(new java.awt.Font("Serif", 0, 12)); jLabel5.setText("年龄"); sex.setText(""); jTextField2.setText(""); this.getContentPane().add(jPanel1, BorderLayout.CENTER); jPanel1.add(jLabel2, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0 ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(5, 0, 0, 0), 0, 0)); jPanel1.add(bh, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0 ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(5, 0, 0, 0), 0, 0)); jPanel1.add(jLabel3, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0 ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(5, 0, 0, 0), 0, 0)); jPanel1.add(name, new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0 ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(5, 0, 0, 0), 0, 0)); jPanel1.add(jLabel4, new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0 ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jPanel1.add(sex, new GridBagConstraints(1, 2, 1, 1, 0.0, 0.0 ,GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(5, 0, 0, 0), 0, 0)); jPanel1.add(jLabel5, new GridBagConstraints(0, 3, 1, 1, 0.0, 0.0 ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jPanel1.add(jTextField2, new GridBagConstraints(1, 3, 1, 1, 0.0, 0.0 ,GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(5, 0, 0, 0), 0, 0)); this.getContentPane().add(jPanel2, BorderLayout.SOUTH); jPanel2.add(jButton2, null); jPanel2.add(jButton1, null); this.getContentPane().add(jPanel3, BorderLayout.NORTH); jPanel3.add(jLabel1, null); this.setWindowCenter(); } void jButton1_actionPerformed(ActionEvent e) { this.dispose(); } void jButton2_actionPerformed(ActionEvent e) { ASDatacenter dc = new ASDatacenter(); dc.connect(); String sql=""; //String sql = "insert into stu_info(xh,name,sex,age) values(" // +bh.getText()+",'"+name.getText()+"',"+sex.getText()+",'"+age.gettext+")"; String[] msg = dc.update(sql); if(msg[0].equals("true")){ int row = ms1.ds.addRow(); try { ms1.ds.setObjectAt(row,"mz_id",new Integer(bh.getText())); ms1.ds.setObjectAt(row,"mz_name",name.getText()); ms1.jTable1.ASTableRepant(); } catch (Exception ex) { } this.dispose(); } else{ JOptionPane.showMessageDialog(this,"数据插入失败!","错误提示",JOptionPane.CANCEL_OPTION); this.dispose(); } dc.disconnect(); }}class mzxxadd_jButton1_actionAdapter implements java.awt.event.ActionListener { mzxxadd adaptee; mzxxadd_jButton1_actionAdapter(mzxxadd adaptee) { this.adaptee = adaptee; } public void actionPerformed(ActionEvent e) { adaptee.jButton1_actionPerformed(e); }}class mzxxadd_jButton2_actionAdapter implements java.awt.event.ActionListener { mzxxadd adaptee; mzxxadd_jButton2_actionAdapter(mzxxadd adaptee) { this.adaptee = adaptee; } public void actionPerformed(ActionEvent e) { adaptee.jButton2_actionPerformed(e); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -