Example #1
0
 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;
   }
 }
Example #2
0
  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);
    }
  }
Example #3
0
  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);
  }