void buttonInsertClick(object sender, EventArgs e)
        {
            InfoMedicaDbHelper db = new InfoMedicaDbHelper(this);

            if (etpeso.Text.Trim().Length < 1)
            {
                Toast.MakeText(this, "Ingrese el Peso.", ToastLength.Short).Show();
                return;
            }
            if (etaltura.Text.Trim().Length < 1)
            {
                Toast.MakeText(this, "Ingrese el altura.", ToastLength.Short).Show();
                return;
            }

            if (etpresionarterial.Text.Trim().Length < 1)
            {
                Toast.MakeText(this, "Ingrese La presion arterial.", ToastLength.Short).Show();
                return;
            }

            InfoMedica im = new InfoMedica();

            if (etid.Text.Trim().Length > 0)
            {
                im.id = int.Parse(etid.Text);
            }
            im.identificacion     = etidentificacion.Text;
            im.idPersona          = Int32.Parse(etidPersona.Text);
            im.peso               = Double.Parse(etpeso.Text);
            im.altura             = Double.Parse(etaltura.Text);
            im.presionArterial    = etpresionarterial.Text;
            im.frecuenciaCardiaca = etfrecuenciacardiaca.Text;
            im.detalle            = etdetalle.Text;

            try {
                if (etid.Text.Trim().Length > 0)
                {
                    db.UpdateInfoMedica(im);
                    Toast.MakeText(this, "Se actualizo correctamente.", ToastLength.Short).Show();
                }
                else
                {
                    db.AddNewInfoMedica(im);
                    Toast.MakeText(this, "Se agrego correctamente.", ToastLength.Short).Show();
                }

                Finish();

                //Go to main activity after save/edit
                var mainActivity = new Intent(this, typeof(InfoMedicaActivity));
                mainActivity.PutExtra("PersonaId", personaId);
                mainActivity.PutExtra("PersonaName", personaNombre);
                mainActivity.PutExtra("PersonaIdentificacion", personaIdentificacion);
                StartActivity(mainActivity);
            } catch (Exception ex) {
                throw new Exception(ex.Message);
            }
        }
Esempio n. 2
0
        private void LoadInfoMedicaInList(string personaId)
        {
            InfoMedicaDbHelper dbVals = new InfoMedicaDbHelper(this);

            listItsms = dbVals.GetAllInfoMedica(personaId);

            lv.Adapter = new InfoMedicaListBaseAdapter(this, listItsms);

            lv.ItemLongClick += lv_ItemLongClick;
        }
        private void LoadDataForEdit(string contactId)
        {
            InfoMedicaDbHelper db    = new InfoMedicaDbHelper(this);
            ICursor            cData = db.getInfoMedicaById(int.Parse(contactId));

            if (cData.MoveToFirst())
            {
                etid.Text                 = cData.GetString(cData.GetColumnIndex("id"));
                etidPersona.Text          = cData.GetString(cData.GetColumnIndex("idPersona"));
                etidentificacion.Text     = cData.GetString(cData.GetColumnIndex("identificacion"));
                etpeso.Text               = cData.GetString(cData.GetColumnIndex("peso"));
                etaltura.Text             = cData.GetString(cData.GetColumnIndex("altura"));
                etpresionarterial.Text    = cData.GetString(cData.GetColumnIndex("presionArterial"));
                etfrecuenciacardiaca.Text = cData.GetString(cData.GetColumnIndex("frecuenciaCardiaca"));
                etdetalle.Text            = cData.GetString(cData.GetColumnIndex("detalle"));
            }
        }
        private void DeleteSelectedPersona(string infoMedicaId)
        {
            InfoMedicaDbHelper _db = new InfoMedicaDbHelper(activity);

            _db.DeleteInfoMedica(infoMedicaId);
        }