Пример #1
0
        private void ModificarProductos()
        {
            //aqui va el stock

            /*   HerramientaProductos herramientaProductos = new HerramientaProductos();
             * VentaVenta p = dtgProductoVenta.ItemsSource as VentaVenta;
             * ProductosFarmacia a = new ProductosFarmacia();
             * foreach (var item in herramientaProductos.Leer())
             * {
             *     if (item.Nombre== p.Producto) {
             *         a.Id = item.Id;
             *         a.Nombre = p.Producto;
             *         a.PrecioCompra = item.PrecioCompra;
             *         a.PrecioVenta = item.PrecioVenta;
             *         a.Presentacion = item.Presentacion;
             *         a.ProductoCategoria = item.ProductoCategoria;
             *         a.Stock = (int.Parse(item.Stock) - p.Cantidad).ToString();
             *         if (herramientaProductos.Modificar(a, item)) {
             *             ActualizarTabla();
             *             MessageBox.Show("Producto Actualizado");
             *         }
             *     }
             * }*/
            List <VentaVenta>        b = new List <VentaVenta>();
            List <ProductosFarmacia> j = new List <ProductosFarmacia>();


            foreach (var item in b)
            {
                foreach (var item2 in j)
                {
                    if (item.Producto == item2.Nombre)
                    {
                        item2.Id                = item2.Id;
                        item2.Nombre            = item.Producto;
                        item2.PrecioCompra      = item2.PrecioCompra;
                        item2.PrecioVenta       = item2.PrecioVenta;
                        item2.Presentacion      = item2.Presentacion;
                        item2.ProductoCategoria = item2.ProductoCategoria;
                        item2.Stock             = ((int.Parse(item2.Stock)) - item.Cantidad).ToString();
                        if (herramientaProductos.Modificar(item2, item2))
                        {
                            MessageBox.Show("Producto Actualizado");
                        }
                        else
                        {
                            MessageBox.Show("Error");
                        }
                    }
                }
            }
        }
Пример #2
0
        private void btnGuardar_Click(object sender, RoutedEventArgs e)
        {
            if (string.IsNullOrEmpty(txbNombre.Text))
            {
                MessageBox.Show("Faltan agregar el Nombre del Producto", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }
            if (string.IsNullOrEmpty(txbPrecioCompra.Text))
            {
                MessageBox.Show("Faltan agregar el Precio de Compra del producto", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }
            if (string.IsNullOrEmpty(txbPrecioVenta.Text))
            {
                MessageBox.Show("Faltan agregar el Precio de la venta", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }
            if (string.IsNullOrEmpty(txbPresentacion.Text))
            {
                MessageBox.Show("Faltan agregar la presentación del producto", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }
            if (string.IsNullOrEmpty(txbDescricpion.Text))
            {
                MessageBox.Show("Faltan agregar la descripción del producto", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }

            if (N)
            {
                ProductosFarmacia a = new ProductosFarmacia()
                {
                    Descripcion       = txbDescricpion.Text,
                    Id                = txbId.Text,
                    PrecioCompra      = txbPrecioCompra.Text,
                    PrecioVenta       = txbPrecioVenta.Text,
                    Presentacion      = txbPresentacion.Text,
                    Nombre            = txbNombre.Text,
                    ProductoCategoria = cmbCategoria.Text,
                    Stock             = txtCantidad.Text,
                };
                if (herramientas.Agregar(a))
                {
                    MessageBox.Show("Guardado con Éxito", "Productos", MessageBoxButton.OK, MessageBoxImage.Information);
                    ActualizarTabla();
                    HabilitarBotones(true);
                    habilitado(false);
                }
                else
                {
                    MessageBox.Show("Error al guardar Productos", "Productos", MessageBoxButton.OK, MessageBoxImage.Error);
                }
            }
            else
            {
                ProductosFarmacia o = dtgProductos.SelectedItem as ProductosFarmacia;
                ProductosFarmacia a = new ProductosFarmacia();
                a.Nombre            = txbNombre.Text;
                a.Descripcion       = txbDescricpion.Text;
                a.Id                = txbId.Text;
                a.PrecioCompra      = txbPrecioCompra.Text;
                a.PrecioVenta       = txbPrecioVenta.Text;
                a.Presentacion      = txbPresentacion.Text;
                a.ProductoCategoria = cmbCategoria.Text;
                a.Stock             = txtCantidad.Text;
                if (herramientas.Modificar(o, a))
                {
                    HabilitarBotones(true);
                    habilitado(false);
                    ActualizarTabla();
                    MessageBox.Show("Producto Actualizado", "Producto", MessageBoxButton.OK, MessageBoxImage.Information);
                }
                else
                {
                    MessageBox.Show("Error al guardar al Producto", "Producto", MessageBoxButton.OK, MessageBoxImage.Error);
                }
            }
        }