private void BotaoAdicionarAluno_Click(object sender, EventArgs e) { Aluno.Aluno novoAluno = new Aluno.Aluno(); novoAluno.Nome = textoNomeAluno.Text; //novoAluno.Nascimento = Convert.ToDateTime(textoDataNascimentoAluno.Text); -> funciona mas pode cair na exception if (DateTime.TryParse(textoDataNascimentoAluno.Text, out var _auxNascimento)) { novoAluno.Nascimento = _auxNascimento; } novoAluno.Endereco = textoEnderecoAluno.Text; novoAluno.Telefone = textoTelefoneAluno.Text; novoAluno.Email = textoEmailAluno.Text; novoAluno.Curso = (Curso)_listaCursos[comboCursos.SelectedIndex]; novoAluno.Cpf = textoCpfAluno.Text; novoAluno.Cidade = textoCidadeAluno.Text; novoAluno.Estado = textoEstadoAluno.Text; if (DateTime.TryParse(textoDataMatriculaAluno.Text, out var _auxMatricula)) { novoAluno.DtMatricula = _auxMatricula; } ; novoAluno.RegistroAluno = Convert.ToInt32(textoRegistroAluno.Text); //this.telaAdicionarAlunos.AdicionaAlunos(novoAluno); foreach (Control dadoObrigatorio in this.Controls) { if (dadoObrigatorio is TextBox && String.IsNullOrWhiteSpace(dadoObrigatorio.Text)) { MessageBox.Show("Existe campo não preenchido!"); } } MessageBox.Show("Adicionado com sucesso!"); }
public telaPesquisaAlunos() { InitializeComponent(); Aluno.Aluno a1 = new Aluno.Aluno(); Aluno.Aluno a2 = new Aluno.Aluno(); Aluno.Aluno a3 = new Aluno.Aluno(); Aluno.Aluno a4 = new Aluno.Aluno(); Aluno.Aluno a5 = new Aluno.Aluno(); }
public void AdicionaAlunos(Aluno.Aluno alunos) { this.novosAlunos[this.numeroDeAlunos] = alunos; this.numeroDeAlunos++; comboAlunos.Items.Add("nome: " + alunos.Nome); }