Exemple #1
0
        public async void OnClickGridButton(object sender, EventArgs e)
        {
            if ((info.isTrial) || ((info.ActiveSubscription != null) && (info.ActiveSubscription.EndDate >= DateTime.UtcNow)))
            {
                var item = (Xamarin.Forms.Button)sender;
                int mode = int.Parse(item.CommandParameter.ToString());
                if (mode == 5)
                {
                    if (searchPage == null)
                    {
                        searchPage = new SearchMealPage();
                    }
                    SelectMealPage     selectPage = searchPage.GetSelectMealPage();
                    IEnumerable <Meal> meals      = conn.Query <Meal>("SELECT IDMeal,Name,Identifier FROM meal WHERE Deleted=0 AND Identifier=1 LIMIT 1");
                    foreach (Meal meal in meals)
                    {
                        //records.Add(new Meal { Name = meal.Name, IDMeal = meal.IDMeal });
                        //Meal myMeal = e.Item as Meal;

                        //selectPage.IDMealSelected = meal.IDMeal;
                        selectPage.IDCategorySelected = mode;
                        selectPage.SelectedDate       = SelectedDate;
                        selectPage.CalcUnits(meal.IDMeal);
                    }
                    await Navigation.PushAsync(selectPage);
                }
                else if (mode == 6)
                {
                    if (exerPage == null)
                    {
                        exerPage = new AddExercisePage();
                    }
                    exerPage.LoadData(SelectedDate);
                    await Navigation.PushAsync(exerPage);
                }
                else
                {
                    if (searchPage == null)
                    {
                        searchPage = new SearchMealPage();
                    }
                    searchPage.SelectedDate = SelectedDate;
                    searchPage.Mode         = mode;
                    await Navigation.PushAsync(searchPage);
                }
            }
            else
            {
                var answer = await App.Current.MainPage.DisplayAlert(Properties.LangResource.subscription, Properties.LangResource.subAlert, Properties.LangResource.yes, Properties.LangResource.no);

                if (answer == true)
                {
                    await Navigation.PushAsync(new ShopPage());
                }
            }
        }
        public async void GotoPage(int mode)
        {
            if ((info.isTrial) || ((info.ActiveSubscription != null) && (info.ActiveSubscription.EndDate >= DateTime.UtcNow)))
            {
                searchPage.Mode = mode;
                MyDayPage.ToggleAddView();

                if (mode == 5)
                {
                    IEnumerable <Meal> meals = conn.Query <Meal>("SELECT IDMeal,Name,Identifier FROM meal WHERE Deleted=0 AND Identifier=1 LIMIT 1");
                    foreach (Meal meal in meals)
                    {
                        //records.Add(new Meal { Name = meal.Name, IDMeal = meal.IDMeal });
                        //Meal myMeal = e.Item as Meal;
                        // selectPage.IDMealSelected = meal.IDMeal;
                        selectPage.IDCategorySelected = mode;
                        selectPage.SelectedDate       = SelectedDate;
                        selectPage.CalcUnits(meal.IDMeal);
                    }
                    await Navigation.PushAsync(selectPage);
                }
                else if (mode == 6)
                {
                    exerPage.LoadData(SelectedDate);
                    await Navigation.PushAsync(exerPage);
                }
                else
                {
                    await Navigation.PushAsync(searchPage);
                }
            }
            else
            {
                var answer = await App.Current.MainPage.DisplayAlert(Properties.LangResource.subscription, Properties.LangResource.subAlert, Properties.LangResource.yes, Properties.LangResource.no);

                if (answer == true)
                {
                    await Navigation.PushAsync(new ShopPage());
                }
            }
        }