Example #1
0
 public void drawListRow(ListField listField, Graphics g, int index, int y, int w) {
   String sColapsado = "";
   Item item = (Item) get(listField, index);
   if (listField.getSelectedIndex() == index) {
     g.setColor(Color.WHITE);
     g.setBackgroundColor(Estilos.getBGSelected());
   } else {
     if (item.isCabecera()) {
       g.setColor(Estilos.getColorInterlinea(0));
       g.setBackgroundColor(Estilos.getBGInterlinea(0));
     } else {
       g.setColor(Estilos.getColorInterlinea(1));
       g.setBackgroundColor(Estilos.getBGInterlinea(1));
     }
     g.clear();
   }
   if (item.isCabecera()) {
     if (item.isColapsado()) {
       sColapsado = Characters.BLACK_RIGHT_POINTING_TRIANGLE + " ";
     } else {
       sColapsado = Characters.BLACK_DOWN_POINTING_TRIANGLE + " ";
     }
   } else {
     sColapsado = Characters.SPACE + "";
   }
   g.drawText(sColapsado + item.getDescripcion(), 0, y, DrawStyle.LEFT, w);
   g.drawText(item.getValor(), 0, y, DrawStyle.RIGHT, w);
 }
Example #2
0
 public void drawListRow(ListField list, Graphics g, int index, int y, int w) {
   if (list.getSelectedIndex() == index) {
   } else {
     g.setColor(Color.WHITE);
     if (get(index).equals("Consultoras") || get(index).equals("Pedidos")) {
       g.setBackgroundColor(Estilos.getBGModulo());
     } else {
       g.setBackgroundColor(Estilos.getBGSubModulo());
     }
     g.clear();
   }
   g.drawText(get(index), 0, y, 0, w);
 }
Example #3
0
 private void seleccion() {
   if (opciones[menu.getSelectedIndex()].equals(MetodosGlobales.opciones[1])) { // Atracciones
     Estilos.pushScreen(new Atracciones());
   } else if (opciones[menu.getSelectedIndex()].equals(MetodosGlobales.opciones[2])) { // Nuevas
     Estilos.pushScreen(new MenuContactos());
   } else if (opciones[menu.getSelectedIndex()].equals(MetodosGlobales.opciones[3])) { // Buscar
     Estilos.pushScreen(new Establecidas(MetodosGlobales.establecidasTitulo()));
   } else if (opciones[menu.getSelectedIndex()].equals(
       MetodosGlobales.opciones[5])) { // Facturacion
     Estilos.pushScreen(new FacturaResumen());
   } else if (opciones[menu.getSelectedIndex()].equals(
       MetodosGlobales.opciones[6])) { // Indicadores
     Estilos.pushScreen(new IndicadorDetalle());
   }
 }
Example #4
0
  protected boolean navigationClick(int status, int time) {
    Field field = this.getFieldWithFocus();
    if (field == _listaConsulResumen) {
      int index = _listaConsulResumen.getSelectedIndex();
      Item item = (Item) get(_listaConsulResumen, index);
      if (item.isCabecera()) {
        item.setColapsado(!item.isColapsado());
        llenaLista();
        _listaConsulResumen.setSelectedIndex(index);
        return true;
      } else {
        item = (Item) jerarquia.elementAt(item.getIndexPadre());
        int op = getCategoria(index);
        if (op >= 0) {
          int cant = Integer.parseInt(((Item) get(_listaConsulResumen, index)).getValor());
          if (cant > 0) {
            String campana =
                item.getDescripcion().substring(4) + item.getDescripcion().substring(1, 3);
            progress.setTitle("Buscando... ");
            progress.open();
            progress.close();
            try {
              Estilos.pushScreen(new ConsultaSeccion(campana, "", "", "", "", "" + op));
            } catch (Exception e) {

            }
          }
        }
        return true;
      }
    }
    return super.navigationClick(status, time);
  }
