Esempio n. 1
0
        private void btnEditar_Click(object sender, EventArgs e)
        {
            if (cbbCategorias.Text == "")
            {
                cbbCategorias.Text = "Ninguna";
            }
            if (txtCodigo.Text == "" || txtDescripcion.Text == "" || cbbCategorias.Text == "" || cbbCategorias.Text == "" || txtStock.Text == "" || txtCosto.Text == "" || txtPrecio.Text == "")
            {
                MessageBox.Show("faltan datos");
                return;
            }
            else
            {
                ProductoModel productoModel = new ProductoModel
                {
                    Codigo      = int.Parse(txtCodigo.Text),
                    Descripcion = txtDescripcion.Text,
                    Categoria   = cbbCategorias.Text,
                    Stock       = int.Parse(txtStock.Text),
                    Costo       = decimal.Parse(txtCosto.Text),
                    Precio      = decimal.Parse(txtPrecio.Text)
                };


                if (dProducto.EditarProducto(productoModel) == true)
                {
                    cargarProductosAll();

                    limpiar();

                    desabilitar_textbox();
                    btnGuardar.Visible  = false;
                    btnnuevo.Visible    = true;
                    btnEditar.Enabled   = false;
                    btnEliminar.Enabled = false;
                    btbcancelar.Enabled = false;
                }
                else
                {
                    MessageBox.Show("Error al editar datos");
                }
            }
        }