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

📄 engage.java

📁 酒店管理应用的系统~JAVA编写
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
				//传姓名给开单窗口
				ev.tf2.setText(dtm.getValueAt(row, 1) + "");
				
				//房间类型编号
				String clRoom = dtm.getValueAt(row, 9) + "";
				//获得此类型房间是否可以开设钟点房
				rs = sunsql.executeQuery("select cl_room from roomtype where " +
				"delmark=0 and id='" + clRoom + "'");
				
				rs.next();
				if(rs.getString(1).equals("N")) {	//不能开设,则开单窗口的钟点选项不可用
					ev.chk1.setSelected(false);		//取消选中状态
					ev.chk1.setEnabled(false);		//设置不可用
				}else {
					ev.chk1.setEnabled(true);		//可用
				}//Endif
				
				//传宾客类型数据给开单窗口
				rs = sunsql.executeQuery("select distinct c_type from customertype where " +
				"delmark = 0 and pk!=0");
				int ct = sunsql.recCount(rs);
				String cType[] = new String[ct];
				for (int i = 0; i < ct; i++) {
					rs.next();
					cType[i] = rs.getString(1);
			    }//Endfor
			    ev.cb2.removeAllItems();
				for (int i = 0; i < ct; i++) {
					ev.cb2.addItem(cType[i]);
			    }//Endfor
			    ev.cb2.setSelectedItem("普通宾客");
				
				//初始化开单房间表---------临时表
				sunsql.executeUpdate("delete from roomnum");		//清空临时表
				sunsql.executeUpdate("insert into roomnum(roomid) values('" + 
				dtm.getValueAt(row, 4) + "')");				//加入当前房间信息
				//初始化开单窗口的开单房间表
				sunsql.initDTM(ev.dtm2,"select roomid 房间编号 from roomnum");
				
				//初始化追加房间表---------当前类型的除当前房间的所有可供房间
				sunsql.executeUpdate("update roominfo set indimark=0");	//刷新所有房间的开单状态
				sunsql.executeUpdate("update roominfo set indimark=1 where id='" + 
				dtm.getValueAt(row, 4) + "'");				//设置当前房间为开单状态
				//初始化开单窗口的可供房间表
				sunsql.initDTM(ev.dtm1,"select a.id 房间编号1 from roominfo " +
				"a,(select id from roomtype where r_type='" + ev.lbB.getText() + 
				"') b where a.delmark=0 and a.indimark=0 and a.state='可供' and a.r_type_id=b.id");
				
			
	    }
	    catch (Exception ex) {
	    	ex.printStackTrace();
	    	System.out.println ("Engage.initIDV(): false");
	    }//End try
	    return true;
	}
	
	
	
	
	
	public void actionPerformed(ActionEvent ae) {
		Object o = ae.getSource();
		if(o==bt1) {
			//增加预定信息
			sunsql.executeUpdate("delete from engage1");
			String sqlCode = "select a.r_type 预定规格,b.r_no 房间 from roomtype as a,engage1 as b where a.id = b.r_type_id";
			sunsql.initDTM(ei.dtm1,sqlCode);
			ei.chk.setSelected(false);
			ei.show(true);
			initDTM();
		//	sunsql.initJComboBox(ei.cb1,"select r_type from roomtype where delmark = 0");
		}
		else if(o==bt2) {
			//修改预定信息
			if(initMrt()) {					//传数据给窗口
				em.show(true);				//修改预定信息
				initDTM();			    	//刷新表数据
			}//Endif
		}
		else if(o==bt3) {
			//删除预定信息
			int rRow[] = tb.getSelectedRows();				//删除预订信息
			if(delInfo (rRow)) {	//执行删除操作
				initDTM();			//刷新房间表数据
			}//Endif
			
		}
		else if(o==bt4) {
			//查询
			String s = tf1.getText();
			String sqlCode = "select a.c_name 宾客姓名,a.c_tel 联系电话,b.r_type 预定房间类型,a.r_no 预定房间编号,a.pa_time 预抵时间,a.keep_time 保留时间,a.eng_time 预定时间,a.remark 备注 "+
				      "from engage as a,roomtype as b where a.r_type_id = b.id and a.delmark = 0 and b.delmark = 0 and a.engagemark = 2 and (a.c_name like '%"+s+"%' or a.r_no like '%"+s+"%' or a.c_tel like '%"+s+"%')";
			sunsql.initDTM(dtm,sqlCode);
		}
		else if(o==bt6) {
			//刷新
			String sqlCode = "select a.c_name 宾客姓名,a.c_tel 联系电话,b.r_type 预定房间类型,a.r_no 预定房间编号,a.pa_time 预抵时间,a.keep_time 保留时间,a.eng_time 预定时间,a.remark 备注 "+
					  "from engage as a,roomtype as b where a.r_type_id = b.id and a.delmark = 0 and b.delmark = 0 and engagemark = 2";
			sunsql.initDTM(dtm,sqlCode);
		}
		else if(o==bt7) {	//开设房间
			int row = tb.getSelectedRow();
			if(row < 0) {
				JOptionPane.showMessageDialog(null, "请在预订列表中选中指定的预订房间,开设房间", 
				"提示", JOptionPane.INFORMATION_MESSAGE);
				return;
			}//Endif
			if(initIDV(row)) {
				ev.show(true);
				initDTM();
			}//Endif
		}
		else if(o==mi1) {
			//过滤今日预抵宾客
			String date = getDate();
			String start = date + " 00:00:00";
			String end = date + " 23:59:59";
			String sqlCode = "select a.c_name 宾客姓名,a.c_tel 联系电话,b.r_type 预定房间类型,a.r_no 预定房间编号,a.pa_time 预抵时间,a.keep_time 保留时间,a.eng_time 预定时间,a.remark 备注 "+
					 		 "from engage as a,roomtype as b where a.r_type_id = b.id and a.delmark = 0 and b.delmark = 0 and engagemark = 2 and a.pa_time between '"+start+"' and '"+end+"'";
			sunsql.initDTM(dtm,sqlCode);
		}
		else if(o==mi2) {
			//过滤明日预抵宾客
			String date = tomorrow();
			String start = date + " 00:00:00";
			String end = date + " 23:59:59";
			String sqlCode = "select a.c_name 宾客姓名,a.c_tel 联系电话,b.r_type 预定房间类型,a.r_no 预定房间编号,a.pa_time 预抵时间,a.keep_time 保留时间,a.eng_time 预定时间,a.remark 备注 "+
					 		 "from engage as a,roomtype as b where a.r_type_id = b.id and a.delmark = 0 and b.delmark = 0 and engagemark = 2 and a.pa_time between '"+start+"' and '"+end+"'";
			sunsql.initDTM(dtm,sqlCode);
		}
	}
	
	//取得当前的日期
	private String getDate() {
		GregorianCalendar gc = new GregorianCalendar();
		String year = gc.get(GregorianCalendar.YEAR)+"";
		//为月份补'0'
		String month = gc.get (GregorianCalendar.MONTH) + 1 + "";
		if( month.length() == 1)
			month = "0" + month;
		//为天补'0'
		String day = gc.get (GregorianCalendar.DAY_OF_MONTH) + "";
		if( day.length () == 1)
			day = "0" + day;
			
		String date = year+"-"+month+"-"+day;
		return date;
	}
	
	//取得下一天的日期
	private String tomorrow() {
		GregorianCalendar gc = new GregorianCalendar();
		int ty = gc.get(GregorianCalendar.YEAR);
		int tM = gc.get(GregorianCalendar.MONTH);
		int td = gc.get(GregorianCalendar.DAY_OF_MONTH) + 1;
		gc.set(ty, tM, td, 0, 0, 0);
		ty = gc.get(GregorianCalendar.YEAR);
		tM = gc.get(GregorianCalendar.MONTH)+1;
		td = gc.get(GregorianCalendar.DAY_OF_MONTH);
		String tomorrow = "";
		if(tM < 10) 
			tomorrow = ty + "-0" + tM;
		else 
			tomorrow = ty + "-" + tM;
		if(td < 10)
			tomorrow = tomorrow + "-0" + td;
		else
			tomorrow = tomorrow + "-" + td;
		return tomorrow;
	}
	
	/**=======================================================================**
	 *			MouseListener 监听
	 **=======================================================================**
	 */
	public void mouseClicked (MouseEvent me) {
		Object o = me.getSource();
		//弹出过滤菜单
		if(o==bt5) {
			int x = me.getX();
			int y = me.getY();
			pm.show(bt5,x,y);
		}
	}

	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 + 
			"查询房间预定信息                         ");
		}else if(o == bt5) {
			HotelFrame.lbA.setText (HotelFrame.clue + 
			"过滤房间预定信息                         ");
		}else if(o == bt6) {
			HotelFrame.lbA.setText (HotelFrame.clue + 
			"刷新房间预定信息                         ");
		}else if(o == bt7) {
			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 + -