public void AddItem(string Iname, int Iqty, int Icat, string Uemail, string Uname, string Uroles) { var result = 0; Models.Item item = new Models.Item(); MyContext _context = new MyContext(); item.Name = Iname; item.Quantity = Iqty; item.Category_Id = Icat; item.isDeleted = false; _context.Items.Add(item); result = _context.SaveChanges(); for (int i = 0; i < Iqty; i++) { ItemDetail iDetail = new ItemDetail(Uemail, Uname, Uroles); iDetail.ShowDialog(); } if (result > 0) { MessageBox.Show("Add Data Item Successful!"); } else { MessageBox.Show("Add Data Item Failed!"); } }
private void ExcuteAddNewCommand() { var itemWindow = new ItemDetail(null, SelectedWarehouse, Visibility.Collapsed); itemWindow.ShowDialog(); var dialogueResult = itemWindow.DialogResult; if (dialogueResult == null || !(bool)dialogueResult) { return; } LoadItems(); //Items = new ObservableCollection<ItemDTO>(ItemsList); SelectedItem = Items.FirstOrDefault(i => i.ItemCode == itemWindow.TxtItemCode.Text); }
private void ExecuteItemViewCommand(object button) { try { var clickedbutton = button as Button; ItemDetail itemDetailWindow; bool? dialogueResult; if (clickedbutton == null) { return; } var buttenTag = clickedbutton.Tag.ToString(); switch (buttenTag) { case "AddNew": itemDetailWindow = new ItemDetail(null, SelectedWarehouse); itemDetailWindow.ShowDialog(); dialogueResult = itemDetailWindow.DialogResult; if (dialogueResult != null && (bool)dialogueResult) { Load(); } break; case "ViewEdit": itemDetailWindow = new ItemDetail(SelectedItemQuantity, SelectedWarehouse); itemDetailWindow.ShowDialog(); dialogueResult = itemDetailWindow.DialogResult; if (dialogueResult != null && (bool)dialogueResult) { Load(); } break; case "SalesList": if (SelectedItemQuantity != null) { var salesDetailWindow = new TransactionItemsList(TransactionTypes.Sale, SelectedItemQuantity.Item); salesDetailWindow.ShowDialog(); } break; case "PurchasesList": var purchasesDetailWindow = new TransactionItemsList(TransactionTypes.Purchase, SelectedItemQuantity.Item); purchasesDetailWindow.ShowDialog(); break; case "PiList": var piDetailWindow = new TransactionItemsList(TransactionTypes.Pi, SelectedItemQuantity.Item); piDetailWindow.ShowDialog(); break; case "ImList": var imDetailWindow = new ItemsTransferList(SelectedItemQuantity.Item); imDetailWindow.ShowDialog(); break; case "Reserve": var reserveWindow = new Reservations(SelectedItemQuantity); reserveWindow.ShowDialog(); dialogueResult = reserveWindow.DialogResult; if (dialogueResult != null && (bool)dialogueResult) { Load(); } break; } } catch (Exception exception) { MessageBox.Show("Can't open window" + Environment.NewLine + exception.Message, "Can't open window", MessageBoxButton.OK, MessageBoxImage.Error); } }