public void init() { JPanel main_jp = new BorderJPanel(); BoxLayout boxLayout = new BoxLayout(main_jp, BoxLayout.Y_AXIS); main_jp.setLayout(boxLayout); main_jp.setBackground(Util.PANEL_COLOR); number = new JLabelJTextFieldComponent(" *", "仓库编号:", 30); name = new JLabelJTextFieldComponent(" *", "仓库名称:", 30); location = new JLabelJTextFieldComponent(" *", "仓库地址:", 30); manager = new JLabelJComboBoxComponent("*", "仓库管理员:", new String[] {}, 188); manager.addElement(new IDNameBean("0", "请选择")); priority = new JLabelJTextFieldComponent("*", "仓库优先级:", "(数字越大,越在前面)", 15); note = new JLabelJTextAreaComponent(" 备 注:", 23, 3); number.getText().setText(UUID.GenUUID15()); number.getText().setEditable(false); priority.getText().setText("0"); main_jp.add(number); main_jp.add(name); main_jp.add(location); main_jp.add(manager); main_jp.add(priority); main_jp.add(note); JPanel p1 = new JPanel(); sureButton = new RPJButtonWhite("保存(Ctrl+S)"); cancelButton = new RPJButtonWhite("取消(Ctrl+Q)"); p1.add(sureButton); p1.add(cancelButton); p1.setOpaque(false); main_jp.add(p1); this.add(main_jp); main_jp.setCursor(Util.CURSOR_DEFAULT); }
@Override public void run() { try { List<TEmployee> list = tEmployeeService.findService(null); if (list != null && list.size() != 0) { for (int i = 0; i < list.size(); i++) { TEmployee emp = list.get(i); manager.addElement(new IDNameBean(emp.getEmployeeID(), emp.getName())); if (tStore != null) { if (emp.getEmployeeID().equals(tStore.getManager())) { manager.getBox().setSelectedIndex(i + 1); } } } } } catch (Exception e) { e.printStackTrace(); } }
@Override public void run() { System.out.println("bbbb"); try { List<TStore> list = tStoreService.findService(null); storeId.getModel().removeAllElements(); storeId.addElement(new JComboBoxPOJO("请选择……")); if (list != null && list.size() != 0) { int length = list.size(); for (int i = 0; i < length; ++i) { TStore tStore = list.get(i); storeId.addElement( new JComboBoxPOJO(tStore.getStoreID(), tStore.getStoreID(), tStore)); } } } catch (Exception e) { e.printStackTrace(); } }
private JPanel initTop() { QueryPanel queryPanel = new QueryPanel("物品领用", ImageFactory.loadImage(ImageFactory.FUN_5_ICON_3)); JPanel top_panel = new JPanel(new FlowLayout(FlowLayout.LEFT)); orderID = new JLabelJTextFieldComponent("领用单号:", 20); employee = new JLabelJTextFieldComponent("领用人:", 20); startTime = new DataPackageComponent("开始时间", 188); endTime = new DataPackageComponent("结束时间", 188); queryButton = new RPJButtonBlue("查询"); clearButton = new RPJButtonGray("清空"); storeId = new JLabelJComboBoxComponent("仓库编号", new String[] {}, 188); storeId.addElement(new JComboBoxPOJO("请选择……")); top_panel.add(storeId); top_panel.add(orderID); top_panel.add(employee); top_panel.add(startTime); top_panel.add(endTime); top_panel.add(queryButton); top_panel.add(clearButton); queryPanel.addPanel(top_panel); // queryPanel.addBoxPanel(top_panel); return queryPanel; }
@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); }