Exemple #1
0
        private void btn_entrar_Click(object sender, EventArgs e)
        {
            login = txt_nome.Text;
            string comandoSQL;

            comandoSQL = ("select login,senha from usuario where login=@login;");


            cn.ConnectionString = "Host=200.145.153.173;Database=72c_18_20_21;Username=a72c2016;Password=alunocti72c;";
            cn.Open();
            NpgsqlCommand cmd = new NpgsqlCommand(comandoSQL, cn);

            cmd.Parameters.Add("login", NpgsqlTypes.NpgsqlDbType.Text).Value = login;
            NpgsqlDataReader dr = null;



            dr = cmd.ExecuteReader();
            while (dr.Read())
            {
                login = dr["login"].ToString();
                senha = dr["senha"].ToString();
            }
            senha_crip = txt_senha.Text;
            crip(senha_crip);
            if (txt_nome.Text == login && senha_crip == senha)
            {
                this.Visible = false;
                FrmInicio abrir = new FrmInicio();
                abrir.Show();
            }
            else if (txt_nome.Text != login || senha_crip != senha)
            {
                MessageBox.Show("Nome de usuário ou senha incorreta!", "SI - CTI DO BEM", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            cn.Close();
        }
Exemple #2
0
        private void button1_Click(object sender, EventArgs e)
        {
            //if()
            string comandoSQL;

            comandoSQL = ("select login,senha from usuario where login=@login;");


            cn.Open();
            NpgsqlCommand cmd = new NpgsqlCommand(comandoSQL, cn);

            cmd.Parameters.Add("login", NpgsqlTypes.NpgsqlDbType.Text).Value = txt_usu.Text;
            NpgsqlDataReader dr = null;



            dr = cmd.ExecuteReader();
            while (dr.Read())
            {
                ususexist = dr["login"].ToString();
            }
            cn.Close();

            if (txt_usu.Text == ususexist && testa == true)
            {
                MessageBox.Show("Nome de usuário já existe!", "SI - CTI DO BEM", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                if (txt_senha.Text == conf_senha.Text)
                {
                    nt = false;
                    cn.Open();


                    string        sql     = "UPDATE usuario SET login=@loginn,senha=@senhaa,nome=@nome,sexo=@sexo where login = @loginatual;";
                    NpgsqlCommand alterar = new NpgsqlCommand(sql, cn);

                    alterar.Parameters.Add("nome", NpgsqlTypes.NpgsqlDbType.Text).Value   = txt_nome.Text;
                    alterar.Parameters.Add("sexo", NpgsqlTypes.NpgsqlDbType.Text).Value   = cmb_sexo.Text;
                    alterar.Parameters.Add("loginn", NpgsqlTypes.NpgsqlDbType.Text).Value = txt_usu.Text;
                    if (cript == true)
                    {
                        senha_crip = txt_senha.Text;
                        crip(senha_crip);
                        alterar.Parameters.Add("senhaa", NpgsqlTypes.NpgsqlDbType.Text).Value = senha_crip;
                    }
                    if (cript == false)
                    {
                        alterar.Parameters.Add("senhaa", NpgsqlTypes.NpgsqlDbType.Text).Value = txt_senha.Text;
                    }


                    alterar.Parameters.Add("loginatual", NpgsqlTypes.NpgsqlDbType.Text).Value = login;
                    alterar.ExecuteNonQuery();
                    cn.Close();
                    MessageBox.Show("Dados alterados com sucesso!", "SI - CTI DO BEM", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    txt_senha.Enabled = false;
                    txt_usu.Enabled   = false;
                    MessageBox.Show("Estamos te redirecionando para o form de login!", "Faça o login novamente!", MessageBoxButtons.OK, MessageBoxIcon.Information);

                    FrmInicio fechar1 = new FrmInicio();
                    fechar1.Close();
                    FrmMeuPerfil fechar = new FrmMeuPerfil("");
                    fechar.Close();
                    FrmLogin abrir = new FrmLogin();
                    abrir.Show();
                }
                else
                {
                    nt = true;
                    MessageBox.Show("Senhas não conferem!", "SI - CTI DO BEM", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
        }