Example #1
0
 public CambiarContra(String nombre, Explorador ex, Inicio i, bool vieneDeInicio)
 {
     if (vieneDeInicio)
     {
         ini = i;
     }
     deInicio = vieneDeInicio;
     exx      = ex;
     nom      = nombre;
     InitializeComponent();
     coneccion = PalcoNet.Support.Conexion.conectar();
 }
Example #2
0
        private void button2_Click_1(object sender, EventArgs e)
        {
            //BOTON SELECCIONAR UN ROL EN ESPECÍFICO
            if (comboBox1.SelectedIndex == 0)
            {
                MessageBox.Show("No has seleccionado ningún rol aún");
                return;
            }
            buscarRolYSaberSiEsAdmin(comboBox1.Text, textBox1.Text);

            Usuario.Rol      = comboBox1.Text;
            Usuario.username = textBox1.Text;
            String    queryss = "SELECT usuario_Id FROM SQLEADOS.Usuario where usuario_nombre LIKE '" + Usuario.username + "'";
            DataTable dts     = DBConsulta.AbrirCerrarObtenerConsulta(queryss);

            Usuario.ID        = Convert.ToInt32(dts.Rows[0][0].ToString());
            textBox1.Text     = "";
            textBox2.Text     = "";
            comboBox1.Visible = false;
            button2.Visible   = false;
            label9.Visible    = false;


            if (primerLogin())
            {
                CambiarContra ca = new CambiarContra(Usuario.username, new Explorador(this), this, true);
                ca.Show();
                this.Hide();
            }
            else
            {
                Explorador form = new Explorador(this);
                form.Show();
                this.Hide();
            }
        }
Example #3
0
        //BUSCA ROLES, SI HAY 1 SOLO ENTRA AL BUSCADOR SINO DEBE ELEJIR ENTRE ELLOS
        private void encontrarRoles()
        {
            if (!tieneAlgunRol(textBox1.Text))
            {
                MessageBox.Show("Usted no tiene ningún rol asignado o habilitado");
                return;
            }
            coneccion.Open();
            esAdmin = new SqlCommand("[SQLeados].esAdministrador", coneccion);

            esAdmin.CommandType = CommandType.StoredProcedure;
            esAdmin.Parameters.Add("@Username", SqlDbType.VarChar).Value = textBox1.Text;


            var resultadoIntentos = esAdmin.Parameters.Add("@Valor", SqlDbType.Int);

            resultadoIntentos.Direction = ParameterDirection.ReturnValue;
            data = esAdmin.ExecuteReader();
            var resultadoIntentos2 = resultadoIntentos.Value;

            data.Close();

            roles = new SqlCommand("SQLeados.Nombreroles", coneccion);

            roles.CommandType = CommandType.StoredProcedure;
            roles.Parameters.Add("@Username", SqlDbType.VarChar).Value = textBox1.Text;

            SqlDataAdapter adapter    = new SqlDataAdapter(roles);
            DataTable      tablaRoles = new DataTable();

            adapter.Fill(tablaRoles);
            SqlDataReader reader    = roles.ExecuteReader();
            List <string> roleslist = new List <string>();

            comboBox1.DataSource    = tablaRoles;
            comboBox1.DisplayMember = "Rol_nombre";
            coneccion.Close();
            if (((int)resultadoIntentos2) == 1)
            {
                DataRow dr = tablaRoles.NewRow();
                dr["Rol_nombre"] = "Seleccione un rol";

                roleslist.Add("Seleccione rol");

                tablaRoles.Rows.InsertAt(dr, 0);
            }

            if (comboBox1.Items.Count == 1)
            {
                //PASA DIRECTO AL EXPLORADOR
                elRolEsAdmin();

                String rol;
                if (roleslist.Count != 0)
                {
                    rol = roleslist.First();
                }
                else
                {
                    rol = (tablaRoles.Rows[0]["Rol_nombre"]).ToString();
                }
                //BUSCO SI ES EL PRIMER LOGIN DEL USER ASI CAMBIA LA CONTRA AUTOGENERADA

                Usuario.Rol      = rol;
                Usuario.username = textBox1.Text;
                String    queryss = "SELECT usuario_Id FROM SQLEADOS.Usuario where usuario_nombre LIKE '" + Usuario.username + "'";
                DataTable dts     = DBConsulta.AbrirCerrarObtenerConsulta(queryss);
                Usuario.ID = Convert.ToInt32(dts.Rows[0][0].ToString());
                if (primerLogin())
                {
                    CambiarContra ca = new CambiarContra(Usuario.username, new Explorador(this), this, true);
                    ca.Show();
                    this.Hide();
                }
                else
                {
                    Explorador form = new Explorador(this);
                    form.Show();
                    this.Hide();
                }
            }
            else
            {
                //MUESTRA LA SECCIÓN DE ELEJIR ROLES
                //        button1.Visible = false;
                label9.Visible    = true;
                comboBox1.Visible = true;
                comboBox1.Text    = "Seleccione un rol";
                button2.Visible   = true;
            }
        }