Example #5
0
public class Reingresos extends GPSScreen implements FieldChangeListener, FocusChangeListener {
  private mkpyStatusProgress progress = new mkpyStatusProgress("");
  private TipoDocDB tipodocs = new TipoDocDB();
  private UsuarioDB usuarios = new UsuarioDB();
  private Usuario usuario;

  private String gpsLon = "";
  private String gpsLat = "";

  private mkpyLabelEditField txtCodConsultora =
      new mkpyLabelEditField(
          "Cod.Consultora:",
          "",
          7,
          EditField.FIELD_LEFT | EditField.NO_NEWLINE | EditField.FILTER_NUMERIC,
          Color.BLACK,
          Color.WHITE);
  private mkpyLabelEditField txtAppaterno =
      new mkpyLabelEditField(
          "Ap.paterno:",
          "",
          15,
          EditField.FIELD_LEFT | EditField.NO_NEWLINE | EditField.FILTER_DEFAULT,
          Color.BLACK,
          Color.WHITE);
  private mkpyLabelEditField txtApmaterno =
      new mkpyLabelEditField(
          "Ap.materno:",
          "",
          15,
          EditField.FIELD_LEFT | EditField.NO_NEWLINE | EditField.FILTER_DEFAULT,
          Color.BLACK,
          Color.WHITE);
  private mkpyLabelEditField txtNombres =
      new mkpyLabelEditField(
          "Nombres:",
          "",
          15,
          EditField.FIELD_LEFT | EditField.NO_NEWLINE | EditField.FILTER_DEFAULT,
          Color.BLACK,
          Color.WHITE);
  private mkpyLabelLabelField
      lblTipoDoc; // = new mkpyLabelChoiceField("Tipo doc:", aTipoDoc, 0,
                  // ObjectChoiceField.USE_ALL_WIDTH, Color.BLACK, Color.WHITE);
  private mkpyLabelEditField
      txtNroDoc; // = new mkpyLabelEditField("Nro doc:", "", 15, EditField.FIELD_LEFT |
                 // EditField.NO_NEWLINE | EditField.FILTER_NUMERIC, Color.BLACK, Color.WHITE);
  private mkpyLabelEditField txtTelefonoCasa =
      new mkpyLabelEditField(
          "Teléfono 1:",
          "",
          10,
          EditField.FIELD_LEFT | EditField.NO_NEWLINE | EditField.FILTER_NUMERIC,
          Color.BLACK,
          Color.WHITE);
  private mkpyLabelEditField txtTelefonoCelular =
      new mkpyLabelEditField(
          "Teléfono 2:",
          "",
          10,
          EditField.FIELD_LEFT | EditField.NO_NEWLINE | EditField.FILTER_NUMERIC,
          Color.BLACK,
          Color.WHITE);

  private ButtonField btnGrabar =
      new ButtonField("Grabar", ButtonField.FIELD_HCENTER | ButtonField.CONSUME_CLICK);
  private LabelField lblEstado = new LabelField("", LabelField.FIELD_RIGHT);

  // INICIO: Record
  private mkpyLabelField lblRecord =
      new mkpyLabelField(
          "Record",
          LabelField.FIELD_HCENTER | LabelField.NON_FOCUSABLE | LabelField.USE_ALL_WIDTH,
          Color.WHITE,
          Estilos.getBGModulo());
  private DateField txtFechaRec =
      new DateField("Fecha:", (new Date()).getTime(), DateField.DATE | DateField.USE_ALL_WIDTH);
  private mkpyLabelEditField txtObsRec =
      new mkpyLabelEditField(
          "Observacion:",
          "",
          20,
          EditField.FIELD_LEFT | EditField.NO_NEWLINE | EditField.FILTER_DEFAULT,
          Color.BLACK,
          Color.WHITE);
  // FIN: Record

  public boolean onClose() {
    if (Dialog.ask(Dialog.D_YES_NO, "¿Desea grabar antes de salir?") != Dialog.NO) {
      grabar();
    } else {
      close();
    }
    return true;
  };

