Ejemplo n.º 1
0
        private void butConsultar_Click(object sender, EventArgs e)
        {
            if (tbCodigo.Text.Length == 0)
            {
                LimparCampos();
                OrganizaBotoes();
                butAlterar.Enabled = false;
                FormGridFuncao grid = new FormGridFuncao(this);
                grid.MdiParent = this.ParentForm;
                grid.Show();
            }
            else
            {
                func    = new Funcao();
                func.Id = Convert.ToInt32(tbCodigo.Text);
                func.ConsultaFuncao();
                if (func.Descricao != null)
                {
                    tbDescricao.Text = func.Descricao;

                    butAlterar.Enabled = true;
                    butExcluir.Enabled = true;
                }
                else
                {
                    this.LimparCampos();
                    this.OrganizaBotoes();
                }
                tbCodigo.SelectAll();
            }
        }
Ejemplo n.º 2
0
        private void tbCodigo_Leave(object sender, EventArgs e)
        {
            if (tbCodigo.Text.Length != 0)
            {
                func    = new Funcao();
                func.Id = Convert.ToInt32(tbCodigo.Text);
                func.ConsultaFuncao();
                //if (func.Descricao != null)
                if (string.IsNullOrEmpty(func.Descricao) == false)
                {
                    tbDescricao.Text = func.Descricao;

                    butAlterar.Enabled = true;
                    butExcluir.Enabled = true;
                    butNovo.Focus();
                }
                else
                {
                    this.LimparCampos();
                    this.OrganizaBotoes();
                    tbCodigo.Focus();
                    tbCodigo.SelectAll();
                }
            }
            else
            {
                this.LimparCampos();
                this.OrganizaBotoes();
            }
        }
Ejemplo n.º 3
0
        private void butAlterar_Click(object sender, EventArgs e)
        {
            novoFuncionario = false;
            req_cpf         = true;
            req_nome        = true;
            this.HabiDesaCampos(true);
            tbCpfCnpj.ReadOnly       = true;
            tbCpfCnpj.TabStop        = false;
            butNovo.Enabled          = false;
            butCancelar.Enabled      = true;
            butConsultar.Enabled     = false;
            butSalvar.Enabled        = true;
            butAlterar.Enabled       = false;
            butExcluir.Enabled       = false;
            btnConsultaGeral.Enabled = false;

            //Preenche ComboBox
            string funcaoAtual = cbxFuncao.Text;

            dt = new DataTable();
            Funcao fun = new Funcao();

            dt = fun.PreencherCbx();
            cbxFuncao.DisplayMember = "descricao";
            cbxFuncao.ValueMember   = "id";
            cbxFuncao.DataSource    = dt;
            cbxFuncao.Text          = funcaoAtual;
            tbNome.Focus();
            this.CancelButton = butCancelar;
        }
Ejemplo n.º 4
0
        private void butConsultar_Click(object sender, EventArgs e)
        {
            if (tbCodigoFuncionario.Text.Length == 0)
            {
                LimparCampos();
                OrganizaBotoes();
                butAlterar.Enabled = false;
                FormGridFuncionarios grid = new FormGridFuncionarios(this);
                grid.MdiParent = this.ParentForm;
                grid.Show();
            }
            else
            {
                func    = new Funcionario();
                func.Id = Convert.ToInt32(tbCodigoFuncionario.Text);
                func.ConsultarMecanico();
                if (func.Nome != null)
                {
                    dt = new DataTable();
                    Funcao fun = new Funcao();
                    fun.Id = func.IdFuncao;
                    fun.ConsultaFuncao();

                    //Preenche ComboBox
                    dt = new DataTable();
                    dt = fun.PreencherCbx();
                    cbxFuncao.DisplayMember = "descricao";
                    cbxFuncao.ValueMember   = "id";
                    cbxFuncao.DataSource    = dt;
                    cbxFuncao.Text          = fun.Descricao;

                    tbBairro.Text     = func.Bairro;
                    tbCelular.Text    = func.Celular;
                    tbCep.Text        = func.Cep;
                    tbCidade.Text     = func.Cidade;
                    tbCpfCnpj.Text    = func.Cpf;
                    dtAdmissao.Text   = Convert.ToString(func.Dataadmi);
                    dtNascimento.Text = Convert.ToString(func.Datanasc);
                    tbEndereco.Text   = func.Logradouro;
                    tbEstado.Text     = func.Estado;
                    tbNome.Text       = func.Nome;
                    tbNumero.Text     = func.Numero;
                    tbRgIe.Text       = func.Rg;
                    tbSalario.Text    = Convert.ToString(func.Salario);
                    tbTelefone1.Text  = func.Telefone;

                    butAlterar.Enabled = true;
                    butExcluir.Enabled = true;
                    tbCodigoFuncionario.Focus();
                    tbCodigoFuncionario.SelectAll();
                }
                else
                {
                }
            }
        }
