protected override void OnStart() { base.OnStart(); var diet = new Dieta(); dietas = diet.all(this); list.Adapter = new DietaAdapter(this, Resource.Layout.itemDiet, dietas); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.pacientDiet); pacient.id = Intent.GetIntExtra("Pacient", 0); pacient.findAndLoad(this, pacient.id); authLevel = Intent.GetIntExtra("Auth", 4); diet.findAndLoad(this, pacient.paciente.idDieta); nameET = FindViewById <EditText>(Resource.Id.dietNameDetailsET); kcal = FindViewById <EditText>(Resource.Id.dietKcalDetailsET); name = FindViewById <Spinner>(Resource.Id.dietNameDetailsSP); description = FindViewById <EditText>(Resource.Id.dietDescriptionDetailsET); var dieta = new Dieta(); dietas = dieta.all(this); nameET.Text = diet.name; kcal.Text = diet.kcal.ToString(); ArrayAdapter <Dieta> adapter = new ArrayAdapter <Dieta>(this, Resource.Layout.support_simple_spinner_dropdown_item, dietas); name.Adapter = adapter; if (pacient.paciente.idDieta == 0) { pacient.paciente.idDieta = dietas[dietas.FindIndex(a => a.name == "Sin dieta")].id; } name.SetSelection(dietas.FindIndex(a => a.id == pacient.paciente.idDieta)); name.ItemSelected += dietSelectionChange; changePacientDietPB = FindViewById <Button>(Resource.Id.changePacientDietPB); changePacientDietPB.Click += changePacientDiet; if (authLevel == 4 || authLevel == 3) { changePacientDietPB.Visibility = ViewStates.Invisible; } cancelPacientDietUpdatePB = FindViewById <Button>(Resource.Id.cancelPacientDietUpdatePB); cancelPacientDietUpdatePB.Click += cancelPacientDietUpdate; savePacientDietUpdatePB = FindViewById <Button>(Resource.Id.savePacientDietUpdatePB); savePacientDietUpdatePB.Click += savePacientDietUpdate; // Create your application here }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.reportMain); pacient.id = Intent.GetIntExtra("Pacient", 0); pacient.findAndLoad(this, pacient.id); var dietasList = dietas.all(this); var rutinasList = rutinas.all(this); Dictionary <int, int> diets = new Dictionary <int, int>(); Dictionary <int, int> rutines = new Dictionary <int, int>(); diets = pacient.paciente.getKcalTot(this); rutines = pacient.paciente.getKcalBurn(this); dietDays = FindViewById <TextView>(Resource.Id.dietDays); rutineDays = FindViewById <TextView>(Resource.Id.rutineDays); kcalTot = FindViewById <TextView>(Resource.Id.kcal); kcalBurn = FindViewById <TextView>(Resource.Id.kcalRutina); int auxiliar = 0; int days = 0; foreach (var x in rutines) { auxiliar += rutinasList[rutinasList.FindIndex(a => a.id == x.Key)].kcal * x.Value; days++; } rutineDays.Text = days.ToString(); kcalBurn.Text = auxiliar.ToString(); auxiliar = 0; days = 0; foreach (var x in diets) { auxiliar += dietasList[dietasList.FindIndex(a => a.id == x.Key)].kcal * x.Value; days++; } kcalTot.Text = auxiliar.ToString(); dietDays.Text = days.ToString(); var historyPB = FindViewById <Button>(Resource.Id.historyPB); historyPB.Click += history; // Create your application here }