📄 addclothestypelistener.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 + -