예제 #1
0
  public void performTask(HttpServletRequest request, HttpServletResponse response) {
    java.sql.Connection con = null;
    HttpSession ses_usr = null;
    BeanUtil bu = null;
    RequestDispatcher dispatcher = null;
    String strAddress = null;
    try {
      ses_usr = request.getSession(false);
      bu = new BeanUtil();
      con = bu.getConn();
      bu.setSession(ses_usr);
      if (!bu.getSessionValues())
        throw new Exception(
            "Por motivos de seguridad la sesi\363n ha expirado\n Registrese nuevamente");
      int accion = 1;
      BeanHelper53 hlp53 = new BeanHelper53();
      dbPROVEEDOR proveedor = new dbPROVEEDOR();
      dbPROVEEDORs proveedores = new dbPROVEEDORs();
      proveedor.setConnection(con);
      proveedores.setConnection(con);
      if (request.getParameter("accion") != null)
        accion = (new Integer(request.getParameter("accion"))).intValue();
      int iidproveedor = 0;
      if (request.getParameter("iidproveedor") != null
          && !request.getParameter("iidproveedor").equals(""))
        iidproveedor = (new Integer(request.getParameter("iidproveedor"))).intValue();
      int iidcategoria = 0;
      if (request.getParameter("iidcategoria") != null
          && !request.getParameter("iidcategoria").equals(""))
        iidcategoria = (new Integer(request.getParameter("iidcategoria"))).intValue();
      int iidgrupo = 0;
      if (request.getParameter("iidgrupo") != null && !request.getParameter("iidgrupo").equals(""))
        iidgrupo = (new Integer(request.getParameter("iidgrupo"))).intValue();
      int iidlinea = 0;
      if (request.getParameter("iidlinea") != null && !request.getParameter("iidlinea").equals(""))
        iidlinea = (new Integer(request.getParameter("iidlinea"))).intValue();
      int iidmarca = 0;
      if (request.getParameter("iidmarca") != null && !request.getParameter("iidmarca").equals(""))
        iidmarca = (new Integer(request.getParameter("iidmarca"))).intValue();
      switch (accion) {
        case 1: // '\001'
          {
            hlp53.getData(con);
            ses_usr.setAttribute("bean53", hlp53.getBean53());
            strAddress = "/jsp/5_3a.jsp";
            break;
          }

        case 3: // '\003'
          {
            dbCLASIFICPROVEEDOR dbCP = new dbCLASIFICPROVEEDOR();
            dbPARTEs partes = new dbPARTEs();
            dbINVENTARIO inventario = new dbINVENTARIO();
            dbCP.setConnection(con);
            partes.setConnection(con);
            inventario.setConnection(con);
            Bean52 bean52 = (Bean52) ses_usr.getAttribute("bean52a");
            for (int i = 0; i < bean52.getProveedoresSize(); i++) {

              if (request.getParameter("C" + bean52.getId(i)) != null) {

                dbCP.setIidproveedor(bean52.getId(i));
                dbCP.setIidcategoria(iidcategoria);
                dbCP.setIidgrupo(iidgrupo);
                dbCP.setIidlinea(iidlinea);
                dbCP.setIidmarca(iidmarca);
                dbCP.create();
                String vchnumparte = Help.getVchnumparte(null, null, null, null);
                partes.findByPar(iidcategoria, iidgrupo, iidlinea, iidmarca, vchnumparte, false);
                Vector v = partes.getResult();
                for (int j = 0; j < v.size(); j++) {
                  dbPARTE parte = (dbPARTE) v.elementAt(j);
                  inventario.setLiidparte(parte.getLiidparte());
                  inventario.setIidproveedor(bean52.getId(i));
                  try {
                    inventario.create();
                  } catch (Exception exception) {
                  }
                }
              }
            }

            // fall through
          }

        case 2: // '\002'
          {
            Bean52 bean52 = new Bean52();
            Bean52 bean = new Bean52();
            bean52.setVProveedores(
                proveedores.findByClasificacion(iidcategoria, iidgrupo, iidlinea, iidmarca));
            proveedores.findByNotClasificacion(iidcategoria, iidgrupo, iidlinea, iidmarca);
            bean.setVProveedores(proveedores.getResult());
            ses_usr.setAttribute("bean52", bean52);
            ses_usr.setAttribute("bean52a", bean);
            strAddress = "/jsp/5_3b.jsp";
            break;
          }

        case 5: // '\005'
          {
            dbCLASIFICPROVEEDOR dbCP = new dbCLASIFICPROVEEDOR();
            dbPARTEs partes = new dbPARTEs();
            dbINVENTARIO inventario = new dbINVENTARIO();
            dbCP.setConnection(con);
            partes.setConnection(con);
            inventario.setConnection(con);
            Bean52 bean52 = (Bean52) ses_usr.getAttribute("bean52");
            for (int i = 0; i < bean52.getProveedoresSize(); i++)
              if (request.getParameter("C" + bean52.getId(i)) != null) {
                dbCP.setIidproveedor(bean52.getId(i));
                dbCP.setIidcategoria(iidcategoria);
                dbCP.setIidgrupo(iidgrupo);
                dbCP.setIidlinea(iidlinea);
                dbCP.setIidmarca(iidmarca);
                dbCP.remove();
                String vchnumparte = Help.getVchnumparte(null, null, null, null);
                partes.findByPar(iidcategoria, iidgrupo, iidlinea, iidmarca, vchnumparte, false);
                Vector v = partes.getResult();
                for (int j = 0; j < v.size(); j++) {
                  dbPARTE parte = (dbPARTE) v.elementAt(j);
                  inventario.setLiidparte(parte.getLiidparte());
                  inventario.setIidproveedor(bean52.getId(i));
                  try {
                    inventario.load();
                  } catch (Exception exception1) {
                  }
                  if (inventario.getIexistencia() == 0)
                    try {
                      inventario.remove();
                    } catch (Exception exception2) {
                    }
                }
              }

            // fall through
          }

        case 4: // '\004'
          {
            Bean52 bean52 = new Bean52();
            bean52.setVProveedores(
                proveedores.findByClasificacion(iidcategoria, iidgrupo, iidlinea, iidmarca));
            ses_usr.setAttribute("bean52", bean52);
            strAddress = "/jsp/5_3c.jsp";
            break;
          }

        case 7: // '\007'
          {
            dbCLASIFICPROVEEDOR dbCP = new dbCLASIFICPROVEEDOR();
            dbCP.setConnection(con);
            Bean53d bean53d = (Bean53d) ses_usr.getAttribute("bean53d");
            for (int i = 0; i < bean53d.getProveedoresSize(); i++) {
              dbCP.setIidproveedor(bean53d.getId(i));
              dbCP.setIidcategoria(iidcategoria);
              dbCP.setIidgrupo(iidgrupo);
              dbCP.setIidlinea(iidlinea);
              dbCP.setIidmarca(iidmarca);
              dbCP.setBitprovefavorito(false);
              if (iidproveedor == bean53d.getId(i)) dbCP.setBitprovefavorito(true);
              dbCP.store();
            }

            // fall through
          }

        case 6: // '\006'
          {
            Bean53d bean53d = new Bean53d();
            dbrCLASIFICPROVEEDORs cp = new dbrCLASIFICPROVEEDORs();
            cp.setConnection(con);
            bean53d.setVProveedores(
                cp.findByClasificacion(iidcategoria, iidgrupo, iidlinea, iidmarca));
            ses_usr.setAttribute("bean53d", bean53d);
            strAddress = "/jsp/5_3d.jsp";
            break;
          }
      }
    } catch (Throwable e) {
      bu.setCommit(false);
      e.printStackTrace();
      BeanError error = new BeanError();
      error.setErrorMessage(e.getMessage());
      request.setAttribute("error", error);
      strAddress = "/jsp/error.jsp";
    } finally {
      try {
        bu.finalizeTransaction(con);
        dispatcher = getServletContext().getRequestDispatcher(strAddress);
        dispatcher.forward(request, response);
      } catch (Exception ex) {
        System.out.println("FATAL:" + ex.getMessage());
      }
    }
  }
