private void Guardarbutton_Click(object sender, EventArgs e) { bool paso = false; if (Validar(2)) { MessageBox.Show("Llenar todos los campos marcados"); return; } MtyerrorProvider.Clear(); if (IdnumericUpDown.Value == 0) { paso = BLL.ArticulosBLL.Guardar(LlenarClase()); } else { paso = BLL.ArticulosBLL.Modificar(LlenarClase()); } if (paso) { MessageBox.Show("Guardado", "Exito", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("No se pudo guardar", "Fallo", MessageBoxButtons.OK, MessageBoxIcon.Error); } Vaciar(); }
private void Buscarbutton_Click(object sender, EventArgs e) { MtyerrorProvider.Clear(); if (Validar(1)) { MessageBox.Show("Ingrese un ID"); return; } int id = Convert.ToInt32(IdnumericUpDown.Value); Articulos articulo = BLL.ArticulosBLL.Buscar(id); if (articulo != null) { DescripciontextBox.Text = articulo.Descripcion; CostonumericUpDown.Value = Convert.ToDecimal(articulo.Costo); GanancianumericUpDown.Value = Convert.ToDecimal(articulo.Ganancia); PrecionumericUpDown.Value = Convert.ToDecimal(articulo.Precio); InventarionumericUpDown.Value = Convert.ToDecimal(articulo.Inventario); } else { MessageBox.Show("No se encontro", "Fallo", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private bool Validar(int validar) { bool paso = false; if (validar == 1 && IdnumericUpDown.Value == 0) { MtyerrorProvider.SetError(IdnumericUpDown, "Ingrese un ID"); paso = true; } return(paso); }
private void Eliminarbutton_Click(object sender, EventArgs e) { MtyerrorProvider.Clear(); if (Validar(1)) { MessageBox.Show("Ingrese un ID"); return; } int id = Convert.ToInt32(IdnumericUpDown.Value); if (BLL.ArticulosBLL.Eliminar(id)) { MessageBox.Show("Eliminado", "Exito", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("No se pudo eliminar", "Fallo", MessageBoxButtons.OK, MessageBoxIcon.Error); } }