private void TxtBxCantidad_KeyPress(object sender, KeyPressEventArgs e) { if (e.KeyChar == (Char)Keys.Enter) { try { cant = int.Parse(TxtBxCantidad.Text); precio = double.Parse(TxtBxPrecio.Text); if (cant > 0 && cant < 1000) { if (LblCantS.Text == "") { preciot = cant * precio; } else { cs = int.Parse(LblCantS.Text); cant = cant + cs; } preciot = cant * precio; LblPrecioT.Text = preciot.ToString(); TxtBxPrecio.Focus(); } else { MessageBox.Show("La cantidad debe ser mayor a 1", "¡Atención!", MessageBoxButtons.OK, MessageBoxIcon.Warning); TxtBxCantidad.Text = ""; } } catch { MessageBox.Show("La cantidad debe ser un valor númerico", "¡Atención!", MessageBoxButtons.OK, MessageBoxIcon.Warning); TxtBxCantidad.Text = ""; } } }
private void TxtBxCantidad_KeyPress(object sender, KeyPressEventArgs e) { if (e.KeyChar == (Char)Keys.Enter) { try { cant = int.Parse(TxtBxCantidad.Text); if (cant > 0 && cant < 1000) { TxtBxPrecio.Focus(); } else { MessageBox.Show("La cantidad debe ser mayor a 1", "¡Atención!", MessageBoxButtons.OK, MessageBoxIcon.Warning); TxtBxCantidad.Text = ""; } } catch { MessageBox.Show("La cantidad debe ser un valor númerico", "¡Atención!", MessageBoxButtons.OK, MessageBoxIcon.Warning); TxtBxCantidad.Text = ""; } } }