예제 #2
0
  public void performTask(HttpServletRequest request, HttpServletResponse response) {
    java.sql.Connection con = null;
    HttpSession ses_usr = null;
    BeanUtil bu = null;
    RequestDispatcher dispatcher = null;
    String strAddress = null;
    try {
      ses_usr = request.getSession(false);
      bu = new BeanUtil();
      con = bu.getConn();
      bu.setSession(ses_usr);
      if (!bu.getSessionValues())
        throw new Exception(
            "Por motivos de seguridad la sesi\363n ha expirado\n Registrese nuevamente");
      int accion = 1;
      dbDESCCARGOSCOMPRA dbDCC = new dbDESCCARGOSCOMPRA();
      dbDCC.setConnection(con);
      dbDESCCARGOSCOMPRAs dbDCCs = new dbDESCCARGOSCOMPRAs();
      dbDCCs.setConnection(con);
      dbPROVEEDORs proveedores = new dbPROVEEDORs();
      proveedores.setConnection(con);
      if (request.getParameter("accion") != null)
        accion = (new Integer(request.getParameter("accion"))).intValue();
      String vchdescripcion = request.getParameter("vchdescripcion");
      String vchleyenda = request.getParameter("vchleyenda");
      float decfactor = 1.0F;
      float porcentaje = 0.0F;
      if (request.getParameter("porcentaje") != null
          && !request.getParameter("porcentaje").equals("")) {
        porcentaje = (new Float(request.getParameter("porcentaje"))).floatValue();
        decfactor = 1.0F - porcentaje / 100F;
      }
      int iidproveedor = 0;
      if (request.getParameter("iidproveedor") != null
          && !request.getParameter("iidproveedor").equals(""))
        iidproveedor = (new Integer(request.getParameter("iidproveedor"))).intValue();
      int iidcategoria = 0;
      if (request.getParameter("iidcategoria") != null
          && !request.getParameter("iidcategoria").equals(""))
        iidcategoria = (new Integer(request.getParameter("iidcategoria"))).intValue();
      int iidgrupo = 0;
      if (request.getParameter("iidgrupo") != null && !request.getParameter("iidgrupo").equals(""))
        iidgrupo = (new Integer(request.getParameter("iidgrupo"))).intValue();
      int iidlinea = 0;
      if (request.getParameter("iidlinea") != null && !request.getParameter("iidlinea").equals(""))
        iidlinea = (new Integer(request.getParameter("iidlinea"))).intValue();
      int iidmarca = 0;
      if (request.getParameter("iidmarca") != null && !request.getParameter("iidmarca").equals(""))
        iidmarca = (new Integer(request.getParameter("iidmarca"))).intValue();
      float costo = 0.0F;
      if (request.getParameter("costo") != null && !request.getParameter("costo").equals(""))
        costo = (new Float(request.getParameter("costo"))).floatValue();
      float costoventa = 0.0F;
      if (request.getParameter("costoventa") != null
          && !request.getParameter("costoventa").equals(""))
        costoventa = (new Float(request.getParameter("costoventa"))).floatValue();
      dbDCC.setIidproveedor(iidproveedor);
      dbDCC.setIidcategoria(iidcategoria);
      dbDCC.setIidgrupo(iidgrupo);
      dbDCC.setIidlinea(iidlinea);
      dbDCC.setIidmarca(iidmarca);
      dbDCC.setVchleyenda(vchdescripcion);
      dbDCC.setDecfactor(decfactor);
      dbCLASIFICPROVEEDOR dcCP = new dbCLASIFICPROVEEDOR();
      dcCP.setConnection(con);
      dcCP.setIidproveedor(iidproveedor);
      dcCP.setIidcategoria(iidcategoria);
      dcCP.setIidgrupo(iidgrupo);
      dcCP.setIidlinea(iidlinea);
      dcCP.setIidmarca(iidmarca);
      switch (accion) {
        case 2: // '\002'
          Bean52 bean52 = new Bean52();
          bean52.setVProveedores(
              proveedores.findByClasificacion(iidcategoria, iidgrupo, iidlinea, iidmarca));
          ses_usr.setAttribute("bean52", bean52);
          strAddress = "/jsp/5_4b.jsp";
          break;

        case 4: // '\004'
          try {
            dbDCC.create();
          } catch (Exception e) {
            throw new Exception("No se pudo crear el registro");
          }
          break;

        case 5: // '\005'
          dbDCC.setVchleyenda(vchleyenda);
          dbDCC.load();
          dbDCC.setDecfactor(decfactor);
          dbDCC.store();
          break;

        case 6: // '\006'
          dbDCC.setVchleyenda(vchleyenda);
          dbDCC.remove();
          break;

        case 7: // '\007'
          dbDCC.setVchleyenda("PRONTO PAGO");
          try {
            dbDCC.load();
            dbDCC.setDecfactor(decfactor);
            dbDCC.store();
          } catch (SQLException e) {
            e.printStackTrace();
            dbDCC.setDecfactor(decfactor);
            dbDCC.create();
          }
          break;

        case 8: // '\b'
          dcCP.load();
          dcCP.setDecfactorvaluainve(costoventa);
          dcCP.setDecfactorcostovent(1.0F - costo / 100F);
          dcCP.store();
          break;
      }
      if (accion == 3 || accion == 4 || accion == 5 || accion == 6 || accion == 7 || accion == 8) {
        Bean54 bean54 = new Bean54();
        dbDCCs.findByPar(iidproveedor, iidcategoria, iidgrupo, iidlinea, iidmarca);
        dcCP.load();
        bean54.setVDesccompra(dbDCCs.getResult());
        bean54.setFactorActual(dcCP.getDecfactorcostovent());
        bean54.setPorcentajeActual((1.0F - dcCP.getDecfactorcostovent()) * 100F);
        ses_usr.setAttribute("bean54", bean54);
        strAddress = "/jsp/5_4c.jsp";
      }
    } catch (Throwable e) {
      bu.setCommit(false);
      e.printStackTrace();
      BeanError error = new BeanError();
      error.setErrorMessage(e.getMessage());
      request.setAttribute("error", error);
      strAddress = "/jsp/error.jsp";
    } finally {
      try {
        bu.finalizeTransaction(con);
        dispatcher = getServletContext().getRequestDispatcher(strAddress);
        dispatcher.forward(request, response);
      } catch (Exception ex) {
        System.out.println("FATAL:" + ex.getMessage());
      }
    }
  }