protected void btnAceptar_Click(object sender, EventArgs e)
 {
     if (!IsValid)
     {
         return;
     }
     try
     {
         DataContext db      = new DcGeneralDataContext();
         String      mensaje = String.Empty;
         if (!this.validacion(ref mensaje))
         {
             this.lblError.Text    = mensaje;
             this.lblError.Visible = true;
             return;
         }
         if (!this.sqlInjectionValida(ref mensaje))
         {
             this.lblError.Text    = mensaje;
             this.lblError.Visible = true;
             return;
         }
         if (!this.htmlInjectionValida(ref mensaje))
         {
             this.lblError.Text    = mensaje;
             this.lblError.Visible = true;
             return;
         }
         var dbUser = db.GetTable <Usuarios>().FirstOrDefault(u => u.strUsername == this.txtUsername.Text.Trim());
         if (dbUser == null)
         {
             this.lblError.Text    = "Nombre de usuario o contraseña incorrectos.";
             this.lblError.Visible = true;
             return;
         }
         if (dbUser.idEstado != 1)
         {
             this.lblError.Text    = "Ups! Parece que este usuario no está activo, consulta con el administrador de sistemas.";
             this.lblError.Visible = true;
             return;
         }
         var passDec = this.DesEncriptar(dbUser.strPassword);
         if (!passDec.Equals(this.txtPassword.Text.Trim()))
         {
             this.lblError.Text    = "Nombre de usuario o contraseña incorrectos.";
             this.lblError.Visible = true;
             return;
         }
         Session["UsernameSession"] = dbUser.strUsername;
         this.Response.Redirect("~/Main.aspx", false);
     } catch (Exception ex)
     {
         CtrlEmail email = new CtrlEmail();
         email.sendEmail(ex.Message, "Login.aspx.cs", "En el método btnAceptar_Click", ex.GetType().ToString());
         this.Response.Redirect("~/ErrorPages/ErrorPage.html", false);
     }
 }
Beispiel #2
0
        protected void btnAceptar_Click(object sender, EventArgs e)
        {
            if (!IsValid)
            {
                return;
            }
            try
            {
                CtrlEmail   email = new CtrlEmail();
                DataContext db    = new DcGeneralDataContext();

                var persona = db.GetTable <Linq.Data.Entity.Persona>().FirstOrDefault(p => p.strCorreo == this.txtCorreoElectronico.Text.Trim());
                if (persona == null)
                {
                    this.lblMensaje.Visible = true;
                    this.lblMensaje.Text    = "El correo ingresado no existe";
                    return;
                }
                var usuario = db.GetTable <Usuario>().FirstOrDefault(u => u.strNombrePersona == persona.id);
                if (usuario == null)
                {
                    this.lblMensaje.Visible = true;
                    this.lblMensaje.Text    = "El correo ingresado no tiene un usuario.";
                    return;
                }
                if (usuario.CatValorUsuario > 1)
                {
                    this.lblMensaje.Visible = true;
                    this.lblMensaje.Text    = "El usuario asignado a este correo no está activo";
                    return;
                }
                var token = this.GetSHA256(Guid.NewGuid().ToString());
                usuario.strTokenRecorver = token;
                db.SubmitChanges();
                if (recoveryPasswordEmail(persona.strCorreo, usuario.strUsuario, token))
                {
                    this.lblMensaje.Visible = true;
                    this.lblMensaje.Text    = "Revise su correopara la recuperacion de la contraseña";
                }
                else
                {
                    this.lblMensaje.Visible = true;
                    this.lblMensaje.Text    = "Error al enviar el correo";
                    return;
                }
            }
            catch (Exception ex)
            {
                Response.Redirect("~/MensajeError.aspx", false);
            }
        }
