Пример #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;
            }
        }
Пример #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));
            }
        }
Пример #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));
            }
        }
Пример #4
0
        public MainPage()
        {
            InitializeComponent();
            IsLogged();
            bool InternetConnection = InternetAvailability.IsInternetAvailable();

            if (InternetConnection != true)
            {
                OfflineUI();
            }
            ShowCategories();
            //DataContext = category;
        }
Пример #5
0
        public CategoryPage(Category category)
        {
            InitializeComponent();
            IsLogged();
            bool InternetConnection = InternetAvailability.IsInternetAvailable();

            if (InternetConnection != true)
            {
                OfflineUI();
            }
            kategorie = category;
            ShowItems();
        }
Пример #6
0
        public DetailPage(Item selectedItem)
        {
            InitializeComponent();
            IsLogged();
            bool InternetConnection = InternetAvailability.IsInternetAvailable();

            if (InternetConnection != true)
            {
                OfflineUI();
            }
            item = selectedItem;
            ShowDetailedItem();
        }
Пример #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);
        }
Пример #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;
        }
Пример #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;
            }
        }