public void mouseClicked(final MouseEvent e) { int selRow = table.getSelectedRow(); // id=table.getValueAt(selRow, 0).toString().trim(); readername.setText(table.getValueAt(selRow, 0).toString().trim()); if (table.getValueAt(selRow, 1).toString().trim().equals("男")) JRadioButton1.setSelected(true); else JRadioButton2.setSelected(true); age.setText(table.getValueAt(selRow, 2).toString().trim()); zjnumber.setText(table.getValueAt(selRow, 3).toString().trim()); date.setText(table.getValueAt(selRow, 4).toString().trim()); maxnumber.setText(table.getValueAt(selRow, 5).toString().trim()); tel.setText(table.getValueAt(selRow, 6).toString().trim()); keepmoney.setText(table.getValueAt(selRow, 7).toString().trim()); comboBox.setSelectedItem(table.getValueAt(selRow, 8).toString().trim()); zy.setText(table.getValueAt(selRow, 9).toString().trim()); ISBN.setText(table.getValueAt(selRow, 10).toString().trim()); bztime.setText(table.getValueAt(selRow, 11).toString().trim()); }
public void actionPerformed(final ActionEvent e) { if (readername.getText().length() == 0) { JOptionPane.showMessageDialog(null, "销售人员姓名文本框不可为空"); return; } if (age.getText().length() == 0) { JOptionPane.showMessageDialog(null, "销售人员年龄文本框不可为空"); return; } if (zjnumber.getText().length() == 0) { JOptionPane.showMessageDialog(null, "证件号码文本框不可为空"); return; } if (keepmoney.getText().length() == 0) { JOptionPane.showMessageDialog(null, "工资文本框不可为空"); return; } if (zy.getText().length() == 0) { JOptionPane.showMessageDialog(null, "毕业文本框不可为空"); return; } if (ISBN.getText().length() == 0) { JOptionPane.showMessageDialog(null, "销售人员条形码文本框不可为空"); return; } if (ISBN.getText().length() != 13) { JOptionPane.showMessageDialog(null, "销售人员条形码文本框为13位"); return; } if (bztime.getText().length() == 0) { JOptionPane.showMessageDialog(null, "办证时间文本框不可为空"); return; } if (tel.getText().length() == 0) { JOptionPane.showMessageDialog(null, "电话号码文本框不可为空"); return; } if (tel.getText().length() > 11 || tel.getText().length() < 0) { JOptionPane.showMessageDialog(null, "电话号码位数小于11位"); return; } if (maxnumber.getText().length() == 0) { JOptionPane.showMessageDialog(null, "最大调货量文本框不可为空"); return; } if (maxnumber.getText().length() > 2 || tel.getText().length() < 0) { JOptionPane.showMessageDialog(null, "最大调货量为两位数字"); return; } String sex = "1"; if (!JRadioButton1.isSelected()) { sex = "2"; } String zj = String.valueOf(comboBox.getSelectedIndex()); System.out.println(comboBox.getSelectedIndex()); int i = Dao.UpdateSalesman( id, readername.getText().trim(), sex, age.getText().trim(), zjnumber.getText().trim(), Date.valueOf(date.getText().trim()), maxnumber.getText().trim(), tel.getText().trim(), Double.valueOf(keepmoney.getText().trim()), zj, zy.getText().trim(), Date.valueOf(bztime.getText().trim()), ISBN.getText().trim()); System.out.println(i); if (i == 1) { JOptionPane.showMessageDialog(null, "修改成功"); Object[][] results = getFileStates(Dao.selectSalesman()); model.setDataVector(results, columnNames); table.setModel(model); } }