📄 dele.java
字号:
/*
* dele.java
*
* Created on 2008年1月23日, 上午5:29
*/
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 javax.swing.JButton;
import javax.swing.JOptionPane;
/**
*
* @author Administrator
*/
public class dele extends java.awt.Frame {
/** Creates new form dele */
public dele() {
initComponents();
}
Frame othis;
Frame ithis = this;
dele( Frame otherthis){
this();
othis = otherthis;
if( othis!= null){
othis.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\u5220\u9664\u8bb0\u5f55\u7684\u7f16\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(46, 46, 46)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
.addComponent(jTextField1, javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addContainerGap(54, 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(24, 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())){
flag = true;
this.remove( jTextField1);
final String liurl = "DELETE FROM inmer where id = '"+li.id+"'";
MyMerPanel aa = new MyMerPanel( ithis, MyMerPanel.DIALOG_DELETE_IN);
li.Name = rs.getString( 3);
li.Make = rs.getString( 4);
li.Operator = rs.getString( 5);
aa.setlist( li);
add( aa);
aa.jButtonok.addActionListener( new ActionListener(){
public void actionPerformed(ActionEvent e) {
int yn = JOptionPane.showConfirmDialog( null,
"你真的要删除这个记录","",JOptionPane.YES_NO_OPTION);
if( yn == JOptionPane.YES_OPTION){
Statement sta = new MSSSQLFather().getStatement();
try{
sta.executeQuery(liurl);
}catch (SQLException ex) {
}JOptionPane.showMessageDialog(null, "删除成功", "", JOptionPane.WARNING_MESSAGE);
othis.setVisible(true);
ithis.dispose();
}
}
}
);
aa.jButtonre.setEnabled( false);
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 dele().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 + -