Beispiel #1
0
        //Update Existing contact
        public void UpdateInfoMedica(InfoMedica infoMedica)
        {
            if (infoMedica == null)
            {
                return;
            }

            //Obtain writable database
            SQLiteDatabase db = this.WritableDatabase;

            //Prepare content values
            ContentValues vals = new ContentValues();

            vals.Put("idPersona", infoMedica.idPersona);
            vals.Put("identificacion", infoMedica.identificacion);
            vals.Put("peso", infoMedica.peso);
            vals.Put("altura", infoMedica.altura);
            vals.Put("presionArterial", infoMedica.presionArterial);
            vals.Put("frecuenciaCardiaca", infoMedica.frecuenciaCardiaca);
            vals.Put("detalle", infoMedica.detalle);

            ICursor cursor = db.Query("InfoMedica",
                                      new String[] { "id", "idPersona", "identificacion", "peso", "altura", "presionArterial", "frecuenciaCardiaca", "detalle" }, "id=?", new string[] { infoMedica.id.ToString() }, null, null, null, null);

            if (cursor != null)
            {
                if (cursor.MoveToFirst())
                {
                    // update the row
                    db.Update("InfoMedica", vals, "id=?", new String[] { cursor.GetString(0) });
                }

                cursor.Close();
            }
        }
        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);
            }
        }
        private void lv_ItemLongClick(object sender, AdapterView.ItemLongClickEventArgs e)
        {
            InfoMedica o = listItsms[e.Position];

            var activityAddEdit = new Intent(this, typeof(AddEditInfoMedicaActivity));

            activityAddEdit.PutExtra("InfoMedicaId", o.id.ToString());
            activityAddEdit.PutExtra("PersonaId", personaId);
            activityAddEdit.PutExtra("PersonaName", personaNombre);
            activityAddEdit.PutExtra("PersonaIdentificacion", personaIdentificacion);
            StartActivity(activityAddEdit);
        }
Beispiel #4
0
        //Add New Contact
        public void AddNewInfoMedica(InfoMedica infoMedica)
        {
            SQLiteDatabase db   = this.WritableDatabase;
            ContentValues  vals = new ContentValues();

            vals.Put("idPersona", infoMedica.idPersona);
            vals.Put("identificacion", infoMedica.identificacion);
            vals.Put("peso", infoMedica.peso);
            vals.Put("altura", infoMedica.altura);
            vals.Put("presionArterial", infoMedica.presionArterial);
            vals.Put("frecuenciaCardiaca", infoMedica.frecuenciaCardiaca);
            vals.Put("detalle", infoMedica.detalle);

            db.Insert("InfoMedica", null, vals);
        }