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

📄 historyaction.java

📁 ktv点歌系统前台收银有开包房
💻 JAVA
字号:
package com.ktv.action;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.actions.DispatchAction;

import com.ktv.dao.IhistoryDAO;
import com.ktv.entity.Box;
import com.ktv.entity.History;

public class HistoryAction extends DispatchAction {
	
	public IhistoryDAO HistoryDAO;
	
	public ActionForward openBoxAction(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response) {
		try {	//开包厢。
			
		int id=Integer.parseInt(request.getParameter("boxId"));  //包房的ID
		Box box=new Box();
		box.setBoxId(id);
		java.util.Date date=new java.util.Date();//取当前时间
		java.util.Date date2=new java.util.Date();//取当前时间
		//SimpleDateFormat sf = new java.text.SimpleDateFormat("yyyy-MM-dd hh:mm:ss");//转换时间格式		
		History history=new History();	
		history.setBox(box);
		history.setBeginTime(date);  //开始时间
		history.setEndTime(date2);    //第二个时间	
		history.setHistoryAllPrice(Double.valueOf(0));
		history.setHistoryRemark("包房已经开了");
		
		HistoryDAO.openBox(history);	 //开包房向数据库里添加一条历史纪录 。		
		HistoryDAO.UpdateBoxPrice(id);   //修改包房的状态。		
		
		} catch (Exception e) {
			e.printStackTrace();
		    return null;
		}	
		return mapping.findForward("boxxian");	
	}
	
	public ActionForward getList3(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response) {
				
				
		        int boxId=Integer.parseInt(request.getParameter("boxId"));
		        
				request.setAttribute("boxonelist",HistoryDAO.getBox(boxId)); //取得包房信息
				request.setAttribute("historyList", HistoryDAO.find(boxId)); //历史纪录信息 
				return mapping.findForward("boxOpenss");
	}
	
	
	public ActionForward closeBoxAction(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response) {
		try {	
			//结账了,将结帐的时间写入数据库
			int boxId=Integer.parseInt(request.getParameter("boxId"));
			java.util.Date date1=new java.util.Date();//取当前时间存到记录表中
			HistoryDAO.updateEndTime(boxId, date1);	
			HistoryDAO.UpdateBoxStauts(boxId);  // 把包房的状态修改为 闲置 。
	       
			//以下要做的是计算时间*单价=消费金额。					
			History hs=(History) HistoryDAO.find(boxId);		
			Box box=(Box)HistoryDAO.getBox(boxId);			
		
			Time time=new Time();     //调用一个时间处理类		
           
			//把取出的时间乘以包房的单价得到总价。
			double zongPrice=(box.getBoxUnitPrice()/60)*(time.GetData(hs.getBeginTime()
					.toString(),hs.getEndTime().toString()));         
			System.out.println(zongPrice+"元钱");
		//	System.out.println(hs.getHistoryId());
			//修改记录表中包房的价格
			int id=hs.getHistoryId();
			System.out.println("包房号是"+id);
			HistoryDAO.updateZongPrice(id, zongPrice);			
		} catch (Exception e) {
			e.printStackTrace();
		    return null;
		}	
		return mapping.findForward("jiezhang");	
	}
	
	
	public ActionForward getList4(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response) {
				
				
		        int boxId=Integer.parseInt(request.getParameter("boxId"));
		        
				request.setAttribute("boxonelist",HistoryDAO.getBox(boxId)); //取得包房信息
				request.setAttribute("historyList", HistoryDAO.find(boxId)); //历史纪录信息 
				return mapping.findForward("boxClose");
	}
	
	public ActionForward getList5(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response) {
				
				
		        int boxId=Integer.parseInt(request.getParameter("boxId"));
		        
				request.setAttribute("boxonelist",HistoryDAO.getBox(boxId)); //取得包房信息
				request.setAttribute("historyList", HistoryDAO.find(boxId)); //历史纪录信息 
				return mapping.findForward("boxMessage");
	}
	
	public ActionForward Checkout(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response) {
								
			
				
				return null;
	}
	
	public IhistoryDAO getHistoryDAO() {
		return HistoryDAO;
	}

	public void setHistoryDAO(IhistoryDAO historyDAO) {
		HistoryDAO = historyDAO;
	}
}

⌨️ 快捷键说明

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