protected void DWPeliculas_Init(object sender, EventArgs e) { try { int id; int.TryParse(Request.QueryString["id"], out id); //Recuperamos id del actor actor = new actorEN(id, ""); //Cargamos id del actor en el EN actor = actor.mostrarActor(); //Cargamos los datos del actor NombreText.Text = actor.Nombre; ApellidosText.Text = actor.Apellidos; fechaNac.Text = actor.FechaNac.Substring(0, 10); paisEN p = new paisEN(actor.Pais); nombrePais.Text = p.mostrarIdPais().Pais; List <peliculaEN> peliculas = actor.mostrarPeliculasActor(); List <string> nombres = new List <string>(); for (int i = 0; i < peliculas.Count; i++)//Guardamos nombres en la lista desplegable { nombres.Add(peliculas[i].NombreP); listaID.Add(peliculas[i].IdP);//Asociamos id a cada nombre de la lista } DWPeliculas.DataSource = nombres; DWPeliculas.DataBind(); DWPeliculas.Items.Insert(0, new ListItem("[Seleccionar]", "0")); }catch (Exception ex) { Response.Redirect("../Pagina_Error.aspx?err=" + ex.Message); } }
protected void BTN_CAMBIARC(object sender, EventArgs e) { Err.Visible = false; if (Text_nombre.Text == "" || Text_apellidos.Text == "") { Err.Visible = true; Err.Text = "*Existen campos vacíos"; Err.ForeColor = Color.Red; } else { paisEN p = new paisEN(DWPais.SelectedItem.ToString()); try { user.Nombre = Text_nombre.Text; user.Apellidos = Text_apellidos.Text; user.Pais = p.mostrarIdPais().IdPais; user.modificarDatos(); Err.Visible = true; Err.Text = "Datos cambiados correctamente"; Err.ForeColor = Color.Green; Session["user_session_data"] = user; } catch (Exception ex) { Err.Visible = true; Err.Text = ex.Message; Err.ForeColor = Color.Red; } } }
protected void BTN_CREAR(object sender, EventArgs e) { Text_Email.BorderColor = Color.Green; Text_Cnt.BorderColor = Color.Green; Text_nom.BorderColor = Color.Green; Text_Rcnt.BorderColor = Color.Green; Text_ap.BorderColor = Color.Green; DWPais.BorderColor = Color.Green; bool correcto = true; EmailErr.Visible = false; CntErr.Visible = false; NombreErr.Visible = false; RcntErr.Visible = false; PaisErr.Visible = false; ApellidosErr.Visible = false; TerminosErr.Visible = false; if (Text_Email.Text == "") { EmailErr.Text = "*Campo vacío."; correcto = false; Text_Email.BorderColor = Color.Red; EmailErr.Visible = true; } else if (!Text_Email.Text.Contains("@gmail.") && !Text_Email.Text.Contains("@hotmail.") && !Text_Email.Text.Contains("@yahoo.")) { correcto = false; EmailErr.Text = "*Dominio incorrecto. Pruebe con @gmail,@hotmail o @yahoo."; Text_Email.BorderColor = Color.Red; EmailErr.Visible = true; } if (Text_Cnt.Text == "") { CntErr.Text = "*Campo vacío"; correcto = false; Text_Cnt.BorderColor = Color.Red; CntErr.Visible = true; } else { if (Text_Cnt.Text.Length < 7) { correcto = false; CntErr.Text = "*La contraseña debe tener como mínimo 7 caracteres"; Text_Cnt.BorderColor = Color.Red; CntErr.Visible = true; } } if (Text_nom.Text == "") { correcto = false; Text_nom.BorderColor = Color.Red; NombreErr.Visible = true; } if (Text_Rcnt.Text == "") { RcntErr.Text = "*Campo vacío."; correcto = false; Text_Rcnt.BorderColor = Color.Red; RcntErr.Visible = true; } else if (Text_Rcnt.Text != Text_Cnt.Text && Text_Rcnt.Text != "") { RcntErr.Text = "*Contraseña distinta"; correcto = false; Text_Rcnt.BorderColor = Color.Red; RcntErr.Visible = true; } if (Text_ap.Text == "") { correcto = false; Text_ap.BorderColor = Color.Red; ApellidosErr.Visible = true; } if (DWPais.SelectedItem.ToString() == "[Seleccionar]") { correcto = false; DWPais.BorderColor = Color.Red; PaisErr.Visible = true; } if (!Terminos.Checked) { correcto = false; TerminosErr.Visible = true; } if (correcto) { string hash = CalculateMD5Hash(Text_Cnt.Text); paisEN pais = new paisEN(DWPais.SelectedItem.ToString()); usuarioEN user = new usuarioEN(); user.Apellidos = Text_ap.Text; user.Contrasenya = hash; user.Email = Text_Email.Text; user.Nombre = Text_nom.Text; user.Pais = pais.mostrarIdPais().IdPais; DateTime fecha = DateTime.Now; user.FechaA = fecha.Date.ToString(); try { SmtpClient cliente = new SmtpClient("smtp.gmail.com", 587); cliente.EnableSsl = true; cliente.Credentials = new System.Net.NetworkCredential("*****@*****.**", "hookin123"); string contenido = "Hola, " + user.Nombre + ". Le informamos de que su registro se ha completado correctamente.\n"; contenido += "Fecha del registro: " + (DateTime.Now).ToString(); contenido += "\nPuede consultar su cuenta en la aplicación de Hookin.\n\n"; contenido += "El equipo de Cuentas de Hookin"; MailMessage mail = new MailMessage("*****@*****.**", user.Email, "¡Bienvenido a Hookin!", contenido); user.anyadirUsuario(); cliente.Send(mail); Session["user_session_data"] = user; Response.Redirect("Area_Cliente/Menu_Cliente.aspx"); } catch (Exception ex) { EmailErr.Visible = true; EmailErr.Text = ex.Message; } } else { EmailErr.Visible = false; } }