Ejemplo n.º 5
0
        private void butSalvar_Click(object sender, EventArgs e)
        {
            if (tbDescricao.Text.Length == 0)
            {
                MessageBox.Show("Digite a descrição da função que deseja cadastrar!", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                tbDescricao.Focus();
            }
            else
            {
                if (novaFuncao)
                {
                    DialogResult res = MessageBox.Show("Confirma a inserção do registro?", "Novo Registro", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                    if (res == DialogResult.Yes)
                    {
                        func           = new Funcao();
                        func.Descricao = tbDescricao.Text;
                        func.InserirFuncao();

                        //Retorna o id do novo registro inserido
                        ds            = func.RetornaCodigo();
                        tbCodigo.Text = Convert.ToString(ds.Tables[0].Rows[0]["id"]);

                        this.HabiDesaCampos(false);
                        this.OrganizaBotoes();
                        this.CancelButton  = butSair;
                        butAlterar.Enabled = true;
                        butExcluir.Enabled = true;
                        novaFuncao         = false;
                        tbCodigo.Focus();
                        tbCodigo.SelectAll();
                    }
                }
                else
                {
                    DialogResult res = MessageBox.Show("Confirma a alteração do registro?", "Atualização", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                    if (res == DialogResult.Yes)
                    {
                        func           = new Funcao();
                        func.Id        = Convert.ToInt32(tbCodigo.Text);
                        func.Descricao = tbDescricao.Text;
                        func.AlterarFuncao();

                        this.HabiDesaCampos(false);
                        this.OrganizaBotoes();
                        this.CancelButton  = butSair;
                        butAlterar.Enabled = true;
                        butExcluir.Enabled = true;
                        novaFuncao         = false;
                        tbCodigo.Focus();
                        tbCodigo.SelectAll();
                    }
                }
            }
        }
Ejemplo n.º 6
0
        private void dataGridView1_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Enter)
            {
                DataGridViewRow linhaAtual = dataGridView1.CurrentRow;
                int             i          = linhaAtual.Index;
                if (frm != null)
                {
                    frm.tbCodigoFuncionario.Text = dataGridView1.Rows[i].Cells[0].Value.ToString();
                    frm.tbNome.Text        = dataGridView1.Rows[i].Cells[1].Value.ToString();
                    frm.tbCpfCnpj.Text     = dataGridView1.Rows[i].Cells[2].Value.ToString();
                    frm.tbRgIe.Text        = dataGridView1.Rows[i].Cells[3].Value.ToString();
                    frm.tbEndereco.Text    = dataGridView1.Rows[i].Cells[4].Value.ToString();
                    frm.tbNumero.Text      = dataGridView1.Rows[i].Cells[5].Value.ToString();
                    frm.tbBairro.Text      = dataGridView1.Rows[i].Cells[6].Value.ToString();
                    frm.tbCidade.Text      = dataGridView1.Rows[i].Cells[7].Value.ToString();
                    frm.tbEstado.Text      = dataGridView1.Rows[i].Cells[8].Value.ToString();
                    frm.tbCep.Text         = dataGridView1.Rows[i].Cells[9].Value.ToString();
                    frm.dtNascimento.Value = Convert.ToDateTime(dataGridView1.Rows[i].Cells[10].Value);
                    frm.dtAdmissao.Value   = Convert.ToDateTime(dataGridView1.Rows[i].Cells[11].Value);
                    frm.tbSalario.Text     = dataGridView1.Rows[i].Cells[12].Value.ToString();
                    frm.tbTelefone1.Text   = dataGridView1.Rows[i].Cells[13].Value.ToString();
                    frm.tbCelular.Text     = dataGridView1.Rows[i].Cells[14].Value.ToString();

                    dt = new DataTable();
                    Funcao fun = new Funcao();
                    fun.Id = Convert.ToInt32(dataGridView1.Rows[i].Cells[15].Value);
                    fun.ConsultaFuncao();

                    //Preenche ComboBox
                    dt = new DataTable();
                    dt = fun.PreencherCbx();
                    frm.cbxFuncao.DisplayMember = "descricao";
                    frm.cbxFuncao.ValueMember   = "id";
                    frm.cbxFuncao.DataSource    = dt;
                    frm.cbxFuncao.Text          = fun.Descricao;

                    frm.butAlterar.Enabled = true;
                    frm.butExcluir.Enabled = true;
                    frm.butNovo.Focus();
                }
                this.Dispose();
            }
            else if (e.KeyCode == Keys.Escape)
            {
                radNome.Checked = true;
                txtNome.Clear();
                txtNome.Focus();
                this.CancelButton = butSair;
            }
        }
Ejemplo n.º 7
0
        private void butExcluir_Click(object sender, EventArgs e)
        {
            DialogResult res = MessageBox.Show("Confirma a exclusão do registro?", "Exclusão", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

            if (res == DialogResult.Yes)
            {
                func    = new Funcao();
                func.Id = Convert.ToInt32(tbCodigo.Text);
                func.ExcluirFuncao();
                this.LimparCampos();
                this.HabiDesaCampos(false);
                this.OrganizaBotoes();
                tbCodigo.Focus();
            }
        }
Ejemplo n.º 8
0
        private void dataGridView1_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.RowIndex < 0)
            {
            }
            else
            {
                if (frm != null)
                {
                    frm.tbCodigoFuncionario.Text = dataGridView1.Rows[e.RowIndex].Cells[0].Value.ToString();
                    frm.tbNome.Text        = dataGridView1.Rows[e.RowIndex].Cells[1].Value.ToString();
                    frm.tbCpfCnpj.Text     = dataGridView1.Rows[e.RowIndex].Cells[2].Value.ToString();
                    frm.tbRgIe.Text        = dataGridView1.Rows[e.RowIndex].Cells[3].Value.ToString();
                    frm.tbEndereco.Text    = dataGridView1.Rows[e.RowIndex].Cells[4].Value.ToString();
                    frm.tbNumero.Text      = dataGridView1.Rows[e.RowIndex].Cells[5].Value.ToString();
                    frm.tbBairro.Text      = dataGridView1.Rows[e.RowIndex].Cells[6].Value.ToString();
                    frm.tbCidade.Text      = dataGridView1.Rows[e.RowIndex].Cells[7].Value.ToString();
                    frm.tbEstado.Text      = dataGridView1.Rows[e.RowIndex].Cells[8].Value.ToString();
                    frm.tbCep.Text         = dataGridView1.Rows[e.RowIndex].Cells[9].Value.ToString();
                    frm.dtNascimento.Value = Convert.ToDateTime(dataGridView1.Rows[e.RowIndex].Cells[10].Value);
                    frm.dtAdmissao.Value   = Convert.ToDateTime(dataGridView1.Rows[e.RowIndex].Cells[11].Value);
                    frm.tbSalario.Text     = dataGridView1.Rows[e.RowIndex].Cells[12].Value.ToString();
                    frm.tbTelefone1.Text   = dataGridView1.Rows[e.RowIndex].Cells[13].Value.ToString();
                    frm.tbCelular.Text     = dataGridView1.Rows[e.RowIndex].Cells[14].Value.ToString();

                    dt = new DataTable();
                    Funcao fun = new Funcao();
                    fun.Id = Convert.ToInt32(dataGridView1.Rows[e.RowIndex].Cells[15].Value);
                    fun.ConsultaFuncao();

                    //Preenche ComboBox
                    dt = new DataTable();
                    dt = fun.PreencherCbx();
                    frm.cbxFuncao.DisplayMember = "descricao";
                    frm.cbxFuncao.ValueMember   = "id";
                    frm.cbxFuncao.DataSource    = dt;
                    frm.cbxFuncao.Text          = fun.Descricao;

                    frm.butAlterar.Enabled = true;
                    frm.butExcluir.Enabled = true;
                    //frm.butSalvar.Enabled = false;
                    frm.butNovo.Focus();
                }
                this.Dispose();
            }
        }
Ejemplo n.º 9
0
        //Metodos_Eventos
        private void butNovo_Click(object sender, EventArgs e)
        {
            novoFuncionario = true;
            this.LimparCampos();
            this.HabiDesaCampos(true);
            butNovo.Enabled          = false;
            butCancelar.Enabled      = true;
            butConsultar.Enabled     = false;
            butAlterar.Enabled       = false;
            butExcluir.Enabled       = false;
            btnConsultaGeral.Enabled = false;

            //Preenche ComboBox
            dt = new DataTable();
            Funcao fun = new Funcao();

            dt = fun.PreencherCbx();
            cbxFuncao.DisplayMember = "descricao";
            cbxFuncao.ValueMember   = "id";
            cbxFuncao.DataSource    = dt;
            tbSalario.Text          = "0,00";
            tbNome.Focus();
            this.CancelButton = butCancelar;
        }