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

📄 scdialog.java~27~

📁 编程简单
💻 JAVA~27~
字号:
package myproject;

import java.awt.*;
import javax.swing.*;
import com.borland.jbcl.layout.*;
import javax.swing.border.*;
import java.awt.event.*;
import java.sql.*;

/**
 * <p>Title: </p>
 * <p>Description: </p>
 * <p>Copyright: Copyright (c) 2005</p>
 * <p>Company: </p>
 * @author unascribed
 * @version 1.0
 */

public class ScDialog extends JDialog {
  private JPanel panel1 = new JPanel();
  private JLabel jLabel1 = new JLabel();
  private XYLayout xYLayout1 = new XYLayout();
  private JTextField indexField = new JTextField();
  private JButton jButton1 = new JButton();
  private JButton jButton2 = new JButton();
  private Border border1;
  private JButton jButton3 = new JButton();
  private JScrollPane jScrollPane1 = new JScrollPane();
  private JTextArea text = new JTextArea();
  private JLabel jLabel2 = new JLabel();
  private JTextField tiaoField = new JTextField();
  private JLabel jLabel3 = new JLabel();
  Connection con = null;
  Frame2 frame = null;

  public ScDialog(Frame2 frame, String title, boolean modal) {
    super(frame, title, modal);
    try {
     this.frame = frame;
     this.con = frame.con1;
      text.setLineWrap(true);
      jbInit();
      pack();
    }
    catch(Exception ex) {
      ex.printStackTrace();
    }
  }

  public ScDialog() {
    this(null, "修改对话框", false);
  }
  private void jbInit() throws Exception {
    border1 = BorderFactory.createEmptyBorder(0,10,15,10);
    panel1.setLayout(xYLayout1);
    jLabel1.setText("请输入要修改的文件名:");
    jButton1.setText("修改");
    jButton1.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(ActionEvent e) {
            jButton1_actionPerformed(e);
      }
    });
    jButton2.setText("取消");
    jButton2.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(ActionEvent e) {
        jButton2_actionPerformed(e);
      }
    });
    jButton3.setText("查找");
    jButton3.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(ActionEvent e) {
        jButton3_actionPerformed(e);
      }
    });
    jLabel2.setText("第");
    jLabel3.setText("条");
    getContentPane().add(panel1);
    panel1.setBorder(border1);
    panel1.add(jLabel1,new XYConstraints(23, 30, 135, 29));
    panel1.add(indexField, new XYConstraints(163, 31, 133, 29));
    panel1.add(jButton1,  new XYConstraints(166, 257, -1, -1));
    panel1.add(jButton2, new XYConstraints(234, 258, -1, -1));
    panel1.add(jButton3,    new XYConstraints(380, 32, -1, -1));
    panel1.add(jScrollPane1,     new XYConstraints(44, 76, 357, 170));
    panel1.add(jLabel3,       new XYConstraints(344, 28, 26, 32));
    panel1.add(tiaoField,  new XYConstraints(312, 30, 29, 32));
    panel1.add(jLabel2, new XYConstraints(299, 32, 22, 29));
    jScrollPane1.getViewport().add(text, null);
  }

  void jButton3_actionPerformed(ActionEvent e) {
    try{
      String indexStr = indexField.getText();
      String tiao = tiaoField.getText();
      Statement sta = con.createStatement();
      String sql = "select tiaowen from fltw where sy_id='"+indexStr+"' and tk_id="+tiao;
      ResultSet set = sta.executeQuery(sql);
      text.setText("");
      while(set.next()){
        String temp = set.getString(1);

       text.append(temp.trim()+"\n");
//        text.setText(temp.trim());

      }
      set.close();
      sta.close();
      frame.validate();
      frame.repaint();
    }
    catch(SQLException ex){
      ex.printStackTrace();
    }
  }

 void jButton1_actionPerformed(ActionEvent e) {
    try{
  String indexStr = indexField.getText();
  String tiao = tiaoField.getText();
  Statement sta = con.createStatement();
  String sql = "delete  from fltw where sy_id='"+indexStr+"' and tk_id="+tiao;
  int i = sta.executeUpdate(sql);
  //if(i > 0 ){
 //   text.setText("");
   // JOptionPane.showMessageDialog(this, "删除成功!!!");
 // }

  }
  catch(SQLException ex){

    }
    try{
    String  str_sy=indexField.getText();
     String  str_nr=text.getText();
     Statement sta = con.createStatement();
    // String  str_tk="select  tk_id=MAX(tk_id) from  fltw  where  sy_id ='"+indexField.getText()+"'";
    // ResultSet set = sta.executeQuery(str_tk);
  //   ResultSet set=null;
   //  set.next();
 //  int  tkid=set.getInt(1);
    String  tk=tiaoField.getText();
   // int  tkid=tk.getI

     String str1="";
     str1="insert into fltw ";
     str1=str1+" values ('"+str_sy+"',";
     str1=str1+tk+",'";
     str1=str1+str_nr+"')";
     sta.executeUpdate(str1);

  }catch(SQLException e2){
    e2.printStackTrace();
  System.out.println("error!!!");}
  }

  void jButton2_actionPerformed(ActionEvent e) {
       this.setVisible(false);
       this.dispose();
  }
}

⌨️ 快捷键说明

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