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

📄 appbuy.java

📁 仓库管理系统,适合各种行业的仓库管理系统
💻 JAVA
字号:
package com.produce.action;

import java.io.IOException;
import java.sql.Connection;
import java.sql.SQLException;

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

import com.bean.DAO.AppbuyDAO;
import com.bean.DTO.AppbuyDTO;
import com.bean.DTO.UserinforDTO;
import com.database.DataSourceFactory;
import com.servlet.AbstractAction;

public class AppBuy extends AbstractAction {

	@Override
	public String process(HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException {
	      String redirect="/shengchanguanli/error.jsp";
	      String error=null;
		  try {
			 
			
			  Connection con=DataSourceFactory.getDataSource().getConnection();
			  String projID=request.getParameter("projectID");
		    String proID=request.getParameter("productID");
		    String check=request.getParameter("check");
		    String appID=request.getParameter("appID");
		    String amount=request.getParameter("amount");
		    String checkamt=request.getParameter("checkamt");
		    String apptime=request.getParameter("appbuytime");
		    
		    
		    if(proID!=null&&check!=null&&appID!=null
		    		&&check.equalsIgnoreCase(proID)
		    		&&amount.equalsIgnoreCase(checkamt)){
		    	int productID=Integer.parseInt(proID);
		    	int projectID=Integer.parseInt(projID);
		    	int buyamount=Integer.parseInt(amount);
		    	int applicantID=Integer.parseInt(appID);
		    	int aID=((UserinforDTO)request.getSession().getAttribute("userinfor")).getUserID();
		    	AppbuyDAO dao=new AppbuyDAO(con);
		    	if(applicantID==aID){
		    	
		    		if(dao.isHave(projectID, productID)){
		    	AppbuyDTO dto=new AppbuyDTO();
		    	dto.setProjectID(projectID);
		    	dto.setProductID(productID);
		    	dto.setApplicantID(applicantID);
		    	dto.setBuyamount(buyamount);
		    	dto.setApptime(apptime);
		    	
		    	
		    	dao.addBuy(dto);
		    	error="提交成功";
		    		}
		    		else{
		    			error="失败,该货品重复提交";
		    		}
		    	}else{
		    		error="你填写的ID与你登录的ID不一致,无权填写";
		    	}
		    	
		    }
		    con.close();
		  }catch (NumberFormatException e) {
				// TODO Auto-generated catch block
				error="输入了非法的数据,请正确填写";
				
			} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace(); 
		}finally{
			     request.setAttribute("error",error);
			     redirect="/shengchanguanli/appbuy.jsp";
		}
	      return redirect;
	}

}

⌨️ 快捷键说明

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