Beispiel #3
0
 protected void btnAceptar_Click(object sender, EventArgs e)
 {
     if (!IsValid)
     {
         return;
     }
     try
     {
         CtrlEmail   email   = new CtrlEmail();
         DataContext db      = new DcGeneralDataContext();
         var         persona = db.GetTable <Linq.Data.Entity.Persona>().FirstOrDefault(p => p.strEmail == this.txtEmail.Text.Trim());
         if (persona == null)
         {
             this.lblError.Visible = true;
             this.lblError.Text    = "El correo ingresado no existe en nuestro sistema.";
             return;
         }
         var usuario = db.GetTable <Usuarios>().FirstOrDefault(u => u.idComPersona == persona.id);
         if (usuario == null)
         {
             this.lblError.Visible = true;
             this.lblError.Text    = "El correo ingresado no está asociado a un usuario.";
             return;
         }
         if (usuario.idEstado > 1)
         {
             this.lblError.Visible = true;
             this.lblError.Text    = "El usuario asignado a este correo no está activo, consulte con el administrador del sistema.";
             return;
         }
         var token = this.GetSHA256(Guid.NewGuid().ToString());
         usuario.strRecoveryToken = token;
         db.SubmitChanges();
         if (email.recoveryPasswordEmail(persona.strEmail, persona.strNombre, token))
         {
             Response.Redirect("~/GenericPages/Recovery.html", false);
         }
         else
         {
             this.lblError.Visible = true;
             this.lblError.Text    = "Hubo un error al enviar el correo, intente más tarde.";
             return;
         }
     } catch (Exception ex)
     {
         CtrlEmail email = new CtrlEmail();
         email.sendEmail(ex.Message, "ForgotPassword.aspx.cs", "En el método btnAceptar_Click", ex.GetType().ToString());
         this.Response.Redirect("~/ErrorPages/ErrorPage.html", false);
     }
 }
 protected void btnAceptar_Click(object sender, EventArgs e)
 {
     if (!IsValid)
     {
         return;
     }
     try
     {
         DataContext db      = new DcGeneralDataContext();
         String      mensaje = String.Empty;
         var         user    = db.GetTable <Usuarios>().FirstOrDefault(u => u.strRecoveryToken == this.recoveryToken);
         if (!this.validacion(ref mensaje))
         {
             this.lblError.Text    = mensaje;
             this.lblError.Visible = true;
             return;
         }
         if (!this.sqlInjectionValida(ref mensaje))
         {
             this.lblError.Text    = mensaje;
             this.lblError.Visible = true;
             return;
         }
         if (!this.htmlInjectionValida(ref mensaje))
         {
             this.lblError.Text    = mensaje;
             this.lblError.Visible = true;
             return;
         }
         user.strPassword      = this.Encriptar(this.txtPassword.Text.Trim());
         user.strRecoveryToken = null;
         db.SubmitChanges();
         Session["UsernameSession"] = user.strUsername;
         Response.Redirect("~/Main.aspx", false);
     } catch (Exception ex)
     {
         CtrlEmail email = new CtrlEmail();
         email.sendEmail(ex.Message, "RecuperarContraseña.aspx.cs", "En el método btnAceptar_Click", ex.GetType().ToString());
         this.Response.Redirect("~/ErrorPages/ErrorPage.html", false);
     }
 }
