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

📄 outaction.java

📁 利用当前管理信息系统科学的、实用的理论
💻 JAVA
字号:
package com.haizi.struts.action;

import java.sql.Date;

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 com.haizi.struts.datebase.DBConnect;
import com.haizi.struts.formbean.OutForm;

public class OutAction {
	public ActionForward execute(
			ActionMapping mapping,
			ActionForm form,
			HttpServletRequest request,
			HttpServletResponse response) {

			int outno = ((OutForm) form).getOut_no();
			Date date = ((OutForm) form).getDate();
			String name = ((OutForm) form).getDraw_name();
			int spareno = ((OutForm) form).getSpare_no();
			String sparename = ((OutForm) form).getSpare_name();
			//float price= ((OutForm) form).getPrice();
			float quan = ((OutForm) form).getQuan();
			String units = ((OutForm) form).getUnits();
			String depname = ((OutForm)form).getDep_name();
			String person = ((OutForm)form).getPerson();
			int storeno = ((OutForm)form).getStore_no();
			String spec = ((OutForm)form).getSpare_spec();
			DBConnect dbc = null;
	        try{
	                dbc  = new DBConnect();
	                dbc.prepareStatement("INSERT INTO out_sto_info ( out_no,name,spare_no,spare_name,dep_name,quan,units,date,person,store_no,spare_spec ) VALUES ( ?,?,?,?,?,?,?,?,?,?,? )");
	                dbc.setInt(1,outno);
	                dbc.setString(2,name);
	                dbc.setInt(3,spareno);
	                dbc.setString(4,sparename);
	                dbc.setString(5,depname);
	                dbc.setFloat(6,quan);
	                dbc.setString(7,units);
	                dbc.setDate(8,date);
	                dbc.setString(9,person);
	                dbc.setInt(10,storeno);
	                dbc.setString(11,spec);
	                dbc.executeUpdate();

	        }catch(Exception e){
	                System.err.println(e);
	                return mapping.findForward("error") ;
	        } finally{
	            try{
	                dbc.close();
	        }catch(Exception e){
	                e.printStackTrace();
	                }
	        }
	        try{
                dbc  = new DBConnect();
                dbc.prepareStatement("update store_info set quan=quan-? where spare=? ");
                dbc.setFloat(1,quan);
                dbc.setInt(2,spareno);
                dbc.executeUpdate();

        }catch(Exception e){
                System.err.println(e);
                return mapping.findForward("error") ;
        }
        finally{
        try{
                dbc.close();
        }catch(Exception e){
                e.printStackTrace();
                }	        
        	}      
	        return mapping.findForward("out");
	}
}

⌨️ 快捷键说明

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