protected void FechaDevText_Init(object sender, EventArgs e) { try { usuarioEN user = (usuarioEN)Session["user_session_data"]; int id; int.TryParse(Request.QueryString["id"], out id); transaccionSerieEN t = new transaccionSerieEN(id, user.Email); t = t.mostrarTransaccionSerie(); serieEN p = new serieEN(id, ""); p = p.mostrarSerie(); producto.Text = p.Titulo; float precio; if (t.Alquiler) { tipo.Text = "Alquiler"; fechaDevNum.Visible = true; fechaDevNum.Text = t.FechaF; FechaDevText.Visible = true; precio = p.PrecioA / 100; importe.Text = precio.ToString() + "€"; } else { tipo.Text = "Compra estándar"; precio = p.PrecioC / 100; importe.Text = precio.ToString() + "€"; } fechaPago.Text = t.FechaC; } catch (Exception ex) { Response.Redirect("../Pagina_Error.aspx?err=" + ex.Message); } }
public transaccionSerieEN mostrarTransaccion(int id, string email) { try { transaccionSerieEN devolver = new transaccionSerieEN(id, email); SqlConnection cn = new SqlConnection(ConfigurationManager.ConnectionStrings["bbdd"].ToString()); cn.Open(); string comando = ""; SqlCommand cmd; comando = "select * from TransaccionS where Email like '" + email + "' and Id_Serie = " + id; cmd = new SqlCommand(comando, cn); var reader = cmd.ExecuteReader(); while (reader.Read()) { devolver.FechaC = reader["Fecha_Compra"].ToString(); if (reader.IsDBNull(4)) { devolver.Alquiler = false; devolver.FechaF = null; } else { devolver.FechaF = reader["Fecha_Devolucion"].ToString(); devolver.Alquiler = true; } } reader.Close(); cn.Close(); return(devolver); } catch (Exception ex) { throw new Exception(ex.Message); } }
protected void Btn_Comprar_Click(object sender, EventArgs e) { try { transaccionSerieEN trans = new transaccionSerieEN(serie.IdS, user.Email); trans.comprarSerie(); Err.Visible = true; Err.Text = "Transaccion completada"; Err.ForeColor = Color.Green; SmtpClient cliente = new SmtpClient("smtp.gmail.com", 587); cliente.EnableSsl = true; cliente.Credentials = new System.Net.NetworkCredential("*****@*****.**", "hookin123"); double precio; precio = serie.PrecioC / 100 + 0.00; string contenido = "Hola, " + user.Nombre + ". Le informamos de que su última compra acaba de ser validada. \nSerie: " + serie.Titulo + "\n"; contenido += "Tipo de compra: Compra estándar \n"; contenido += "Fecha de compra: " + (DateTime.Now).ToString() + "\n"; contenido += "Precio total: " + precio.ToString() + "€\n"; contenido += "Puede comprobar su compra en la aplicación de Hookin.\n\n"; contenido += "El equipo de Cuentas de Hookin"; MailMessage mail = new MailMessage("*****@*****.**", user.Email, "Factura de compra", contenido); cliente.Send(mail); } catch (Exception ex) { Err.Visible = true; Err.Text = ex.Message; Err.ForeColor = Color.Red; } }
public List <transaccionSerieEN> listaTransaccionesAlquilerS(string email) { try { transaccionSerieEN trans = new transaccionSerieEN(); SqlConnection cn = new SqlConnection(ConfigurationManager.ConnectionStrings["bbdd"].ToString()); cn.Open(); string comando = "select * from TransaccionS where Email like '" + email + "'"; SqlCommand cmd = new SqlCommand(comando, cn); var reader = cmd.ExecuteReader(); List <transaccionSerieEN> lista = new List <transaccionSerieEN>(); while (reader.Read()) { trans = new transaccionSerieEN(); trans.Email = reader["Email"].ToString(); trans.IdS = (int)reader["Id_Serie"]; trans.FechaC = reader["Fecha_Compra"].ToString(); trans.Alquiler = (bool)reader["Alquiler"]; if (trans.Alquiler) { trans.FechaF = reader["Fecha_Devolucion"].ToString(); lista.Add(trans); } else { trans.FechaF = null; } } reader.Close(); cn.Close(); return(lista); } catch (Exception ex) { throw new Exception(ex.Message); } }