示例#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();
            }
        }
示例#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();
            }
        }
示例#3
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
                {
                }
            }
        }
示例#4
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;
            }
        }
示例#5
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();
            }
        }