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

📄 addclothestypelistener.java

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

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

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

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

public class AddClothesTypeListener implements ActionListener{
	private AddNewClothesTypePanel addClothesPanel;
	private AddClothesTypeDlg addClothesTypeDlg;

	/**
	 * @param addClothesPanel
	 */
	public AddClothesTypeListener(AddClothesTypeDlg addClothesTypeDlg) {
		super();
		this.addClothesTypeDlg = addClothesTypeDlg;
		this.addClothesPanel = addClothesTypeDlg.getAddClothesTypePanel(); 
	}
	
	public void actionPerformed(ActionEvent e){
		String command = e.getActionCommand();
		if(command.equals("添加")){
			ClothesTypeVo clothesTypeVo = null;
			try{
				 clothesTypeVo = addClothesPanel.getClothesTypeVo();
			}catch(NumberFormatException nfe){
				JOptionPane.showMessageDialog(null, "输入格式不正确:"+nfe.getMessage());
				addClothesPanel.clearContent();
				return;
			}
			if(clothesTypeVo == null){
				return;
			}
			ClothesTypeDao clothesTypeDao = new ClothesTypeDaoImpl();
			try{
				if(clothesTypeDao.insertClothesType(clothesTypeVo)){
					JOptionPane.showMessageDialog(null, "添加成功!");
					
					DefaultTableModel tableModel = (DefaultTableModel)addClothesTypeDlg.getClothesTypeDlg().
									getClothesTypePanel().buildClothesTable().getModel();
					Object[] content = {new Integer(clothesTypeVo.getClothesId()),clothesTypeVo.getClothesName(),
							clothesTypeVo.getServiceType(),new Double(clothesTypeVo.getUnitOriginalPrice()),
							new Double(clothesTypeVo.getLowestDiscount()),clothesTypeVo.getOperatorName(),
							clothesTypeVo.getAddDate()};
					tableModel.addRow(content);
				}
			}catch(DbException de){
				JOptionPane.showMessageDialog(null, de.getMessage());
			}
		}else if(command.equals("清空")){
			addClothesPanel.clearContent();
		}else if(command.equals("退出")){
			this.addClothesTypeDlg.dispose();
		}
	}
}

⌨️ 快捷键说明

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