public bool VerificarTarjeta(entTarjeta t) { SqlCommand cmd = null; SqlDataReader dr = null; bool resultado = false; try { SqlConnection conex = Conexion.Instancia.Conectar(); cmd = new SqlCommand("spVerificarTarjeta", conex); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@prmNroDocumento", t.NroDocumento); cmd.Parameters.AddWithValue("@prmNroTarjeta", t.NroTarjeta); cmd.Parameters.AddWithValue("@prmCredito", t.Credito); cmd.Parameters.AddWithValue("@prmFechaCaducidad", t.FechaCaducidad); conex.Open(); dr = cmd.ExecuteReader(); if (dr.Read()) { resultado = true; } } catch (Exception ex) { throw ex; } finally { cmd.Connection.Close(); } return resultado; }
protected void btnPagar_Click(object sender, EventArgs e) { char estado; if (rbCincuenta.Checked || rbTotal.Checked) { DataTable dt = (DataTable)Session["reserva"]; entCliente c = (entCliente)Session["cliente"]; if (rbCincuenta.Checked) { p.Pagado = (double)(p.Total * 50) / 100; estado = 'P'; } else { p.Pagado = p.Total; estado = 'R'; } //VERIFICAR QUE EXISTA LA TARJETA entTarjeta t = new entTarjeta(); t.Titular = txtTitular.Text; t.NroDocumento = c.NroDocumento; t.NroTarjeta = txtNroTarjeta.Text; t.FechaCaducidad = Convert.ToDateTime(txtFechaCaducidad.Text); //EN LA VARIABLE CREDITO LE ENVIAMOS EL MONTO QUE PAGO EL USUARIO t.Credito = p.Pagado; bool resultado = negTarjeta.Instancia.VerificarTarjeta(t); if (resultado) { int i = negReserva.Instancia.RegistrarReserva(dt, c, p, estado); //ENVIAR CORREO Boolean correcto = negEnviarCorreo.Instancia.enviaCorreo(c.Correo); //AL REALIZAR LA RESERVA SE REALIZA EL TRIGGER PARA DISMINUIR EL MONTO DE LA TARJETA DEL USUARIO if (i > 0) { Response.Write("<script>alert('Su Reserva se ha realizado con Éxito')</script>"); Session.Remove("reserva"); Response.Redirect("historialReservas.aspx"); } else { Response.Write("<script>alert('Error al Reservar')</script>"); } } else { Response.Write("<script>alert('La Tarjeta no es Valida')</script>"); } } }
public bool VerificarTarjeta(entTarjeta t) { return datTarjeta.Instancia.VerificarTarjeta(t); }