private void ArtClick(object sender, RoutedEventArgs e) { var btn = sender as Button; int idArtigo = int.Parse(btn.Tag.ToString()); if (Menu.Quantidade == 0) { _cart.InsertArtigo(idArtigo, ControlArtigos.DevolveArtigoById(idArtigo).Quantidade); } else { if (_cart.InsertArtigo(idArtigo, Menu.Quantidade)) { Menu.Quantidade = 0; } } _cart.RefreshCart(); }
private void Window_KeyDown(object sender, KeyEventArgs e) { List <Key> keys = new List <Key>() { Key.D1, Key.D2, Key.D3, Key.D4, Key.D5, Key.D6, Key.D7, Key.D8, Key.D9, Key.D0, Key.NumPad0, Key.NumPad1, Key.NumPad2, Key.NumPad3, Key.NumPad4, Key.NumPad5, Key.NumPad6, Key.NumPad7, Key.NumPad8, Key.NumPad9, }; if (keys.Contains(e.Key)) { wAddArtigoByKeryboard temp = null; foreach (Window openWin in System.Windows.Application.Current.Windows) { if (openWin is wAddArtigoByKeryboard) { temp = (wAddArtigoByKeryboard)openWin; } } if (temp != null) { temp.Focus(); } else { temp = new wAddArtigoByKeryboard(e.Key); temp.ShowDialog(); if (temp.idArtigo != -1) { Artigo aux = ControlArtigos.DevolveArtigoById(temp.idArtigo); if (aux != null) { if (_quantidade != 0) { DataCart.InsertArtigo(aux.Id, Quantidade); Quantidade = 0; } else { DataCart.InsertArtigo(aux.Id, aux.Quantidade); } } } temp.Visibility = Visibility.Hidden; } } }