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

📄 uperbackservlet.java

📁 该源代码实现了系统的进货
💻 JAVA
字号:
package EnterServlet;

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

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

import operation.UperBackOperation;


public class UperBackServlet extends HttpServlet
{
	public final static String jdkDateFormat="yyyy-MM-dd";
	/**
	 * Constructor of the object.
	 */
	public UperBackServlet()
	{
		super();
	}

	/**
	 * Destruction of the servlet. <br>
	 */
	public void destroy()
	{
		super.destroy(); // Just puts "destroy" string in log
		// Put your code here
	}

	/**
	 * The doGet method of the servlet. <br>
	 *
	 * This method is called when a form has its tag value method equals to get.
	 * 
	 * @param request the request send by the client to the server
	 * @param response the response send by the server to the client
	 * @throws ServletException if an error occurred
	 * @throws IOException if an error occurred
	 */
	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException
	{

		response.setContentType("text/html");
		PrintWriter out = response.getWriter();
		out.close();
	}

	/**
	 * The doPost method of the servlet. <br>
	 *
	 * This method is called when a form has its tag value method equals to post.
	 * 
	 * @param request the request send by the client to the server
	 * @param response the response send by the server to the client
	 * @throws ServletException if an error occurred
	 * @throws IOException if an error occurred
	 */
	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException
	{

		request.setCharacterEncoding("GB2312");
		response.setContentType("text/html;charset=gb2312");
		PrintWriter out=response.getWriter();
		UperBackOperation ubo=new UperBackOperation();
		
		
		//得到系统时间
		Date date=new Date();
		java.sql.Date sqldate = null;
		SimpleDateFormat dateFormat=new SimpleDateFormat(jdkDateFormat);
		try
		{
			 sqldate=new java.sql.Date(date.getTime());
		}
		catch(Exception e)
		{
			e.printStackTrace();
		}
		
		String UperBackID=ubo.getUperBackID();                                                     //得到退货编号
		String EnterID=request.getParameter("EnterID");                                            //得到进货编号
		int BackQuantity=Integer.parseInt(request.getParameter("BackQuantity"));                   //得到进货数量
		String BackNotice=request.getParameter("BackNotice");                                      //得到进货备注
		HttpSession session=request.getSession();
		String Chargeman=(String)session.getAttribute("userID");                          //得到经手人   
		java.sql.Date BackDate=sqldate;                                                            //得到退货日期
		
		
		
		float BackPrice=ubo.getPrice(EnterID);                                                     //得到退货价格
		float BackSum=BackPrice*BackQuantity;                                                      //得到退货总金额
		String ProductID=ubo.getProductID(EnterID);                                                //得到产品编号
		
		int b=ubo.checkEnterQuantity(EnterID, BackQuantity);  
		int c=ubo.checkProductQuantity(ProductID, BackQuantity);
		if(b==0)
		{
			out.println("<script> alert('退货数量大于进货数量,请核对后再输!');window.location.href='entercheck.jsp';</script>");
		}
		else 
		{
		  if(c==0)
		  {
			  out.println("<script> alert('库存量不够退货数量,请核对后再输!');window.location.href='entercheck.jsp';</script>");
		  }
		  else
		  {
		   int a=ubo.checkSum(EnterID, BackSum);   //判断金额
		   if(a==-1)
		   {
			out.println("<script> alert('退货金额大于应付金额,请核对后重输!');window.location.href='entercheck.jsp';</script>");
		   }
		   else 
		   {
		    ubo.UperBackInsert(a, UperBackID, EnterID, BackQuantity, BackPrice, BackSum, BackDate, Chargeman, BackNotice,ProductID);
		    out.println("<script> alert('退货成功!');window.location.href='entercheck.jsp';</script>");
		   }
		}
		ubo.close();
		}
	}

	/**
	 * Initialization of the servlet. <br>
	 *
	 * @throws ServletException if an error occure
	 */
	public void init() throws ServletException
	{
		// Put your code here
	}

}

⌨️ 快捷键说明

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