// 设置单元格的值 @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); } }
@Override public void actionPerformed(ActionEvent e) { if (e.getSource() == sureButton) { String storeIDStr = number.getText().getText().trim(); String nameStr = name.getText().getText().trim(); String locationStr = location.getText().getText().trim(); Object managerObj = manager.getBox().getSelectedItem(); String priorityStr = priority.getText().getText().trim(); String noteStr = note.getArea().getText().trim(); if (nameStr.equals("") || nameStr.length() > 128) { JOptionPane.showMessageDialog(null, "仓库名称不能为空,且不能大于128个字"); name.getText().requestFocus(); return; } if (locationStr.equals("") || locationStr.length() > 100) { JOptionPane.showMessageDialog(null, "仓库地址不能为空,且不能大于100个字"); location.getText().requestFocus(); return; } if (noteStr.length() > 100) { JOptionPane.showMessageDialog(null, "备注不能大于100个字"); note.getArea().requestFocus(); return; } if (priorityStr.equals("") || !MatcherFormatUtil.MatcherNumberScheme(priorityStr) || priorityStr.length() > 10) { JOptionPane.showMessageDialog(null, "优先级只能输入数字,且不能大于10位"); priority.getText().requestFocus(); return; } IDNameBean bean = (IDNameBean) managerObj; if (bean.getStrId().equals("0")) { JOptionPane.showMessageDialog(null, "请先选择仓库管理员"); manager.getBox().requestFocus(); return; } boolean isOpLog = false; if (tStore == null) { tStore = new TStore(); isOpLog = true; } tStore.setStoreID(storeIDStr); tStore.setName(nameStr); tStore.setLocation(locationStr); tStore.setManager(bean.getStrId()); tStore.setPriority(Integer.parseInt(priorityStr)); tStore.setNote(noteStr); try { if (isOpLog) { List<TStore> list = storeService.findByNameService(nameStr); if (list != null && list.size() != 0) { if (Util.showConfirmDialog("存在相同名字的仓库,确定添加吗?") != 0) return; } } this.storeService.saveOrUpdateService(tStore); this.isSuccess = true; if (isOpLog) { BuildSpringApplication.getInstance().getTOpLogServiceImpl().addOpLogService("添加仓库信息"); } else { BuildSpringApplication.getInstance().getTOpLogServiceImpl().addOpLogService("修改仓库信息"); } JOptionPane.showMessageDialog(null, "操作成功"); } catch (Exception e1) { e1.printStackTrace(); this.isSuccess = false; JOptionPane.showMessageDialog(null, "操作失败"); } this.dispose(); } else if (e.getSource() == cancelButton) { this.isSuccess = false; this.dispose(); } super.actionPerformed(e); }
@Override public void actionPerformed(ActionEvent e) { if (e.getSource() == sureButton) { Boolean isShow = false; // 确定 String fillMoneyT = fillMoneyTF.getText().getText().trim(); // 充值金额 String giftMoneyT = giftMoneyTF.getText().getText().trim(); // 赠送金额 if (!MatcherFormatUtil.MatcherPriceScheme(fillMoneyT)) { JOptionPane.showMessageDialog(null, "充值金额 不能为空,且小数点左边最多10位数字,右边最多2位数字"); fillMoneyTF.getText().setText(""); fillMoneyTF.getText().requestFocus(); return; } if (!MatcherFormatUtil.MatcherPriceScheme(giftMoneyT)) { JOptionPane.showMessageDialog(null, "请在充值金额栏点击回车获取赠送金额!"); giftMoneyTF.getText().setText(""); giftMoneyTF.getText().requestFocus(); return; } for (int i = 0; i < tUser.size(); i++) { if (giftMoneyTF.getText().getText().trim() != "") { Double totalMoney = Double.parseDouble(giftMoneyTF.getText().getText().trim()) + Double.parseDouble(fillMoneyT); tUser.get(i).setMoney(totalMoney + tUser.get(i).getMoney()); } else { tUser.get(i).setMoney(Double.parseDouble(fillMoneyT)); } try { Date date = new Date(); if (tUserService.modifyRechargeService(tUser.get(i))) { BuildSpringApplication.getInstance() .getTOpLogServiceImpl() .addOpLogService("会员充值,卡号为:+" + tUser.get(i).getCardNum() + ",充值金额:" + fillMoneyT); TShopRecharge tShopRecharge = new TShopRecharge(); // 添加明细 tShopRecharge.setRechargeID(UUID.GenUUID15()); tShopRecharge.setUserID(userID); // 单据编号CHAR(15) tShopRecharge.setChargeRuleID(""); tShopRecharge.setHappenTime(date); tShopRecharge.setMoney(Double.parseDouble(fillMoneyT)); tShopRecharge.setGiftMoney(Double.parseDouble(giftMoneyTF.getText().getText().trim())); tShopRechargeService.saveService(tShopRecharge); // 添加资金出入 ApplicationContext.addMondyInOut( ApplicationContext.MONEYINOUT_TYPE_IN, ApplicationContext.OPERATOR_ID, ApplicationContext.MONEYINOUT_SOURCE_TYPE5, tShopRecharge.getRechargeID()); isShow = true; } } catch (Exception e1) { isShow = false; e1.printStackTrace(); } } if (isShow) { JOptionPane.showMessageDialog(null, "充值成功!"); this.dispose(); } else { JOptionPane.showMessageDialog(null, "数据异常。"); } } else if (e.getSource() == cancelButton) { this.dispose(); } }