コード例 #1
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;
        }
コード例 #2
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
                {
                }
            }
        }
コード例 #3
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;
            }
        }
コード例 #4
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();
            }
        }
コード例 #5
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;
        }