Beispiel #5
0
 protected void btnAceptar_Click(object sender, EventArgs e)
 {
     if (!IsValid)
     {
         return;
     }
     try
     {
         DataContext dcGuardar = new DcGeneralDataContext();
         Usuarios    usuario   = new Usuarios();
         DateTime    dateValue = DateTime.Now;
         if (this.idUsuarios == 0)
         {
             // agregar
             usuario.idComPersona = int.Parse(this.ddlPersona.SelectedValue);
             usuario.strUsername  = this.txtUsername.Text.Trim();
             usuario.strPassword  = this.Encriptar(this.txtPassword.Text.Trim());
             usuario.idEstado     = 1;
             if (DateTime.TryParseExact(this.txtDateAd.Text.Trim(), "dd/MM/yyyy", CultureInfo.InvariantCulture, DateTimeStyles.None, out dateValue))
             {
                 usuario.dtFechaIngreso = dateValue;
             }
             String mensaje = String.Empty;
             if (!this.validacion(usuario, ref mensaje))
             {
                 this.lblErrorM3V.Text    = mensaje;
                 this.lblErrorM3V.Visible = true;
                 return;
             }
             if (!this.sqlInjectionValida(ref mensaje))
             {
                 this.lblErrorM3V.Text    = mensaje;
                 this.lblErrorM3V.Visible = true;
                 return;
             }
             if (!this.htmlInjectionValida(ref mensaje))
             {
                 this.lblErrorM3V.Text    = mensaje;
                 this.lblErrorM3V.Visible = true;
                 return;
             }
             if (!this.sqlQueryValidation(usuario, ref mensaje))
             {
                 this.lblErrorM3V.Text    = mensaje;
                 this.lblErrorM3V.Visible = true;
                 return;
             }
             // usuario.dtFechaIngreso = (!DateTime.TryParseExact(this.txtDateAd.Text.Trim(), "dd/MM/yyyy", CultureInfo.InvariantCulture, DateTimeStyles.None, out dateValue)) ? dateValue : dateValue;
             dcGuardar.GetTable <Usuarios>().InsertOnSubmit(usuario);
             dcGuardar.SubmitChanges();
             this.Response.Redirect("~/UsuariosPrincipal.aspx", false);
         }
         if (this.idUsuarios > 0)
         {
             usuario = dcGuardar.GetTable <Usuarios>().First(u => u.id == this.idUsuarios);
             // pendiente usuario.idComPersona = 1;
             usuario.strUsername = this.txtUsername.Text.Trim();
             usuario.strPassword = this.Encriptar(this.txtPassword.Text.Trim());
             usuario.idEstado    = int.Parse(this.ddlEstado.SelectedValue);
             //if (DateTime.TryParseExact(this.txtDateAd.Text.Trim(), "dd/MM/yyyy", CultureInfo.InvariantCulture, DateTimeStyles.None, out dateValue))
             //{
             //    usuario.dtFechaIngreso = dateValue;
             //}
             String mensaje = String.Empty;
             if (!this.validacion(usuario, ref mensaje))
             {
                 this.lblErrorM3V.Text    = mensaje;
                 this.lblErrorM3V.Visible = true;
                 return;
             }
             if (!this.sqlInjectionValida(ref mensaje))
             {
                 this.lblErrorM3V.Text    = mensaje;
                 this.lblErrorM3V.Visible = true;
                 return;
             }
             if (!this.htmlInjectionValida(ref mensaje))
             {
                 this.lblErrorM3V.Text    = mensaje;
                 this.lblErrorM3V.Visible = true;
                 return;
             }
             if (!this.sqlQueryValidationEditar(usuario, ref mensaje))
             {
                 this.lblErrorM3V.Text    = mensaje;
                 this.lblErrorM3V.Visible = true;
                 return;
             }
             dcGuardar.SubmitChanges();
             this.Response.Redirect("~/UsuariosPrincipal.aspx", false);
             // editar
         }
     } catch (Exception ex)
     {
         CtrlEmail email = new CtrlEmail();
         email.sendEmail(ex.Message, "UsuariosManager.aspx.cs", "En el método btnAceptar_Click", ex.GetType().ToString());
         this.Response.Redirect("~/ErrorPages/ErrorPage.html", false);
     }
 }
 protected void btnAceptar_Click(object sender, EventArgs e)
 {
     if (!IsValid)
     {
         // this.showMessageException("Ups, parece que hay algunos errores en el formulario, por favor, intenta nuevamente.");
         return;
     }
     try
     {
         // throw new Exception("Excepción de prueba para correo.");
         // ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "validate", "validate();", true);
         DataContext dcGuardar = new DcGeneralDataContext();
         UTTT.Ejemplo.Linq.Data.Entity.Persona persona = new Linq.Data.Entity.Persona();
         int      i         = 0;
         DateTime dateValue = DateTime.Now;
         if (this.idPersona == 0)
         {
             persona.strClaveUnica = this.txtClaveUnica.Text.Trim();
             persona.strNombre     = this.txtNombre.Text.Trim();
             persona.strAMaterno   = this.txtAMaterno.Text.Trim();
             persona.strAPaterno   = this.txtAPaterno.Text.Trim();
             persona.idCatSexo     = int.Parse(this.ddlSexo.Text);
             // persona.dtFechaNacimiento = this.dtFechaNacimiento.SelectedDate.Date;
             persona.dtFechaNacimiento = (!DateTime.TryParseExact(this.txtFechaNacimientoAjax.Text.Trim(), "dd/MM/yyyy", CultureInfo.InvariantCulture, DateTimeStyles.None, out dateValue)) ? (DateTime?)null : dateValue;
             persona.intNumHermanos    = this.txtNumHermanos.Text.Trim().Length > 0 ? (int.TryParse(this.txtNumHermanos.Text.Trim(), out i) ? int.Parse(this.txtNumHermanos.Text.Trim()) : 0) : 0;
             persona.strEmail          = this.txtEmail.Text.Trim();
             persona.strCP             = this.txtCP.Text.Trim();
             // persona.intCP = this.txtCP.Text.Trim().Length > 0 ? (int.TryParse(this.txtCP.Text.Trim(), out i) ? int.Parse(this.txtCP.Text.Trim()) : 0) : 0;
             persona.strRFC        = this.txtRFC.Text.Trim();
             persona.idEstadoCivil = int.Parse(this.ddlEstadoCivil.Text);
             String mensaje = String.Empty;
             if (!this.validacion(persona, ref mensaje))
             {
                 this.lblErrorM3V.Text    = mensaje;
                 this.lblErrorM3V.Visible = true;
                 return;
             }
             if (!this.sqlInjectionValida(ref mensaje))
             {
                 this.lblErrorM3V.Text    = mensaje;
                 this.lblErrorM3V.Visible = true;
                 return;
             }
             if (!this.htmlInjectionValida(ref mensaje))
             {
                 this.lblErrorM3V.Text    = mensaje;
                 this.lblErrorM3V.Visible = true;
                 return;
             }
             if (!this.sqlQueryValidation(persona, ref mensaje))
             {
                 this.lblErrorM3V.Text    = mensaje;
                 this.lblErrorM3V.Visible = true;
                 return;
             }
             dcGuardar.GetTable <UTTT.Ejemplo.Linq.Data.Entity.Persona>().InsertOnSubmit(persona);
             dcGuardar.SubmitChanges();
             this.showMessage("El registro se agrego correctamente.");
             this.Response.Redirect("~/PersonaPrincipal.aspx", false);
         }
         if (this.idPersona > 0)
         {
             persona = dcGuardar.GetTable <UTTT.Ejemplo.Linq.Data.Entity.Persona>().First(c => c.id == idPersona);
             persona.strClaveUnica = this.txtClaveUnica.Text.Trim();
             persona.strNombre     = this.txtNombre.Text.Trim();
             persona.strAMaterno   = this.txtAMaterno.Text.Trim();
             persona.strAPaterno   = this.txtAPaterno.Text.Trim();
             persona.idCatSexo     = int.Parse(this.ddlSexo.Text);
             // persona.dtFechaNacimiento = this.dtFechaNacimiento.SelectedDate.Date;
             // var olv = DateTime.TryParseExact(this.txtFechaNacimientoAjax.Text.Trim(), "MM/dd/yyyy", CultureInfo.InvariantCulture, DateTimeStyles.None, out dateValue);
             persona.dtFechaNacimiento = (!DateTime.TryParseExact(this.txtFechaNacimientoAjax.Text.Trim(), "dd/MM/yyyy", CultureInfo.InvariantCulture, DateTimeStyles.None, out dateValue)) ? (DateTime?)null : dateValue;
             persona.intNumHermanos    = this.txtNumHermanos.Text.Trim().Length > 0 ? (int.TryParse(this.txtNumHermanos.Text.Trim(), out i) ? int.Parse(this.txtNumHermanos.Text.Trim()) : 0) : 0;
             persona.strEmail          = this.txtEmail.Text.Trim();
             persona.strCP             = this.txtCP.Text.Trim();
             // persona.intCP = this.txtCP.Text.Trim().Length > 0 ? (int.TryParse(this.txtCP.Text.Trim(), out i) ? int.Parse(this.txtCP.Text.Trim()) : 0) : 0;
             persona.strRFC        = this.txtRFC.Text.Trim();
             persona.idEstadoCivil = int.Parse(this.ddlEstadoCivil.Text);
             String mensaje = String.Empty;
             if (!this.validacion(persona, ref mensaje))
             {
                 this.lblErrorM3V.Text    = mensaje;
                 this.lblErrorM3V.Visible = true;
                 return;
             }
             if (!this.sqlInjectionValida(ref mensaje))
             {
                 this.lblErrorM3V.Text    = mensaje;
                 this.lblErrorM3V.Visible = true;
                 return;
             }
             if (!this.htmlInjectionValida(ref mensaje))
             {
                 this.lblErrorM3V.Text    = mensaje;
                 this.lblErrorM3V.Visible = true;
                 return;
             }
             if (!this.sqlQueryValidationEditar(persona, ref mensaje))
             {
                 this.lblErrorM3V.Text    = mensaje;
                 this.lblErrorM3V.Visible = true;
                 return;
             }
             dcGuardar.SubmitChanges();
             this.showMessage("El registro se edito correctamente.");
             this.Response.Redirect("~/PersonaPrincipal.aspx", false);
         }
     }
     catch (Exception _e)
     {
         CtrlEmail email = new CtrlEmail();
         //String messageException = _e.Message;
         //String archivo = "PersonaManager.aspx.cs";
         //String at = DateTime.Now.ToString();
         //String customMessage = String.Format("Ocurrió una excepción en el sistema. {0} Mensaje de la excepción: {1}{0} " +
         //    "En el archivo: {2}{0} Fecha y Hora: {3}", Environment.NewLine, messageException, archivo, at);
         email.sendEmail(_e.Message, "PersonaManager.aspx.cs", "En el método btnAceptar_Click", _e.GetType().ToString());
         this.Response.Redirect("~/ErrorPages/ErrorPage.html", false);
         // this.showMessageException(_e.Message);
     }
 }
