示例#1
0
        public StockPage()
        {
            Title = "Stock";

            ListView listView = new ListView {
                RowHeight    = 40,
                ItemTemplate = new DataTemplate(typeof(GeStockItemCell))
            };

            _myItems             = new ObservableCollection <GeStockItem>();
            listView.ItemsSource = _myItems;

            Content = new StackLayout {
                Children =
                {
                    new Label {
                        HorizontalOptions = LayoutOptions.Center
                    },
                    listView
                }
            };

            listView.ItemSelected += (sender, e) => {
                GeStockItem geStockItem = (GeStockItem)e.SelectedItem;

                Navigation.PushAsync(new ProductXAML(geStockItem));
            };

            MessagingCenter.Subscribe <ListView, GeStockItem> (listView, "deleteProduct", (sender, arg) => {
                _myItems.Remove(arg);

                App.Database.Delete((GeStockItem)arg);
            });
        }
示例#2
0
 public void Restore(GeStockItem originalStockItem)
 {
     Name        = StockItem.Name = originalStockItem.Name;
     Quantity    = StockItem.Quantity = originalStockItem.Quantity;
     Description = StockItem.Description = originalStockItem.Description;
     Location    = StockItem.Location = originalStockItem.Location;
 }
示例#3
0
        void _refreshList()
        {
            _myItems.Clear();

            var items = App.Database.GetControlKits();

            foreach (ControlKit controlKit in items)
            {
                ControlKitCell._useRedBG = false;

                dynamic json = Newtonsoft.Json.JsonConvert.DeserializeObject(controlKit.Elements);

                foreach (var property in json)
                {
                    GeStockItem item = App.Database.GetItem(Convert.ToUInt16((string)property.Name));

                    int quantity = Convert.ToUInt16((string)property.Value);

                    if (quantity > item.Quantity)
                    {
                        ControlKitCell._useRedBG = true;
                        break;
                    }
                }

                _myItems.Add(controlKit);
            }

            ControlKitCell._useRedBG = false;
        }
示例#4
0
        void _refresh()
        {
            _myItems = new ObservableCollection <GeStockItem>();
            ObjectsList.ItemsSource = _myItems;

            GeStockItemCell.showDelete = false;

            ObjectsList.ItemTemplate = new DataTemplate(typeof(GeStockItemCell));

            dynamic json = Newtonsoft.Json.JsonConvert.DeserializeObject(_controlKitViewModel.Elements);

            foreach (var property in json)
            {
                GeStockItem item = App.Database.GetItem(Convert.ToUInt16((string)property.Name));

                int quantity = Convert.ToUInt16((string)property.Value);

                GeStockItemCell._useRedBG = quantity > item.Quantity;

                item.Quantity = quantity;

                _myItems.Add(item);
            }

            GeStockItemCell._useRedBG = false;
        }
示例#5
0
 public GeStockItem(GeStockItem stockItem)
 {
     ID          = stockItem.ID;
     Name        = stockItem.Name;
     Quantity    = stockItem.Quantity;
     Description = stockItem.Description;
     Location    = stockItem.Location;
     Category    = stockItem.Category;
 }
示例#6
0
        public ControlKitPage()
        {
            Title = "Kit";

            ListView listView = new ListView {
                RowHeight    = 40,
                ItemTemplate = new DataTemplate(typeof(ControlKitCell))
            };

            _myItems = new ObservableCollection <ControlKit>();

            _refreshList();

            listView.ItemsSource = _myItems;

            Content = new StackLayout {
                Children =
                {
                    new Label {
                        HorizontalOptions = LayoutOptions.Center
                    },
                    listView
                }
            };

            listView.ItemSelected += (sender, e) => {
                ControlKit controlKit = (ControlKit)e.SelectedItem;

                Navigation.PushAsync(new ControlKitXAML(controlKit));
            };

            MessagingCenter.Subscribe <ListView, ControlKit> (listView, "deleteControlKit", (sender, arg) => {
                _myItems.Remove(arg);

                App.Database.Delete((ControlKit)arg);
            });

            MessagingCenter.Subscribe <ListView, string> (listView, "useKit", (sender, arg) => {
                var kits = App.Database.GetControlKits();

                ControlKit kit = kits.First(x => x.Name == arg);

                dynamic json = Newtonsoft.Json.JsonConvert.DeserializeObject(kit.Elements);

                foreach (var property in json)
                {
                    GeStockItem item = App.Database.GetItem(Convert.ToUInt16((string)property.Name));

                    item.Quantity -= Convert.ToUInt16((string)property.Value);

                    App.Database.Save(item);
                }

                _refreshList();
            });
        }
