📄 clothesitemdlg.java
字号:
package view.dialog.getClothes;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.text.DecimalFormat;
import java.util.Iterator;
import java.util.Vector;
import javax.swing.JComboBox;
import javax.swing.JDialog;
import javax.swing.JOptionPane;
import javax.swing.event.CaretEvent;
import javax.swing.event.CaretListener;
import view.common.CenterWindow;
import view.frame.MainFrame;
import view.panel.getClothes.AddClothesPanel;
import view.panel.getClothes.GetClothesPanel;
import vo.ClothesAccessoriesVo;
import vo.ClothesBrandsVo;
import vo.ClothesColorsVo;
import vo.ClothesFlawsVo;
import vo.ClothesTypeVo;
import vo.VipVo;
import control.getClothes.ClothesItemDlgListener;
import dao.clothesAdditionDao.ClothesAdditionDao;
import dao.clothesAdditionDao.additionDaoImpl.AdditionDaoImpl;
import dao.common.DbException;
import dao.getClothesDao.GetClothesDao;
import dao.getClothesDao.getClothesDaoImpl.GetClothesDaoImpl;
public class ClothesItemDlg extends JDialog{
private AddClothesPanel addClothesPanel;
private GetClothesPanel getClothesPanel;
private ClothesTypeVo clothesTypeVo;
public ClothesItemDlg(GetClothesPanel getClothesPanel,ClothesTypeVo clothesTypeVo){
super(MainFrame.getMainFrame(),"衣服详细信息设置",true);
this.getClothesPanel = getClothesPanel;
this.clothesTypeVo = clothesTypeVo;
addClothesPanel = new AddClothesPanel();
this.add(addClothesPanel);
initialize();
this.setSize(600, 300);
this.pack();
CenterWindow.centerWindow(this);
addClothesPanel.buildQuantityTxFld().addCaretListener(new CaretListener(){
public void caretUpdate(CaretEvent arg0) {
// TODO Auto-generated method stub
DecimalFormat format = new DecimalFormat("#0.0");
double uinitPrice = Double.parseDouble(addClothesPanel.buildPriceLb().getText());
double discount = Double.parseDouble(addClothesPanel.buildDiscountLb().getText());
int quantity = 0;
try {
quantity = Integer.parseInt(addClothesPanel.buildQuantityTxFld().getText());
}catch(Exception e){
JOptionPane.showMessageDialog(null, "输入件数必须为整数");
return;
}
addClothesPanel.buildTotalPriceTxFld().setText(
new Double(format.format(uinitPrice*discount*quantity/10)).toString());
}
});
addClothesPanel.buildOkBtn().addActionListener(new ClothesItemDlgListener(this));
addClothesPanel.buildCancelBtn().addActionListener(new ClothesItemDlgListener(this));
this.addWindowListener(new WindowAdapter(){
public void windowDeiconified(WindowEvent e){}
public void windowIconified(WindowEvent we){}
public void windowClosing(WindowEvent we){
we.getWindow().dispose();
}
});
}
public void initialize(){
VipVo vipVo = getClothesPanel.getVipVo();
//初始化衣服类型信息面板
addClothesPanel.buildClothesNameLb().setText(clothesTypeVo.getClothesName());
addClothesPanel.buildServiceTypeLb().setText(clothesTypeVo.getServiceType());
addClothesPanel.buildPriceLb().setText(new Double(clothesTypeVo.getUnitOriginalPrice()).toString());
//初始化实际折扣标签
GetClothesDao clothesDaoImpl = new GetClothesDaoImpl();
double discount = 1;
try{
if(vipVo != null)
discount = clothesDaoImpl.getVipDiscountByLevel(vipVo.getVipCard().getVipLevel());
}catch(DbException de){
JOptionPane.showMessageDialog(null, de.getMessage());
return;
}
double realDiscount = discount;
if(clothesTypeVo.getLowestDiscount() != 0){
realDiscount = clothesTypeVo.getLowestDiscount();
}
addClothesPanel.buildDiscountLb().setText(new Double(realDiscount).toString());
//初始化附加信息面板
ClothesAdditionDao clothesAdditionDao = new AdditionDaoImpl();
try{
Vector brandsV = clothesAdditionDao.getClothesBrands();
Iterator iBrands = brandsV.iterator();
JComboBox brandCmbBox = addClothesPanel.buildBrandCmbBox();
while(iBrands.hasNext()){
brandCmbBox.addItem(((ClothesBrandsVo)iBrands.next()).getClothesBrand());
}
Vector accessoriesV = clothesAdditionDao.getClothesAccessoriess();
Iterator iAccessories = accessoriesV.iterator();
JComboBox accessoryCmbBox = addClothesPanel.buildAccesoriesCmbBox();
while(iAccessories.hasNext()){
accessoryCmbBox.addItem(((ClothesAccessoriesVo)iAccessories.next()).getAccessory());
}
Vector colorsV = clothesAdditionDao.getClothesColors();
Iterator iColors = colorsV.iterator();
JComboBox colorCmbBox = addClothesPanel.buildColorCmbBox();
while(iColors.hasNext()){
colorCmbBox.addItem(((ClothesColorsVo)iColors.next()).getColor());
}
Vector flawsV = clothesAdditionDao.getClothesFlaws();
Iterator iFlaws = flawsV.iterator();
JComboBox flawCmbBox = addClothesPanel.buildFlawCmbBox();
while(iFlaws.hasNext()){
flawCmbBox.addItem(((ClothesFlawsVo)iFlaws.next()).getFlaw());
}
}catch(DbException de){
JOptionPane.showMessageDialog(null, de.getMessage());
}
}
/**
* @return the addClothesPanel
*/
public AddClothesPanel getAddClothesPanel() {
return addClothesPanel;
}
/**
* @return the getClothesPanel
*/
public GetClothesPanel getGetClothesPanel() {
return getClothesPanel;
}
/**
* @return the clothesTypeVo
*/
public ClothesTypeVo getClothesTypeVo() {
return clothesTypeVo;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -