⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 individual.java

📁 用JAVA完成的酒店管理系统.包括需求说明.数据库.设计文档在内.适合于新手.
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
			JOptionPane.showMessageDialog(null, "请在开单列表中选中指定房间," +
			"再移除", "提示", JOptionPane.INFORMATION_MESSAGE);
			return;
		}//endif
	}
	
	/**=======================================================================**
	 *		[## private boolean isValidity() {} ]: 	测试用户输入的数据是否合法
	 *			参数   :无
	 *			返回值 :boolean
	 *			修饰符 :private
	 *			功能   :测试用户输入的数据是否合法
	 **=======================================================================**
	 */
	private boolean isValidity() {
		if(tf1.getText().length() == 0) {
			JOptionPane.showMessageDialog(null, "[ 证件编码 ] 不能为空", 
			"提示", JOptionPane.INFORMATION_MESSAGE);
			tf1.requestFocus(true);
			return false;
		}else if(tf2.getText().length() == 0) {
			JOptionPane.showMessageDialog(null, "[ 宾客名称 ] 不能为空", 
			"提示", JOptionPane.INFORMATION_MESSAGE);
			tf2.requestFocus(true);
			return false;
		}else if(tf4.getText().length() == 0) {
			JOptionPane.showMessageDialog(null, "[ 地址信息 ] 不能为空", 
			"提示", JOptionPane.INFORMATION_MESSAGE);
			tf4.requestFocus(true);
			return false;
		}
		else if(!suntools.isNum(tf3.getText(), 2, 1, 15)) {
			JOptionPane.showMessageDialog(null, "散客开单中 [ 宾客人数 ] 至少是1人," +
			"最多15人", "提示", JOptionPane.INFORMATION_MESSAGE);
			tf3.setText("1");
			tf3.requestFocus(true);
			return false;
		}else if(!suntools.isNum(tf8.getText(), 2, 1, 99)) {
			JOptionPane.showMessageDialog(null, "散客开单的 [ 预住天数 ] 至少是1天," +
			"最多99天,超过三个月的请到VIP部办理包房", "提示", JOptionPane.INFORMATION_MESSAGE);
			tf8.setText("1");
			tf8.requestFocus(true);
			return false;
		}else if(!suntools.isNum(tf9.getText(), 7, 100, 8000)) {
			JOptionPane.showMessageDialog(null, "散客开单的 [ 实收押金 ] 最少为100元," +
			"最多8000元,超过8000元宾客的请到VIP部办理金卡", "提示", JOptionPane.INFORMATION_MESSAGE);
			tf8.requestFocus(true);
			return false;
		}//Endif
		return true;
	}
	
	/**=======================================================================**
	 *		[## private void saveLiveIn() {} ]: 
	 *			参数   :无
	 *			返回值 :无
	 *			修饰符 :private
	 *			功能   :保存宾客入住信息
	 **=======================================================================**
	 */
	private void saveLiveIn() {
		long pkMain = sunsql.getPrimaryKey();			//主PK
		String inNumber = suntools.getNumber(suntools.Number_RZ);	//入住单号
		String roomMain = lbA.getText();				//主房间号
		String cName	= tf2.getText();				//客户名称
		String sex		= cb3.getSelectedItem().toString().trim();	//性别
		String zjType	= cb1.getSelectedItem() + "";	//证件类型
		String zjNo		= tf1.getText();				//证件编号
		String address	= tf4.getText();				//地址
		String renShu	= tf3.getText();				//人数
		String inTime	= Journal.getNowDTime();		//入住时间
		String days		= tf8.getText();				//预注天数
		String account	= tb2.getRowCount() +"";		//消费数量
		String foregift = tf9.getText();				//押金
		String reMark	= tf5.getText();				//备注
		String userid	= HotelFrame.userid;			//经手人
		int cluemark 	= 0;							//提醒标志
		if(chk2.isSelected())
			cluemark	= 1;
		String sqlCode[]= new String[tb2.getRowCount() * 2];	//要存数数,还要改状态,所以是两倍大小的SQL数组
		try {
			int rcss = 0;					//表格记录指针
			for (int i = 0; i < tb2.getRowCount() * 2; i++) {
				sqlCode[i] = "insert into livein(pk,in_no,r_no,r_type_id,main_room," +
				"main_pk,c_type_id,c_name,sex,zj_type,zj_no,address,renshu,in_time,days," +
				"foregift,remark,userid,cluemark) values(" + (pkMain + rcss) + ",'" + inNumber + 
				"','" + dtm2.getValueAt(rcss, 0) + "','" + roomType + "','" + roomMain + "'," + 
				pkMain + ",'" + cType + "','" + cName + "','" + sex + "','" + zjType + "','" + 
				zjNo + "','" + address + "','" + renShu + "','" + inTime + "','" + days + "','" +
				foregift + "','" + reMark + "','" + userid + "'," + cluemark + ")";//写入了一条入住信息
				
				i++;
				if(chk1.isSelected()) {	
					sqlCode[i] = "update roominfo set state='钟点' where delmark=0 " +
					"and id='" + dtm2.getValueAt(rcss, 0) + "'";	//钟点房状态设置
					//更换房间状态图片
					RightTopPanel.setViewListButtonImage(roomType, dtm2.getValueAt(rcss, 0) + "", "钟点");
				}else {
					sqlCode[i] = "update roominfo set state='占用' where delmark=0 " +
					"and id='" + dtm2.getValueAt(rcss, 0) + "'";	//普通入住状态设置
					//更换房间状态图片
					RightTopPanel.setViewListButtonImage(roomType, dtm2.getValueAt(rcss, 0) + "", "占用");
				}//Endif
				
				rcss++;		//DTM指针 +1
		    }//Endfor
		    
		    //以事务的方式提交给数据库
		    int livins = sunsql.runTransaction(sqlCode);
		    if(livins < tb2.getRowCount() * 2) {
		    	JOptionPane.showMessageDialog(null, "开设房间操作失败,请检查网络" +
		    	"连接或联系管理员", "提示", JOptionPane.INFORMATION_MESSAGE);
		    	//如果事务失败的话,则恢复状态图片
		    	for (int i = 0; i < tb2.getRowCount(); i++) {
		    		RightTopPanel.setViewListButtonImage(roomType, dtm2.getValueAt(rcss, 0) + "", "可供");
			    }
				return;					//用户继续输入
		    }//Endif
		    tf1.setText("");			//如果事务执行正常,则窗口控件清零
			tf2.setText("");
			tf3.setText("1");
			tf4.setText("");
			tf5.setText("");
			tf8.setText("1");
			tf9.setText("0.00");
			cb1.setSelectedIndex(0);
			cb3.setSelectedIndex(0);
			suntools.savNumber(inNumber, suntools.Number_RZ);
			this.setVisible(false);		//返回主窗口
	    }
	    catch (Exception ex) {
	    	System.out.println ("Individual.saveLiveIn(): false");
	    }//End try
	}
	
	
	/**=======================================================================**
	 *			ActionListener 监听
	 **=======================================================================**
	 */
	public void actionPerformed(ActionEvent ae) {
		Object o = ae.getSource();
		try {
			ResultSet rs = null;
			if(o == tf1) {					//证件编码框获得焦点时回车
				//查找宾客以前入住记录
				rs = sunsql.executeQuery("select c_name,address from " +
				"livein where delmark=0 and zj_no='" + tf1.getText() + "'");
				
				if(rs.next()) {
					tf2.setText(rs.getString(1));	//宾客姓名
					tf4.setText(rs.getString(2));	//宾客地址
				}else {					//如果是第一次来的宾客则自测省份
					String gt = tf1.getText();
					if(gt.length() > 5 && gt.equals("370203")) {
						tf4.setText("原户籍:山东省青岛市市北区");
					}else if(gt.length() > 5 && gt.equals("370502")) {
						tf4.setText("原户籍:山东省东营市东营区");
					}else if(gt.length() > 5 && gt.equals("370603")) {
						tf4.setText("原户籍:山东省烟台市");
					}//Endif
				}//Endif
				tf2.requestFocus(true);		//将焦点给宾客名称		    
			}else if(o == tf2) {
				tf3.requestFocus(true);		//将焦点给宾客人数
			}else if(o == tf3) {
				tf4.requestFocus(true);		//将焦点给宾客地址
			}else if(o == tf4) {
				tf5.requestFocus(true);		//将焦点给备注
			}else if(o == tf5) {
				tf8.requestFocus(true);		//将焦点给预住天数
			}else if(o == tf8) {
				//获得房间的预设押金
				rs = sunsql.executeQuery("select foregift from roomtype where " +
				"delmark=0 and r_type='" + lbB.getText() + "'");
				if(rs.next()) {
					tf9.setText(rs.getDouble(1) + "");	//预交押金
				}//Endif
			}else if(o == cb2) {
				//自动折扣计算
				rs = sunsql.executeQuery("select a.discount,a.dis_price,a.id,b.id from " +
				"customertype a,(select id from roomtype where delmark=0 and " +
				"r_type='" + lbB.getText() + "') b where a.delmark=0 and " +
				"a.c_type='" + cb2.getSelectedItem() + "' and a.dis_attr=b.id");
				if(rs.next()) {
					tf6.setText(rs.getString(1));	//折扣
					disPrice = rs.getDouble(2);		//折扣价
					tf7.setText("¥" + disPrice);
					cType = rs.getString(3);
					roomType  = rs.getString(4);
				}//Endif
				tf1.requestFocus(true);				//确定
			}else if(o == bt1) {
				if(isValidity()) {
					int isAdd = JOptionPane.showConfirmDialog(null, "您确定以当前宾客信息,以 [ " + 
					lbA.getText() + " ] 为主房间,开设房间吗?", "提示", JOptionPane.YES_NO_OPTION);
					
					if(isAdd == JOptionPane.YES_OPTION) {
						saveLiveIn();					//保存入住信息
					}//Endif
				}//Endif
			}else if(o == bt2) {					//取消
				tf1.setText("");
				tf2.setText("");
				tf3.setText("1");
				tf4.setText("");
				tf5.setText("");
				tf8.setText("1");
				tf9.setText("0.00");
				cb1.setSelectedIndex(0);
				cb3.setSelectedIndex(0);
				this.setVisible(false);
			}else if(o == bt3) {					//加入到开单房间
				if(zRooms < 4) {					//检查房间数量
					addRoom();
				}else {
					JOptionPane.showMessageDialog(null, "最多只能追加四间客房," +
					"入住五间以上客房请使用团体开单", "提示", JOptionPane.INFORMATION_MESSAGE);
					return;
				}//Endif
			}else if(o == bt4) {
				if(zRooms >= 0) {					//检查房间数量
					subRoom();
				}else {
					JOptionPane.showMessageDialog(null, "[ 散客开单 ] 至少要开设一个房间", 
					"提示", JOptionPane.INFORMATION_MESSAGE);
					return;
				}//Endif
			}//Endif
		}
		catch (Exception ex) {
			//ex.printStackTrace();
			System.out.println ("Individual.actionPerformed: false");
		}//End try
	}
	
	
	/**=======================================================================**
	 *			MouseListener 监听
	 **=======================================================================**
	 */
	public void mouseClicked (MouseEvent me) {
	}

	public void mousePressed (MouseEvent me) {
		Object o = me.getSource();
		if(o == bt3) {
			bt3.setIcon(new ImageIcon("pic/right2.gif"));
		}if(o == bt4) {
			bt4.setIcon(new ImageIcon("pic/left2.gif"));
		}//Endif
	}

	public void mouseReleased(MouseEvent me) {
		Object o = me.getSource();
		if(o == bt3) {
			bt3.setIcon(new ImageIcon("pic/right.gif"));
		}if(o == bt4) {
			bt4.setIcon(new ImageIcon("pic/left.gif"));
		}//Endif
	}

	public void mouseEntered (MouseEvent me) {		//鼠标移进提示
		Object o = me.getSource ();
		if(o == bt1) {
			HotelFrame.lbA.setText (HotelFrame.clue + 
			"确认当前宾客的入住信息                   ");
		}else if(o == bt2) {
			HotelFrame.lbA.setText (HotelFrame.clue + 
			"取消添加入住信息                         ");
		}else if(o == bt3) {
			bt3.setIcon(new ImageIcon("pic/right1.gif"));
		}else if(o == bt4) {
			bt4.setIcon(new ImageIcon("pic/left1.gif"));
		}//Endif
	}

	public void mouseExited (MouseEvent me) {
		HotelFrame.lbA.setText (HotelFrame.clue + "请选择功能项 ...                       ");
		bt3.setIcon(new ImageIcon("pic/right.gif"));
		bt4.setIcon(new ImageIcon("pic/left.gif"));
	}
	
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -