// 设置单元格的值 @Override public void setValueAt(Object aValue, int rowIndex, int columnIndex) { TShopCharge tShopCharge = tShopChargeList.get(rowIndex); if (tShopCharge != null && aValue != null) { switch (columnIndex) { case 0: break; case 1: tShopCharge.setSelect(!tShopCharge.isSelect()); return; case 2: if (aValue != null && !aValue.toString().equals("") && MatcherFormatUtil.MatcherPriceScheme(aValue.toString()) && aValue.toString().length() < 10) { tShopCharge.setAMount(Double.parseDouble(aValue.toString())); } break; case 3: if (aValue != null && !aValue.toString().equals("") && MatcherFormatUtil.MatcherPriceScheme(aValue.toString()) && aValue.toString().length() < 10) { tShopCharge.setGiftAmount(Double.parseDouble(aValue.toString())); } break; case 4: tShopCharge.setType(aValue.toString()); break; case 5: return; case 6: tShopCharge.setStartTimeStr(aValue.toString()); try { tShopCharge.setStartTime(DateUtil.getDate(aValue.toString(), DateUtil.TYPE_DATE)); } catch (ParseException e) { e.printStackTrace(); } break; case 7: tShopCharge.setEndTimeStr(aValue.toString()); try { tShopCharge.setEndTime(DateUtil.getDate(aValue.toString(), DateUtil.TYPE_DATE)); } catch (ParseException e) { e.printStackTrace(); } break; case 9: tShopCharge.setIsValid(!tShopCharge.isIsValid()); break; } tShopCharge.setSelect(true); fireTableCellUpdated(rowIndex, 1); } }
/** 添加一行 */ public void addRow() { TShopCharge tShopCharge = new TShopCharge(); tShopCharge.setSelect(true); tShopCharge.setIsValid(true); tShopCharge.setOperatorName(ApplicationContext.OPERATOR_NAME); tShopCharge.setOperator(ApplicationContext.OPERATOR_ID); tShopCharge.setHappenTime(new Date()); tShopCharge.setHappenTimeStr( DateUtil.format(tShopCharge.getHappenTime(), DateUtil.TYPE_DATETIME)); tShopCharge.setType("1、充值xx送xx"); tShopChargeList.add(tShopCharge); this.fireTableRowsInserted(tShopChargeList.size() - 1, tShopChargeList.size() - 1); }