private void ButtonAdd_OnClick(object sender, RoutedEventArgs e) { AddElementWindow addElementWindow = new AddElementWindow { Owner = this }; addElementWindow.ShowDialog(); RefreshWarehouse(); }
private void ButtonModify_OnClick(object sender, RoutedEventArgs e) { if (ListViewWarehouse.SelectedItems.Count <= 0) { MessageBox.Show("Selezionare l'elemento del Magazzino da modificare.", "Modifica", MessageBoxButton.OK, MessageBoxImage.Information); return; } AddElementWindow addElementWindow = new AddElementWindow("", false, (WarehouseItem)ListViewWarehouse.SelectedItems[0]) { Owner = this }; addElementWindow.ShowDialog(); RefreshWarehouse(); }
private void TimerOnTick(object sender, EventArgs eventArgs) { string code = TextBoxBarcode.Text; _timer.Stop(); TextBoxBarcode.Clear(); WarehouseItem warehouseItemDb; try { warehouseItemDb = DB.GetWarehouseItemById(code); } catch (Exception ex) { MessageBox.Show("Errore durante la connessione al Database: " + Environment.NewLine + ex.Message, "Errore", MessageBoxButton.OK, MessageBoxImage.Error); return; } if (warehouseItemDb == null) { //L'elemento con quel codice non esiste nel DB MessageBoxResult msgBoxResult = MessageBox.Show("Elemento con Id " + code + " non registrato in Magazzino." + Environment.NewLine + "Desidera registrarlo?", "Informazione", MessageBoxButton.YesNo, MessageBoxImage.Information, MessageBoxResult.Yes); if (msgBoxResult == MessageBoxResult.Yes) { AddElementWindow addElementWindow = new AddElementWindow(code) { Owner = this }; addElementWindow.ShowDialog(); RefreshWarehouse(); } } else { //L'elemento con quel codice ESISTE nel DB //Ne controllo la quantità presente WarehouseItem selectedWareHouseItem = ShoppingItems.FirstOrDefault(x => x.Id == warehouseItemDb.Id); if (selectedWareHouseItem == null) { if (warehouseItemDb.Quantity <= 0) { MessageBox.Show("Elemento " + warehouseItemDb.Name + " (ID: " + warehouseItemDb.Id + ") non disponibile in Magazzino per la quantità desiderata."); } else { warehouseItemDb.Quantity = 1; ShoppingItems.Add(warehouseItemDb); TotalPrice += warehouseItemDb.Price; } } else { if (warehouseItemDb.Quantity < selectedWareHouseItem.Quantity + 1) { MessageBox.Show("Elemento " + warehouseItemDb.Name + " (ID: " + warehouseItemDb.Id + ") non disponibile in Magazzino per la quantità desiderata."); } else { selectedWareHouseItem.Quantity++; TotalPrice += warehouseItemDb.Price; } } } }