Beispiel #7
0
        protected void btnAceptar_Click(object sender, EventArgs e)
        {
            if (!IsValid)
            {
                return;
            }


            try
            {
                DataContext dcGuardar = new DcGeneralDataContext();
                UTTT.Ejemplo.Linq.Data.Entity.Persona persona = new Linq.Data.Entity.Persona();
                int i = 0;
                if (this.idPersona == 0)
                {
                    persona.strClaveUnica   = this.txtClaveUnica.Text.Trim();
                    persona.strNombre       = this.txtNombre.Text.Trim();
                    persona.strAMaterno     = this.txtAMaterno.Text.Trim();
                    persona.strAPaterno     = this.txtAPaterno.Text.Trim();
                    persona.idCatSexo       = int.Parse(this.ddlSexo.Text);
                    persona.fechaNacimiento = this.Calendar1.SelectedDate.Date;
                    persona.correo          = this.TextBox1.Text.Trim();
                    persona.codigoPostal    = this.TextBox3.Text.Trim();
                    persona.rfc             = this.TextBox2.Text.Trim();

                    String mensaje = String.Empty;

                    if (!this.validacion(persona, ref mensaje))
                    {
                        this.Label1.Text    = mensaje;
                        this.Label1.Visible = true;
                        return;
                    }
                    if (!this.sqlInjectionValida(ref mensaje))
                    {
                        this.Label1.Text    = mensaje;
                        this.Label1.Visible = true;
                        return;
                    }
                    if (!this.htmlInjectionValida(ref mensaje))
                    {
                        this.Label1.Text    = mensaje;
                        this.Label1.Visible = true;
                        return;
                    }


                    dcGuardar.GetTable <UTTT.Ejemplo.Linq.Data.Entity.Persona>().InsertOnSubmit(persona);
                    dcGuardar.SubmitChanges();
                    this.showMessage("El registro se agrego correctamente.");
                    this.Response.Redirect("~/PersonaPrincipal.aspx", false);
                }
                if (this.idPersona > 0)
                {
                    persona = dcGuardar.GetTable <UTTT.Ejemplo.Linq.Data.Entity.Persona>().First(c => c.id == idPersona);
                    persona.strClaveUnica   = this.txtClaveUnica.Text.Trim();
                    persona.strNombre       = this.txtNombre.Text.Trim();
                    persona.strAMaterno     = this.txtAMaterno.Text.Trim();
                    persona.strAPaterno     = this.txtAPaterno.Text.Trim();
                    persona.idCatSexo       = int.Parse(this.ddlSexo.Text);
                    persona.fechaNacimiento = this.Calendar1.SelectedDate.Date;
                    persona.correo          = this.TextBox1.Text.Trim();
                    persona.rfc             = this.TextBox2.Text.Trim();
                    persona.codigoPostal    = this.TextBox3.Text.Trim();
                    String mensaje = String.Empty;
                    if (!this.validacion(persona, ref mensaje))
                    {
                        this.Label1.Text    = mensaje;
                        this.Label1.Visible = true;
                        return;
                    }
                    if (!this.sqlInjectionValida(ref mensaje))
                    {
                        this.Label1.Text    = mensaje;
                        this.Label1.Visible = true;
                        return;
                    }
                    if (!this.htmlInjectionValida(ref mensaje))
                    {
                        this.Label1.Text    = mensaje;
                        this.Label1.Visible = true;
                        return;
                    }


                    dcGuardar.SubmitChanges();
                    this.showMessage("El registro se edito correctamente.");
                    this.Response.Redirect("~/PersonaPrincipal.aspx", false);
                }
            }
            catch (Exception _e)
            {
                CtrlEmail email = new CtrlEmail();

                email.sendEmail(_e.Message, "PersonaManager.aspx.cs", "error en btnAceptar_Click", _e.GetType().ToString());

                this.Response.Redirect("~/ErrorPage/colorlib-error-404-12/index.html", false);
            }
        }