コード例 #1
0
        private void btnModificar_Click(object sender, EventArgs e)
        {
            if (txtNombre.Text != "Nombre" && txtCodigo.Text != "Codigo" && txtExistencia.Text != "Existencia" && txtDescripcion.Text != "Descripcion" && cbCategoria.Text != "Categoria")
            {
                string   nombre      = txtNombre.Text;
                string   codigo      = txtCodigo.Text;
                int      existencia  = Convert.ToInt32(txtExistencia.Text);
                DateTime fecha       = dtpFecha.Value;
                string   descripcion = txtDescripcion.Text;
                string   categoria   = cbCategoria.Text;
                bool     estado      = true;
                if (rdbActivo.Checked == true)
                {
                    estado = true;
                }
                else
                {
                    estado = false;
                }

                try
                {
                    if (N_producto.ModificarProducto(id, nombre, codigo, existencia, fecha, descripcion, categoria, estado))
                    {
                        MessageBox.Show("El registro se edito de manera exitosa", "Exito", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                    else
                    {
                        MessageBox.Show("No se pudo modificar el registro", "Advertencia", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    }
                    LimpiarForm();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.ToString());
                }
            }
            else
            {
                MessageBox.Show("Debe llenar todos los campos", "Advertencia", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }