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

📄 searchcheckguestframe.java

📁 java酒店管理系统
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
    searchByNamePanel.setLayout(new BorderLayout());
    searchByNamePanel.add(checkinInfoByNamescrollpane,BorderLayout.CENTER); 
    ///////////////////////////////////////////////////////////////
    //所有客人的信息				
	searchAllCheckInIdList = searchCheckGuest.getCheckInInfoList();   
	
	//按钮事件处理   
	searchAllButton.addActionListener(new ActionListener() {
		public void actionPerformed(ActionEvent e) {			
			searchAllInfo_searchAllButtonClick();				   
		}
	});	
	//按钮事件处理   
	searchCheckInIdButton.addActionListener(new ActionListener() {
		public void actionPerformed(ActionEvent e) {			
			searchById_searchCheckInIdButtonClick();				   
		}
	});	
	//按钮事件处理   
	SearchByNameButton.addActionListener(new ActionListener() {
		public void actionPerformed(ActionEvent e) {			
			searchByName_searchCheckInIdButtonClick();				   
		}
	});	
	exitButton.addActionListener(new ActionListener() {
		public void actionPerformed(ActionEvent e) {			
			closeFrame();			   
		}
	});	
	exitCheckInIdButton.addActionListener(new ActionListener() {
		public void actionPerformed(ActionEvent e) {			
			closeFrame();			   
		}
	});	
	exitbyNameButton.addActionListener(new ActionListener() {
		public void actionPerformed(ActionEvent e) {			
			closeFrame();			   
		}
	});	
    ////////////////////////////////////////////
    this.setVisible(true);
    searchCheckInTabbedPane.setSelectedComponent(searchAllCheckInPanel);
    //searchCheckInTabbedPane.setSelectedIndex(0);
    ////////////////////////////////////////////   
  }  
  //所有客人的信息
  void searchAllInfo_searchAllButtonClick(){
  	  	
  	while(allCheckInInfoModel.getRowCount()!=0){
  	 	allCheckInInfoModel.removeRow(0);
  	}
  	//从 SearchCheckGuest 类对象获取的信息: 登记客人信息
	//所有客人的信息
	//searchAllCheckInIdList.removeAllElements();				
	//searchAllCheckInIdList = searchCheckGuest.getCheckInInfoList();
	CheckInInfo cii=new CheckInInfo();
	for(int i=0;i<searchAllCheckInIdList.size();i++)
	{
		cii=(CheckInInfo)searchAllCheckInIdList.get(i);
		String sex="";
		String certificateKind="";
		
		if(cii.getSex()==1)
			sex="男";
		else
			sex="女";
			
		if(cii.getCertificateKind()==0)
			certificateKind="身份证";
		else if(cii.getCertificateKind()==1)
			certificateKind="军官证";
		else 
			certificateKind="学生证";
		allCheckInInfoModel.addRow(new Object[]{ 
						Integer.toString(cii.getCheckInGuestId()),
						certificateKind,
						cii.getCertificateId().toString().trim(),
						cii.getGuestName().toString().trim(),						
						sex,
						cii.getArriveDate().toString().trim(),						
						Integer.toString(cii.getStayDayNum()),
						Integer.toString(cii.getGuestNum()),
						Integer.toString(cii.getDesposit())
				 		});	
		}			
	
  }
  void searchById_searchCheckInIdButtonClick(){
  	int id=0;
  	boolean mark=false;
  	try{//错误处理
  		id=Integer.parseInt(checkInIdTextField.getText().trim());
   	}catch(NumberFormatException nfe){   		
   		JOptionPane.showMessageDialog(this,"输入错误,请重新输入!","ok",
  		 							JOptionPane.ERROR_MESSAGE);
   		return;   				
   	}   	
  	while(checkInInfoByIdModel.getRowCount()!=0){
  	 	checkInInfoByIdModel.removeRow(0);
  	}
  	//从 SearchCheckGuest 类对象获取的信息: 登记客人信息
	//所有客人的信息
	//searchAllCheckInIdList.removeAllElements();				
	//searchAllCheckInIdList = searchCheckGuest.getCheckInInfoList();
	CheckInInfo cii=new CheckInInfo();
	
	for(int i=0;i<searchAllCheckInIdList.size();i++)
	{
		cii=(CheckInInfo)searchAllCheckInIdList.get(i);
		if(id==cii.getCheckInGuestId()){
			////////////////////////////////////
			String sex="";
			String certificateKind="";
		
			if(cii.getSex()==1)
				sex="男";
			else
				sex="女";
			
			if(cii.getCertificateKind()==0)
				certificateKind="身份证";
			else if(cii.getCertificateKind()==1)
				certificateKind="军官证";
			else 
				certificateKind="学生证";
			checkInInfoByIdModel.addRow(new Object[]{ 
				Integer.toString(cii.getCheckInGuestId()),
				certificateKind,
				cii.getCertificateId().toString().trim(),
				cii.getGuestName().toString().trim(),						
				sex,
				cii.getArriveDate().toString().trim(),						
				Integer.toString(cii.getStayDayNum()),
				Integer.toString(cii.getGuestNum()),
				Integer.toString(cii.getDesposit())
			});	
			////////////////////////////////////
			mark=true;	//标志查到了		
		}		
	}
	if(!mark){
		//如果没有找到,则通知不存在该客人入住
		JOptionPane.showMessageDialog(this,"不存在该客人入住!","ok",
  		 							JOptionPane.INFORMATION_MESSAGE);
	}
  }
  
  void searchByName_searchCheckInIdButtonClick(){
  	boolean mark=false;  	
  	while(checkInInfoByNameModel.getRowCount()!=0){
  	 	checkInInfoByNameModel.removeRow(0);
  	}  	
	CheckInInfo cii=new CheckInInfo();
	String name=searchNameTextField.getText().trim();
	for(int i=0;i<searchAllCheckInIdList.size();i++)
	{
		cii=(CheckInInfo)searchAllCheckInIdList.get(i);
		if(name.equals(cii.getGuestName().trim())){
				String sex="";
			String certificateKind="";
		
			if(cii.getSex()==1)
				sex="男";
			else
				sex="女";
			
			if(cii.getCertificateKind()==0)
				certificateKind="身份证";
			else if(cii.getCertificateKind()==1)
				certificateKind="军官证";
			else 
				certificateKind="学生证";
			checkInInfoByNameModel.addRow(new Object[]{ 
				Integer.toString(cii.getCheckInGuestId()),
				certificateKind,
				cii.getCertificateId().toString().trim(),
				cii.getGuestName().toString().trim(),						
				sex,
				cii.getArriveDate().toString().trim(),						
				Integer.toString(cii.getStayDayNum()),
				Integer.toString(cii.getGuestNum()),
				Integer.toString(cii.getDesposit())
			});	
			////////////////////////////////////
			mark=true;	//标志查到了			
		}	
	
	}
	if(!mark){
		//如果没有找到,则通知不存在该客人入住
		JOptionPane.showMessageDialog(this,"不存在该客人入住!","ok",
  		 							JOptionPane.INFORMATION_MESSAGE);
	}			
  }
  //close this frame when window is closed
  protected void processWindowEvent(WindowEvent e) {
    super.processWindowEvent(e);
    if (e.getID() == WindowEvent.WINDOW_CLOSING) {
      closeFrame();
    }
  }
  void closeFrame() {
          this.dispose();	
  } 
}

⌨️ 快捷键说明

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