Beispiel #1
0
        public bool getValidarUsuarioAdministrador(logica.Models.clsUsuarios obclsUsuarios)
        {
            try
            {
                DataSet dsConsulta = new DataSet();
                _SqlConnection = new SqlConnection(stConexion);
                _SqlConnection.Open();

                _SqlCommand             = new SqlCommand("spConsultarUsuarioAdministrador", _SqlConnection);
                _SqlCommand.CommandType = CommandType.StoredProcedure;

                _SqlCommand.Parameters.Add(new SqlParameter("@cCorreo", obclsUsuarios.stCorreo));
                _SqlCommand.Parameters.Add(new SqlParameter("@cPassword", obclsUsuarios.stPassword));
                _SqlCommand.ExecuteNonQuery();

                _SqlDataAdapter = new SqlDataAdapter(_SqlCommand);
                _SqlDataAdapter.Fill(dsConsulta);

                if (dsConsulta.Tables[0].Rows.Count > 0)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            catch (Exception ew)
            {
                throw ew;
            }
            finally { _SqlConnection.Close(); }
        }
Beispiel #2
0
 public bool getvalidarUsuarioController(logica.Models.clsUsuarios obclsUsuarios)
 {
     try
     {
         logica.BL.clsUsuarios obclsUsuario = new logica.BL.clsUsuarios();
         return(obclsUsuario.getvalidarUsuario(obclsUsuarios));
     }
     catch (Exception ex) { throw ex; }
 }
Beispiel #3
0
 public String setCrearCuentaControllers(logica.Models.clsUsuarios obclsUsuarioModels, int inOpcion)
 {
     try
     {
         logica.BL.clsUsuarios clsUsuarios = new logica.BL.clsUsuarios();
         return(clsUsuarios.setCrearCuenta(obclsUsuarioModels, inOpcion));
     }catch (Exception ew)
     {
         throw ew;
     }
 }
Beispiel #4
0
 public DataSet getConsultarPasswordController(logica.Models.clsUsuarios obclsUsuarios)
 {
     try
     {
         logica.BL.clsRecuperarPassword obclsRecuperarPassword = new logica.BL.clsRecuperarPassword();
         return(obclsRecuperarPassword.getConsultarPassword(obclsUsuarios));
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Beispiel #5
0
 public bool getValidarUsuarioAdministradorController(logica.Models.clsUsuarios obclsUsuarios)
 {
     try
     {
         logica.BL.clsUsuarios obclsUsuario = new logica.BL.clsUsuarios();
         return(obclsUsuario.getValidarUsuarioAdministrador(obclsUsuarios));
     }
     catch (Exception ew)
     {
         throw ew;
     }
 }
Beispiel #6
0
        /// <summary>
        /// CREAR CUENTA DE USUARIO
        /// </summary>
        /// <param name="obclsUsuarios"></param>
        /// <returns> MENSAJE DE BBDD</returns>
        public string setCrearCuenta(logica.Models.clsUsuarios obclsUsuarios, int inOpcion)
        {
            try
            {
                _SqlConnection = new SqlConnection(stConexion);
                _SqlConnection.Open();

                _SqlCommand             = new SqlCommand("sp_AdministrarUsuarios", _SqlConnection);
                _SqlCommand.CommandType = CommandType.StoredProcedure;


                //PARAMETROS DE ENTRADA
                _SqlCommand.Parameters.Add(new SqlParameter("@cNombre", obclsUsuarios.stNombre));
                _SqlCommand.Parameters.Add(new SqlParameter("@cApellido", obclsUsuarios.stApellido));
                _SqlCommand.Parameters.Add(new SqlParameter("@cCorreo", obclsUsuarios.stCorreo));
                _SqlCommand.Parameters.Add(new SqlParameter("@cPassword", obclsUsuarios.stPassword));
                _SqlCommand.Parameters.Add(new SqlParameter("@cImagen", obclsUsuarios.stUsuaImagen));
                _SqlCommand.Parameters.Add(new SqlParameter("@nOpcion", inOpcion));


                //PARAMETROS  DE SALIDA
                _SqlParameter = new SqlParameter();
                _SqlParameter.ParameterName = "@cMensaje";
                _SqlParameter.Direction     = ParameterDirection.Output;
                _SqlParameter.SqlDbType     = SqlDbType.VarChar;
                _SqlParameter.Size          = 50;

                _SqlCommand.Parameters.Add(_SqlParameter);

                _SqlCommand.ExecuteNonQuery();

                return(_SqlParameter.Value.ToString());
            }
            catch (Exception ew)
            {
                throw ew;
            }
            finally { _SqlConnection.Close(); }
        }
Beispiel #7
0
        protected void btnAceptar_Click(object sender, EventArgs e)
        {
            try
            {
                string stMensaje = string.Empty;
                if (string.IsNullOrEmpty(txtemail.Text))
                {
                    stMensaje += "ingrese Email,";
                }
                if (string.IsNullOrEmpty(txtPassword.Text))
                {
                    stMensaje += "ingrese Password,";
                }


                if (!string.IsNullOrEmpty(stMensaje))
                {
                    throw new Exception(stMensaje.TrimEnd(','));
                }

                //defino objeto con propiedades
                logica.Models.clsUsuarios obclsUsuarios = new logica.Models.clsUsuarios
                {
                    stLogin    = txtemail.Text,
                    stPassword = txtPassword.Text
                };
                //instancio controlador
                Controllers.LoginController obloginController = new Controllers.LoginController();

                bool blBandera = obloginController.getvalidarUsuarioController(obclsUsuarios);

                if (blBandera)
                {
                    Session["sessionEmail"] = txtemail.Text;

                    if (CheckRecordar.Checked)
                    {
                        //crear objeto cookie
                        HttpCookie cookie = new HttpCookie("cookieEmail", txtemail.Text);

                        //adicciono time de vida
                        cookie.Expires = DateTime.Now.AddDays(2);

                        //adicciono ala coleccion de cookie
                        Response.Cookies.Add(cookie);
                    }
                    else
                    {
                        //crear objeto cookie
                        HttpCookie cookie = new HttpCookie("cookieEmail", txtemail.Text);

                        //cookie expira el dira de ayer
                        cookie.Expires = DateTime.Now.AddDays(-1);
                        Response.Cookies.Add(cookie);
                    }

                    Response.Redirect("../Index/Index.aspx?stEmail=" + txtemail.Text); //redirecciono y atrapo el coreo y lo pongo en la url
                }


                else
                {
                    throw new Exception("Usuario o clave incorrecta");
                }
            }
            catch (Exception ex)
            {
                ClientScript.RegisterStartupScript(this.GetType(), "mensaje", "<script> swal('error!','" + ex.Message + "!', 'error') </Script>");
            }
        }
Beispiel #8
0
        protected void btnAceptar_Click(object sender, EventArgs e)
        {
            try
            {
                String stMensaje = String.Empty;
                if (String.IsNullOrEmpty(txtEmail.Text))
                {
                    stMensaje += "Ingrese Email, ";
                }
                if (String.IsNullOrEmpty(txtPassword.Text))
                {
                    stMensaje += "Ingrese Contraseña, ";
                }
                if (!String.IsNullOrEmpty(stMensaje))
                {
                    throw new Exception(stMensaje.TrimEnd(','));
                }
                //Defino Objeto con prioridades
                logica.Models.clsUsuarios obclsUsuarios = new logica.Models.clsUsuarios
                {
                    stCorreo   = txtEmail.Text,
                    stPassword = txtPassword.Text
                };
                //Instancio Controlador
                Controllers.LoginControllers obLogingController = new Controllers.LoginControllers();
                bool blBandera = obLogingController.getValidarUsuarioAdministradorController(obclsUsuarios);

                if (blBandera)
                {
                    if (chkRecordar.Checked)
                    {
                        HttpCookie cookieEmail = new HttpCookie("EmailAdministrador", txtEmail.Text);
                        cookieEmail.Expires = DateTime.Now.AddDays(2);
                        Response.Cookies.Add(cookieEmail);
                    }
                    else
                    {
                        HttpCookie cookieEmail = new HttpCookie("EmailAdministrador", txtEmail.Text);
                        cookieEmail.Expires = DateTime.Now.AddDays(-1);
                        Response.Cookies.Add(cookieEmail);
                    }

                    ViewState["viewLoginAdministrador"]    = txtEmail.Text;
                    ViewState["ViewPasswordAdministrador"] = txtPassword.Text;

                    Session["SessionEmailAdministrador"]   = txtEmail.Text;
                    Session["sesionPasswordAdministrador"] = txtPassword.Text;

                    Response.Redirect("../IndexAdmin/IndexAdmin.aspx");


                    //Session.RemoveAll(); Remover todas
                    //Session.Remove("sesionLogin"); Nombre Variable a remover
                }
                else
                {
                    throw new Exception("Usuario o password incorrectos");
                }
            }
            catch (Exception ex)
            {
                ClientScript.RegisterStartupScript(this.GetType(), "Mesaje", "<Script> swal('ERROR!', '" + ex.Message + "!', 'error')</Script>");
            }
        }
Beispiel #9
0
        protected void btnRegistrar_Click(object sender, EventArgs e)
        {
            try
            {
                String stMensaje = String.Empty;
                if (String.IsNullOrEmpty(txtNombre.Text))
                {
                    stMensaje += "Ingrese el Nombre,";
                }
                if (String.IsNullOrEmpty(txtLastName.Text))
                {
                    stMensaje += " Ingrese el apellido,";
                }
                if (String.IsNullOrEmpty(txtEmail.Text))
                {
                    stMensaje += " Ingrese Email,";
                }
                if (String.IsNullOrEmpty(txtPassword.Text))
                {
                    stMensaje += " Ingrese La Contraseña,";
                }
                if (String.IsNullOrEmpty(txtConfirmPassword.Text))
                {
                    stMensaje += " Ingrese la confirmacion de la contraseña,";
                }
                if (txtPassword.Text != txtConfirmPassword.Text)
                {
                    stMensaje += "Las Contraseñas son diferentes,";
                }
                if (!String.IsNullOrEmpty(stMensaje))
                {
                    throw new Exception(stMensaje.TrimEnd(','));
                }


                Controllers.CrearCuentaControllers obCrearCuentaControllers = new Controllers.CrearCuentaControllers();
                if (fuImagen.HasFile)
                {
                    if (!Path.GetExtension(fuImagen.FileName).Equals(".jpg"))
                    {
                        throw new Exception("Solo se admiten formatos .JPG");
                    }

                    String stRuta = Server.MapPath(@"~\tmp\") + fuImagen.FileName;
                    fuImagen.PostedFile.SaveAs(stRuta);
                    String stRutaDestino = Server.MapPath(@"~\Images\") + txtEmail.Text + Path.GetExtension(fuImagen.FileName);
                    if (File.Exists(stRutaDestino))
                    {
                        File.SetAttributes(stRutaDestino, FileAttributes.Normal);
                        File.Delete(stRutaDestino);
                    }

                    File.Copy(stRuta, stRutaDestino);
                    File.SetAttributes(stRuta, FileAttributes.Normal);
                    File.Delete(stRuta);

                    logica.Models.clsUsuarios obclsUsuarios = new logica.Models.clsUsuarios
                    {
                        stNombre     = txtNombre.Text,
                        stApellido   = txtLastName.Text,
                        stCorreo     = txtEmail.Text,
                        stPassword   = txtPassword.Text,
                        stUsuaImagen = stRutaDestino
                    };
                    ClientScript.RegisterStartupScript(this.GetType(), "mensaje", "<script> swal('Mensaje!', '" + obCrearCuentaControllers.setCrearCuentaControllers(obclsUsuarios, 1) + "!', 'success') </script>");
                }
            }
            catch (Exception ex)
            {
                ClientScript.RegisterStartupScript(this.GetType(), "Mesaje", "<Script> swal('ERROR!', '" + ex.Message + "!', 'error')</Script>");
            }
        }
Beispiel #10
0
        protected void btnRecuperar_Click(object sender, EventArgs e)
        {
            try
            {
                String stMensaje = String.Empty;
                if (String.IsNullOrEmpty(txtIngresarEmail.Text))
                {
                    stMensaje = "Ingrese el Email";
                }
                if (!String.IsNullOrEmpty(stMensaje))
                {
                    throw new Exception(stMensaje);
                }

                Controllers.RecuperarPasswordControllers obRecuperarPasswordControllers = new Controllers.RecuperarPasswordControllers();
                logica.Models.clsUsuarios obclsUsuarios = new logica.Models.clsUsuarios
                {
                    stCorreo = txtIngresarEmail.Text
                };

                DataSet dsConsulta = obRecuperarPasswordControllers.getConsultarPasswordController(obclsUsuarios);

                if (dsConsulta.Tables[0].Rows.Count > 0)
                {
                    string[] stLogin      = dsConsulta.Tables[0].Rows[0]["usuaCorreo"].ToString().Split('@');
                    string   stCuerpoHTML = "<!DOCTYPE html>";
                    stCuerpoHTML += "<html lang='es'>";
                    stCuerpoHTML += "<head>";
                    stCuerpoHTML += "<meta charset='utf - 8'>";
                    stCuerpoHTML += "<title>Recuperacion de correo</title>";
                    stCuerpoHTML += "</head>";
                    stCuerpoHTML += "<body style='background - color: black '>";
                    stCuerpoHTML += "<table style='max - width: 600px; padding: 10px; margin: 0 auto; border - collapse: collapse; '>	";
                    stCuerpoHTML += "<tr>";
                    stCuerpoHTML += "<td style='padding: 0'>";
                    stCuerpoHTML += "<img style='padding: 0; display: block' src='cid:Fondo' width='100%' height='10%'>";
                    stCuerpoHTML += "</td>";
                    stCuerpoHTML += "</tr>";
                    stCuerpoHTML += "<tr>";
                    stCuerpoHTML += "<td style='background - color: #ecf0f1'>";
                    stCuerpoHTML += "<div style='color: #34495e; margin: 4% 10% 2%; text-align: justify;font-family: sans-serif'>";
                    stCuerpoHTML += "<h2 style='color: #e67e22; margin: 0 0 7px'>Hola " + stLogin[0] + "</h2>";
                    stCuerpoHTML += "<p style='margin: 2px; font - size: 15px'>";
                    stCuerpoHTML += "Hemos recibido una solicitud para restablecer el password de su cuenta asociada con ";
                    stCuerpoHTML += "esta dirección de correo electrónico. Si no ha realizado esta solicitud, puede ignorar este ";
                    stCuerpoHTML += "correo electrónico y le garantizamos que su cuenta es completamente segura.";
                    stCuerpoHTML += "<br/>";
                    stCuerpoHTML += "<br/>";
                    stCuerpoHTML += "Su password es: " + dsConsulta.Tables[0].Rows[0]["usuaPassword"].ToString();
                    stCuerpoHTML += "</p>";
                    stCuerpoHTML += "<p style='color: #b3b3b3; font-size: 12px; text-align: center;margin: 30px 0 0'>Copyright © Conoce a:Colombia 2018</p>";
                    stCuerpoHTML += "</div>";
                    stCuerpoHTML += "</td>";
                    stCuerpoHTML += "</tr>";
                    stCuerpoHTML += "</table>";
                    stCuerpoHTML += "</body>";
                    stCuerpoHTML += "</html>";
                    logica.Models.clsCorreo obclsCorreo = new logica.Models.clsCorreo()
                    {
                        stServidor       = ConfigurationManager.AppSettings["stServidor"].ToString(),
                        stUsuario        = ConfigurationManager.AppSettings["stUsuario"].ToString(),
                        stPassword       = ConfigurationManager.AppSettings["stPassword"].ToString(),
                        stPuerto         = ConfigurationManager.AppSettings["stPuerto"].ToString(),
                        blAutenticacion  = true,
                        blConexionSegura = true,
                        inPrioridad      = 0,
                        inTipo           = 1,
                        stAsunto         = "Recuperacion de Password",
                        stFrom           = ConfigurationManager.AppSettings["stUsuario"].ToString(),
                        stTo             = txtIngresarEmail.Text,
                        stImage          = Server.MapPath("~") + @"\Resources\Images\hqdefault.jpg",
                        stIdImage        = "Fondo",
                        stMensaje        = stCuerpoHTML
                    };

                    obRecuperarPasswordControllers.setEmailController(obclsCorreo);
                    ClientScript.RegisterStartupScript(this.GetType(), "Mesaje", "<Script> swal('Mensaje!', 'Se realizo proceso con exito!', 'success')</Script>");
                }
                else
                {
                    throw new Exception("No se encotro información asociada con esa dirección de correo");
                }
            }
            catch (Exception ex)
            {
                ClientScript.RegisterStartupScript(this.GetType(), "Mesaje", "<Script> swal('ERROR!', '" + ex.Message + "!', 'error')</Script>");
            }
        }