⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 change.java

📁 随着科学技术的发展
💻 JAVA
字号:
/*
 * change.java
 *
 * Created on 2008年1月23日, 上午6:25
 */

package javaapplication6;

import java.awt.Dimension;
import java.awt.Frame;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import javaapplication6.MyMerPanel;
import javax.swing.JOptionPane;

/**
 *
 * @author  Administrator
 */
public class change extends java.awt.Frame {
    
    Frame othis = null;
    Frame ithis = this;
    /** Creates new form change */
    public change() {
        initComponents();
    }
    change( Frame otherthis){
        this();
        this.othis = otherthis;
        if( otherthis != null){
            otherthis.setVisible( false);
        }Dimension dim = getToolkit().getScreenSize();
            setBounds( ( dim.width - getWidth()) / 2, 
                    ( dim.height - getHeight()) / 2,
                    getWidth(), getHeight());
    }
    
    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    // <editor-fold defaultstate="collapsed" desc=" 生成的代码 ">//GEN-BEGIN:initComponents
    private void initComponents() {
        jLabel1 = new javax.swing.JLabel();
        jTextField1 = new javax.swing.JTextField();

        addWindowListener(new java.awt.event.WindowAdapter() {
            public void windowClosing(java.awt.event.WindowEvent evt) {
                exitForm(evt);
            }
        });

        jLabel1.setText("\u8f93\u5165\u8981\u4fee\u6539\u7684\u5546\u54c1\u53f7");

        jTextField1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jTextField1ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(47, 47, 47)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                    .addComponent(jTextField1, javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel1, javax.swing.GroupLayout.Alignment.LEADING))
                .addContainerGap(50, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel1)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(23, Short.MAX_VALUE))
        );
        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jTextField1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextField1ActionPerformed
        if( jTextField1!=null&&jTextField1.getText().length() > 0){
            Statement sta = new MSSSQLFather().getStatement();
            String url = " * FROM inmer where id='" 
                    + jTextField1.getText() +"'";
            try {
                    ResultSet rs = sta.executeQuery("SELECT * FROM inmer");
                    boolean flag = false;
                    while (rs.next()) {
                        list li = new list();
                        li.id = rs.getString( "id");
                        if(  IsSame.isSame(li.id,jTextField1.getText())){
                            li.Name = rs.getString( 3);
                            li.Make  = rs.getString( 4);
                            li.Operator = rs.getString( 5);
                            flag = true;
                            this.remove( jTextField1);
                            final MyMerPanel aa = new  MyMerPanel( ithis, MyMerPanel.DIALOG_REWORK_IN);
                            aa.setEnabledlist( true);
                            aa.setlist( li);
                            add( aa);
                            final String liurle = "DELETE FROM inmer where id = '"+li.id+"'";
                            aa.jButtonok.addActionListener( new ActionListener(){
                            public void actionPerformed(ActionEvent e) {
                                    list lis = aa.getlist();
                                    if( lis == null){
                                        JOptionPane.showMessageDialog(null,"表不能为空","",JOptionPane.ERROR_MESSAGE);
                                        return ;
                                    }
                                int yn = JOptionPane.showConfirmDialog( null,
                                        "确定修改","",JOptionPane.YES_NO_OPTION);
                                if( yn == JOptionPane.YES_OPTION){
                                    MSSSQLFather.close();
                                    Statement sta = new MSSSQLFather().getStatement();
                                    try{
                                    String urll="insert into inmer(id,name,make) values('"+lis.id+"','"+lis.Name+"','"
                            +lis.Make+"')";
                                    sta.executeQuery(urll);
                                    MSSSQLFather.close();
                                    sta.close();
                                    }catch (SQLException ex) {
                    }
                                    sta = new MSSSQLFather().getStatement();
                                    try {
                                        sta.executeQuery(new String(liurle));
                                    } catch (SQLException ex) {
                                        //ex.printStackTrace();
                                    }
                                    JOptionPane.showMessageDialog(null, "修改成功", "", JOptionPane.WARNING_MESSAGE);
                                    if( othis!=null)
                    othis.setVisible(true);
                    ithis.dispose();
                                }
                            }
                                
                            }
                                    );
                            break;
                        }
                    }
                    if( !flag){
                        JOptionPane.showMessageDialog(null, "无些编号", "", JOptionPane.WARNING_MESSAGE);
                    }
        }catch (SQLException ex) {
                    JOptionPane.showMessageDialog(null, "连接失败", "警告", JOptionPane.WARNING_MESSAGE);
                }} 
    }//GEN-LAST:event_jTextField1ActionPerformed
    
    /** Exit the Application */
    private void exitForm(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_exitForm
        if( othis != null)
        othis.setVisible( true);
        dispose();
    }//GEN-LAST:event_exitForm
    
    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new change().setVisible(true);
            }
        });
    }
    
    
    // 变量声明 - 不进行修改//GEN-BEGIN:variables
    private javax.swing.JLabel jLabel1;
    private javax.swing.JTextField jTextField1;
    // 变量声明结束//GEN-END:variables
    
}

⌨️ 快捷键说明

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