예제 #1
0
        private void Remove_Click(object sender, RoutedEventArgs e)
        {
            bool   found    = false;
            string SKU_temp = Interaction.InputBox("Ingrese el SKU del producto a remover de la lista de inventario:", "Buscar por SKU");

            if (SKU_temp != "")
            {
                foreach (InventoryInfo element in InventoryIO.items)
                {
                    if (element.SKU == int.Parse(SKU_temp))
                    {
                        info  = element;
                        found = true;
                    }
                }
                if (found)
                {
                    var option = MessageBox.Show("Estas seguro de remover el siguiente item:\n" +
                                                 "SKU: " + info.SKU +
                                                 "\nNombre del Producto: " + info.ProductInfo, "Eliminar item", MessageBoxButton.YesNo, MessageBoxImage.Question);
                    if (option == MessageBoxResult.Yes)
                    {
                        int index = InventoryIO.items.IndexOf(info);
                        InventoryIO.items.RemoveAt(index);
                        InventoryIO.InventorySet();
                        ItemList.Items.Refresh();
                        MessageBox.Show("Elemento eliminado con exito.", "Eliminar item", MessageBoxButton.OK, MessageBoxImage.Asterisk);
                    }
                }
                else
                {
                    MessageBox.Show("No se encontro el elemento.", "Buscar por SKU", MessageBoxButton.OK, MessageBoxImage.Error);
                }
            }
        }
예제 #2
0
        private void Update_Click(object sender, RoutedEventArgs e)
        {
            bool   error = false;
            double price = 0;
            int    cant  = 0;

            if (PN.Text.Contains(".") || PN.Text.Contains("-") || PN.Text.Contains(",") || PN.Text.Contains("/"))
            {
                MessageBox.Show("Error.\nEstos simbolos no son admisibles: . - , /", "Añadir elemento", MessageBoxButton.OK, MessageBoxImage.Error);
                error = true;
            }
            if (PI.Text.Contains(".") || PI.Text.Contains("-") || PI.Text.Contains(",") || PI.Text.Contains("/"))
            {
                MessageBox.Show("Error.\nEstos simbolos no son admisibles: . - , /", "Añadir elemento", MessageBoxButton.OK, MessageBoxImage.Error);
                error = true;
            }
            try
            {
                price = double.Parse(Price.Text);
                cant  = int.Parse(Cant.Text);
            }
            catch (FormatException err)
            {
                MessageBox.Show("Error.\n" + err.Message, "Añadir elemento", MessageBoxButton.OK, MessageBoxImage.Error);
                error = true;
            }
            if (WindowMode == 0 && !error)
            {
                int index = InventoryIO.items.IndexOf(InventoryWindow.info);
                InventoryIO.items.RemoveAt(index);
                InventoryInfo info = new InventoryInfo()
                {
                    SKU = int.Parse(SKU.Text), ProductName = PI.Text, ProductInfo = PN.Text, Price = double.Parse(Price.Text), Cant = int.Parse(Cant.Text)
                };
                InventoryIO.items.Insert(index, info);
                InventoryIO.InventorySet();
                MessageBox.Show("Refresque la lista de items al salir", "Modificar Item", MessageBoxButton.OK, MessageBoxImage.Asterisk);
                this.Close();
            }
            if (WindowMode == 1 && !error)
            {
                ToAdd.SKU         = int.Parse(SKU.Text);
                ToAdd.ProductName = PI.Text;
                ToAdd.ProductInfo = PN.Text;
                ToAdd.Price       = price;
                ToAdd.Cant        = cant;
                InventoryIO.items.Add(ToAdd);
                InventoryIO.InventorySet();
                MessageBox.Show("Refresque la lista de items al salir", "Modificar Item", MessageBoxButton.OK, MessageBoxImage.Asterisk);
                this.Close();
            }
        }