Ejemplo n.º 1
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            // Set our view from the "main" layout resource  
            SetContentView(Resource.Layout.Foto);

            base.OnCreate(savedInstanceState);
            datos_usuario     = JsonConvert.DeserializeObject <cls_usuario>(Intent.GetStringExtra("datos_usuario"));
            datos_paciente    = JsonConvert.DeserializeObject <cls_paciente>(Intent.GetStringExtra("datos_paciente"));
            datos_informacion = JsonConvert.DeserializeObject <cls_informacion>(Intent.GetStringExtra("datos_informacion"));

            TextView lbl_nombre = FindViewById <TextView>(Resource.Id.lbl_nombre);
            TextView lbl_edad   = FindViewById <TextView>(Resource.Id.lbl_edad);

            DateTime date    = DateTime.Now;
            int      year    = date.Year;
            int      ano_nac = datos_paciente.fecnac.Year;
            int      edad    = year - ano_nac;

            int max = datos_paciente.nombre_com.Length;

            if (max > 20)
            {
                max = 23;
            }
            lbl_nombre.Text = "Id:" + datos_paciente.id_paciente.ToString() + " " + datos_paciente.nombre_com.Substring(0, max) + ".";
            lbl_edad.Text   = edad.ToString();
            TextView lbl_episodio_foto = FindViewById <TextView>(Resource.Id.lbl_episodio_foto);

            lbl_episodio_foto.Text = "Ep.:" + datos_informacion.id_episodio.ToString() + " Fecha:" + datos_informacion.fecha + " (" + datos_informacion.veo.ToString() + ")";

            if (datos_informacion.veo > 0)
            {
                Mostar_Foto();
            }

            Button btn_borra_foto = FindViewById <Button>(Resource.Id.btn_borra_foto);

            btn_borra_foto.Click += btn_borra_foto_Click;

            Button btn_foto_mas = FindViewById <Button>(Resource.Id.btn_foto_mas);

            btn_foto_mas.Click += btn_foto_mas_Click;

            Button btn_foto_menos = FindViewById <Button>(Resource.Id.btn_foto_menos);

            btn_foto_menos.Click += btn_foto_menos_Click;

            if (IsThereAnAppToTakePictures())
            {
                CreateDirectoryForPictures();
                Button button = FindViewById <Button>(Resource.Id.btn_camara);
                button.Click += TomarFoto;
            }
        }
Ejemplo n.º 2
0
        private void validar_usuario(object sender, EventArgs eventArgs)
        {
            EditText txt_nombre   = FindViewById <EditText>(Resource.Id.txt_nombre);
            EditText txt_password = FindViewById <EditText>(Resource.Id.txt_password);

            TextView result = FindViewById <TextView>(Resource.Id.lbl_Resultado);

            using (TRAtaMeWS.TRAtaMeWS TRAtaMe = new TRAtaMeWS.TRAtaMeWS())
            {
                result.Text = "";
                String mensaje = "Entrada de usuario a la aplicacón móvil.";
                if (TRAtaMe.paciente_en_TRA(txt_password.Text, ref mensaje))
                {
                    mensaje = "Devuelve el id del paciente";

                    int id_paciente = TRAtaMe.hay_paciente(txt_password.Text, ref mensaje);

                    datos_paciente = TRAtaMe.datos_paciente_HCIS(Int32.Parse(txt_password.Text), txt_nombre.Text, ref mensaje);

                    if (id_paciente == 0)
                    {
                        TRAtaMe.nuevo_paciente(ref datos_paciente, ref mensaje);
                        TRAtaMe.crea_usuario_paciente(datos_paciente, ref mensaje);
                    }
                    else
                    {
                        datos_paciente.id_paciente = id_paciente;
                        TRAtaMe.actualiza_paciente(datos_paciente, ref mensaje);
                    }

                    datos_usuario = TRAtaMe.valida_entrada(txt_nombre.Text, txt_password.Text);

                    if (datos_usuario.permiso > 0)
                    {
                        if (TRAtaMe.inserta_log(datos_usuario.dni, 0, ref mensaje))
                        {
                            txt_nombre.Text   = "";
                            txt_password.Text = "";
                            Intent intent = new Intent(this, typeof(EpisodioActivity));
                            intent.PutExtra("datos_usuario", JsonConvert.SerializeObject(datos_usuario));
                            intent.PutExtra("datos_paciente", JsonConvert.SerializeObject(datos_paciente));
                            this.StartActivity(intent);
                        }
                        else
                        {
                            result.Text = "Sin acceso a log, contacte con informática." + mensaje;
                        }
                    }
                    else
                    {
                        TRAtaMe.borra_usuario_paciente(txt_nombre.Text, txt_password.Text, ref mensaje);
                        result.Text = "Credenciales no válidas";
                    }
                }
                else
                {
                    TRAtaMe.borra_usuario_paciente(txt_nombre.Text, txt_password.Text, ref mensaje);
                    if (mensaje == "")
                    {
                        mensaje = "Paciente sin intervención quirúrgica";
                    }
                    result.Text = mensaje;
                }
            }
        }