  public Reingresos() {
    // setTitle("Reingreso");
    add(
        new BitmapField(
            Bitmap.getBitmapResource("img/titulos/reingreso.png"), BitmapField.HCENTER));
    usuario = usuarios.getUsuario();

    // JGF: en caso de requerirse deshabilitar GPS
    if (!usuario.getHabilitaD().equals("1")) {
      GPSScreen.StopMessure();
      GPSScreen.CancelTimer();
      GPSScreen.PrintMessage("GPS deshabilitado!");
    }

    lblTipoDoc =
        new mkpyLabelLabelField(
            "Tipo doc:",
            usuario.getIdTipoDoc(),
            ObjectChoiceField.FIELD_RIGHT,
            Color.BLACK,
            Color.WHITE);

    add(txtCodConsultora);
    txtCodConsultora.setChangeListener(this);
    txtCodConsultora.setFocusListener(this);
    add(lblTipoDoc);
    if (usuario.getIdPais().equals("7")) { // PR
      txtNroDoc =
          new mkpyLabelEditField(
              "Nro doc:",
              "",
              9,
              EditField.FIELD_LEFT | EditField.NO_NEWLINE | EditField.FILTER_NUMERIC,
              Color.BLACK,
              Color.WHITE);
    }
    if (usuario.getIdPais().equals("8")) { // DOM
      txtNroDoc =
          new mkpyLabelEditField(
              "Nro doc:",
              "",
              11,
              EditField.FIELD_LEFT | EditField.NO_NEWLINE | EditField.FILTER_NUMERIC,
              Color.BLACK,
              Color.WHITE);
    }
    add(txtNroDoc);
    txtNroDoc.setChangeListener(this);
    txtNroDoc.setFocusListener(this);
    add(txtAppaterno);
    txtAppaterno.setChangeListener(this);
    txtAppaterno.setFocusListener(this);
    add(txtApmaterno);
    txtApmaterno.setChangeListener(this);
    txtApmaterno.setFocusListener(this);
    add(txtNombres);
    txtNombres.setChangeListener(this);
    txtNombres.setFocusListener(this);
    add(txtTelefonoCasa);
    txtTelefonoCasa.setChangeListener(this);
    txtTelefonoCasa.setFocusListener(this);
    add(txtTelefonoCelular);
    txtTelefonoCelular.setChangeListener(this);
    txtTelefonoCelular.setFocusListener(this);

    if (usuario.getHabilitaC().equals("1")) {
      add(lblRecord);
      add(txtFechaRec);
      txtFechaRec.setChangeListener(this);
      txtFechaRec.setFocusListener(this);

      add(txtObsRec);
      txtObsRec.setChangeListener(this);
      txtObsRec.setFocusListener(this);
    }

    add(btnGrabar);
    btnGrabar.setChangeListener(this);
    setStatus(lblEstado);
  }

  public void fieldChanged(Field field, int context) {
    if (field == btnGrabar) {
      grabar();
    } else {
      if (field instanceof mkpyLabelEditField) {
        lblEstado.setText(
            ""
                + (((mkpyLabelEditField) field).getText().getMaxSize()
                    - ((mkpyLabelEditField) field)
                        .getText()
                        .getTextLength())); // + (txtZona.getTextLength() -
                                            // txtZona.getText().length()));
      }
    }
  }

