public FrmAlunoCadastrar(AcaoNaTela acaoNaTela, Aluno aluno) { InitializeComponent(); acaoNaTelaInformada = acaoNaTela; ObjetivoNegocio objetivoNegocio = new ObjetivoNegocio(); ListaObjetivo listaObjetivo = objetivoNegocio.CarregarCampoDescricao(); cmbCadastrarDescricao.DataSource = listaObjetivo; cmbCadastrarDescricao.ValueMember = "IDObjetivo"; cmbCadastrarDescricao.DisplayMember = "Descricao"; if (acaoNaTelaInformada == AcaoNaTela.Inserir) { this.Text = "Cadastrar Aluno"; this.lblAlunoCadastrarAlunoTitulo.Text = "Cadastrar Aluno"; this.btnAlunoCadastrar.Text = "Salvar"; this.txtCadastrarNome.Select(); this.cmbCadastrarDescricao.SelectedItem = null; } else if (acaoNaTelaInformada == AcaoNaTela.Alterar) { this.Text = "Alterar Aluno"; this.pbxCadastrarAluno.Image = global::Apresentacao.Properties.Resources._1440662980_edit_user; this.lblAlunoCadastrarAlunoTitulo.Text = "Alterar Aluno"; this.btnAlunoCadastrar.Text = "Salvar"; this.txtCadastrarCodigo.Text = aluno.Pessoa.IDPessoa.ToString(); this.txtCadastrarNome.Text = aluno.Pessoa.Nome; this.txtCadastrarRG.Text = aluno.Pessoa.RG; this.mskCadastrarCPF.Text = aluno.Pessoa.CPF; this.rbtCadastrarSexoMasculino.Checked = aluno.Pessoa.Sexo == true ? true : false; this.rbtCadastrarSexoFeminino.Checked = aluno.Pessoa.Sexo == false ? true : false; this.rbtCadastrarAtivoSim.Checked = aluno.Pessoa.Ativo == true ? true : false; this.rbtCadastrarAtivoNao.Checked = aluno.Pessoa.Ativo == false ? true : false; this.dtpCadastrarDataNascimento.Value = aluno.Pessoa.DataNascimento; this.mskCadastrarTelefoneCelular.Text = aluno.Pessoa.TelefoneCelular; this.mskCadastrarTelefoneResidencial.Text = aluno.Pessoa.TelefoneResidencial; this.txtCadastrarEmail.Text = aluno.Pessoa.Email; this.txtCadastrarUsuario.Text = aluno.Pessoa.Usuario; this.cmbCadastrarUF.Text = aluno.Pessoa.Endereco.UF; this.cmbCadastrarDescricao.Text = aluno.Objetivo.Descricao; this.txtCadastrarStatus.Text = aluno.Status; this.txtCadastrarSenha.Text = aluno.Pessoa.Senha; this.txtCadastrarCEP.Text = aluno.Pessoa.Endereco.CEP; this.txtCadastrarRua.Text = aluno.Pessoa.Endereco.Rua; this.txtCadastrarNumero.Text = aluno.Pessoa.Endereco.Numero.ToString(); this.txtCadastrarComplemento.Text = aluno.Pessoa.Endereco.Complemento; this.txtCadastrarBairro.Text = aluno.Pessoa.Endereco.Bairro; this.txtCadastrarCidade.Text = aluno.Pessoa.Endereco.Cidade; } }
public void Dispose() { acessoDadosSqlServer = null; listaObjetivo = null; }
public void AtualizarGridObjetivo(DialogResult dialogResult) { using (ObjetivoNegocio objetivoNegocio = new ObjetivoNegocio()) { ValidacaoInterfaces validarInterfaces = new ValidacaoInterfaces(); if (dialogResult == DialogResult.Yes) { try { ListaObjetivo listaObjetivo = objetivoNegocio.ConsultarObjetivoCodigoDescricao(null, "%"); dgwSelecionarObjetivo.DataSource = null; dgwSelecionarObjetivo.DataSource = listaObjetivo; dgwSelecionarObjetivo.Update(); dgwSelecionarObjetivo.Refresh(); txtSelecionarCodNome.Clear(); txtSelecionarCodNome.Focus(); return; } catch (Exception ex) { MessageBox.Show("Não foi possível atualizar, após ter inserido ou alterado objetivo. Detalhes: " + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } } else if (validarInterfaces.ValidarCampoPesquisar(this.txtSelecionarCodNome, "descrição") == true) { return; } else if (this.txtSelecionarCodNome.Text.Where(c => char.IsNumber(c)).Count() > 0) { try { ListaObjetivo listaObjetivo = objetivoNegocio.ConsultarObjetivoCodigoDescricao(Convert.ToInt32(this.txtSelecionarCodNome.Text), null); if (listaObjetivo.Count() > 0) { dgwSelecionarObjetivo.DataSource = null; dgwSelecionarObjetivo.DataSource = listaObjetivo; dgwSelecionarObjetivo.Update(); dgwSelecionarObjetivo.Refresh(); txtSelecionarCodNome.Focus(); return; } else { MessageBox.Show("Não existe nenhum objetivo com esse código: " + txtSelecionarCodNome.Text, "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Information); txtSelecionarCodNome.Focus(); return; } } catch (Exception ex) { MessageBox.Show("Não foi possível pesquisar objetivo por código. Detalhes: " + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Information); txtSelecionarCodNome.Focus(); return; } } else { try { ListaObjetivo listaObjetivo = objetivoNegocio.ConsultarObjetivoCodigoDescricao(null, this.txtSelecionarCodNome.Text); if (listaObjetivo.Count() > 0) { dgwSelecionarObjetivo.DataSource = null; dgwSelecionarObjetivo.DataSource = listaObjetivo; dgwSelecionarObjetivo.Update(); dgwSelecionarObjetivo.Refresh(); txtSelecionarCodNome.Focus(); return; } else { MessageBox.Show("Não existe nenhum objetivo com essa descrição: " + txtSelecionarCodNome.Text, "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Information); txtSelecionarCodNome.Focus(); return; } } catch (Exception ex) { MessageBox.Show("Não foi possível pesquisar objetivo por descrição. Detalhes: " + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Information); txtSelecionarCodNome.Focus(); return; } } } }