private void btnGrabar_Click(object sender, EventArgs e) { try { if (MessageBox.Show("¿Desea ingresar la venta?", "Venta", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { Clases.Venta ve = new Clases.Venta(); ve.codigo = Convert.ToInt32(txtCodigo.Text); ve.precioUnidad = Convert.ToInt32(txtPrecioUnitario.Text); ve.cantidad = Convert.ToInt32(txtCantidad.Text); ve.fecha = Convert.ToDateTime(dateFecha.Text); ve.ObtenerSubtotal(); ve.ObternerDescuento(); ve.ObtenerTotal(); ventas.Add(ve.codigo, ve); cargarDatos(); } }catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }