Beispiel #1
0
 private void BtnGuardar_Click(object sender, EventArgs e)
 {
     try
     {
         Producto pro = null;
         if (modo == "I")
         {
             pro = ObtenerProductoFormulario();
             if (pro != null)
             {
                 Producto.AgregarProductos(pro);
                 MessageBox.Show("Registro insertado correctamente", "Alta", MessageBoxButtons.OK, MessageBoxIcon.Information);
                 ListarProducto();
                 LimpiarFormulario();
                 PanelMantenimiento.Enabled = false;
                 PanelConsulta.Enabled      = true;
             }
         }
         else if (modo == "E")
         {
             int index = Convert.ToInt32(dgvProducto.CurrentRow.Cells[0].Value);
             pro = ObtenerProductoFormulario();
             if (pro != null)
             {
                 Producto.EditarProducto(index, pro);
                 MessageBox.Show("Registro editado correctamente", "Modificación", MessageBoxButtons.OK, MessageBoxIcon.Information);
                 ListarProducto();
                 LimpiarFormulario();
                 PanelMantenimiento.Enabled = false;
                 PanelConsulta.Enabled      = true;
             }
             txtBuscar.Focus();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString(), "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }