Ejemplo n.º 1
0
        public List <Rutina> all(Context context)
        {
            List <Rutina> lista = new List <Rutina>();
            Conexion      con   = new Conexion();

            con.start(context);
            MySqlDataReader data = null;

            try
            {
                var cmd = new MySqlCommand(string.Format("SELECT * FROM rutinas"), con.getConnection());
                data = cmd.ExecuteReader();
                while (data.Read())
                {
                    Rutina aux = new Rutina();
                    aux.id      = data.GetInt32("ID");
                    aux.kcal    = data.GetInt32("kcal");
                    aux.name    = data.GetString("Nombre");
                    aux.content = data.GetString("Contenido");
                    lista.Add(aux);
                }
                data.Close();
                con.end(context);
                return(lista);
            }
            catch (Exception ex)
            {
                con.end(context);
                Toast.MakeText(context, ex.ToString(), ToastLength.Long).Show();
                return(lista);
            }
        }
Ejemplo n.º 2
0
        protected override void OnStart()
        {
            base.OnStart();
            var rutine = new Rutina();

            rutinas      = rutine.all(this);
            list.Adapter = new RutinaAdapter(this, Resource.Layout.itemRutine, rutinas);
        }
Ejemplo n.º 3
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.pacientRutine);

            pacient.id = Intent.GetIntExtra("Pacient", 0);
            pacient.findAndLoad(this, pacient.id);
            authLevel = Intent.GetIntExtra("Auth", 4);
            rutine.findAndLoad(this, pacient.paciente.idRutina);

            nameET = FindViewById <EditText>(Resource.Id.rutineNameDetailsET);
            kcal   = FindViewById <EditText>(Resource.Id.rutineKcalDetailsET);


            name        = FindViewById <Spinner>(Resource.Id.rutineNameDetailsSP);
            description = FindViewById <EditText>(Resource.Id.rutineDescriptionDetailsET);
            var rutina = new Rutina();

            rutinas     = rutina.all(this);
            nameET.Text = rutine.name;
            kcal.Text   = rutine.kcal.ToString();
            ArrayAdapter <Rutina> adapter = new ArrayAdapter <Rutina>(this, Resource.Layout.support_simple_spinner_dropdown_item, rutinas);

            name.Adapter = adapter;

            if (pacient.paciente.idRutina == 0)
            {
                pacient.paciente.idRutina = rutinas[rutinas.FindIndex(a => a.name == "Sin Rutina")].id;
            }

            name.SetSelection(rutinas.FindIndex(a => a.id == pacient.paciente.idRutina));
            name.ItemSelected += rutineSelectionChange;

            changePacientRutinePB        = FindViewById <Button>(Resource.Id.changePacientRutinePB);
            changePacientRutinePB.Click += changePacientRutine;

            if (authLevel == 4 || authLevel == 2)
            {
                changePacientRutinePB.Visibility = ViewStates.Invisible;
            }

            cancelPacientRutineUpdatePB        = FindViewById <Button>(Resource.Id.cancelPacientRutineUpdatePB);
            cancelPacientRutineUpdatePB.Click += cancelPacientRutineUpdate;

            savePacientRutineUpdatePB        = FindViewById <Button>(Resource.Id.savePacientRutineUpdatePB);
            savePacientRutineUpdatePB.Click += savePacientRutineUpdate;



            // Create your application here
        }
Ejemplo n.º 4
0
        private void AgregarRutina(object sender, EventArgs e)
        {
            Rutina rutine = new Rutina();
            var    name   = FindViewById <EditText>(Resource.Id.rutineNameAdd);

            rutine.name = name.Text;
            var content = FindViewById <EditText>(Resource.Id.rutineDescriptionAdd);

            rutine.content = content.Text;
            var kcal = FindViewById <EditText>(Resource.Id.rutineKcalAdd);

            if (kcal.Text != "")
            {
                rutine.kcal = int.Parse(kcal.Text);
            }
            else
            {
                rutine.kcal = 0;
            }
            if (!(rutine.name.Trim() != "" && rutine.content.Trim() != ""))
            {
                Toast.MakeText(this, "Debe llenar todos los campos", ToastLength.Short).Show();
                return;
            }
            if (rutine.findAndLoad(this, rutine.name))
            {
                Toast.MakeText(this, "La rutina ya esta registrada", ToastLength.Short).Show();
            }
            else
            {
                rutine.save(this);
                name.Text    = "";
                content.Text = "";
                kcal.Text    = "";
                Finish();
            }
        }