首页>代码>Struts2+Hibernate开发学生成绩后台管理系统>/student/xscj_chao/src/chao/action/CjAction.java
package chao.action;

import java.util.List;
import java.util.Map;

import chao.model.Cjb;
import chao.model.CjbId;
import chao.model.Kcb;
import chao.model.Xsb;
import chao.service.CjService;
import chao.service.KcService;
import chao.service.XsService;
import chao.serviceimp.CjServiceImp;
import chao.serviceimp.KcServiceImp;
import chao.serviceimp.XsServiceImp;
import chao.tool.Pager;

import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;

public class CjAction extends ActionSupport{
    private Cjb cj;
    private int pageNow=1;
	private int pageSize=8; 
	public int getPageNow() {
		return pageNow;
	}
	public void setPageNow(int pageNow) {
		this.pageNow = pageNow;
	}
	public int getPageSize() {
		return pageSize;
	}
	public void setPageSize(int pageSize) {
		this.pageSize = pageSize;
	}
	public Cjb getCj() {
		return cj;
	}
	public void setCj(Cjb cj) {
		this.cj = cj;
	}
	XsService xsService=new XsServiceImp();
    KcService kcService=new KcServiceImp();
    CjService cjService=new CjServiceImp();
	@Override
	public String execute() throws Exception {
		// TODO Auto-generated method stub
		List list1=xsService.findAll(1, xsService.findXsSize());
		List list2=kcService.FindAll(1, kcService.findKcSize());
		Map request=(Map) ActionContext.getContext().get("request");
		request.put("list1", list1);
		request.put("list2", list2);
		return SUCCESS;
	}
	public String addCj() throws Exception {
		String xh=cj.getId().getXsb().getXh();
		String kch=cj.getId().getKcb().getKch();
		if(cjService.getXsCj(xh, kch)!=null)
		{
			return ERROR;
		}
		Cjb cj1=new Cjb();
		CjbId cjId=new CjbId();
		cjId.setXsb(cj.getId().getXsb());
		cjId.setKcb(cj.getId().getKcb());
		cj1.setId(cjId);
		cj1.setCj(cj.getCj());
		Kcb kc1=kcService.find(cj.getId().getKcb().getKch());
		if(cj.getCj()>60||cj.getCj()==60)
		{
			cj1.setXf(kc1.getXf());
		}
		else
			cj1.setXf(0);
		cjService.save(cj1);
		return SUCCESS;
	}
	public String xscjInfo() throws Exception {
		List list=cjService.findAllCj(pageNow, pageSize);
		Map request=(Map) ActionContext.getContext().get("request");
		Pager page=new Pager(pageNow, cjService.findCjSize());
		request.put("list", list);
		request.put("page", page);
		return SUCCESS;
	}
	public String findXscj() throws Exception {
		List list=cjService.getXsCjList(cj.getId().getXsb().getXh());
		if(list.size()>0)
		{
			Map request=(Map) ActionContext.getContext().get("request");
			request.put("list", list);
			return SUCCESS;
		}
		else
			return ERROR;
	}
	public String findCj() throws Exception {
		Cjb stucj=cjService.getXsCj(cj.getId().getXsb().getXh(),cj.getId().getKcb().getKch());
		Map request=(Map) ActionContext.getContext().get("request");
		request.put("stucj", stucj);
		return SUCCESS;
	}
	public String deleteCj() throws Exception {
		String xh=cj.getId().getXsb().getXh();
		String kch=cj.getId().getKcb().getKch();
        cjService.deleteCj(xh, kch);
		return SUCCESS;
	}
	public String updateCjView() throws Exception {
		Cjb cjInfo=cjService.getXsCj(cj.getId().getXsb().getXh(),cj.getId().getKcb().getKch());
		Map request=(Map) ActionContext.getContext().get("request");
		request.put("cjInfo", cjInfo);
		return SUCCESS;
	}
	public String updateXscj() throws Exception {
		// TODO Auto-generated method stub
		Cjb cj1=null;
		CjbId cjId1=new CjbId();
		cjId1.setXsb(cj.getId().getXsb());
		cjId1.setKcb(cj.getId().getKcb());
		if(cjService.getXsCj(cj.getId().getXsb().getXh(), cj.getId().getKcb().getKch())==null)
		{
			cj1=new Cjb();
			cj1.setId(cjId1);
		}
		else
		{
			cj1=cjService.getXsCj(cj.getId().getXsb().getXh(), cj.getId().getKcb().getKch());
		}
		Kcb kc1=kcService.find(cj.getId().getKcb().getKch());
		cj1.setCj(cj.getCj());
		if(cj.getCj()>60||cj.getCj()==60)
		{
			cj1.setXf(kc1.getXf());
		}
		else
			cj1.setXf(0);
		Map request=(Map) ActionContext.getContext().get("request");
		cjService.update(cj1);
		return SUCCESS;
	}
	
}
最近下载更多
fesfefe  LV13 2023年9月26日
15116483404  LV2 2021年12月13日
云脏111111  LV2 2021年5月15日
tx1121  LV14 2021年5月6日
admin_z  LV22 2021年5月1日
and123456  LV11 2021年4月10日
pierce  LV12 2021年3月11日
862960632  LV14 2020年7月7日
dqsy520  LV4 2020年6月12日
张青峰  LV10 2020年6月8日
最近浏览更多
WBelong  LV7 2023年12月25日
卢本伟不开挂  LV4 2023年10月22日
fesfefe  LV13 2023年9月26日
wbx666  LV1 2023年9月18日
zhanglm119  LV3 2023年8月30日
sandihha  LV9 2023年4月24日
upup996  LV6 2022年12月15日
kman404  LV1 2022年11月23日
485415187  LV6 2022年11月19日
cenabobo  LV1 2022年11月11日
顶部 客服 微信二维码 底部
>扫描二维码关注最代码为好友扫描二维码关注最代码为好友