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

📄 team.java

📁 主要功能包括散客开单、团体开单、宾客结帐、客房预订、营业查询、客户管理、网络设置、系统设置等等。 详细说明见阳光酒店管理系统需求规格说明书。
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
		sunsql.initDTM(dtm1,sqlCode);
		tb1.removeColumn(tb1.getColumn("id"));
	}
	
	/**=======================================================================**
	 *		[## private void initDTM2() {} ]: 
	 *			参数   :无
	 *			返回值 :无
	 *			修饰符 :private
	 *			功能   :初始化开单房间列表
	 **=======================================================================**
	 */
	public static void initDTM2() {
		sunsql.initDTM(Team.dtm2,"select roomid 客房编号,price 标准单价,rr_type from roomnums");
		tb2.removeColumn(tb2.getColumn("rr_type"));
	}
	
	/**=======================================================================**
	 *		[## private void addRoom() {} ]: 
	 *			参数   :无
	 *			返回值 :无
	 *			修饰符 :private
	 *			功能   :加到开单区
	 **=======================================================================**
	 */
	private void addRoom() {
		//获得选择的行号
		int arows[] = tb1.getSelectedRows();
		
		int ar = 0;
		String sqlCode[]  = new String[arows.length * 2];
		if(arows.length > 0) {
			
			if(tf5.getText().length() == 0) {		//默认第一个加入的房间为主房间
				tf5.setText(dtm1.getValueAt(arows[0], 0) + "");
			}//Endif
			
			for (int i = 0; i < arows.length; i++) {
				//加入开单列表
				sqlCode[ar] = "insert into roomnums(roomid,price,rr_type) values('" +
				dtm1.getValueAt(arows[i], 0) + "'," + dtm1.getValueAt(arows[i], 1) + ",'" + 
				dtm1.getValueAt(arows[i], 2) + "')";
				ar++;
				//清除可供列表
				sqlCode[ar] = "update roominfo set indimark=1 where " +
				"delmark=0 and id='" + dtm1.getValueAt(arows[i], 0) + "'";
				ar++;
			}//Endfor
			int flag = sunsql.runTransaction(sqlCode);
			
			if(flag < arows.length) {
				JOptionPane.showMessageDialog(null, "添加失败,请检查网络情况", 
				"提示", JOptionPane.INFORMATION_MESSAGE);
				return;
			}//Endif
			initDTM1(rt);		//刷新可供列表
			initDTM2();			//刷新开单列表
		}else {
			JOptionPane.showMessageDialog(null, "请在可供房间列表中选中指定房间," +
			"再追加", "提示", JOptionPane.INFORMATION_MESSAGE);
			return;
		}//endif
	}
	
	/**=======================================================================**
	 *		[## private void subRoom() {} ]: 
	 *			参数   :无
	 *			返回值 :无
	 *			修饰符 :private
	 *			功能   :从开单区移除
	 **=======================================================================**
	 */
	private void subRoom() {
		//获得选择的行号
		int arows[] = tb2.getSelectedRows();
		
		int ar = 0;
		String sqlCode[]  = new String[arows.length * 2];
		if(arows.length > 0) {
			for (int i = 0; i < arows.length; i++) {
				sqlCode[ar] = dtm2.getValueAt(arows[i], 0) + "";
				if(!sqlCode[ar].equals(tf5.getText())) {		//判断主房间不能删除
					sqlCode[ar] = "delete from roomnums where roomid='" +
					dtm2.getValueAt(arows[i], 0) + "'";//移除开单列表
					ar++;
					//清除可供列表
					sqlCode[ar] = "update roominfo set indimark=0 where " +
					"delmark=0 and id='" + dtm2.getValueAt(arows[i], 0) + "'";
					ar++;
				}else {
					JOptionPane.showMessageDialog(null, "[ " + dtm2.getValueAt(arows[i], 0) + 
					" ] 房间是主房间,不能移除 ...", "提示", JOptionPane.INFORMATION_MESSAGE);
					return;
				}//Endif
			}//Endfor
			int flag = sunsql.runTransaction(sqlCode);
			
			if(flag < arows.length) {
				JOptionPane.showMessageDialog(null, "移除失败,请检查网络情况", 
				"提示", JOptionPane.INFORMATION_MESSAGE);
				return;
			}//Endif
			initDTM1(rt);		//刷新可供列表
			initDTM2();			//刷新开单列表
		}else {
			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(tf7.getText().length() == 0) {
			JOptionPane.showMessageDialog(null, "[ 地址信息 ] 不能为空", 
			"提示", JOptionPane.INFORMATION_MESSAGE);
			tf7.requestFocus(true);
			return false;
		}else if(tf5.getText().length() == 0) {
			JOptionPane.showMessageDialog(null, "[ 主客房间 ] 不能为空", 
			"提示", JOptionPane.INFORMATION_MESSAGE);
			return false;
		}else if(!suntools.isNum(tf3.getText(), 3, 1, 600)) {
			JOptionPane.showMessageDialog(null, "[ 宾客人数 ] 只能由数字组成," +
			"且至少是1人,最多600人", "提示", JOptionPane.INFORMATION_MESSAGE);
			tf3.setText("1");
			tf3.requestFocus(true);
			return false;
		}else if(!suntools.isNum(tf6.getText(), 2, 1, 99)) {
			JOptionPane.showMessageDialog(null, "散客开单的 [ 预住天数 ] 至少是1天," +
			"最多99天,超过三个月的请到VIP部办理包房", "提示", JOptionPane.INFORMATION_MESSAGE);
			tf6.setText("1");
			tf6.requestFocus(true);
			return false;
		}else if(!suntools.isNum(tf4.getText(), 8, 1000, 20000)) {
			JOptionPane.showMessageDialog(null, "团体开单的 [ 实收押金 ] 最少为1000元," +
			"最多20000元,超过50000元的团体请到VIP部开设房间", "提示", JOptionPane.INFORMATION_MESSAGE);
			tf4.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 = tf5.getText();				//主房间号
		String cName	= tf2.getText();				//客户名称
		String sex		= cb3.getSelectedItem().toString().trim();	//性别
		String zjType	= cb1.getSelectedItem() + "";	//证件类型
		String zjNo		= tf1.getText();				//证件编号
		String address	= tf7.getText();				//地址
		String renShu	= tf3.getText();				//人数
		String inTime	= Journal.getNowDTime();		//入住时间
		String days		= tf6.getText();				//预注天数
		String account	= tb2.getRowCount() +"";		//消费数量
		String foregift = tf4.getText();				//押金
		String reMark	= tf8.getText();				//备注
		String userid	= HotelFrame.userid;			//经手人
		int cluemark 	= 0;							//提醒标志
		if(chk.isSelected())
			cluemark	= 1;
		String sqlCode[]= new String[tb2.getRowCount() * 2];	//要存数据,还要改状态,所以是两倍大小的SQL数组
		try {
			ResultSet rs = sunsql.executeQuery("select distinct id from customertype where " +
			"delmark = 0 and pk!=0 and c_type='" + cb2.getSelectedItem() + "'");
			rs.next();
			String cType = rs.getString(1);		//获得客户类型编号
			
			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) + "','" + dtm2.getValueAt(rcss, 2) + "','" + roomMain + "'," + 
				pkMain + ",'" + cType + "','" + cName + "','" + sex + "','" + zjType + "','" + 
				zjNo + "','" + address + "','" + renShu + "','" + inTime + "','" + days + "','" +
				foregift + "','" + reMark + "','" + userid + "'," + cluemark + ")";//写入了一条入住信息
				
				i++;
				sqlCode[i] = "update roominfo set state='占用' where delmark=0 " +
				"and id='" + dtm2.getValueAt(rcss, 0) + "'";	//普通入住状态设置
				//更换房间状态图片
				RightTopPanel.setViewListButtonImage(dtm2.getValueAt(rcss, 2) + "", dtm2.getValueAt(rcss, 0) + "", "占用");
				
				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(dtm2.getValueAt(rcss, 0) + "", 
		    		dtm2.getValueAt(rcss, 0) + "", "可供");
			    }
				return;					//用户继续输入
		    }//Endif

			tf1.setText("");			//如果事务执行正常,则窗口控件清零
			tf2.setText("");
			tf3.setText("1");
			tf4.setText("0.00");
			tf5.setText("");
			tf6.setText("1");
			tf7.setText("");
			tf8.setText("");
			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));	//宾客姓名
					tf7.setText(rs.getString(2));	//宾客地址
				}else {					//如果是第一次来的宾客则自测省份
					String gt = tf1.getText();
					if(gt.length() > 5 && gt.equals("370203")) {
						tf7.setText("原户籍:山东省青岛市市北区");
					}else if(gt.length() > 5 && gt.equals("370502")) {
						tf7.setText("原户籍:山东省东营市东营区");
					}else if(gt.length() > 5 && gt.equals("370603")) {
						tf7.setText("原户籍:山东省烟台市");
					}//Endif
				}//Endif
				tf2.requestFocus(true);		//将焦点给宾客名称		    
			}else if(o == tf2) {
				tf3.requestFocus(true);		//将焦点给宾客人数	
			}else if(o == tf3) {
				tf4.requestFocus(true);		//将焦点给预交押金
			}else if(o == tf4) {
				tf6.requestFocus(true);		//将焦点给预住天数
			}else if(o == tf6) {
				tf7.requestFocus(true);		//将焦点给宾客地址	
			}else if(o == tf7) {
				tf8.requestFocus(true);		//将焦点给备注
			}else if(o == cb) {
				rt = cb.getSelectedItem()+"";
				initDTM1(rt);				//以指定的房间类型可供房间类型
			}else if(o == bt1) {			//确定
				if(isValidity()) {
					int isAdd = JOptionPane.showConfirmDialog(null, "您确定以当前团体信息开设房间的吗?\n" +
					"主房间 [ " + tf5.getText() + " ]   主宾客 [ " + tf2.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("0.00");
				tf5.setText("");
				tf6.setText("1");
				tf7.setText("");
				tf8.setText("");
				cb1.setSelectedIndex(0);
				cb3.setSelectedIndex(0);
				this.setVisible(false);
			}else if(o == bt3) {			//加入到开单房间
				addRoom();
			}else if(o == bt4) {			//移除开单房间
				subRoom();
			}//Endif
	    }
	    catch (Exception ex) {
	    	ex.printStackTrace();
	    	System.out.println ("Team.actionPerformed(): false");
	    }//End try
		
	}
	
	/**=======================================================================**
	 *			MouseListener 监听
	 **=======================================================================**
	 */
	public void mouseClicked (MouseEvent me) {
	}

	public void mousePressed (MouseEvent me) {
	}

	public void mouseReleased(MouseEvent me) {
	}

	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) {
			HotelFrame.lbA.setText (HotelFrame.clue + 
			"添加房间到团体开单区                       ");
		}else if(o == bt4) {
			HotelFrame.lbA.setText (HotelFrame.clue + 
			"从开单区移除房间信息                       ");
		}
	}

	public void mouseExited (MouseEvent me) {
		HotelFrame.lbA.setText (HotelFrame.clue + "请选择功能项 ...                       ");
	}
	
}

⌨️ 快捷键说明

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