private void btnGrabar_Click(object sender, EventArgs e) { if (cmbNroCuenta.SelectedItem == null) { MessageBox.Show("Seleccione un Número de Cuenta, por favor"); return; } if (cmbNroCuenta.Text == " ") { MessageBox.Show("Seleccione un Número de Cuenta, por favor"); return; } if (cmbMoneda.SelectedItem == null) { MessageBox.Show("Seleccione un tipo de moneda, por favor"); return; } else { if (cmbMoneda.Text != "Dólares") { MessageBox.Show("El importe debe estar expresado en Dolares"); return; } } if (txtImporte.Text == "") { MessageBox.Show("Ingrese un Importe, por favor"); return; } decimal temp; try { if (txtImporte.Text != "") { temp = Convert.ToDecimal(txtImporte.Text); if (temp < 0) { MessageBox.Show("El importe debe ser positivo."); return; } } } catch (Exception h) { MessageBox.Show("Importe solo puede contener números",h.ToString()); return; } Conexion con = new Conexion(); //CORROBORO SALDO string query = "SELECT saldo FROM LPP.CUENTAS WHERE num_cuenta = "+ Convert.ToDecimal(cmbNroCuenta.Text)+" AND saldo >= "+Convert.ToDecimal(txtImporte.Text)+""; importe = Convert.ToDecimal(txtImporte.Text); id_moneda = this.getIdMoneda(); con.cnn.Open(); SqlCommand command = new SqlCommand(query, con.cnn); SqlDataReader lector = command.ExecuteReader(); if (lector.Read()) { Cheque form_cheque = new Cheque(Convert.ToDecimal(cmbNroCuenta.Text), usuario); form_cheque.importe = importe; form_cheque.id_moneda = id_moneda; form_cheque.Show(); this.Close(); } else { MessageBox.Show("La cuenta tiene saldo insuficiente"); return; } con.cnn.Close(); }
private void btnGrabar_Click(object sender, EventArgs e) { if (cmbNroCuenta.SelectedItem == null) { MessageBox.Show("Seleccione un Número de Cuenta, por favor"); return; } if (cmbMoneda.SelectedItem == null) { MessageBox.Show("Seleccione un tipo de moneda, por favor"); return; } else { if (cmbMoneda.Text != "Dólares") { MessageBox.Show("El importe debe estar expresado en Dolares"); return; } } if (txtImporte.Text == "") { MessageBox.Show("Ingrese un Importe, por favor"); return; } int temp; try { if (txtImporte.Text != "") { temp = Convert.ToInt32(txtImporte.Text); } } catch (Exception h) { MessageBox.Show("Importe solo puede contener números", h.ToString()); return; } Conexion con = new Conexion(); //CORROBORO SALDO string query = "SELECT saldo FROM LPP.CUENTAS WHERE num_cuenta = " + Convert.ToDecimal(cmbNroCuenta.Text) + " AND saldo >= " + Convert.ToDecimal(txtImporte.Text) + ""; importe = Convert.ToDecimal(txtImporte.Text); id_moneda = this.getIdMoneda(); con.cnn.Open(); SqlCommand command = new SqlCommand(query, con.cnn); SqlDataReader lector = command.ExecuteReader(); if (lector.Read()) { Cheque form_cheque = new Cheque(Convert.ToDecimal(cmbNroCuenta.Text), usuario); form_cheque.importe = importe; form_cheque.id_moneda = id_moneda; form_cheque.Show(); this.Close(); } else { MessageBox.Show("La cuenta tiene saldo insuficiente"); return; } con.cnn.Close(); }