private void btnUpdatProduct_Click(object sender, RoutedEventArgs e) { if (cboProduct.SelectedIndex > -1) { int idCategory = cboCategoryUpdate.SelectedIndex + 1; int idProduct = cboProduct.SelectedIndex + 1; int price = Convert.ToInt32(txtPriceUpdate.Text); var producto = new Product { Id = idProduct, Name_product = txtProductUpdate.Text, unitPrice = price, Id_category = idCategory }; try { MenuBL.GetInstance().UpdateProduct(producto); MessageBoxRM.Show("Producto actualizado correctamente!", "Actualizacion de Producto", MessageBoxButtonRM.OK, MessageBoxIconRM.Information); cboProduct.SelectedIndex = -1; cboCategoryUpdate.SelectedIndex = -1; txtProductUpdate.Clear(); txtPriceUpdate.Clear(); RechargeAllCbo(); } catch (Exception ex) { MessageBoxRM.Show(ex.InnerException.Message, "Ha ocurrido un error :(", MessageBoxButtonRM.OK, MessageBoxIconRM.Error); } } }
public void RechargeAllCbo() { cboCategory.ItemsSource = MenuBL.GetInstance().GetCategoryList(); cboCategory.DisplayMemberPath = "Name"; cboCategoryUpdate.ItemsSource = MenuBL.GetInstance().GetCategoryList(); cboCategoryUpdate.DisplayMemberPath = "Name"; cboProduct.ItemsSource = MenuBL.GetInstance().GetProductList(); cboProduct.DisplayMemberPath = "Name"; }
private void cboProduct_SelectionChanged(object sender, SelectionChangedEventArgs e) { if (cboProduct.SelectedIndex != -1) { txtProductUpdate.Text = cboProduct.SelectedValue.ToString(); int idProducto = cboProduct.SelectedIndex + 1; Product product; var producto = new Product { Id = idProducto }; product = MenuBL.GetInstance().GetProductDetail(producto); txtPriceUpdate.Text = product.unitPrice.ToString(); cboCategoryUpdate.SelectedIndex = product.Id_category - 1; } }
public void LoadMenuFood() { List <MenuBL.Categorias> categorias; categorias = MenuBL.GetInstance().GetCategorias(); List <MenuItem_UC> menuItems; menuItems = MenuBL.GetInstance().GetMenuItems(); for (int i = 0; i < categorias.Count; i++) { listBox = addListBox(i); TabMenu.Items.Add(new TabItem() { Header = categorias[i].Nombre, Cursor = Cursors.Hand, Content = listBox }); listBox.SelectionChanged += ListBox_SelectionChanged; var item = menuItems.Where(a => a.Categoria == categorias[i].Nombre); foreach (MenuItem_UC nombre in item) { listBox.Items.Add(nombre); } } }
private void btnRegProduct_Click(object sender, RoutedEventArgs e) { try { if (!string.IsNullOrEmpty(txtProduct.Text)) { if (!string.IsNullOrEmpty(txtPrice.Text)) { if (cboCategory.SelectedIndex > -1) { int idCategory = cboCategory.SelectedIndex + 1; int price = Convert.ToInt32(txtPrice.Text); MenuBL.GetInstance().RegisterProduct(txtProduct.Text, price, idCategory); MessageBoxRM.Show("Producto registrado correctamente!", "Registro de Producto", MessageBoxButtonRM.OK, MessageBoxIconRM.Information); txtProduct.Clear(); txtPrice.Clear(); cboCategory.SelectedIndex = -1; RechargeAllCbo(); } else { ToolTip toolTip = new ToolTip(); toolTip.PlacementTarget = cboCategory; cboCategory.ToolTip = toolTip; toolTip.Content = "Esta opcion es requerida"; ToolTipService.SetShowDuration(cboCategory, 4000); ToolTipService.SetPlacement(cboCategory, System.Windows.Controls.Primitives.PlacementMode.Bottom); cboCategory.BorderBrush = Brushes.Red; bdrValidation_Copy1.Visibility = Visibility.Visible; validationIcon = bdrValidationIcon.Caegory; timer.Start(); } } else { ToolTip toolTip = new ToolTip(); toolTip.PlacementTarget = txtPrice; txtPrice.ToolTip = toolTip; toolTip.Content = "Este campo es requerido"; ToolTipService.SetShowDuration(txtPrice, 4000); ToolTipService.SetPlacement(txtPrice, System.Windows.Controls.Primitives.PlacementMode.Bottom); txtPrice.BorderBrush = Brushes.Red; txtPrice.BorderThickness = new Thickness(1, 1, 1, 1); bdrValidation_Copy.Visibility = Visibility.Visible; validationIcon = bdrValidationIcon.Price; timer.Start(); } } else { ToolTip toolTip = new ToolTip(); toolTip.PlacementTarget = txtProduct; txtProduct.ToolTip = toolTip; toolTip.Content = "Este campo es requerido"; ToolTipService.SetShowDuration(txtProduct, 4000); ToolTipService.SetPlacement(txtProduct, System.Windows.Controls.Primitives.PlacementMode.Bottom); txtProduct.BorderBrush = Brushes.Red; txtProduct.BorderThickness = new Thickness(1, 1, 1, 1); bdrValidation.Visibility = Visibility.Visible; validationIcon = bdrValidationIcon.User; timer.Start(); } } catch (Exception ex) { MessageBoxRM.Show(ex.InnerException.Message, "Ha ocurrido un error :(", MessageBoxButtonRM.OK, MessageBoxIconRM.Error); } }