示例#7
0
        void AddProduct(object sender, EventArgs e)
        {
            string productName = ProductPicker.Items [ProductPicker.SelectedIndex];

            GeStockItem product = products.First(x => x.Name == productName);

            product.Quantity = (int)quantity;

            _myItems.Add(product);
        }
示例#8
0
        public ProductXAML(GeStockItem geStockItem)
        {
            _geStockItemViewModel = new GeStockItemViewModel(geStockItem);

            BindingContext = _geStockItemViewModel;

            InitializeComponent();

            _refresh();
        }
示例#9
0
        public SearchPage()
        {
            Title = "Rechercher";

            Label header = new Label {
                Text = "Chercher un produit",
                HorizontalOptions = LayoutOptions.Center
            };

            SearchBar searchBar = new SearchBar {
                Placeholder = "mon produit"
            };

            _resultsLabel = new Label();

            ListView listView = new ListView {
                RowHeight    = 40,
                ItemTemplate = new DataTemplate(typeof(GeStockItemCell))
            };

            _myItems             = new ObservableCollection <GeStockItem>();
            listView.ItemsSource = _myItems;

            Content = new StackLayout {
                Children =
                {
                    new Label {
                        HorizontalOptions = LayoutOptions.Center
                    },
                    listView
                }
            };

            listView.ItemSelected += (sender, e) => {
                GeStockItem geStockItem = (GeStockItem)e.SelectedItem;

                Navigation.PushAsync(new ProductXAML(geStockItem));
            };

            Content = new StackLayout {
                Children =
                {
                    header,
                    searchBar,
                    listView
                }
            };

            searchBar.TextChanged += OnSearchBarButtonPressed;
            //searchBar.SearchButtonPressed += OnSearchBarButtonPressed;
        }
示例#10
0
        public GeStockItemViewModel(GeStockItem stockItem)
        {
            StockItem = stockItem;

            quantity    = StockItem.Quantity;
            name        = StockItem.Name;
            description = StockItem.Description;
            location    = StockItem.Location;

            if (StockItem.ID != 0)
            {
                category = App.Database.GetCategory(StockItem.Category).Name;
            }

            CategoryIndex = StockItem.Category;
        }
示例#11
0
        public EditProductXAML(GeStockItemViewModel geStockItemViewModel)
        {
            _geStockItemOriginal = new GeStockItem(geStockItemViewModel.StockItem);

            _geStockItemViewModel = geStockItemViewModel;

            BindingContext = _geStockItemViewModel;

            InitializeComponent();

            categories = App.Database.GetCategories();

            foreach (Category category in categories)
            {
                CategoryPicker.Items.Add(category.Name);
            }
        }
        public EditControlKitXAML(ControlKitViewModel controlKitViewModel)
        {
            _controlKitOriginal = new ControlKit(controlKitViewModel.ControlKit);

            _controlKitViewModel = controlKitViewModel;

            InitializeComponent();

            products = App.Database.GetItems();
            foreach (GeStockItem product in products)
            {
                ProductPicker.Items.Add(product.Name);
            }

            ProductPicker.SelectedIndex = 0;

            StepperQuantity.Value = quantity;
            LabelQuantity.Text    = quantity.ToString();

            GeStockItemCell.showDelete = true;
            GeStockItemCell.IdMessage  = "deleteProductFromControlKit";

            _myItems = new ObservableCollection <GeStockItem>();
            ObjectsList.ItemsSource  = _myItems;
            ObjectsList.ItemTemplate = new DataTemplate(typeof(GeStockItemCell));

            dynamic json = Newtonsoft.Json.JsonConvert.DeserializeObject(_controlKitViewModel.Elements);

            foreach (var property in json)
            {
                GeStockItem item = App.Database.GetItem(Convert.ToUInt16((string)property.Name));

                item.Quantity = Convert.ToUInt16((string)property.Value);

                _myItems.Add(item);
            }

            MessagingCenter.Subscribe <ListView, GeStockItem> (ObjectsList, "deleteProductFromControlKit", (sender, arg) => {
                _myItems.Remove(arg);
            });

            BindingContext = _controlKitViewModel;
        }