www.pudn.com > BeiJie.rar > UperBackServlet.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. 
*/ public void destroy() { super.destroy(); // Just puts "destroy" string in log // Put your code here } /** * The doGet method of the servlet.
* * 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.
* * 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(""); } else { if(c==0) { out.println(""); } else { int a=ubo.checkSum(EnterID, BackSum); //判断金额 if(a==-1) { out.println(""); } else { ubo.UperBackInsert(a, UperBackID, EnterID, BackQuantity, BackPrice, BackSum, BackDate, Chargeman, BackNotice,ProductID); out.println(""); } } ubo.close(); } } /** * Initialization of the servlet.
* * @throws ServletException if an error occure */ public void init() throws ServletException { // Put your code here } }