Пример #1
0
        private void btnAltaProducto_Click(object sender, EventArgs e)
        {
            try
            {
                bool   resultado = false;
                string mensaje   = ValidarCampos();

                if (string.IsNullOrEmpty(mensaje))
                {
                    Producto nuevo = new Producto();

                    nuevo.Descripcion = txtDescripcion.Text;
                    nuevo.Sku         = txtSku.Text;
                    nuevo.Precio      = decimal.Parse(txtPrecio.Text);
                    nuevo.Stock       = int.Parse(txtStock.Text);

                    if (!isUpdate)
                    {
                        resultado = _ProductoRepo.AltaProducto(nuevo);
                    }
                    else
                    {
                        nuevo.Id  = idP;
                        resultado = _ProductoRepo.ModificarProducto(nuevo);
                    }

                    if (resultado)
                    {
                        if (!isUpdate)
                        {
                            MessageBox.Show("ALTA EXITOSA.");
                        }
                        else
                        {
                            MessageBox.Show("MODIFICACIÓN EXITOSA.");
                        }

                        Close();
                    }
                    else
                    {
                        MessageBox.Show("Se produjo un error, intente mas tarde.");
                    }
                }
                else
                {
                    MessageBox.Show(mensaje);
                }
            }
            catch (Exception)
            {
                throw;
            }
        }