private void btnSalvar_Click(object sender, EventArgs e)
        {
            Professor novoProf = new Professor();

            novoProf.Nome       = txtNome.Text;
            novoProf.CPF        = mtxtCPF.Text;
            novoProf.Disciplina = txtFormacao.Text;

            ProfessorController professorController = new ProfessorController();

            professorController.Inserir(novoProf);
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            AlunosController     alunosController     = new AlunosController();
            ProfessorController  professorController  = new ProfessorController();
            DisciplinaController disciplinaController = new DisciplinaController();


            //Cadastrando alunos
            Aluno a = CadastrarAluno();

            alunosController.Inserir(a);

            Aluno b = CadastrarAluno();

            alunosController.Inserir(b);

            Aluno c = CadastrarAluno();

            alunosController.Inserir(c);

            foreach (Aluno aluno in alunosController.ListarTodos())
            {
                ImprimeDadosAluno(aluno);
            }

            //Cadastrando Professores
            Professor d = CadastrarProfessor();

            professorController.Inserir(d);

            Professor e = CadastrarProfessor();

            professorController.Inserir(e);

            Professor f = CadastrarProfessor();

            professorController.Inserir(f);

            foreach (Professor professor in professorController.ListarTodos())
            {
                ImprimeDadosProfessor(professor);
            }

            //Cadastrando disciplina
            Disciplina g = CadastrarDisciplina();

            disciplinaController.Inserir(g);

            Disciplina h = CadastrarDisciplina();

            disciplinaController.Inserir(h);

            Disciplina i = CadastrarDisciplina();

            disciplinaController.Inserir(i);

            foreach (Disciplina disciplina in disciplinaController.ListarTodos())
            {
                ImprimeDadosDisciplina(disciplina);
            }

            Console.ReadKey();
        }
Exemplo n.º 3
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (comboBox1.Text != "Escolha o tipo" && textBox1.Text.Trim() != "" && textBox2.Text.Trim() != "" && textBox3.Text.Trim() != "" && textBox4.Text.Trim() != "" && textBox5.Text.Trim() != "" && textBox6.Text.Trim() != "")
            {
                SHA256 mySHA256 = SHA256.Create();

                byte[] hashValue = mySHA256.ComputeHash(Encoding.UTF8.GetBytes(textBox6.Text));
                string senhaHash = "";
                for (int i = 0; i < hashValue.Length; i++)
                {
                    senhaHash += hashValue[i].ToString("x2");
                }

                try
                {
                    bool telefone  = Regex.IsMatch(textBox4.Text, @"^\d{16}$");
                    bool telefone2 = Regex.IsMatch(textBox4.Text, @"^\d{15}$");
                    bool senha     = Regex.IsMatch(textBox6.Text, @"(?!^[0-9]$)(?!^[a-zA-Z]$)^([a-zA-Z0-9]{8,15})$");
                    if (int.Parse(textBox2.Text) > 0 && int.Parse(textBox2.Text) < 120 && textBox3.Text.Count() == 11 && telefone == true || telefone2 == true && senha == true)
                    {
                        if (comboBox1.Text == "Professor")
                        {
                            Professor novo = new Professor();
                            novo.Nome     = textBox1.Text;
                            novo.Idade    = int.Parse(textBox2.Text);
                            novo.Cpf      = textBox3.Text;
                            novo.Telefone = textBox4.Text;
                            novo.Login    = textBox5.Text;
                            novo.senha    = senhaHash;
                            novo.Situacao = 1;
                            if (ProfessorController.Inserir(novo))
                            {
                                MessageBox.Show("Cadastro realizado com sucesso!");
                                textBox1.Clear();
                                textBox2.Clear();
                                textBox3.Clear();
                                textBox4.Clear();
                                textBox5.Clear();
                                textBox6.Clear();
                            }
                            else
                            {
                                MessageBox.Show("Usuário já existente!");
                            }
                        }
                        else
                        {
                            Aluno novo = new Aluno();
                            novo.Nome     = textBox1.Text;
                            novo.Idade    = int.Parse(textBox2.Text);
                            novo.Cpf      = textBox3.Text;
                            novo.Telefone = textBox4.Text;
                            novo.Login    = textBox5.Text;
                            novo.senha    = senhaHash;
                            novo.Situacao = 1;
                            if (AlunoController.Inserir(novo))
                            {
                                MessageBox.Show("Cadastro realizado com sucesso!");
                                textBox1.Clear();
                                textBox2.Clear();
                                textBox3.Clear();
                                textBox4.Clear();
                                textBox5.Clear();
                                textBox6.Clear();
                            }
                            else
                            {
                                MessageBox.Show("Usuário já existente!");
                            }
                        }
                    }
                }
                catch
                {
                    MessageBox.Show("Dados fornecidos inválidos!\nConfira os dados novamente!");
                }
            }
            else
            {
                MessageBox.Show("Dados fornecidos inválidos!\nConfira os dados novamente!!!");
            }
        }