private void ViewMedicamentoDetail(int id) { // Instanciamos _medicamento = new Medicamento(); _medicamentoService = new MedicamentoService(); // Consultamos _medicamento = _medicamentoService.getMedicamentoPacienteById(id); // Devuelve un medicamento de un paciente por Id // Mostramos los datos _txtFarmaco.Text = _medicamento.farmaco; _txtDosis.Text = _medicamento.dosis.ToString(); //ToString: convierte de entero a string if (_medicamento.viaOral == true) { _txtViaAdmin.Text = "Oral"; } if (_medicamento.viaSubcutanea == true) { _txtViaAdmin.Text = "Subcutánea"; } if (_medicamento.viaIntramuscular == true) { _txtViaAdmin.Text = "Intramuscular"; } if (_medicamento.viaIntravenoso == true) { _txtViaAdmin.Text = "Intravenoso"; } if (_medicamento.viaInhalatoria == true) { _txtViaAdmin.Text = "Inhalatoria"; } _txtFecha.Text = _medicamento.fecha; _txtHora.Text = _medicamento.hora; }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.MedicamentoEdit); Toolbar toolbar = FindViewById <Toolbar>(Resource.Id.toolbar); SetSupportActionBar(toolbar); // Una marca atrás en el icono en ActionBar SupportActionBar.SetDisplayHomeAsUpEnabled(true); _edtFarmaco = FindViewById <EditText>(Resource.Id.edtFarmaco); // Farmaco _edtDosis = FindViewById <EditText>(Resource.Id.edtDosis); // Dosis _radio1 = FindViewById <RadioButton>(Resource.Id.radio1); // Oral _radio2 = FindViewById <RadioButton>(Resource.Id.radio2); // Subcutanea _radio3 = FindViewById <RadioButton>(Resource.Id.radio3); // Intramuscular _radio4 = FindViewById <RadioButton>(Resource.Id.radio4); // Intravenoso _radio5 = FindViewById <RadioButton>(Resource.Id.radio5); // Inhalatoria _edtFecha = FindViewById <EditText>(Resource.Id.edtFecha); // Fecha _edtHora = FindViewById <EditText>(Resource.Id.edtHora); // Hora _btnEdit = FindViewById <Button>(Resource.Id.btnEdit); // Botón // Click Fecha _edtFecha.Click += delegate { DatePickerFragment frag = DatePickerFragment.NewInstance(delegate(DateTime time) { _edtFecha.Text = time.ToShortDateString(); // Mostrar la fecha seleccionada en el edittext _medicamento.fecha = _edtFecha.Text; // Cargamos la fecha }); frag.Show(FragmentManager, DatePickerFragment.TAG); }; // Click Hora _edtHora.Click += delegate { TimePickerFragment frag = TimePickerFragment.NewInstance(delegate(DateTime time) { _edtHora.Text = time.ToShortTimeString(); // Mostrar la hora seleccionada en el edittext _medicamento.hora = _edtHora.Text; // Cargamos la hora }); frag.Show(FragmentManager, TimePickerFragment.TAG); }; // Recibimos el Id Medicamento var id = Intent.Extras.GetInt(KEY_ID); // Instanciamos _medicamento = new Medicamento(); _medicamentoService = new MedicamentoService(); // Consultamos la lista medicamentos de un paciente por Id _medicamento = _medicamentoService.getMedicamentoPacienteById(id); // Mostramos los datos _edtFarmaco.Text = _medicamento.farmaco; _edtDosis.Text = _medicamento.dosis.ToString(); //ToString: convierte de entero a string if (_medicamento.viaOral == true) { _radio1.Checked = true; } if (_medicamento.viaSubcutanea == true) { _radio2.Checked = true; } if (_medicamento.viaIntramuscular == true) { _radio3.Checked = true; } if (_medicamento.viaIntravenoso == true) { _radio4.Checked = true; } if (_medicamento.viaInhalatoria == true) { _radio5.Checked = true; } _edtFecha.Text = _medicamento.fecha; _edtHora.Text = _medicamento.hora; // Click Actualizar _btnEdit.Click += updateAlertMedicamento; }