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

📄 modifyclothestypelistener.java

📁 一个优秀的干洗店管理系统
💻 JAVA
字号:
package control.clothesTpye;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JOptionPane;
import javax.swing.JTable;
import javax.swing.table.DefaultTableModel;

import view.dialog.clothesType.ModifyClothesTypeDlg;
import view.panel.clothesType.ModifyClothesTypeInfoPanel;
import vo.ClothesTypeVo;
import dao.clothesTypeDao.ClothesTypeDao;
import dao.clothesTypeDao.clothesTypeDaoImpl.ClothesTypeDaoImpl;
import dao.common.DbException;

public class ModifyClothesTypeListener implements ActionListener {
	private ModifyClothesTypeInfoPanel modifyClothesPanel;
	private ModifyClothesTypeDlg modifyClothesTypeDlg;

	/**
	 * @param addClothesPanel
	 */
	public ModifyClothesTypeListener(ModifyClothesTypeDlg modifyClothesTypeDlg) {
		super();
		this.modifyClothesTypeDlg = modifyClothesTypeDlg;
		this.modifyClothesPanel = modifyClothesTypeDlg
				.getModifyClothesTypePanel();
	}

	public void actionPerformed(ActionEvent e) {
		String command = e.getActionCommand();
		if (command.equals("确定")) {
			ClothesTypeVo clothesTypeVo = null;
			try{
				 clothesTypeVo = modifyClothesPanel.getClothesTypeVo();
			}catch(NumberFormatException nfe){
				JOptionPane.showMessageDialog(null, "输入格式不正确:"+nfe.getMessage(), "信息",
						JOptionPane.YES_OPTION);
				modifyClothesPanel.clearContent();
				return;
			}
			if(clothesTypeVo == null){
				return;
			}
			ClothesTypeDao clothesTypeDao = new ClothesTypeDaoImpl();
			try {
				if (clothesTypeDao.modifyClothesType(clothesTypeVo)) {
					JOptionPane.showMessageDialog(null, "修改成功!", "信息",
							JOptionPane.YES_OPTION);
					JTable table = modifyClothesTypeDlg.getClothesTypeDlg()
							.getClothesTypePanel().buildClothesTable();
					DefaultTableModel tableModel = (DefaultTableModel)table.getModel();
					Object[] content = {
							new Integer(clothesTypeVo.getClothesId()),
							clothesTypeVo.getClothesName(),
							clothesTypeVo.getServiceType(),
							new Double(clothesTypeVo.getUnitOriginalPrice()),
							new Double(clothesTypeVo.getLowestDiscount()),
							clothesTypeVo.getOperatorName(),
							clothesTypeVo.getAddDate() };
					int row = table.getSelectedRow();
					int columnCount = table.getColumnCount();
					for(int i = 0 ; i < columnCount;i++){
						tableModel.setValueAt(content[i],row,i);
					}
					modifyClothesTypeDlg.dispose();
				}
			} catch (DbException de) {
				JOptionPane.showMessageDialog(null, de.getMessage(), "信息",
						JOptionPane.YES_OPTION);
			}
		} else if (command.equals("清空")) {
			modifyClothesPanel.clearContent();
		} else if (command.equals("退出")) {
			modifyClothesTypeDlg.dispose();
		}
	}
}

⌨️ 快捷键说明

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