方法实现案例
package com.gxa.bj.action;
import java.io.IOException;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import javax.jms.Session;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;
import com.gxa.bj.dao.imp.VoucherMapper;
import com.gxa.bj.model.Buser;
import com.gxa.bj.model.Voucher;
import com.gxa.bj.service.VoucherService;
import com.gxa.bj.util.DBHelper;
@Controller
public class VoucherAction {
public VoucherService getVoucherService() {
return voucherService;
}
public void setVoucherService(VoucherService voucherService) {
this.voucherService = voucherService;
}
private VoucherService voucherService;
// 录入凭证的方法
@RequestMapping(value="/vouchevIn.action")
public void voucherIn(HttpServletRequest req,HttpServletResponse resp) throws IOException, ParseException{
Voucher v=new Voucher();
String data=DBHelper.GetDate();
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
Date indata =new Date();
indata=format.parse(data);
String pages=req.getParameter("page");
Integer page=Integer.valueOf(pages);
String jaccount=req.getParameter("jk");
String daccount=req.getParameter("dk");
String debits=req.getParameter("debit");
Double debit=Double.valueOf(debits);
String credits=req.getParameter("credit");
Double credit=Double.valueOf(credits);
String digest=req.getParameter("digest");
HttpSession session=req.getSession();
String staff=(String)session.getAttribute("name");
v.setIndata(indata);
v.setPage(page);
v.setJaccount(jaccount);
v.setDaccount(daccount);
v.setDebit(debit);
v.setCredit(credit);
v.setDigest(digest);
v.setManager("未知");
v.setStaff(staff);
v.setState("未审核");
voucherService.addItem(v);
resp.sendRedirect("voucherIn.jsp");
}
// 获取数据库凭证数据的方法
@RequestMapping(value="/getlist.action")
public List<Voucher> getlist(Voucher v){
// 返回集合
return voucherService.getList(v);
}
// 在页面显示未审核的凭证
@RequestMapping(value="/auditshow.action")
public ModelAndView audit(){
Voucher v=new Voucher();
v.setState("未审核");
ModelAndView model=new ModelAndView();
List<Voucher> list =voucherService.getList(v);
for(Voucher o:list){
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
String data=format.format(o.getIndata());
o.setIndatas(data);
}
model.addObject("unpass",list);
model.setViewName("audit.jsp");
return model;
}
// 审核的方法
@RequestMapping(value="/audit.action")
public void remove(HttpServletRequest req,HttpServletResponse resp) throws IOException{
String belums=req.getParameter("belum");
Integer belum=Integer.valueOf(belums);
Voucher v=new Voucher();
v.setBelum(belum);
HttpSession session=req.getSession();
String manager=session.getAttribute("name").toString();
v.setManager(manager);
v.setState("已审核");
voucherService.updateItem(v);;
resp.sendRedirect("auditshow.action");
//审核通过过后直接调用登账的方法录入相应科目的账本;
}
}