protected void MensajeButton_Click(object sender, EventArgs e) { bool retorno = true; ValidacionLimpiar(); if (!Seguridad.ValidarNombre(NombreTextBox.Text)) { Mensajes.ShowToastr(this, "Error", "Nombre Invalido", "Error"); NombreDiv.Attributes.Add("class", " controls has-error "); retorno = false; } if (!Seguridad.ValidarTelefono(TelefonoTextBox.Text)) { Mensajes.ShowToastr(this, "Error", "Telefono Invalido", "Error"); TelefonoDiv.Attributes.Add("class", " controls has-error "); retorno = false; } if (!Seguridad.ValidarEmail(EmailTextBox.Text)) { Mensajes.ShowToastr(this, "Error", "Email Invalido", "Error"); EmailDiv.Attributes.Add("class", " controls has-error "); retorno = false; } if (!Seguridad.ValidarNombre(MensajeTextBox.Text)) { Mensajes.ShowToastr(this, "Error", "Mensaje Invalido", "Error"); MensajeDiv.Attributes.Add("class", " controls has-error "); retorno = false; } if (retorno) { if (Persona.Length == 0) { Persona = NombreTextBox.Text; } else { Persona = Context.User.Identity.Name; } if (EnvioCorreo.EnviarCorreo("Usuario", "Buenas has recibido un mensaje de: " + Persona + " T: " + TelefonoTextBox.Text, EmailTextBox.Text, NombreTextBox.Text, "", MensajeTextBox.Text)) { Mensajes.ShowToastr(this.Page, "Se Envio su Mensaje", "Felicidades", "Success"); Limpiar(); } else { Mensajes.ShowToastr(this.Page, "Hay problemas para enviar", "Ups", "Error"); } } }
protected void GuardarButton_Click(object sender, EventArgs e) { if (LLenarDatos()) { if (Usuario.Insertar()) { Mensajes.ShowToastr(this.Page, "Se Registro", "Felicidades", "Success"); Usuario.IniciarSesion(); Limpiar(); } else { Mensajes.ShowToastr(this.Page, "No se pudo Registrar", "Error", "Error"); } } else { Mensajes.ShowToastr(this.Page, "Faltan Datos", "Atencion", "Error"); } }
protected void IniciarButton_Click(object sender, EventArgs e) { bool retorno = true; ValidacionLimpiar(); if (!Seguridad.ValidarNombre(NombreTextBox.Text)) { Mensajes.ShowToastr(this, "Error", "Nombre de Usuario Invalido", "Error"); NombreDiv.Attributes.Add("class", " controls has-error "); retorno = false; } if (retorno) { Usuario.NombreUsuario = NombreTextBox.Text; } if (ContrasenaTextBox.Text.Length == 0) { Mensajes.ShowToastr(this, "Error", "Contraseña Invalido", "Error"); ContrasenaDiv.Attributes.Add("class", " controls has-error "); retorno = false; } if (retorno) { Usuario.Contrasena = ContrasenaTextBox.Text; } if (Usuario.IniciarSesion()) { FormsAuthentication.RedirectFromLoginPage(NombreTextBox.Text, RecordarmeCheckBox.Checked); } else { Mensajes.ShowToastr(this.Page, "Error de Inicio", "Error", "Error"); Limpiar(); } }
bool LLenarDatos() { bool retorno = true; ValidacionLimpiar(); if (!Seguridad.ValidarNombre(NombreUsuarioTextBox.Text)) { Mensajes.ShowToastr(this, "Error", "Nombre de Usuario Invalido", "Error"); NombreUsuarioDiv.Attributes.Add("class", " col-md-8 has-error "); retorno = false; } if (retorno) { Usuario.NombreUsuario = NombreUsuarioTextBox.Text; } if (NombreUsuarioTextBox.Text.Length > 0) { if (Usuario.Comprobar()) { Mensajes.ShowToastr(this.Page, "Ya existe ese Usuario Eliga otro", "Atencion", "Error"); NombreUsuarioTextBox.Text = ""; } } if (ContrasenaTextBox.Text.Length < 6) { Mensajes.ShowToastr(this, "Error", "Contraseña Invalido Mayor que 6", "Error"); NombreDiv.Attributes.Add("class", " col-md-8 has-error "); retorno = false; } if (retorno) { Usuario.Contrasena = ContrasenaTextBox.Text; } if (!Seguridad.ValidarNombre(NombreTextBox.Text)) { Mensajes.ShowToastr(this, "Error", "Nombre Invalido", "Error"); ContrasenaDiv.Attributes.Add("class", " col-md-8 has-error "); retorno = false; } if (retorno) { Usuario.Nombre = NombreTextBox.Text; } if (!Seguridad.ValidarNombre(ApellidoTextBox.Text)) { Mensajes.ShowToastr(this, "Error", "Apellido Invalido", "Error"); ApellidoDiv.Attributes.Add("class", " col-md-8 has-error "); retorno = false; } if (retorno) { Usuario.Apellido = ApellidoTextBox.Text; } if (!Seguridad.ValidarEmail(EmailTextBox.Text)) { Mensajes.ShowToastr(this, "Error", "Email Invalido", "Error"); EmailDiv.Attributes.Add("class", " col-md-8 has-error "); retorno = false; } if (retorno) { Usuario.Email = EmailTextBox.Text; } if (!Seguridad.ValidarTelefono(TelefonoTextBox.Text)) { Mensajes.ShowToastr(this, "Error", "Telefono Invalido", "Error"); TelefonoDiv.Attributes.Add("class", " col-md-8 has-error "); retorno = false; } if (retorno) { Usuario.Telefono = TelefonoTextBox.Text; } if (FechaNacimientoTextBox.Text.Length == 0) { Mensajes.ShowToastr(this, "Error", "Fecha Invalido", "Error"); TelefonoDiv.Attributes.Add("class", " col-md-8 has-error "); retorno = false; } if (retorno) { Usuario.FechaNacimiento = Seguridad.ValidarDateTime(FechaNacimientoTextBox.Text); } Usuario.TipoUsuarioId = Seguridad.ValidarEntero(TipoUsuarioDropDownList.SelectedValue); return(retorno); }