public void create(HttpServletRequest request, HttpServletResponse response) throws Exception { // HttpSession session = request.getSession(); // UserSession us = (UserSession)session.getValue(Constants.USER_SESSION); pre(request, response); Stockout so = new Stockout(this.db); String job_no = so.genJobNo(String.valueOf(offcode)); so.setJob_no(job_no); so.setOffName(offname); so.setStockout_date(new Date()); so.setTransfer_by(uData.getIdCard()); request.setAttribute("so", so); request.setAttribute("staff_name2", uData.getFullName()); this.tranLogSave(TRAN_LOG_MSG_CREATE); forward(JSP_FORM_PAGE, request, response); }
/** * Business Logic for get data from request to model * * @param request * @param stock_out */ protected boolean processUpdate(HttpServletRequest request) { Long id = ServletRequestUtils.getLongParameter(request, "id", -1); // String job_no = ServletRequestUtils.getStringParameter(request, "job_no", ""); String stockout_code1 = ServletRequestUtils.getStringParameter(request, "stockout_code1", ""); String stockout_code2 = ServletRequestUtils.getStringParameter(request, "stockout_code2", ""); String stockout_date = ServletRequestUtils.getStringParameter(request, "stockout_date", ""); String subject = ServletRequestUtils.getStringParameter(request, "subject", ""); String subject_type = ServletRequestUtils.getStringParameter(request, "subject_type", ""); String report_to_staff = ServletRequestUtils.getStringParameter(request, "report_to_staff", ""); String report_to_posname = ServletRequestUtils.getStringParameter(request, "report_to_posname", ""); String offcode_to = ServletRequestUtils.getStringParameter(request, "offcode_to", ""); String transfer_by = ServletRequestUtils.getStringParameter(request, "transfer_by", ""); Long legislation_id = ServletRequestUtils.getLongParameter(request, "legislation_id", -1); String remarks = ServletRequestUtils.getStringParameter(request, "remarks", ""); String group_id = ServletRequestUtils.getStringParameter(request, "product_group_id", ""); Stockout stock_out = new Stockout(this.db); boolean id_exist = false; if (id != -1) { // if id not equals -1 then process update try { stock_out = stock_out.findByPk(id); id_exist = true; } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); log.error("Fail on Load Stockout:" + e.getMessage()); } } // stock_out.setJob_no(job_no); stock_out.setStockout_code(stockout_code1 + "/" + stockout_code2); stock_out.setStockout_date(DateUtil.getDateFromString(stockout_date)); stock_out.setSubject(subject); stock_out.setSubject_type(subject_type); if (legislation_id != -1) stock_out.setLegislation_id(legislation_id); stock_out.setReport_to_staff(report_to_staff); stock_out.setReport_to_posname(report_to_posname); if (!"".equals(offcode_to)) stock_out.setOffcode_to(offcode_to); if (!"".equals(transfer_by)) stock_out.setTransfer_by(transfer_by); stock_out.setRemarks(remarks); // set optional field stock_out.setStockout_type("5"); stock_out.setGroup_id(group_id); if (id_exist) { try { stock_out.setUpdate_by(update_by); stock_out.setUpdate_on(update_on); stock_out = stock_out.update(); updateChildExhibit(request, stock_out); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); log.error("Fail on Update Stockout:" + e.getMessage()); } } else { try { stock_out.setJob_no( new RunningKey(db).getRunningKey("STOCKOUT", "STOCKOUT_TYPE", "5", offcode)); stock_out.setCreate_by(create_by); stock_out.setCreate_on(create_on); stock_out.setOffcode(offcode); stock_out = stock_out.create(); updateChildExhibit(request, stock_out); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); log.error("Fail on Create Stockout:" + e.getMessage()); } } re_id = (stock_out.getId() == null) ? -1 : stock_out.getId(); return id_exist; }