@RequestMapping(value = "/wfstepDelete", method = RequestMethod.GET)
  @RequestScoped
  public ModelAndView wfStepDelete(HttpServletRequest request, HttpServletResponse response) {
    response.setCharacterEncoding("UTF-8");
    String wfstepid = null;

    try {
      wfstepid = request.getParameter("wfstepidDelete");
      String msg = wfstepService.wfstepDelete(wfstepid);

      if (msg.equals("S")) {
        sess = request.getSession(false);
        Date date = new Date();
        String modifiedDate = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(date);
        auditLogService.setAuditLogSave(
            sess.getAttribute("userId").toString(),
            "D",
            "Process Step",
            "ROW",
            String.valueOf(wfstepid),
            "1",
            modifiedDate,
            sess.getAttribute("userName").toString());
        request.setAttribute("wfstepDeleteSuccess", "Work Flow Step has been deleted");
      } else {
        request.setAttribute("wfstepDeleteError", "Work Flow Step has not been deleted");
      }
    } catch (Exception e) {
      request.setAttribute("wfstepDeleteError", "Work Flow Step has not been deleted");
      e.printStackTrace();
    }
    return new ModelAndView("wfstepHome", "wfstepAdd", new WFStep());
  }
  @Override
  public String saveValuationCategoryDetails(Object object, String userId, String userName) {
    // TODO Auto-generated method stub

    try {
      Serializable id = getHibernateTemplate().save(object);
      if (id != null) {

        Date date = new Date();
        String modifiedDate = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(date);
        auditLogService.setAuditLogSave(
            userId,
            "A",
            "Valuatiion Category",
            "ROW",
            String.valueOf(id),
            "1",
            modifiedDate,
            userName);
        msg = "S";
      }

    } catch (Exception e) {
      msg = "F";
      e.printStackTrace();
    }

    return msg;
  }
  @RequestMapping(value = "/inspOperationAdd", method = RequestMethod.POST)
  public String saveInspOperation(
      @ModelAttribute("inspOperationCmd") InspOperationBean inspOperationBean,
      HttpServletRequest request,
      HttpServletResponse response) {
    String inspOperationSave = null;
    response.setCharacterEncoding("UTF-8");
    List<InspOperationStep> inspOperationStep = new ArrayList<InspOperationStep>();

    String stepNo[] = inspOperationBean.getInspOperStepNo();
    String sam[] = inspOperationBean.getNoOfSamples();

    InspOperationBean inspBean = (InspOperationBean) inspOperationBean;

    if (stepNo != null) {
      for (int m = 0; m < stepNo.length; m++) {
        InspOperationStep dnd = new InspOperationStep();
        dnd.setInspOperStepNo(stepNo[m]);
        dnd.setNoOfSamples(sam[m]);
        inspOperationStep.add(dnd);
      }
    }
    try {
      inspBean.setInspOprStep(inspOperationStep);
      flag = inspOperService.saveInspOperationDetails(inspBean);

      if (flag == true) {
        session = request.getSession(false);
        Date date = new Date();
        String modifiedDate = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(date);
        auditLogService.setAuditLogSave(
            session.getAttribute("userId").toString(),
            "A",
            "Inspection Operation",
            "ROW",
            String.valueOf(inspBean.getInspOperationId()),
            "1",
            modifiedDate,
            session.getAttribute("userName").toString());
        inspOperationSave = "Inspection Operation Data Saved Successfully";

      } else {
        inspOperationSave = "Inspection Operation Data Insertion Failures";
        return "redirect:inspOperationHome.mnt?addIOSFail=" + inspOperationSave + "";
      }

    } catch (Exception e) {
      e.printStackTrace();
    }

    return "redirect:inspOperationHome.mnt?addIOSsus=" + inspOperationSave + "";
  }
  @Override
  public String saveSalesAreaDetails(Object object, String userId, String userName) {

    try {
      SalesAreaBean salesBean = (SalesAreaBean) object;
      id = getHibernateTemplate().save(salesBean);
      if (id != null) {
        Date date = new Date();
        String modifiedDate = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(date);
        auditLogService.setAuditLogSave(
            userId, "A", "SalesOrg", "ROW", String.valueOf(id), "1", modifiedDate, userName);
      }

    } catch (Exception e) {
      e.printStackTrace();
      return "F";
    }
    return "S";
  }
  @RequestMapping(value = "/inspOperationDelete", method = RequestMethod.GET)
  public String inspOperationDelete(
      @ModelAttribute("inspOperationCmd") InspOperationBean inspOperationBeanDelete,
      Model model,
      HttpServletRequest request,
      HttpServletResponse response) {

    response.setCharacterEncoding("UTF-8");
    String IOSDelete = null;
    int dId = Integer.parseInt(request.getParameter("inspOperationId"));

    try {
      flag = inspOperService.deleteInspOperation(dId);

      if (flag == true) {
        session = request.getSession(false);
        Date date = new Date();
        String modifiedDate = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(date);
        auditLogService.setAuditLogSave(
            session.getAttribute("userId").toString(),
            "D",
            "Inspection Operation",
            "ROW",
            String.valueOf(dId),
            "1",
            modifiedDate,
            session.getAttribute("userName").toString());
        IOSDelete = "Inspection Operation Deleted Successfully";

      } else {
        IOSDelete = "Inspection Operation Deletion Failed due to Conatraint Violation";
        return "redirect:inspOperationHome.mnt?DeleteIOSFail=" + IOSDelete + "";
      }

    } catch (Exception e) {
      e.printStackTrace();
    }
    return "redirect:inspOperationHome.mnt?DeleteIOSsus=" + IOSDelete + "";
  }
  /*
   * =================================Delete
   * Method=======================================
   */
  @RequestMapping(value = "/vendorReturnIdDelete", method = RequestMethod.GET)
  public String vendorReturnDelete(
      @ModelAttribute("vendorReturnCommand") VendorReturn vendorReturnDelete,
      Model model,
      HttpServletRequest request,
      HttpServletResponse response) {
    response.setCharacterEncoding("UTF-8");
    List<String> list = new ArrayList<String>();

    String vendorReturnUpdate = null;
    int id = Integer.parseInt(request.getParameter("vendorReturnId"));

    try {
      String msg = vrService.deleteVendorReturn(id);
      if (msg.equals("Deleted")) {
        session = request.getSession(false);
        Date dates = new Date();
        String modifiedDate = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(dates);
        auditLogService.setAuditLogSave(
            session.getAttribute("userId").toString(),
            "D",
            "Vendor Returns",
            "ROW",
            String.valueOf(id),
            "1",
            modifiedDate,
            session.getAttribute("userName").toString());
        vendorReturnUpdate = "Vendor Return Details Deleted Successfully";
        list.add("2");
      } else {
        vendorReturnUpdate = "Deletion Failed Due to Constraint Violation";
        return "redirect:VendorReturn.mnt?deleteFail=" + vendorReturnUpdate + "";
      }

    } catch (Exception e) {
      e.printStackTrace();
    }
    return "redirect:VendorReturn.mnt?deleteSuccess=" + vendorReturnUpdate + "";
  }
  @RequestMapping(value = "/applicantDelete", method = RequestMethod.GET)
  public String deleteApplicant(
      @ModelAttribute("applicant") ApplicantBean applicant,
      Model model,
      HttpServletRequest request,
      HttpServletResponse response) {
    String msg = null;
    int id = 0;
    HttpSession session = null;
    try {

      response.setCharacterEncoding("UTF-8");
      id = Integer.parseInt(request.getParameter("applicantCodeDelete"));
      msg = appService.deleteApplicant(id);
      if (msg.equals("S")) {
        session = request.getSession(false);
        Date date = new Date();
        String modifiedDate = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(date);
        auditLogService.setAuditLogSave(
            session.getAttribute("userId").toString(),
            "D",
            "Applicant",
            "ROW",
            String.valueOf(id),
            "1",
            modifiedDate,
            session.getAttribute("userName").toString());

        request.setAttribute("applicantDelete", "Applicant Data is deleted Successfully");
      } else {
        request.setAttribute("applicantDeleteError", "Applicant Data  is not deleted properly ");
      }
    } catch (Exception e) {
      e.printStackTrace();
    }
    model.addAttribute("applicant", new ApplicantBean());
    return "applicantHome";
  }
  /* ================================Add Method========================== */
  @RequestMapping(value = "/vendorReturn", method = RequestMethod.GET)
  public String addVendorReturn(
      @ModelAttribute("vendorReturnCommand") VendorReturn vendorReturnAdd,
      HttpServletRequest request,
      HttpServletResponse response,
      Model model) {

    response.setCharacterEncoding("UTF-8");
    List<String> list = new ArrayList<String>();
    VendorReturnLine vrLine = null;
    List<VendorReturnLine> vrLines = null;
    String vrAddSus = null;
    String msg = null;

    String checkVrNo = vendorReturnAdd.getVendorReturnNo();
    int list1 = vrService.checkDuplicate(checkVrNo);
    if (list1 == 0) {

      try {

        vrLines = new ArrayList<VendorReturnLine>();

        String material = vendorReturnAdd.getmId();
        String[] bNo = vendorReturnAdd.getBatchNo();
        List<String> mlist = Arrays.asList(material.split(","));
        Object[] materialiid = mlist.toArray();

        Integer[] quantity = vendorReturnAdd.getQuantity();
        String unit = vendorReturnAdd.getUomm();
        List<String> uomlist = Arrays.asList(unit.split(","));
        Object[] uomid = uomlist.toArray();

        float[] price = vendorReturnAdd.getPrice();

        String rfr = vendorReturnAdd.getRfrId();
        List<String> rfrlist = Arrays.asList(rfr.split(","));
        Object[] rfrid = rfrlist.toArray();

        String storage = vendorReturnAdd.getStLId();
        List<String> storagelist = Arrays.asList(storage.split(","));
        Object[] storageid = storagelist.toArray();

        for (int i = 0; i < quantity.length; i++) {
          vrLine = new VendorReturnLine();
          vrLine.setMaterial_Id(materialiid[i].toString());
          vrLine.setQuantity(quantity[i]);
          vrLine.setUom_Id(uomid[i].toString());
          vrLine.setPrice(price[i]);
          vrLine.setReasonForRejectionId(rfrid[i].toString());
          vrLine.setStorageLocationId(storageid[i].toString());
          vrLine.setBatchNo(bNo[i]);
          vrLines.add(vrLine);

          float enteredQty = vrLine.getQuantity();
          int materialid = Integer.parseInt(vrLine.getMaterial_Id());
          float materialStock;
          materialStock = materialService.materialStockGet(materialid);
          float updatedStock = 0;
          updatedStock = materialStock - enteredQty;
          // msg =
          // materialService.materialStockUpdate(materialid,updatedStock);
          // Update Goods Receipt Line Returns Qty
          vrService.updateGRLQtyReturns(
              Integer.parseInt(vendorReturnAdd.getGoodsReceiptId()),
              materialiid[i].toString(),
              String.valueOf(bNo[i]),
              quantity[i].floatValue());
        }
        vendorReturnAdd.setVendorReturnDate(
            dateService.dateFormat(
                dateService.dateParse(vendorReturnAdd.getVendorReturnDate(), "au"), "au"));
        vendorReturnAdd.setVendorReturnLine(vrLines);
        msg = vrService.addVendorReturn(vendorReturnAdd);
        request.setAttribute("addVendorReturn", "Vendor Return Details Successfully Saved");
      } catch (Exception e) {
        e.printStackTrace();
      }

      if (msg.equals("S")) {
        session = request.getSession(false);
        Date dates = new Date();
        String modifiedDate = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(dates);
        auditLogService.setAuditLogSave(
            session.getAttribute("userId").toString(),
            "A",
            "Vendor Returns",
            "ROW",
            String.valueOf(vendorReturnAdd.getVendorReturnId()),
            "1",
            modifiedDate,
            session.getAttribute("userName").toString());
        vrAddSus = "Vendor Return Details Successfully Saved";
        list.add("2");
      }
      model.addAttribute("vendorReturnCommand", new VendorReturn());

      return "redirect:VendorReturn.mnt?Addsuccess=" + vrAddSus + "";

    } else {
      vendorReturnAdd.setAid(1);

      request.setAttribute(
          "addVendorReturnDuplicate", "Vendor Return No Already Exists Choose Another One");
      return "redirect:VendorReturn.mnt?AddFail=" + vrAddSus + "";
    }
  }