Esempio n. 1
0
        public void CarregarDadosGrid()
        {
            try
            {
                BLL.Nivel cat = new BLL.Nivel();
                dataGridView1.DataSource = cat.Listar(textBox1.Text, 1).Tables[0];
                // textBox1.Focus();
                //a propriedade DATASOURCE do datagrid é a fonte de dados. Esta propriedade recebe (=) do objeto USU o método LISTAR usando como parametro o texto TEXT.TRIM().TOUPPER() digitado no TEXTBOX1. Esse DATASOURCE usará a tabela zero TABLES[0] do método LISTAR

                if (dataGridView1.Rows.Count == 0)
                {
                    btnAlterar.Enabled   = false;
                    btnConsultar.Enabled = false;
                    btnAtivar.Enabled    = false;
                    btnDesativar.Enabled = false;
                }
                else
                {
                    btnAlterar.Enabled   = true;
                    btnConsultar.Enabled = true;
                    btnAtivar.Enabled    = true;
                    btnDesativar.Enabled = true;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                //throw;
            }
        }
Esempio n. 2
0
        private void BuscarNivelAcesso(object o, EventArgs e)
        {
            try
            {
                int CodigoNivelUsuarioLogado;

                CodigoNivelUsuarioLogado = Convert.ToInt32(lblNivel.Text);

                BLL.Nivel n = new BLL.Nivel();

                n.CodigoNivel = CodigoNivelUsuarioLogado;
                System.Data.SqlClient.SqlDataReader ddr;
                ddr = n.Consultar();
                ddr.Read();

                if (ddr.HasRows)
                {
                    lblNivel.Text = Convert.ToString(ddr["NomeNivelAcesso"]);
                    PermissõesAcesso();
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Esempio n. 3
0
        private void FrmUsuario_Load(object sender, EventArgs e)
        {
            BLL.Nivel c = new BLL.Nivel();

            cbNiv.DataSource    = c.Listar(String.Empty, (byte)1).Tables[0];
            cbNiv.DisplayMember = "NomeNivelAcesso";
            cbNiv.ValueMember   = "CodigoNivel";
        }
Esempio n. 4
0
        public void btnCadastrar_Click(object sender, EventArgs e)
        {
            if (VerificarDigitacao() == false)
            {
                return;
            }

            BLL.Nivel n = new BLL.Nivel();
            n.NomeNivelAcesso = txtNomeNivel.Text;
            n.IncluirComParametro();
            MessageBox.Show("Cadastrado com sucesso");
        }
Esempio n. 5
0
        public void Alterar(object o, EventArgs e)
        {
            if (VerificarDigitacao() == false)
            {
                return;
            }


            BLL.Nivel n = new BLL.Nivel();
            n.CodigoNivel     = Codigo;
            n.NomeNivelAcesso = txtNomeNivel.Text;
            n.AlterarComParametro();
            MessageBox.Show("Alterado com sucesso");
            Close();
        }
Esempio n. 6
0
        private void Fixar(Object o, EventArgs e)
        {
            try
            {
                //o é objeto que foi clicado
                var b = (Button)o;
                //variávl 'b' é o botão 'o'
                if (MessageBox.Show(b.Text, "Atencao", MessageBoxButtons.YesNo, MessageBoxIcon.Error, MessageBoxDefaultButton.Button2) == DialogResult.No)
                {
                    return;
                }
                BLL.Nivel forn = new BLL.Nivel();
                forn.CodigoNivel = Convert.ToInt32(dataGridView1.CurrentRow.Cells[0].Value);
                //propriedade '.codigo' do objeto 'usu' recebe '=' o valor 'value' da primeira coluna 'cells[0]' da linha atual 'currentrow' do grid 'datagridview1'
                switch (b.Text)
                {
                case "Ativar": forn.Ativar(); break;

                case "Desativar": forn.Desativar(); break;
                }
                String msg = "";
                if (b.Text == "Editar")
                {
                    msg = "Nivel de acesso editado com sucesso";
                }
                if (b.Text == "Ativar")

                {
                    msg = "Nivel de acesso  ativado com sucesso";
                }
                if (b.Text == "Desativar")

                {
                    msg = "Nivel de acesso  desativado com sucesso";
                }
                MessageBox.Show(msg, "Sucesso");
                CarregarDadosGrid();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                //throw;
            }
        }