private void updateAlertMedicamento(object sender, EventArgs e) { // Recibimos el Id Paciente var id = Intent.Extras.GetInt(KEY_ID); // Cargamos los datos _medicamento.Id = id; _medicamento.farmaco = _edtFarmaco.Text; _medicamento.viaOral = _radio1.Checked == true ? true : false; _medicamento.viaSubcutanea = _radio2.Checked == true ? true : false; _medicamento.viaIntramuscular = _radio3.Checked == true ? true : false; _medicamento.viaIntravenoso = _radio4.Checked == true ? true : false; _medicamento.viaInhalatoria = _radio5.Checked == true ? true : false; _medicamento.confirmar = false; // Por defecto es false // Validacion if (Validate()) { DateTime now = DateTime.Now; // Fecha y hora actual DateTime selectedDT = Convert.ToDateTime(_medicamento.fecha + " " + _medicamento.hora); // Fecha y hora seleccionado // No debe aplicarse en la fecha pasada. Debe ser mayor a la fecha y hora seleccionada if (selectedDT > now) { _medicamentoService = new MedicamentoService(); // Instanciamos _medicamentoService.updateMedicamento(_medicamento); // Actualizar el registro en la base de datos _paciente = new Paciente(); // Instanciamos _paciente = _medicamentoService.getPacienteByIdMedicamento(_medicamento.Id); // Devuelve paciente por id medicamento AlarmMedicamento(_medicamento); // Mensaje Toast.MakeText(this, "Se ha actualizado el medicamento", ToastLength.Short).Show(); // Acción redireccionar a otra activity Intent otroActivity = new Intent(this, typeof(MedicamentoList)); 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 Medicamento _medicamento = _listMedicamentos[e.Position]; if (_medicamento.confirmar == true) { Android.App.AlertDialog.Builder dialog = new AlertDialog.Builder(Activity); AlertDialog alert = dialog.Create(); alert.SetTitle("Medicamento"); 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("Medicamento"); alert.SetIcon(Resource.Drawable.logo); alert.SetButton("Confirmar", (c, ev) => { //_medicamento = _listMedicamentos[e.Position]; _medicamento.confirmar = true; // Confirmar Medicamento _medicamentoService.updateMedicamento(_medicamento); // 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("Medicamento"); alert.SetIcon(Resource.Drawable.logo); alert.SetButton("Confirmar", (c, ev) => { _medicamento = _listMedicamentos[e.Position]; _medicamento.confirmar = true; // Confirmar Medicamento _medicamentoService.updateMedicamento(_medicamento); // 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(); }