Ejemplo n.º 3
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            // Create your application here
            SetContentView(Resource.Layout.Episodio);

            base.OnCreate(savedInstanceState);

            Button btn_foto = FindViewById <Button>(Resource.Id.btn_foto);

            btn_foto.Click += btn_foto_Click;

            Button btn_episodio = FindViewById <Button>(Resource.Id.btn_episodio);

            btn_episodio.Click += btn_episodio_Click;
            btn_episodio.RequestFocus();

            Button btn_respuestas = FindViewById <Button>(Resource.Id.btn_respuestas);

            btn_respuestas.Click += btn_respuestas_Click;
            btn_respuestas.RequestFocus();

            datos_usuario  = JsonConvert.DeserializeObject <cls_usuario>(Intent.GetStringExtra("datos_usuario"));
            datos_paciente = JsonConvert.DeserializeObject <cls_paciente>(Intent.GetStringExtra("datos_paciente"));

            TextView lbl_nombre = FindViewById <TextView>(Resource.Id.lbl_nombre);
            TextView lbl_edad   = FindViewById <TextView>(Resource.Id.lbl_edad);

            DateTime date    = DateTime.Now;
            int      year    = date.Year;
            int      ano_nac = datos_paciente.fecnac.Year;
            int      edad    = year - ano_nac;

            int max = datos_paciente.nombre_com.Length;

            if (max > 20)
            {
                max = 23;
            }
            lbl_nombre.Text = "Id:" + datos_paciente.id_paciente.ToString() + " " + datos_paciente.nombre_com.Substring(0, max) + ".";
            lbl_edad.Text   = edad.ToString();

            Spinner spn_episodio = FindViewById <Spinner>(Resource.Id.spn_episodio);

            spn_episodio.ItemSelected += new EventHandler <AdapterView.ItemSelectedEventArgs>(spn_episodio_ItemSelected);

            EditText txt_pregunta = FindViewById <EditText>(Resource.Id.txt_pregunta);

            listener = txt_pregunta.KeyListener;

            txt_pregunta.KeyListener = null;
            editable = false;
            txt_pregunta.LongClick += txt_pregunta_LongClick;

            using (TRAtaMeWS.TRAtaMeWS TRAtaMe = new TRAtaMeWS.TRAtaMeWS())
            {
                string mensaje        = "";
                char[] delimiterChars = { '[' };

                datos_informacion.id_episodio = TRAtaMe.existe_episodio(datos_paciente.id_paciente, ref mensaje);
                if (datos_informacion.id_episodio > 0)
                {
                    mensaje = "";
                    if (!monta_spinner_episodios(ref mensaje)) // Error
                    {
                        if (mensaje != "")
                        {
                            ShowAlert("ERROR", mensaje, "S", 0, null, null);
                        }
                    }
                    else
                    {
                        if (datos_informacion.id_episodio > 0) // si viene con un episodio seleccionado
                        {
                            for (int i = 1; i < spn_episodio.Count; i++)
                            {
                                int episodio;
                                episodio = Int32.Parse(spn_episodio.GetItemAtPosition(i).ToString().Substring(0, spn_episodio.GetItemAtPosition(i).ToString().IndexOf(" - ")));
                                if (episodio == datos_informacion.id_episodio)
                                {
                                    datos_informacion.codser = "";                                                                         //OJO necesita para coger los datos de informacion globales
                                    TRAtaMe.toda_informacion(episodio.ToString(), ref datos_paciente, ref datos_informacion, ref mensaje); // En este punto recupero toda la estructora de un episodio
                                    spn_episodio.SetSelection(i);
                                    break;
                                }
                            }
                        }
                    }
                }
                else // Paciente sin episodios
                {
                    string[] lista   = { "NUEVO EPISODIO (Genera uno nuevo)" };
                    var      adapter = new ArrayAdapter <String>(this, Android.Resource.Layout.SimpleSpinnerItem, lista);
                    adapter.SetDropDownViewResource(Android.Resource.Layout.SimpleSpinnerDropDownItem);
                    spn_episodio.Adapter = adapter;

                    txt_pregunta.Text = "";
                }
            }
        }