日期:2014-05-20 浏览次数:20761 次
class ProductModel extends AbstractTableModel{
Vector<YProduct> data=new Vector<YProduct>();
String[] columns={"编号","名称","计量单位","品牌","规格","分类","条形码","进价","批发价","零售价","数量"};
public ProductModel(Vector<YProduct> data){
this.data=data;
}
@Override
public int getRowCount() {
if(this.data==null)
return 0;
return this.data.size();
}
@Override
public int getColumnCount() {
return columns.length;
}
@Override
public Object getValueAt(int rowIndex, int columnIndex) {
YProduct product=data.get(rowIndex);
String r="";
switch(columnIndex){
case 0:
r=product.getId();
break;
case 1:
r=product.getName();
break;
case 2:
if(product.getUnit()!=null)
r=product.getUnit();
break;
case 3:
if(product.getBrand()!=null)
r=product.getBrand();
break;
case 4:
if(product.getSpecification()!=null)
r=product.getSpecification();
break;
case 5:
if(PmsDictionary.getDesc("PMSPRODUCT", "CATEGORY", (byte)product.getCategory())!=null)
r=PmsDictionary.getDesc("PMSPRODUCT", "CATEGORY", (byte)product.getCategory());
break;
case 6:
if(product.getShapeCode()!=null)
r=product.getShapeCode();
break;
case 7:
if(product.getBidPrice()!=0)
r=product.getBidPrice()+"";
break;
case 8:
if(product.getTradePrice()!=0)
r=product.getTradePrice()+"";
break;
case 9:
if(product.getRetailPrice()!=0)
r=product.getRetailPrice()+"";
break;
case 10:
if(product.getCount()!=0)
r=product.getCount()+"";
break;
}
return r;
}
@Override
public String getColumnName(int column) {
return columns[column];
}
public boolean isCellEditable(int rowIndex, int columnIndex) {
return false;
}
}