📄 deltrainfo.java
字号:
package employee;
import java.awt.*;
import java.sql.*;
import java.awt.event.*;
import javax.swing.*;
/**
* 培训信息管理模块
* 修改培训信息的类
*/
public class DelTraInfo extends TraInfo{
String tName_str = "";
public DelTraInfo() {
this.setTitle("删除培训信息");
this.setResizable(false);
tTid.setEditable(false);
tName.setText("请查询培训名称");
tName.setEditable(false);
tContent.setEditable(false);
//设置运行位置,使对话框居中
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
this.setLocation( (int) (screenSize.width - 400) / 2 ,
(int) (screenSize.height - 300) / 2 +45);
}
public void downInit(){
searchInfo.setText("培训名称查询");
searchInfo.setFont(new Font("Dialog",0,12));
downPanel.add(searchInfo);
deleteInfo.setText("删除");
deleteInfo.setFont(new Font("Dialog",0,12));
downPanel.add(deleteInfo);
clearInfo.setText("清空");
clearInfo.setFont(new Font("Dialog",0,12));
downPanel.add(clearInfo);
eixtInfo.setText("退出");
eixtInfo.setFont(new Font("Dialog",0,12));
downPanel.add(eixtInfo);
contentPane.add(downPanel,BorderLayout.SOUTH);
searchInfo.setEnabled(true);
deleteInfo.setEnabled(false);
eixtInfo.setEnabled(true);
//添加事件侦听
searchInfo.addActionListener(this);
deleteInfo.addActionListener(this);
eixtInfo.addActionListener(this);
}
/**
* 事件处理
*/
public void actionPerformed(ActionEvent e) {
Object obj = e.getSource();
String[] s = new String[2];
if (obj == eixtInfo) { //退出
this.dispose();
}
else if (obj == deleteInfo) { //删除
int ifdel = JOptionPane.showConfirmDialog(null,"真的要删除该信息?","提示信息",JOptionPane.YES_NO_OPTION,JOptionPane.INFORMATION_MESSAGE );
if(ifdel == JOptionPane.YES_OPTION){
TraBean delTra = new TraBean();
delTra.traDel(tName.getText());
this.dispose();
DelTraInfo dti = new DelTraInfo();
dti.downInit();
dti.pack();
dti.setVisible(true);
}
else{
return;
}
}
else if (obj == searchInfo) { //培训编号查询
TraInfoSearchTname tist = new TraInfoSearchTname(this);
tist.pack();
tist.setVisible(true);
tName_str = tist.getTname();
TraBean searchTra = new TraBean();
s = searchTra.traSearch(tName_str);
if(s == null){
JOptionPane.showMessageDialog(null, "记录不存在!");
tTid.setText("");
tName.setText("请查询培训名称");
tContent.setText("");
tName.setEditable(false);
tContent.setEditable(false);
deleteInfo.setEnabled(false);
return;
}
else{
tTid.setText(s[0]);
tName.setText(tName_str);
tContent.setText(s[1]);
tName.setEditable(true);
tContent.setEditable(true);
deleteInfo.setEnabled(true);
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -