コード例 #1
0
 public Aluno(int matriculaIn, string nomeIn, string cpfIn, DateTime nascimentoIn, EnumeradorSexo sexoIn)
 {
     Matricula  = matriculaIn;
     Nome       = nomeIn;
     Cpf        = cpfIn;
     Nascimento = nascimentoIn;
     Sexo       = sexoIn;
 }
コード例 #2
0
ファイル: Aluno.cs プロジェクト: Luca-Benetti-EM/WindowsForms
 public Aluno(int matricula, string nome, DateTime nascimento, string cpf, EnumeradorSexo sexo)
 {
     Matricula  = matricula;
     Nome       = nome;
     Sexo       = sexo;
     Nascimento = nascimento;
     CPF        = cpf;
 }
コード例 #3
0
        private void btnAdicionar_Click(object sender, EventArgs e)
        {
            int            matricula;
            string         nome       = txtNome.Text;
            DateTime       nascimento = ConverteParaData(txtNascimento.Text);
            EnumeradorSexo sexo       = (EnumeradorSexo)cboSexo.SelectedItem;
            string         CPF        = ConverteParaCPF(txtCPF.Text);

            if (StringVazia(txtMatricula.Text))
            {
                MessageBox.Show("Matrícula não inserida");
                txtMatricula.Focus();
                return;
            }
            matricula = Convert.ToInt32(txtMatricula.Text);

            if (StringVazia(nome))
            {
                MessageBox.Show("Nome não inserido");
                txtNome.Focus();
                return;
            }

            if (!ValidaData(nascimento))
            {
                MessageBox.Show("Data inserida incorretamente ou data futura");
                txtNascimento.Focus();
                return;
            }

            if (!(ValidaCPF(CPF)))
            {
                MessageBox.Show("CPF não é válido");
                txtCPF.Focus();
                return;
            }

            if (MatriculaJaCadastrada(matricula))
            {
                MessageBox.Show("Matrícula já cadastrada, altere para inserir novo aluno");
                txtMatricula.Focus();
                return;
            }


            if (CPFJaCadastrado(CPF))
            {
                MessageBox.Show("CPF já cadastrado");
                txtMatricula.Focus();
                return;
            }

            repositorio.Add(new Aluno(matricula, nome, nascimento, CPF, sexo));

            bsListaAlunos.DataSource = repositorio.GetAll().OrderBy(a => a.Matricula);
            AtualizaDGV();
        }
コード例 #4
0
ファイル: Aluno.cs プロジェクト: BenHurFR/Projeto-estagio
        public Aluno(int matricula, string nome, string cpf, DateTime nascimento, EnumeradorSexo sexo)
        {
            if (string.IsNullOrWhiteSpace(nome))
            {
                throw new ValidationException("Aluno deve ter um nome!");
            }
            if (nascimento.CompareTo(DateTime.Today) > 0)
            {
                throw new ValidationException("O aluno deve ter nascido!");
            }

            Matricula  = matricula;
            Nome       = nome;
            Cpf        = cpf;
            Nascimento = nascimento;
            Sexo       = sexo;
        }
コード例 #5
0
        private void btnModificar_Click(object sender, EventArgs e)
        {
            string         nome       = txtNome.Text;
            DateTime       nascimento = ConverteParaData(txtNascimento.Text);
            EnumeradorSexo sexo       = (EnumeradorSexo)cboSexo.SelectedItem;
            string         CPF        = ConverteParaCPF(txtCPF.Text);

            Aluno aluno = RetornaAlunoMatriculaAtual();


            if (StringVazia(nome))
            {
                MessageBox.Show("Nome não inserido");
                txtNome.Focus();
                return;
            }

            if (!ValidaData(nascimento))
            {
                MessageBox.Show("Data inserida incorretamente ou data futura");
                txtNascimento.Focus();
                return;
            }

            if (!(ValidaCPF(CPF)))
            {
                MessageBox.Show("CPF não é válido");
                txtCPF.Focus();
                return;
            }


            if (CPFJaCadastrado(CPF) && (CPF != aluno.CPF))
            {
                MessageBox.Show("CPF já cadastrado");
                txtMatricula.Focus();
                return;
            }

            repositorio.Update(new Aluno(aluno.Matricula, nome, nascimento, CPF, sexo));

            bsListaAlunos.DataSource = repositorio.GetAll();
            AtualizaDGV();
        }
コード例 #6
0
ファイル: Form1.cs プロジェクト: BenHurFR/Projeto-estagio
        private void _adicionar_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(txtMatricula.Text))
            {
                MessageBox.Show("Matricula vazia!");
                txtMatricula.Focus();
                return;
            }
            if (!DateTime.TryParse(mtxtNascimento.Text, out DateTime data))
            {
                MessageBox.Show("Nascimento inválido");
                return;
            }

            if (_adicionar.Text == "Adicionar")
            {
                if (validaCpf(txtCpf.Text) || txtCpf.Text.Length == 0)
                {
                    try
                    {
                        EnumeradorSexo sexo  = cbSexo.Text.Equals("Masculino") ? EnumeradorSexo.Masculino : EnumeradorSexo.Feminino;
                        Aluno          aluno = new Aluno(Convert.ToInt32(txtMatricula.Text), txtNome.Text, txtCpf.Text, Convert.ToDateTime(mtxtNascimento.Text), sexo);
                        repositorio.Add(aluno);
                        bs.DataSource  = repositorio.GetAll();
                        dgv.DataSource = bs;
                        btnLimpa_Click(sender, e);
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message);
                    }
                }
                else
                {
                    MessageBox.Show("Cpf invalido!", "Tente novamente", MessageBoxButtons.OK, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2);
                }
            }
            else
            {
                if (validaCpf(txtCpf.Text) || txtCpf.Text.Length == 0)
                {
                    try
                    {
                        EnumeradorSexo sexo  = cbSexo.Text.Equals("Masculino") ? EnumeradorSexo.Masculino : EnumeradorSexo.Feminino;
                        Aluno          aluno = new Aluno(Convert.ToInt32(txtMatricula.Text), txtNome.Text, txtCpf.Text, Convert.ToDateTime(mtxtNascimento.Text), sexo);
                        repositorio.Update(aluno);
                        bs.DataSource  = repositorio.GetAll();
                        dgv.DataSource = bs;
                        btnLimpa_Click(sender, e);
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message);
                    }
                }
                else
                {
                    MessageBox.Show("Cpf invalido!", "Tente novamente", MessageBoxButtons.OK, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2);
                }
            }
        }
コード例 #7
0
 public void GivenQueEuInformarOSexoComo(string sexo)
 {
     _sexo = (sexo.Equals("Masculino") || sexo.Equals("masculino")) ? EnumeradorSexo.Masculino : EnumeradorSexo.Feminino;
 }
コード例 #8
0
        public void GivenQueEuInformoOSexoComo(string sexo)
        {
            EnumeradorSexo enumSexo = (sexo.Equals("Masculino") || sexo.Equals("masculino")) ? EnumeradorSexo.Masculino : EnumeradorSexo.Feminino;

            _aluno.Sexo = enumSexo;
        }
コード例 #9
0
        public void DadoAtualizoOSexoPara(string sexo)
        {
            EnumeradorSexo enumSexo = (sexo.Equals("Masculino") || sexo.Equals("masculino")) ? EnumeradorSexo.Masculino : EnumeradorSexo.Feminino;

            _aluno.Sexo = enumSexo;
        }