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

📄 moneyaction.java

📁 医药供应链管理系统
💻 JAVA
字号:
/*
 * Generated by MyEclipse Struts
 * Template path: templates/java/JavaClass.vtl
 */
package com.captainli.struts.action;

import java.io.IOException;
import java.io.PrintWriter;
import java.text.SimpleDateFormat;
import java.util.Calendar;

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

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.captainli.bean.AccountlistBean;
import com.captainli.bean.MoneyAddBean;
import com.captainli.dboperation.BankDA;
import com.captainli.dboperation.MoneyClassDA;

/** 
 * MyEclipse Struts
 * Creation date: 11-25-2008
 * 
 * XDoclet definition:
 * @struts.action validate="true"
 */
public class MoneyAction extends DispatchAction {
	/*
	 * Generated Methods
	 */

	/** 
	 * 添加帐务信息
	 * @param mapping
	 * @param form
	 * @param request
	 * @param response
	 * @return ActionForward
	 * @throws IOException 
	 */
	public ActionForward addMoney(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response) throws IOException {
		//js乱码问题解决
		response.setContentType("text/html;UTF-8");
		response.setCharacterEncoding("UTF-8");
		
		PrintWriter out = response.getWriter();
		HttpSession session = request.getSession();
		
		int m_mbc_type = Integer.parseInt(request.getParameter("m_mbc_type"));
		int m_mbc_id = Integer.parseInt(request.getParameter("m_mbc_id"));
		int m_msc_id = Integer.parseInt(request.getParameter("m_msc_id"));
		double m_amount = Double.parseDouble(request.getParameter("m_amount"));
		int m_b_id = Integer.parseInt(request.getParameter("m_b_id"));
		int m_l_id = Integer.parseInt(request.getParameter("m_l_id"));
		String m_note = request.getParameter("m_note").toString();
		//获得系统时间
		Calendar cal=Calendar.getInstance();
        SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        String m_time=sdf.format(cal.getTime());
        
        MoneyAddBean bean = new MoneyAddBean();
        bean.setM_mbc_type(m_mbc_type);
        bean.setM_mbc_id(m_mbc_id);
        bean.setM_msc_id(m_msc_id);
        bean.setM_amount(m_amount);
        bean.setM_b_id(m_b_id);
        bean.setM_l_id(m_l_id);
        bean.setM_note(m_note);
        bean.setM_time(m_time);
        
        if(m_mbc_type == 1){//收入
        	new BankDA().updateBankMoney(m_b_id, m_amount);
        	new MoneyClassDA().addMoney(bean);
        	int m_id = new MoneyClassDA().showIdByBean(bean);
        	session.setAttribute("mid", m_id);
        	out.write("<script language='javascript'>window.alert('出纳帐务成功!');window.location.href='bookkeepingPages/money_add.jsp';window.open('bookkeepingPages/money_show.jsp', '', 'width=600,height=240,top=176,left=161,toolbar=no,location=no,directories=no,status=no,menubar=no,resizable=no,scrollbars=yes'); win.focus();</script>");
    		out.flush();
    		out.close();
        }else{//支出
        	m_amount = 0 - m_amount;
        	new BankDA().updateBankMoney(m_b_id, m_amount);
        	new MoneyClassDA().addMoney(bean);
        	int m_id = new MoneyClassDA().showIdByBean(bean);
        	session.setAttribute("mid", m_id);
        	out.write("<script language='javascript'>window.alert('出纳帐务成功!');window.location.href='bookkeepingPages/money_add.jsp';window.open('bookkeepingPages/money_show.jsp', '', 'width=600,height=240,top=176,left=161,toolbar=no,location=no,directories=no,status=no,menubar=no,resizable=no,scrollbars=yes'); win.focus();</script>");
    		out.flush();
    		out.close();
        }
		return null;
	}
	/**
	 * 查看单据
	 * @param mapping
	 * @param form
	 * @param request
	 * @param response
	 * @return
	 * @throws IOException
	 */
	public ActionForward showMoney(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response) throws IOException {
		//js乱码问题解决
		response.setContentType("text/html;UTF-8");
		response.setCharacterEncoding("UTF-8");
		
		PrintWriter out = response.getWriter();
		HttpSession session = request.getSession();
		int m_id = Integer.parseInt(request.getParameter("m_id"));
		session.setAttribute("mid", m_id);
		out.write("<script language='javascript'>window.location.href='bookkeepingPages/money_show.jsp'; win.focus();</script>");
		out.flush();
		out.close();
		return null;
	}
	/**
	 * 单据红冲
	 * @param mapping
	 * @param form
	 * @param request
	 * @param response
	 * @return
	 * @throws IOException
	 */
	public ActionForward moneyHongChong(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response) throws IOException {
		//js乱码问题解决
		response.setContentType("text/html;UTF-8");
		response.setCharacterEncoding("UTF-8");
		
		PrintWriter out = response.getWriter();
		int m_id = Integer.parseInt(request.getParameter("m_id"));
		MoneyAddBean bean = new MoneyClassDA().showMoneyByM_id(m_id);
		new MoneyClassDA().moneyHongchong(m_id);
		new MoneyClassDA().addMoneyChong(bean);
		if(bean.getM_mbc_type() == 1){
			double b_amount = 0 - bean.getM_amount();
			new BankDA().updateBankMoney(bean.getM_b_id(), b_amount);
		}else{
			new BankDA().updateBankMoney(bean.getM_b_id(), bean.getM_amount());
		}
		out.write("<script language='javascript'>window.alert('单据红冲成功!');window.location.href='bookkeepingPages/money_find_frame.jsp';</script>");
		out.flush();
		out.close();
		return null;
	}
	/**
	 * money表清空
	 * @param mapping
	 * @param form
	 * @param request
	 * @param response
	 * @return
	 * @throws IOException
	 */
	public ActionForward moneyDel(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response) throws IOException {
		//js乱码问题解决
		response.setContentType("text/html;UTF-8");
		response.setCharacterEncoding("UTF-8");
		
		PrintWriter out = response.getWriter();
		new MoneyClassDA().moneyDel();
		out.write("<script language='javascript'>window.alert('单据清空成功!');window.location.href='bookkeepingPages/money_find_frame.jsp';</script>");
		out.flush();
		out.close();
		return null;
	}
	/**
	 * 红冲单据删除
	 * @param mapping
	 * @param form
	 * @param request
	 * @param response
	 * @return
	 * @throws IOException
	 */
	public ActionForward moneyHongChongDel(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response) throws IOException {
		//js乱码问题解决
		response.setContentType("text/html;UTF-8");
		response.setCharacterEncoding("UTF-8");
		
		PrintWriter out = response.getWriter();
		int m_id = Integer.parseInt(request.getParameter("mid"));
		new MoneyClassDA().moneyHongchongDel(m_id);
		out.write("<script language='javascript'>window.alert('删除成功!');window.location.href='bookkeepingPages/money_findhongchong_frame.jsp';</script>");
		out.flush();
		out.close();
		return null;
	}
}

⌨️ 快捷键说明

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