📄 usermodifyaction.java
字号:
package action.implementclass.dialogaction;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Iterator;
import java.util.Vector;
import javax.swing.JOptionPane;
import javax.swing.table.DefaultTableModel;
import view.dialog.UserModifyDialog;
import view.dialog.basedialog.UserBaseDialog;
import view.dialog.dialogoper.UserBaseOper;
import vo.UserPwdVo;
import dao.UserPwdDao;
/**
* 修改用户事件
* @author wenjie
*
*/
public class UserModifyAction implements ActionListener {
public void actionPerformed(ActionEvent e) {
int row = UserBaseDialog.table.getSelectedRow();
if (e.getActionCommand().equals("确定")) {
int ch = JOptionPane.showConfirmDialog(null, "确定要修改吗?", "提示信息",
JOptionPane.YES_NO_OPTION);
// 确认是否修改该记录
if (ch == JOptionPane.YES_OPTION) {
if (new UserPwdDao().updateUser(UserBaseOper.getInputTextValue())) {
JOptionPane.showMessageDialog(null, "修改成功,请按刷新按钮进行查看");
} else {
JOptionPane.showMessageDialog(null, "修改不成功!");
}
}
} else if (e.getActionCommand().equals("取消")) {
UserModifyDialog.userModifyDialog.dispose();
} else if (e.getActionCommand().equals("重置")) {
UserBaseOper.initialTextValue();
} else if (e.getActionCommand().equals("刷新")) {
Vector v = new UserPwdDao().getUserInfo();
Iterator iter = v.iterator();
DefaultTableModel tableModel = (DefaultTableModel) UserBaseDialog.table
.getModel();
int counts = tableModel.getRowCount();
// 循环删除jtable中的所有数据
for (int i = counts - 1; i >= 0; i--) {
tableModel.removeRow(i);
}
while (iter.hasNext()) {
UserPwdVo value = (UserPwdVo) iter.next();
Object[] data = { new Integer(value.getUser_id()),
value.getUser_name(), value.getUser_type(), value.getPassword(),
new Long(value.getPhone()), };
tableModel.addRow(data);
}
} else if (e.getActionCommand().equals("数据上移")) {
UserBaseOper.initialModifyValue();
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -