Esempio n. 1
0
        private async void ShowItems()
        {
            bool InternetConnection = InternetAvailability.IsInternetAvailable();

            if (InternetConnection == true)
            {
                var request = new RestRequest(Method.GET);
                request.AddParameter("Type", "get_items_by_category");
                //Array categoryId = ["Category_id"][kategorie.Id];
                request.AddParameter("Data", SimpleJson.SerializeObject(kategorie));
                //MessageBox.Show(SimpleJson.SerializeObject(kategorie), "Upozornění", MessageBoxButton.OK, MessageBoxImage.Warning);
                var         response      = client.Execute <Input>(request);
                Input       responseInput = SimpleJson.DeserializeObject <Input>(response.Content);
                List <Item> items         = SimpleJson.DeserializeObject <List <Item> >(responseInput.Data);
                ListBoxItems.ItemsSource = items;
                CategoryName.Content     = kategorie.Name;
            }
            else
            {
                InternetStatus.Visibility = Visibility.Visible;
                var itemsFromDb = await Database.GetItemsByIdAsync(kategorie.Id);

                ListBoxItems.ItemsSource = itemsFromDb;
            }
        }
Esempio n. 2
0
        private void Item_Clicked(object sender, RoutedEventArgs e)
        {
            /*Category kategorie = new Category();
             * kategorie = sender as Category;*/
            var grid = sender as Grid;

            ListBoxCategories.SelectedItem = grid.DataContext;
            bool InternetConnection = InternetAvailability.IsInternetAvailable();

            if (InternetConnection == true)
            {
                Category selectedItem = ListBoxCategories.SelectedItem as Category;
                this.NavigationService.Navigate(new CategoryPage(selectedItem));
            }
            else
            {
                CategoryLocal selectedItem = ListBoxCategories.SelectedItem as CategoryLocal;
                Category      kategorie    = new Category();
                kategorie.Id          = selectedItem.Id;
                kategorie.Name        = selectedItem.Name;
                kategorie.Image_path  = selectedItem.Image_path;
                kategorie.Description = selectedItem.Description;
                this.NavigationService.Navigate(new CategoryPage(kategorie));
            }
        }
Esempio n. 3
0
        private void Item_Clicked(object sender, RoutedEventArgs e)
        {
            var grid = sender as Grid;

            ListBoxItems.SelectedItem = grid.DataContext;
            bool InternetConnection = InternetAvailability.IsInternetAvailable();

            if (InternetConnection == true)
            {
                Item selectedItem = ListBoxItems.SelectedItem as Item;
                //MessageBox.Show(selectedItem.Name, "Info", MessageBoxButton.OK, MessageBoxImage.Information);
                this.NavigationService.Navigate(new DetailPage(selectedItem));
            }
            else
            {
                ItemLocal selectedItem = ListBoxItems.SelectedItem as ItemLocal;
                Item      localitem    = new Item();
                localitem.Id          = selectedItem.Id;
                localitem.Name        = selectedItem.Name;
                localitem.Description = selectedItem.Description;
                localitem.Category_id = selectedItem.Category_id;
                localitem.Image_path  = selectedItem.Image_path;
                localitem.Price       = selectedItem.Price;
                localitem.Quantity    = selectedItem.Quantity;
                this.NavigationService.Navigate(new DetailPage(localitem));
            }
        }
Esempio n. 4
0
        public MainPage()
        {
            InitializeComponent();
            IsLogged();
            bool InternetConnection = InternetAvailability.IsInternetAvailable();

            if (InternetConnection != true)
            {
                OfflineUI();
            }
            ShowCategories();
            //DataContext = category;
        }
Esempio n. 5
0
        public CategoryPage(Category category)
        {
            InitializeComponent();
            IsLogged();
            bool InternetConnection = InternetAvailability.IsInternetAvailable();

            if (InternetConnection != true)
            {
                OfflineUI();
            }
            kategorie = category;
            ShowItems();
        }
Esempio n. 6
0
        public DetailPage(Item selectedItem)
        {
            InitializeComponent();
            IsLogged();
            bool InternetConnection = InternetAvailability.IsInternetAvailable();

            if (InternetConnection != true)
            {
                OfflineUI();
            }
            item = selectedItem;
            ShowDetailedItem();
        }
Esempio n. 7
0
        public MainWindow()
        {
            InitializeComponent();
            //RestClient client = new RestClient(Shared.Url);
            bool InternetConnection = InternetAvailability.IsInternetAvailable();

            if (InternetConnection == true)
            {
                Synchronize();
            }
            MainPage MainPage = new MainPage();

            frame.NavigationService.Navigate(MainPage);
        }
Esempio n. 8
0
        private void ShowDetailedItem()
        {
            Name.Content = item.Name;
            BitmapImage logo = new BitmapImage();

            logo.BeginInit();
            bool InternetConnection = InternetAvailability.IsInternetAvailable();

            if (InternetConnection == true)
            {
                logo.UriSource = new Uri(item.Image_path);
            }
            else
            {
                logo.UriSource = new Uri(item.Relative_Image_Path);
            }
            //logo. = item.Image_path;
            logo.EndInit();
            Image.Source     = logo;
            Price.Content    = item.Price;
            Description.Text = item.Description;
        }
Esempio n. 9
0
        private async void ShowCategories()
        {
            bool InternetConnection = InternetAvailability.IsInternetAvailable();

            if (InternetConnection == true)
            {
                //Synchronize.SyncCategories();
                var request = new RestRequest(Method.GET);
                request.AddParameter("Type", "get_categories");
                request.AddParameter("Data", "ahoj");
                var             response      = client.Execute <Input>(request);
                Input           responseInput = SimpleJson.DeserializeObject <Input>(response.Content);
                List <Category> categories    = SimpleJson.DeserializeObject <List <Category> >(responseInput.Data);
                ListBoxCategories.ItemsSource = categories;
            }
            else
            {
                //MessageBox.Show("OFFLINE Režim", "Upozornění", MessageBoxButton.OK, MessageBoxImage.Warning);
                InternetStatus.Visibility = Visibility.Visible;
                var itemsFromDb = await Database.GetCategoriesAsync();

                ListBoxCategories.ItemsSource = itemsFromDb;
            }
        }