Beispiel #1
0
        private void updateAlertRotacion(object sender, EventArgs e)
        {
            // Recibimos el Id Rotación
            var id = Intent.Extras.GetInt(KEY_ID);

            // Cargamos los datos
            _rotacion.Id         = id;
            _rotacion.comun      = _radioComun.Checked == true ? true : false;
            _rotacion.aire       = _radioAire.Checked == true ? true : false;
            _rotacion.lateralIzq = _radio1.Checked == true ? true : false;
            _rotacion.lateralDer = _radio2.Checked == true ? true : false;
            _rotacion.supina     = _radio3.Checked == true ? true : false;
            _rotacion.prono      = _radio4.Checked == true ? true : false;
            _rotacion.confirmar  = false; // Por defecto es false

            // Validacion
            if (Validate())
            {
                DateTime now        = DateTime.Now;                                               // Fecha y hora actual
                DateTime selectedDT = Convert.ToDateTime(_rotacion.fecha + " " + _rotacion.hora); // Fecha y hora seleccionado

                // No debe aplicarse en la fecha pasada. Debe ser mayor a la fecha y hora seleccionada
                if (selectedDT > now)
                {
                    _rotacionService = new RotacionService();                           // Instanciamos
                    _rotacionService.updateRotacion(_rotacion);                         // Actualizar el registro en la base de datos

                    _paciente = new Paciente();                                         // Instanciamos
                    _paciente = _rotacionService.getPacienteByIdRotacion(_rotacion.Id); // Devuelve paciente por id rotación

                    AlarmRotacion(_rotacion);

                    // Mensaje
                    Toast.MakeText(this, "Se ha actualizado la rotación", ToastLength.Short).Show();

                    // Acción redireccionar a otra activity
                    Intent otroActivity = new Intent(this, typeof(RotacionList));
                    otroActivity.PutExtra("KEY_ID", _paciente.Id); // Pasamos el Id Paciente
                    StartActivity(otroActivity);
                }
                else
                {
                    Toast.MakeText(this, "Esta es una selección no válida de fecha y hora", ToastLength.Short).Show();
                }
            }
        }
        private void List_ItemClick(object sender, AdapterView.ItemClickEventArgs e)
        {
            // Item Rotacion
            _rotacion = _listRotacion[e.Position];

            if (_rotacion.confirmar == true)
            {
                Android.App.AlertDialog.Builder dialog = new AlertDialog.Builder(Activity);
                AlertDialog alert = dialog.Create();
                alert.SetTitle("Rotación");
                alert.SetMessage("Ya ha sido confirmado!");
                alert.SetButton("Cerrar", delegate
                {
                    alert.Dispose();
                });

                alert.Show();
            }
            else
            {
                AlertDialog.Builder dialog = new AlertDialog.Builder(Activity);
                AlertDialog         alert  = dialog.Create();
                alert.SetTitle("Rotación");
                alert.SetIcon(Resource.Drawable.logo);
                alert.SetButton("Confirmar", (c, ev) =>
                {
                    //_rotacion = _listRotacion[e.Position];
                    _rotacion.confirmar = true;                 // Confirmar Rotación
                    _rotacionService.updateRotacion(_rotacion); // Actualiza el registro en la base de datos

                    // Para refresh
                    Activity.Finish(); StartActivity(Activity.Intent);

                    GC.Collect();
                });

                alert.SetButton2("Omitir", (c, ev) => { });
                alert.Show();
            }
        }
        private void List_ItemClick(object sender, AdapterView.ItemClickEventArgs e)
        {
            AlertDialog.Builder dialog = new AlertDialog.Builder(this);
            AlertDialog         alert  = dialog.Create();

            alert.SetTitle("Rotación");
            alert.SetIcon(Resource.Drawable.logo);
            alert.SetButton("Confirmar", (c, ev) =>
            {
                _rotacion           = _listRotacion[e.Position];
                _rotacion.confirmar = true;                 // Confirmar Rotación
                _rotacionService.updateRotacion(_rotacion); // Actualiza el registro en la base de datos

                // Para actualizar una actividad desde dentro de sí mismo
                Finish(); StartActivity(Intent);

                GC.Collect();
            });

            alert.SetButton2("Omitir", (c, ev) => { });
            alert.Show();
        }