用户注册



邮箱:

密码:

用户登录


邮箱:

密码:
记住登录一个月忘记密码?

发表随想


还能输入:200字
云代码 - jsp代码库

【CSMS源码】服装库存管理系统源码(jsp+servlet+dao版)

2013-07-11 作者: 小蜜锋举报

[jsp]代码库

package com.csms.action.servlet;

import java.io.IOException;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

import javax.servlet.RequestDispatcher;
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 com.csms.action.vo.OrderInVo;
import com.csms.action.vo.WarehouseVo;
import com.csms.service.inter.OrderInDtlService;
import com.csms.service.inter.OrderInService;
import com.csms.service.inter.WarehouseService;
import com.csms.service.interImpl.ServiceFactory;

public class OrderInServlet extends HttpServlet {
	ServiceFactory serviceFactory = new ServiceFactory();
	OrderInService orderInService = serviceFactory.getOrderInService();
	OrderInDtlService orderInDtlService = serviceFactory.getOrderInDtlService();
	WarehouseService warehouseService = serviceFactory.getWarehouseService();

	/**
	 * Constructor of the object.
	 */
	public OrderInServlet() {
		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;charset=utf-8");
		request.setCharacterEncoding("utf-8");
		String opt = request.getParameter("opt");
		if ("query".equals(opt)) {
			try {
				doQuery(request, response, "");
			} catch (SQLException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			} catch (ClassNotFoundException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
		if ("addBind".equals(opt)) {
			try {
				doAddBind(request, response);
			} catch (SQLException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			} catch (ClassNotFoundException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
		if ("add".equals(opt)) {
			try {
				doAdd(request, response);
			} catch (SQLException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			} catch (ClassNotFoundException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
		if ("del".equals(opt)) {
			try {
				doDel(request, response);
			} catch (SQLException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			} catch (ClassNotFoundException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
		if ("update".equals(opt)) {
			try {
				doUpdate(request, response);
			} catch (SQLException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			} catch (ClassNotFoundException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
		if ("queryForUpdate".equals(opt)) {
			try {
				doQueryForUpdate(request, response);
			} catch (SQLException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			} catch (ClassNotFoundException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
		if ("submit".equals(opt)) {
			try {
				doSubmit(request, response);
			} catch (SQLException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			} catch (ClassNotFoundException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
	}

	/**
	 * 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 {
		doGet(request, response);
	}

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

	public void doQuery(HttpServletRequest request,
			HttpServletResponse response, String msg) throws ServletException,
			IOException, ClassNotFoundException, SQLException {
		String orderInNum = request.getParameter("query_txt_orderInNum");
		String warehouseNum = request.getParameter("query_txt_warehouse");
		String startDate = request.getParameter("query_txt_startDate");
		String endDate = request.getParameter("query_txt_endDate");
		StringBuffer sqlStr = new StringBuffer();
		if (orderInNum != "" && orderInNum != null) {
			sqlStr.append(" and orderInNum='" + orderInNum + "' ");
		}
		if (warehouseNum != "" && warehouseNum != null) {
			sqlStr.append(" and orderin.warehouseNum='" + warehouseNum + "' ");
		}
		if ((startDate != "" && startDate != null)
				&& (endDate != "" && endDate != null)) {
			sqlStr.append(" and inDate between '" + startDate + "' and '"
					+ endDate + "'");
		}
		List<WarehouseVo> warehouseVoList = new ArrayList<WarehouseVo>();
		warehouseVoList = warehouseService.query(" flag=0 ");
		request.setAttribute("warehouseVoList", warehouseVoList);
		ResultSet rs = orderInService.query(" orderIn.flag in (0,2) "
				+ sqlStr.toString());
		request.setAttribute("rs", rs);
		RequestDispatcher rd = request
				.getRequestDispatcher("/stock/order2001.jsp?msg=" + msg);
		rd.forward(request, response);
	}

	public void doAddBind(HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException,
			ClassNotFoundException, SQLException {
		List<WarehouseVo> warehouseVoList = new ArrayList<WarehouseVo>();
		warehouseVoList = warehouseService.query(" flag=0 ");
		request.setAttribute("warehouseVoList", warehouseVoList);
		RequestDispatcher rd = request
				.getRequestDispatcher("/stock/order2002.jsp?opt=add");
		rd.forward(request, response);
	}

	public void doAdd(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException, ClassNotFoundException,
			SQLException {
		boolean flag = true;
		String msg = "";
		String orderInNum = request.getParameter("txt_orderInNum");
		String inDate = request.getParameter("txt_inDate");
		String warehouseNum = request.getParameter("txt_warehouseNum");
		String befrom = request.getParameter("txt_befrom");
		String note = request.getParameter("txt_note");
		ResultSet rs = orderInService.query("");
		while (rs.next()) {
			if (orderInNum.equals(rs.getString("orderInNum"))) {
				flag = false;
				msg = "新增失败,该入库单号在数据库中已经存在!";
			}
		}
		if (flag) {
			OrderInVo orderInVo = new OrderInVo();
			orderInVo.setBefrom(befrom);
			orderInVo.setFlag(0);
			orderInVo.setInDate(inDate);
			orderInVo.setNote(note);
			orderInVo.setOrderInNum(orderInNum);
			HttpSession session = request.getSession();
			String person = (String) session.getAttribute("userLogin");
			orderInVo.setPerson(person);
			orderInVo.setWarehouseNum(warehouseNum);
			orderInService.addOrderIn(orderInVo);
		}
		doQuery(request, response, msg);
	}

	public void doQueryForUpdate(HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException,
			ClassNotFoundException, SQLException {
		String orderInNum = request.getParameter("hd_orderInNum");
		int flag = orderInService.getFlag(orderInNum);
		String msg = "";
		if (flag == 2) {
			msg = "该入库单已确认,不能修改";
			doQuery(request, response, msg);
		} else {
			HttpSession session = request.getSession();
			session.setAttribute("orderInNum", orderInNum);
			List<WarehouseVo> warehouseVoList = new ArrayList<WarehouseVo>();
			warehouseVoList = warehouseService.query(" flag=0 ");
			request.setAttribute("warehouseVoList", warehouseVoList);
			ResultSet rs = orderInService
					.query(" orderIn.flag in (0,2) and orderInNum='"
							+ orderInNum + "'");
			request.setAttribute("rs", rs);
			ResultSet orderInDtlRs = orderInDtlService
					.query(" orderindtl.flag=0 and orderindtl.orderInNum='"
							+ orderInNum + "' ");
			request.setAttribute("orderInDtlRs", orderInDtlRs);
			RequestDispatcher rd = request
					.getRequestDispatcher("/stock/order2002.jsp?opt=update&orderInNum="
							+ orderInNum);
			rd.forward(request, response);
		}
	}

	public void doDel(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException, ClassNotFoundException,
			SQLException {
		String orderInNum = request.getParameter("hd_orderInNum");
		int flag = orderInService.getFlag(orderInNum);
		String msg = "";
		if (flag == 2) {
			msg = "该入库单已确认,不能删除";
		} else {
			orderInService.delOrderIn(orderInNum);
			msg = "删除成功";
		}
		doQuery(request, response, msg);
	}

	public void doUpdate(HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException,
			ClassNotFoundException, SQLException {
		String orderInNum = request.getParameter("txt_orderInNum");
		String inDate = request.getParameter("txt_inDate");
		String warehouseNum = request.getParameter("txt_warehouseNum");
		String befrom = request.getParameter("txt_befrom");
		String note = request.getParameter("txt_note");
		OrderInVo orderInVo = new OrderInVo();
		orderInVo.setBefrom(befrom);
		orderInVo.setFlag(0);
		orderInVo.setInDate(inDate);
		orderInVo.setNote(note);
		orderInVo.setOrderInNum(orderInNum);
		HttpSession session = request.getSession();
		String person = (String) session.getAttribute("userLogin");
		orderInVo.setPerson(person);
		orderInVo.setWarehouseNum(warehouseNum);
		orderInService.updateOrderIn(orderInVo);
		doQuery(request, response, "修改成功!");
	}

	public void doSubmit(HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException,
			ClassNotFoundException, SQLException {
		String orderInNum = request.getParameter("txt_orderInNum");
		orderInService.submitOrderIn(orderInNum);
		doQuery(request, response, "");
	}
}

[代码运行效果截图]


【CSMS源码】服装库存管理系统源码(jsp+servlet+dao版)

[源代码打包下载]




网友评论    (发表评论)

共12 条评论 1/1页

发表评论:

评论须知:

  • 1、评论每次加2分,每天上限为30;
  • 2、请文明用语,共同创建干净的技术交流环境;
  • 3、若被发现提交非法信息,评论将会被删除,并且给予扣分处理,严重者给予封号处理;
  • 4、请勿发布广告信息或其他无关评论,否则将会删除评论并扣分,严重者给予封号处理。


扫码下载

加载中,请稍后...

输入口令后可复制整站源码

加载中,请稍后...