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

📄 deldepinfo.java

📁 完整的JAVA工程
💻 JAVA
字号:
package employee;

import java.awt.*;
import java.sql.*;
import java.awt.event.*;
import javax.swing.*;

/**
 * 部门信息管理模块
 * 修改部门信息的类
 */
public class DelDepInfo extends DepInfo{
	String dName_str = "";
	public DelDepInfo() {
		this.setTitle("删除部门信息");
		this.setResizable(false);

		dDid.setEditable(false);
		dName.setEditable(false);
		dName.setText("请查询部门名称");
		dManager.setEditable(false);
		dManagerphone.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[3];

		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){
				DepBean delDep = new DepBean();
				delDep.depDel(dName.getText());
				
				this.dispose();

				DelDepInfo ddi = new DelDepInfo();
				ddi.downInit();
				ddi.pack();
				ddi.setVisible(true);
			}
			else{
				return;
			}
		}
		else if (obj == searchInfo) { //部门名称查询
			DepInfoSearchDname disd = new DepInfoSearchDname(this);
			disd.pack();
			disd.setVisible(true);
			dName_str = disd.getDname();

			DepBean searchDep = new DepBean();
			s = searchDep.depSearch(dName_str);
			if(s == null){
				JOptionPane.showMessageDialog(null, "记录不存在!");
				dDid.setText("请查询部门编号");
				dName.setText("");
				dManager.setText("");
				dManagerphone.setText("");
								
				dName.setEditable(false);
				dManager.setEditable(false);
				dManagerphone.setEditable(false);
				deleteInfo.setEnabled(false);
				return;
			}
			else{
				dDid.setText(s[0]);
				dName.setText(dName_str);
				dManager.setText(s[1]);
				dManagerphone.setText(s[2]);

				dName.setEditable(true);
				dManager.setEditable(true);
				dManagerphone.setEditable(true);
				deleteInfo.setEnabled(true);
			}
		}
	}
}

⌨️ 快捷键说明

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