示例#1
0
        private void dataGridView1_DoubleClick(object sender, EventArgs e)
        {
            string    login = dataGridView1.CurrentRow.Cells[0].Value.ToString();
            FrmAdmUsu abrir = new FrmAdmUsu(login);

            abrir.Show();
        }
示例#2
0
        private void button1_Click(object sender, EventArgs e)
        {
            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)
            {
                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,tipo=@tipo 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;
                    alterar.Parameters.Add("senhaa", NpgsqlTypes.NpgsqlDbType.Text).Value     = txt_senha.Text;
                    alterar.Parameters.Add("loginatual", NpgsqlTypes.NpgsqlDbType.Text).Value = login;
                    alterar.Parameters.Add("tipo", NpgsqlTypes.NpgsqlDbType.Text).Value       = cmb_tipo.Text;
                    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();
                    FrmAdmUsu fechar = new FrmAdmUsu("");
                    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);
                }
            }
        }