📄 guestregister.java
字号:
+ RegisterID + "' , '" + strName + "', '" +
strCompany +
"', '" + strCounty + "', '"
+ strPhone + "', '" + strPaType + "', '" +
strPaperNo + "','" + strRegiType + "', '" +
strCheckINType +
"', '" + strDeposit +
"', '" + strGoDate + "', '" +
strLiveDate + "', '" + iLiveDay + "', '" +
strEndDate + "','" +
strPersonNo +
"','" + strRoomNo + "','" +
strReason + "', '" + ReturnPopedom.strEmpID +
"')";
connect2.sql2 =
" INSERT INTO HIMS_Register_Account (AccountID,Reckoning,DutyID) VALUES('"
+ RegisterID + "',null,null)";
connect3.sql3 =
" UPDATE HIMS_RoomState SET StartDate= '" +
strStartDate + "', EndDate = '"
+ strEndDate + "' where RoomID = '" +
GuestChechInRoom.strRoomName01 + "' or RoomID = '" +
GuestChechInRoom.strRoomName02
+ "' or RoomID = '" + GuestChechInRoom.strRoomName03 +
"' or RoomID = '" + GuestChechInRoom.strRoomName04 +
"' or RoomID = '" + GuestChechInRoom.strRoomName05 +
"' or RoomID = '" + GuestChechInRoom.strRoomName02
+ "' or RoomID = '" + GuestChechInRoom.strRoomName06 +
"' or RoomID = '" + GuestChechInRoom.strRoomName07 +
"' or RoomID = '" + GuestChechInRoom.strRoomName08 + "'";
connect1.stmt1.executeUpdate(connect1.sql1);
connect2.stmt2.executeUpdate(connect2.sql2);
connect3.stmt3.executeUpdate(connect3.sql3);
//-----------------------------------------------------------------------------------------------------
JOptionPane.showMessageDialog(this, "新建成功!", "酒店信息管理系统提示",
JOptionPane.INFORMATION_MESSAGE);
jTFName.setEnabled(false); //姓名
jTFPaperNo.setEnabled(false); //证件号码
jCBPaperType.setEnabled(false); //证件类型
jTFCounty.setEnabled(false); //国家
jTFCheckInDay.setEnabled(false); //入住天数
jTFRegPhone.setEnabled(false); //联系电话
jTFPersonMon.setEnabled(false); //入住人数
jTFGuestRegID.setEnabled(false); //客人登记号
jBGuestRegID.setEnabled(false); //验证
jTACHOReason.setEnabled(false); //入住原因
jBFSetRoomMon.setEnabled(false); //订房数设置
jTFRoomMon.setEnabled(false); //订房数
jTextField7.setEnabled(false); //押金
jBNewBuildFinish.setEnabled(false); //新建完成
jBNewBuild.setEnabled(true);
jTFWillCheckDate.setEnabled(false); //抵店日期
} catch (SQLException ex) {
ex.printStackTrace();
} 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 jBFSetRoomMon_actionPerformed(ActionEvent e) { //设置订房数
RegisterID = jTFGuestRegID.getText(); //ID号
RoomMon = jTFRoomMon.getText(); //订房数
if (RoomMon.equals("")) {
JOptionPane.showMessageDialog(null,
"订房数不能为空,请重新输入!",
"酒店信息管理系统警告",
JOptionPane.WARNING_MESSAGE);
jTFRoomMon.setText("");
return;
}
if (!judgeval.isFigure(RoomMon)) {
JOptionPane.showMessageDialog(null,
"订房数必须是数字,请重新输入!",
"酒店信息管理系统警告",
JOptionPane.WARNING_MESSAGE);
jTFRoomMon.setText("");
return;
}
if (Integer.valueOf(RoomMon).intValue() > 8 ||
Integer.valueOf(RoomMon).intValue() < 0) {
JOptionPane.showMessageDialog(null,
"房间数最多只能入住8个,最少不能为0,请重新输入!",
"酒店信息管理系统警告",
JOptionPane.WARNING_MESSAGE);
jTFRoomMon.setText("");
return;
}
jTFRoomMon.setEnabled(false);
jBFSetRoomMon.setEnabled(false);
strStartDate = format.format(date);
try {
connect1 = new DataConnect();
connect1.con1 = DriverManager.getConnection(connect1.url); //建立连接
connect1.stmt1 = connect1.con1.createStatement(); //创建语句
connect1.sql1 =
"SELECT RegRoomID FROM HIMS_Register_CheckInRoom";
rs1l = connect1.stmt1.executeQuery(connect1.sql1);
//-----------------------------------------------------------------------------------------------------
while (rs1l.next()) {
String strID = rs1l.getString("RegRoomID");
if (strID.equals(RegisterID)) {
GuestChechInRoom chichinroom = new GuestChechInRoom();
chichinroom.setVisible(true);
return;
}
} //while
connect2 = new DataConnect();
connect2.con2 = DriverManager.getConnection(connect2.url); //建立连接
connect2.stmt2 = connect2.con2.createStatement(); //创建语句
connect2.sql2 = " INSERT INTO HIMS_Register_CheckInRoom (RegRoomID,RoomName01,RoomName02,RoomName03,RoomName04,RoomName05,RoomName06,RoomName07,RoomName08) VALUES('"
+ RegisterID +
"' ,'','','','','','','','') ";
connect2.stmt2.executeUpdate(connect2.sql2);
GuestChechInRoom chichinroom = new GuestChechInRoom();
chichinroom.setVisible(true);
} catch (SQLException ex) {
ex.printStackTrace();
} finally {
try {
if (connect1.con1 != null && connect2.con2 != null) {
connect1.con1.close(); //关闭数据库admin
connect2.con2.close(); //关闭数据库admin
connect1.stmt1.close();
connect2.stmt2.close();
} //if
} catch (SQLException ex) {
System.out.println(ex);
} //catch
} //finally
}
public void jBDelete_actionPerformed(ActionEvent e) { //删除
RegisterID = jTFGuestRegID.getText(); //ID号
int inChoose = JOptionPane.showConfirmDialog(null,
"真的要删除吗!将会把关于此客户信息删除,请慎选!!",
"酒店信息管理系统提示",
JOptionPane.YES_NO_OPTION);
if (inChoose == 0) { //inchoose为0时,用户选则“是”
//-----------------------------------------------------------------
try {
connect1 = new DataConnect();
connect2 = new DataConnect();
connect3 = new DataConnect();
connect4 = new DataConnect();
connect1.con1 = DriverManager.getConnection(connect1.url); //建立连接
connect2.con2 = DriverManager.getConnection(connect2.url); //建立连接
connect3.con3 = DriverManager.getConnection(connect3.url); //建立连接
connect4.con4 = DriverManager.getConnection(connect4.url); //建立连接
connect1.stmt1 = connect1.con1.createStatement(); //创建语句
connect2.stmt2 = connect2.con2.createStatement(); //创建语句
connect3.stmt3 = connect3.con3.createStatement(); //创建语句
connect4.stmt4 = connect4.con4.createStatement(); //创建语句
connect1.sql1 =
" UPDATE HIMS_RoomState SET OnUser = '4' , Reason = '预定取消!!' where HIMS_RoomState.RoomID in (select RoomName01 from HIMS_Register_CheckInRoom where RegRoomID = '" +
RegisterID + "') or HIMS_RoomState.RoomID in (select RoomName02 from HIMS_Register_CheckInRoom where RegRoomID = '" +
RegisterID + "') or HIMS_RoomState.RoomID in (select RoomName03 from HIMS_Register_CheckInRoom where RegRoomID = '" +
RegisterID + "') or HIMS_RoomState.RoomID in (select RoomName04 from HIMS_Register_CheckInRoom where RegRoomID = '" +
RegisterID + "') or HIMS_RoomState.RoomID in (select RoomName05 from HIMS_Register_CheckInRoom where RegRoomID = '" +
RegisterID + "') or HIMS_RoomState.RoomID in (select RoomName06 from HIMS_Register_CheckInRoom where RegRoomID = '" +
RegisterID + "') or HIMS_RoomState.RoomID in (select RoomName07 from HIMS_Register_CheckInRoom where RegRoomID = '" +
RegisterID + "') or HIMS_RoomState.RoomID in (select RoomName08 from HIMS_Register_CheckInRoom where RegRoomID = '" +
RegisterID + "')";
connect2.sql2 = "Delete from HIMS_Register WHERE RegisterID ='" +
RegisterID + "'";
connect3.sql3 =
"Delete from HIMS_Register_Account WHERE AccountID ='" +
RegisterID + "'";
connect4.sql4 =
"Delete from HIMS_Register_CheckInRoom WHERE RegRoomID='" +
RegisterID + "'";
connect1.stmt1.executeUpdate(connect1.sql1);
connect2.stmt2.executeUpdate(connect2.sql2);
connect3.stmt3.executeUpdate(connect3.sql3);
connect4.stmt4.executeUpdate(connect4.sql4);
JOptionPane.showMessageDialog(this, "删除成功!", "酒店信息管理系统提示",
JOptionPane.INFORMATION_MESSAGE);
} catch (SQLException ex) {
System.err.println("SQLException:" + ex.getMessage());
} finally {
try {
if (connect1.con1 != null && connect2.con2 != null &&
connect3.con3 != null && connect4.con4 != null) {
connect1.con1.close(); //关闭数据库
connect2.con2.close(); //关闭数据库
connect3.con3.close(); //关闭数据库
connect4.con4.close(); //关闭数据库
connect1.stmt1.close();
connect2.stmt2.close();
connect3.stmt3.close();
connect4.stmt4.close();
} //if
} catch (SQLException ex) {
System.out.println(ex);
} //catch
} //finally
}
}
public void jBEmpIDQuery_actionPerformed(ActionEvent e) { //查找
jBEdit.setEnabled(true); //修改
jBDelete.setEnabled(true); //删除
String strRegisterID = jTFEmpIDQuery.getText();
SimpleDateFormat dateformat = new SimpleDateFormat("yyyy-MM-dd");
try {
//-----------------------------------------------------------------------------------------------------
connect1 = new DataConnect();
connect1.con1 = DriverManager.getConnection(connect1.url); //建立连接
connect1.stmt1 = connect1.con1.createStatement(); //创建语句
connect1.sql1 = "SELECT RegisterID,Name,Company,County,RegPhone,PaperType,PaperNo, RegiType,CheckInType,Deposit,WillCheckDate,CheckInDate,CheckInDay,QuitDate,PersonMon,RoomMon,Reason FROM HIMS_Register";
rs1l = connect1.stmt1.executeQuery(connect1.sql1);
//-----------------------------------------------------------------------------------------------------
while (rs1l.next()) {
String strRID = rs1l.getString("RegisterID");
String strName = rs1l.getString("Name");
String strCompany = rs1l.getString("Company");
String strCounty = rs1l.getString("County");
String strRegPhone = rs1l.getString("RegPhone");
String strPaperType = rs1l.getString("PaperType");
String strPaperNo = rs1l.getString("PaperNo");
String strRegiTypes = rs1l.getString("RegiType");
String strCheckInTypes = rs1l.getString("CheckInType");
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -