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 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 DWPais_Init(object sender, EventArgs e) { try { if (DWPais != null) { paisEN pais = new paisEN(); DWPais.DataSource = pais.mostrarListaNombresPaises(); DWPais.DataBind(); } }catch (Exception ex) { Response.Redirect("../Pagina_Error.aspx?err=" + ex.Message); } }
protected void DWPais_Init(object sender, EventArgs e) { try { if (DWPais != null) { paisEN pais = new paisEN(); Session["user_session_data"] = null; DWPais.DataSource = pais.mostrarListaNombresPaises(); DWPais.DataBind(); DWPais.Items.Insert(0, new ListItem("[Seleccionar]", "0")); } }catch (Exception ex) { Response.Redirect("Pagina_Error.aspx?err=" + ex.Message); } }
protected void DWPais_Init(object sender, EventArgs e) { int i; List <int> nums = new List <int>(); if (DWPais != null) { paisEN pais = new paisEN(); DWPais.DataSource = pais.mostrarListaNombresPaises(); DWPais.DataBind(); DWPais.Items.Insert(0, new ListItem("[Seleccionar]", "0")); } if (DWdia != null) { nums.Clear(); for (i = 1; i < 32; i++) { nums.Add(i); } DWdia.DataSource = nums; DWdia.DataBind(); } if (DWmes != null) { nums.Clear(); for (i = 1; i < 13; i++) { nums.Add(i); } DWmes.DataSource = nums; DWmes.DataBind(); } if (DWaño != null) { nums.Clear(); for (i = 1900; i < 2019; i++) { nums.Add(i); } DWaño.DataSource = nums; DWaño.DataBind(); } }
public paisEN mostrarIdPais(string nombre) { paisEN devolver = new paisEN(); devolver.Pais = nombre; SqlConnection cn = new SqlConnection(ConfigurationManager.ConnectionStrings["bbdd"].ToString()); cn.Open(); string comando = "select Id_pais from Paises where Pais = '" + nombre + "'"; SqlCommand cmd = new SqlCommand(comando, cn); var reader = cmd.ExecuteReader(); while (reader.Read()) { devolver.IdPais = (int)(reader["Id_pais"]); } reader.Close(); cn.Close(); return(devolver); }
public paisEN mostrarPais(int id) { paisEN devolver = new paisEN(); devolver.IdPais = id; SqlConnection cn = new SqlConnection(ConfigurationManager.ConnectionStrings["bbdd"].ToString()); cn.Open(); string comando = "select Pais from Paises where Id_pais = " + id.ToString(); SqlCommand cmd = new SqlCommand(comando, cn); var reader = cmd.ExecuteReader(); while (reader.Read()) { devolver.Pais = (reader["Pais"].ToString()); } reader.Close(); cn.Close(); return(devolver); }
protected void Page_Load(object sender, EventArgs e) { try { paisEN p = new paisEN(); Response.Charset = "utf-8"; usuarioEN user = (usuarioEN)Session["user_session_data"]; p.IdPais = user.Pais; pais.Text = p.mostrarNombrePais().Pais; nombre.Text = user.Nombre + " " + user.Apellidos; email.Text = user.Email; fecha.Text = user.FechaA.Substring(0, 11); if (user.AdMin) { admin.Visible = true; } } catch (Exception ex) { Response.Redirect("../Pagina_Error.aspx?err=" + ex.Message); } }
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; } }