Esempio n. 1
0
        private void button1_Click(object sender, EventArgs e)
        {
            validaciones.Encriptacion en = new validaciones.Encriptacion();
            string claveencrip = (en.Encriptar("1234"));
            txt_nombre.Text = claveencrip;


        }
Esempio n. 2
0
        private void button1_Click(object sender, EventArgs e)
        {
            SqlConnection cn = new SqlConnection(ConfigurationManager.ConnectionStrings["coneccion"].ConnectionString);

            cn.Open();
            validaciones.Validaciones vali = new validaciones.Validaciones();
            if (string.IsNullOrEmpty(txt_email.Text) || string.IsNullOrEmpty(txt_clave.Text))
            {
                MessageBox.Show("Los campos 'Usuario' y 'Password' son obligatorios.", "LOGIN", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                txt_email.Focus();
            }
            else
            {
                if (vali.validarEmail(txt_email.Text) == false)
                {
                    MessageBox.Show("Ingrese un email válido.", "LOGIN", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    txt_email.Focus();
                }
                else
                {
                    validaciones.Encriptacion en = new validaciones.Encriptacion();
                    string        claveencrip    = (en.Encriptar(txt_clave.Text));
                    SqlCommand    consulta       = new SqlCommand("SELECT * FROM usuario WHERE email_user='******' AND pass_user='******'", cn);
                    SqlDataReader ejecuta        = consulta.ExecuteReader();
                    if (ejecuta.Read() == true)
                    {
                        MessageBox.Show("Bienvenido");
                        MDIprincipal menu = new MDIprincipal();
                        this.Hide();
                        menu.Show();
                    }
                    else
                    {
                        MessageBox.Show("Usuario no encontrado");
                        txt_clave.Text = "USUARIO";
                        txt_email.Text = "CONTRASEÑA";
                    }
                }
            }
            cn.Close();
            cn.Dispose();
        }
Esempio n. 3
0
        private void button3_Click(object sender, EventArgs e)
        {
            validaciones.Validaciones vali = new validaciones.Validaciones();
            ErrorProvider err = new ErrorProvider();

            if (!vali.validarEmail(txt_email.Text))
            {
                err.SetError(txt_email, "El email inválido");
            } 
            if (!vali.validacionIsNumeric(txt_telefono.Text))
            {
                err.SetError(txt_telefono, "No se admiten letras");
            }

            if (vali.validacionIsNumeric(txt_telefono.Text) == false)
            {
                MessageBox.Show("Ingrese un número de teléfono válido.", "NUMERO TELEFONO", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                txt_email.Focus();
            }
            else
            {

                crud.Usuarios insSql = new crud.Usuarios();
                validaciones.Encriptacion en = new validaciones.Encriptacion();
                string password = en.Encriptar("1234");
                int estado, perfil;
                estado = Convert.ToInt32(cb_estado.SelectedValue);
                perfil = Convert.ToInt32(cb_perfil.SelectedValue);
                insSql.inserta_Usuario_SQL(txt_nombre.Text, txt_apellido.Text, txt_email.Text, estado, txt_empresa.Text, txt_telefono.Text, txt_telefono2.Text, perfil, password);
                MessageBox.Show("Usuario guardado correctamente");
                SqlCommand consulta = new SqlCommand("select id_user,name_user,lastname_user,email_user, pass_user,state_user,empresa_user,phone_user,phone_user,name_role from usuario u inner join rol r on r.id_role=u.id_role ", cn);
                SqlDataAdapter da = new SqlDataAdapter(consulta);
                DataTable dt = new DataTable();
                da.Fill(dt);
                dataGridView1.DataSource = dt;
                cn.Close();

            }
        }