📄 empinfrecord.java~94~
字号:
connect1.stmt1.close();
} //if
} catch (SQLException ex) {
System.out.println(ex);
} //catch
} //finally
}
public void jBDelete_actionPerformed(ActionEvent e) { //删除
int inChoose = JOptionPane.showConfirmDialog(null,
"真的要删除吗!将会把关于此职工的所有信息删除,请慎选!!",
"酒店信息管理系统提示",
JOptionPane.YES_NO_OPTION);
if (inChoose == 0) { //inchoose为0时,用户选则“是”
//-----------------------------------------------------------------
try {
connect1 = new DataConnect();
connect2 = new DataConnect();
connect3 = new DataConnect();
connect1.con1 = DriverManager.getConnection(connect1.url); //建立连接
connect2.con2 = DriverManager.getConnection(connect2.url); //建立连接
connect3.con3 = DriverManager.getConnection(connect3.url); //建立连接
connect1.stmt1 = connect1.con1.createStatement(); //创建语句
connect2.stmt2 = connect2.con2.createStatement(); //创建语句
connect3.stmt3 = connect3.con3.createStatement(); //创建语句
connect1.sql1 = "Delete from HIMS_Employee WHERE EmpID='" +
jTGetEmpID.getText() + "'"; //删除用户的SQL语句
connect2.sql2 = "Delete from HIMS_OnDuty_Date WHERE EmpID='" +
jTGetEmpID.getText() + "'"; //删除用户的SQL语句
connect3.sql3 = "Delete from HIMS_OnDuty WHERE EmpID='" +
jTGetEmpID.getText() + "'"; //删除用户的SQL语句
connect1.stmt1.executeUpdate(connect1.sql1);
connect2.stmt2.executeUpdate(connect2.sql2);
connect3.stmt3.executeUpdate(connect3.sql3);
JOptionPane.showMessageDialog(this, "删除成功!", "酒店信息管理系统提示",
JOptionPane.INFORMATION_MESSAGE);
//----------------------------------------------------------------------
jTFQueryEmpID.setEnabled(true); //员工ID框
jBEditFinish.setEnabled(false); //修改完成
jBQueryEmpID.setEnabled(true); //查找
jBPassword.setEnabled(false); //密码修改
jBDelete.setEnabled(false); //删除
jBPurview.setEnabled(false); //权限修改
jBEdit.setEnabled(false); //修改
jBNewBuild.setEnabled(true); //新建
jBNewBuildFinish.setEnabled(false); //新建完成
//-----------------------------------------------------------------------
jTGetEmpID.setText(""); //员工ID
jTFName.setText(""); //姓名
jTFNationality.setText(""); //民族
jTFBirthday.setText(""); //出生年月
jTFNative.setText(""); //籍贯
jTFIDCard.setText(""); //身份证号
jTFAddress.setText(""); //地址
jTFPhone.setText(""); //联系电话
jTFPurview.setText(""); //权限
jPFPassword.setText(""); //密码
jTARemark.setText(""); //备注
jCBSex.removeAllItems(); //性别
jCGetDepartment.removeAllItems(); //部门
jCBDuty.removeAllItems(); //职务
jTFQueryEmpID.setText("");
//-----------------------------------------------------------------------
} catch (SQLException ex) {
System.err.println("SQLException:" + ex.getMessage());
} finally {
try {
if (connect1.con1 != null && connect2.con2 != null &&
connect3.con3 != null) {
connect1.con1.close(); //关闭数据库
connect2.con2.close(); //关闭数据库
connect3.con3.close(); //关闭数据库
connect1.stmt1.close();
connect2.stmt2.close();
connect3.stmt3.close();
} //if
} catch (SQLException ex) {
System.out.println(ex);
} //catch
} //finally
}
}
public void jBNewBuild_actionPerformed(ActionEvent e) { //新建
jBValEmpID.setEnabled(true); //员工ID验证
jTGetEmpID.setText(""); //员工ID框
jTGetEmpID.setEnabled(true); //员工ID框
jTFQueryEmpID.setText(""); //员工ID查询框
jTFQueryEmpID.setEnabled(false); //员工ID查询框
jBQueryEmpID.setEnabled(false); //查找
jTFName.setText(""); //姓名
jTFNationality.setText(""); //民族
jTFBirthday.setText(""); //出生年月
jTFNative.setText(""); //籍贯
jTFIDCard.setText(""); //身份证号
jTFAddress.setText(""); //地址
jTFPhone.setText(""); //联系电话
jTFPurview.setText("4"); //权限
jPFPassword.setText("123"); //密码
jTARemark.setText(""); //备注
jCBSex.removeAllItems(); //性别
jCBSex.addItem(" ");
jCBSex.addItem("男");
jCBSex.addItem("女");
jCGetDepartment.removeAllItems(); //部门
jCGetDepartment.addItem(" ");
jCGetDepartment.addItem("服务部");
jCGetDepartment.addItem("客房部");
jCBDuty.removeAllItems(); //职务
jCBDuty.addItem(" ");
jCBDuty.addItem("经理");
jCBDuty.addItem("前台");
jCBDuty.addItem("服务员");
jBEdit.setEnabled(false); //修改
jBNewBuild.setEnabled(false); //新建
jBPurview.setEnabled(false); //权限修改
jBPassword.setEnabled(false); //密码修改
jBDelete.setEnabled(false); //删除
}
public void jBNewBuildFinish_actionPerformed(ActionEvent e) { //新建完成
String strUserID = jTGetEmpID.getText(); //员工ID
String strName = jTFName.getText(); //姓名
if (strName.equals("")) {
JOptionPane.showMessageDialog(null,
"姓名不能为空,请重新输入!",
"酒店信息管理系统警告",
JOptionPane.WARNING_MESSAGE);
jTFName.setText("");
return;
}
if (!judgeval.IsChineseCharacters(strName)) {
JOptionPane.showMessageDialog(null,
"姓名必须是汉字,请重新输入!",
"酒店信息管理系统警告",
JOptionPane.WARNING_MESSAGE);
jTFName.setText("");
return;
}
if (strName.length() > 10) {
JOptionPane.showMessageDialog(null,
"姓名不能超过5个汉字,请重新输入!",
"酒店信息管理系统警告",
JOptionPane.WARNING_MESSAGE);
jTFName.setText("");
return;
}
String strSex = jCBSex.getSelectedItem().toString(); //性别
if (strSex.equals(" ")) {
JOptionPane.showMessageDialog(null,
"性别不能为空,请重新输入!",
"酒店信息管理系统警告",
JOptionPane.WARNING_MESSAGE);
return;
}
String strNationality = jTFNationality.getText(); //民族
if (!judgeval.IsChineseCharacters(strNationality)) {
JOptionPane.showMessageDialog(null,
"民族必需是汉字,请重新输入!",
"酒店信息管理系统警告",
JOptionPane.WARNING_MESSAGE);
jTFNationality.setText("");
return;
}
if (strNationality.length() > 20) {
JOptionPane.showMessageDialog(null,
"民族不能超过10个汉字,请重新输入!",
"酒店信息管理系统警告",
JOptionPane.WARNING_MESSAGE);
jTFNationality.setText("");
return;
}
String strBirthday = jTFBirthday.getText(); //出生年月
if (judgeval.DateValidity(strBirthday) != 2) {
JOptionPane.showMessageDialog(null,
"出生日期出错,请重新输入!",
"酒店信息管理系统警告",
JOptionPane.WARNING_MESSAGE);
jTFBirthday.setText("");
return;
}
if (strBirthday.equals("")) {
JOptionPane.showMessageDialog(null,
"出生日期不能为空,请重新输入!",
"酒店信息管理系统警告",
JOptionPane.WARNING_MESSAGE);
jTFBirthday.setText("");
return;
}
String strIDCard = jTFIDCard.getText(); //身份证号
if (!judgeval.isFigure(strIDCard)) {
JOptionPane.showMessageDialog(null,
"身份证号必需是为数字,请重新输入!",
"酒店信息管理系统警告",
JOptionPane.WARNING_MESSAGE);
jTFIDCard.setText("");
return;
}
if (strIDCard.length() > 19) {
JOptionPane.showMessageDialog(null,
"身份证号不能超过19位,请重新输入!",
"酒店信息管理系统警告",
JOptionPane.WARNING_MESSAGE);
jTFIDCard.setText("");
return;
}
if (strIDCard.equals("")) {
JOptionPane.showMessageDialog(null,
"身份证号不能为空,请重新输入!",
"酒店信息管理系统警告",
JOptionPane.WARNING_MESSAGE);
jTFIDCard.setText("");
return;
}
String strNative = jTFNative.getText(); //籍贯
if (!judgeval.IsChineseCharacters(strNative)) {
JOptionPane.showMessageDialog(null,
"籍贯必需是汉字,请重新输入!",
"酒店信息管理系统警告",
JOptionPane.WARNING_MESSAGE);
jTFNative.setText("");
return;
}
if (strNative.length() > 20) {
JOptionPane.showMessageDialog(null,
"籍贯不能超过10个汉字,请重新输入!",
"酒店信息管理系统警告",
JOptionPane.WARNING_MESSAGE);
jTFNative.setText("");
return;
}
String strAddress = jTFAddress.getText(); //地址
if (strAddress.length() > 60) {
JOptionPane.showMessageDialog(null,
"地址不能超过30个,请重新输入!",
"酒店信息管理系统警告",
JOptionPane.WARNING_MESSAGE);
jTFAddress.setText("");
return;
}
String strPhone = jTFPhone.getText(); //联系电话
if (!judgeval.isFigure(strPhone)) {
JOptionPane.showMessageDialog(null,
"联系电话必需是为数字,请重新输入!",
"酒店信息管理系统警告",
JOptionPane.WARNING_MESSAGE);
jTFPhone.setText("");
return;
}
if (strPhone.length() < 7 || strPhone.length() > 11) {
JOptionPane.showMessageDialog(null,
"联系电话不能小于7位大于11位,请重新输入!",
"酒店信息管理系统警告",
JOptionPane.WARNING_MESSAGE);
jTFPhone.setText("");
return;
}
String strDepartment = jCGetDepartment.getSelectedItem().toString(); //部门
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -