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

📄 updateaction.java~40~

📁 简单的硬盘配置界面
💻 JAVA~40~
字号:
package informationsystem.gui;

import java.awt.event.*;
import java.sql.*;
import informationsystem.gui.MainWindow;
import informationsystem.information.HardDisk;
import informationsystem.information.HardDisk;

public class UpdateAction
    implements ActionListener {
  private MainWindow window;

  public UpdateAction(MainWindow window) {
    this.window = window;
  }

  /**
   * Invoked when an action occurs.
   *
   * @param e ActionEvent
   * @todo Implement this java.awt.event.ActionListener method
   */
  public void actionPerformed(ActionEvent e) {
    try {
      if (this.window.jTextField1.getText().length() == 0) {
        this.window.jTextPane1.setText("不能修改,请先输入价格!");
      }
      else {
        String number = this.window.jTextField1.getText();
        HardDisk theHardDisk = new HardDisk(number);
        if (theHardDisk.getBelongInterface().equals("") &&
            theHardDisk.getFactory().equals("") &&
            theHardDisk.getCapacity().equals("")&&theHardDisk.getPrice().equals("")) {
          this.window.jTextPane1.setText("该价格不存在");
          return;
        }
        //this.window.jTextField5.setText(this.window.jTextField1.getText());//*******************
         ///////2007-10-07
         if (this.window.jTextField1.getText().length() != 0) {
          theHardDisk.setCapacity(this.window.jTextField1.getText()); // 更新硬盘的容量;
        }
         ///////
        if (this.window.jTextField2.getText().length() != 0) {
          theHardDisk.setCapacity(this.window.jTextField2.getText()); // 更新硬盘的容量;
        }
        if (this.window.jTextField3.getText().length() != 0) {
          theHardDisk.setFactory(this.window.jTextField3.getText()); // 更新硬盘的产家;
        }
        if (this.window.jTextField4.getText().length() != 0) {
          theHardDisk.setInterfaceType(this.window.jTextField4.getText()); // 更新硬盘的接口类型;**************
        }
        //////////////////////////2007-10-07
        if (this.window.jTextField5.getText().length() != 0) {
          theHardDisk.setApplyType(this.window.jTextField5.getText()); // 更新硬盘的用户类型;**************
        }
        //////////////////////////
        if (this.window.jTextField1.getText().length() == 0&&
            this.window.jTextField2.getText().length() == 0 &&
            this.window.jTextField3.getText().length() == 0 &&
            this.window.jTextField4.getText().length() == 0&&
            this.window.jTextField5.getText().length() == 0) {
          this.window.jTextPane1.setText("请输入修改的数据");
        }
        else {
          if (theHardDisk.update()) {
            this.window.jTextPane1.setText("记录修改成功!");
          }
          else {
            this.window.jTextPane1.setText("修改失败,请重试!");
          }
        }
      }

      // 清空文本框
      this.window.jTextField1.setText("");
      this.window.jTextField2.setText("");
      this.window.jTextField3.setText("");
      this.window.jTextField4.setText("");
      this.window.jTextField5.setText("");
    }
    catch (Exception ex) {
      ex.printStackTrace();
    }
  }
}

⌨️ 快捷键说明

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