  private void grabar() {

    int longapepat, longapemat, longnombre = 0;

    if (txtCodConsultora.getText().getText().length() == 0
        && txtNroDoc.getText().getText().length() == 0) {
      Dialog.inform("Debe ingresar un código de consultora o número de documento");
      return;
    }

    if (txtCodConsultora.getText().getText().length() > 0) {
      if (txtCodConsultora.getText().getText().length() < txtCodConsultora.getText().getMaxSize()) {
        txtCodConsultora.setFocus();
        Dialog.inform("Faltan dígitos en el Código de Consultora.");
        return;
      }
    }

    if (txtNroDoc.getText().getText().length() > 0) {
      if (txtNroDoc.getText().getText().length() < txtNroDoc.getText().getMaxSize()) {
        txtNroDoc.setFocus();
        Dialog.inform("Faltan dígitos en el documento");
        return;
      }
    }

    longapepat = txtAppaterno.getText().getText().length();
    if (longapepat == 0) {
      txtAppaterno.setFocus();
      Dialog.inform("Debe ingresar apellido paterno");
      return;
    } else if (longapepat < 2) {
      txtAppaterno.setFocus();
      Dialog.inform("Debe haber al menos 2 caracteres en apellido paterno");
      return;
    } else if (txtAppaterno.haveNumbers()) {
      txtAppaterno.setFocus();
      Dialog.inform("Existen números en el apellido paterno");
      return;
    }

    longapemat = txtApmaterno.getText().getText().length();
    if (longapemat == 0) {
      txtApmaterno.setFocus();
      Dialog.inform("Debe ingresar apellido materno");
      return;
    } else if (longapemat < 2) {
      txtApmaterno.setFocus();
      Dialog.inform("Debe haber al menos 2 caracteres en apellido materno");
      return;
    } else if (txtApmaterno.haveNumbers()) {
      txtApmaterno.setFocus();
      Dialog.inform("Existen números en el apellido materno");
      return;
    }

    longnombre = txtNombres.getText().getText().length();
    if (longnombre == 0) {
      txtNombres.setFocus();
      Dialog.inform("Debe ingresar nombres");
      return;
    } else if (longnombre < 2) {
      txtNombres.setFocus();
      Dialog.inform("Debe haber al menos 2 caracateres en los nombres");
      return;
    } else if (txtNombres.haveNumbers()) {
      txtNombres.setFocus();
      Dialog.inform("Existen números en los nombres");
      return;
    }

    if (txtTelefonoCasa.getText().getText().length() == 0
        && txtTelefonoCelular.getText().getText().length() == 0) {
      txtTelefonoCasa.setFocus();
      Dialog.inform("Debe ingresar uno de los telefonos de la solicitante");
      return;
    }
    if (txtTelefonoCasa.getText().getText().length() > 0) {
      if (txtTelefonoCasa.getText().getText().length() < txtTelefonoCasa.getText().getMaxSize()) {
        txtTelefonoCasa.setFocus();
        Dialog.inform("Debe ingresar el telefono de la solicitante");
        return;
      }
    }
    if (txtTelefonoCelular.getText().getText().length() > 0) {
      if (txtTelefonoCelular.getText().getText().length()
          < txtTelefonoCelular.getText().getMaxSize()) {
        txtTelefonoCelular.setFocus();
        Dialog.inform("Debe ingresar el telefono 2 de la solicitante");
        return;
      }
    }

    gpsLon = "0";
    gpsLat = "0";

    // JGF: GPS
    //		if(usuario.getHabilitaD().equals("1"))  // usuario tiene habilidado el GPS
    //    	{
    //			if(Dialog.ask(Dialog.D_YES_NO, "Se encuentra en el domicilio?") == Dialog.YES)
    //			{
    //	    		progress.setTitle("Capturando localización");
    //
    //	    		while(Dialog.ask(Dialog.D_YES_NO, "Desea grabar GPS: (" + gpsLon + ", " + gpsLat +
    // ")?") == Dialog.NO)
    //	    		{
    //		    		gpsLon = "" + String.valueOf(GPSScreen.getLongitude()); // JGF: faltaba la conversión
    // a String
    //		        	gpsLat = "" + String.valueOf(GPSScreen.getLatitude());
    //	    		}
    //
    //	    		GPSScreen.StopMessure();
    //	    		GPSScreen.CancelTimer();
    //
    //	        	// JGF: muestra las coordenadas registradas
    //	        	progress.setTitle("Localización registrada: (" + gpsLon + ", " + gpsLat + ")");
    //			}
    //    	}

    // JGF: GPS
    if (usuario.getHabilitaD().equals("1")) // usuario tiene habilidado el GPS
    {
      if (Dialog.ask(Dialog.D_YES_NO, "¿Se encuentra en el domicilio?") == Dialog.YES) {
        /*
        if(Dialog.ask(Dialog.D_OK_CANCEL,"Ubiquese en una zona sin techo de la casa, puede ser la puerta de ingreso")== Dialog.D_OK)
         		{progress.setTitle("Capturando localización");};
         		*/

        Dialog.ask(
            Dialog.D_OK_CANCEL,
            "Ubiquese en una zona sin techo de la casa, puede ser la puerta de ingreso");

        gpsLon =
            "" + String.valueOf(GPSScreen.getLongitude()); // JGF: faltaba la conversión a String
        gpsLat = "" + String.valueOf(GPSScreen.getLatitude());

        /*

        while(Dialog.ask(Dialog.D_YES_NO, "Desea grabar GPS: (" + gpsLon + ", " + gpsLat + ")?") == Dialog.NO)
        {
        	gpsLon = "" + String.valueOf(GPSScreen.getLongitude()); // JGF: faltaba la conversión a String
           	gpsLat = "" + String.valueOf(GPSScreen.getLatitude());
        }
        */

        GPSScreen.StopMessure();
        GPSScreen.CancelTimer();

        // JGF: muestra las coordenadas registradas
        // progress.setTitle("Localización registrada: (" + gpsLon + ", " + gpsLat + ")");
      }
    }

    progress.setTitle("Grabando...");
    progress.open();
    SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmm");

    ReingresoDB reingresos = new ReingresoDB();
    Reingreso reingreso = new Reingreso();
    reingreso.setCodConsultora(txtCodConsultora.getText().getText());
    reingreso.setApPaterno(txtAppaterno.getText().getText());
    reingreso.setApMaterno(txtApmaterno.getText().getText());
    reingreso.setNombres(txtNombres.getText().getText());
    reingreso.setTipoDocumento("");
    reingreso.setNroDocumento(txtNroDoc.getText().getText());
    reingreso.setTelefonoCasa(txtTelefonoCasa.getText().getText());
    reingreso.setTelefonoCelular(txtTelefonoCelular.getText().getText());
    reingreso.setFechaRegistro(Fechas.dateToString("yyyyMMddHHmm"));
    reingreso.setCampana("");
    reingreso.setEnviado("0");

    RecordLocation record = new RecordLocation();
    record.setFechaVisita(sdf.formatLocal(txtFechaRec.getDate()));
    record.setObservacion(txtObsRec.getText().getText());
    record.setIMSI(Sistema.getImsi());
    record.setPIN("" + Sistema.getPin());

    if (usuario.getHabilitaD().equals("1")) { // si tiene habilidada el gps
      record.setLatitude(gpsLat);
      record.setLongitude(gpsLon);
      record.setMargen("0");
      record.setSatelites("0");
    } else {
      record.setLatitude("0");
      record.setLongitude("0");
      record.setMargen("0");
      record.setSatelites("0");
    }
    reingreso.setRecord(record);
    progress.setTitle("Enviando...");

    if (reingresos.putRemote(reingreso)) {
      reingreso.setEnviado("1");
      reingresos.saveObject(reingreso);
      reingresos.commitChanges();
      Dialog.inform("El reingreso se envío con éxito");
      progress.close();
      reingresos = null;
      close();
    } else {
      progress.close();
      Error error = reingresos.getError();
      Dialog.inform("Se produjo un error al enviar el reingreso, " + error.getMensaje());
      manejoErrores(error);
    }
  }

  public void focusChanged(Field field, int eventType) {
    lblEstado.setText("");
  }

  protected boolean onSavePrompt() {
    if (Dialog.ask(Dialog.D_YES_NO, "Descartar los cambios?") == Dialog.YES) return true;
    else return false;
  }

  private void manejoErrores(Error error) {
    int idError = error.getIdError();
    switch (idError) {
      case 1:
        txtCodConsultora.setFocus();
        break;
      case 2:
        txtCodConsultora.setFocus();
        break;
      case 20:
        txtCodConsultora.setFocus();
        break;
      case 21:
        txtCodConsultora.setFocus();
        break;
      default:
        txtCodConsultora.setFocus();
        break;
    }
  }
}