private void btn_salvarCurso_Click(object sender, EventArgs e)
        {
            if (!(txt_nomeCurso.Text.Trim().Length != 0 && Verifica.Moeda(txt_vMatricula.Text.Trim()) &&
                  Verifica.Moeda(txt_vTotal.Text.Trim()) &&
                  txt_vMulta.Text.Trim().ToString().Length != 0 && Verifica.Moeda(txt_vRescisao.Text.Trim()) &&
                  txt_meses.Text.Trim().Length != 0 &&
                  txt_modulos.Text.Trim().Length != 0 && msk_horas.Text.Trim().Length != 0 &&
                  (cmb_dias.SelectedIndex + 1).ToString().Length != 0))
            {
                MessageBox.Show("Verifique se todos os campos foram preenchidos corretamente " +
                                "e se nenhum campo obrigatório foi deixado em branco",
                                "Erro!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }

            string nome       = txt_nomeCurso.Text.Trim(),
                   vMatricula = txt_vMatricula.Text.Trim(),
                   total      = txt_vTotal.Text.Trim(),
                   multa      = txt_vMulta.Text.Trim(),
                   rescisao   = txt_vRescisao.Text.Trim(),
                   meses      = txt_meses.Text.Trim(),
                   horas      = msk_horas.Text.Trim(),
                   aulaSem    = (cmb_dias.SelectedIndex + 1).ToString(),
                   descricao  = txt_descricaoCurso.Text.Trim(),
                   modulos    = txt_modulos.Text.Trim();

            FormCadastrarModulo form = new FormCadastrarModulo(int.Parse(modulos), GerenciadorBanco.GetCodCurso() + 1, nome, descricao, meses, horas,
                                                               aulaSem, vMatricula, float.Parse(total), float.Parse(multa), float.Parse(rescisao));

            form.ShowDialog();
            return;
        }
        private void btn_salvarResp_Click(object sender, EventArgs e)
        {
            string nome       = txt_nomeResp.Text.Trim(),
                   rg         = msk_rgResp.Text.Trim(),
                   cpf        = msk_cpfResp.Text.Trim(),
                   nasc       = msk_nascResp.Text.Trim(),
                   dddResp    = msk_dddResp.Text.Trim(),
                   telResp    = msk_telResp.Text.Trim(),
                   dddAltResp = msk_dddAltResp.Text.Trim(),
                   telAltResp = msk_telAltResp.Text.Trim(),
                   endereco   = txt_enderecoResp.Text.Trim(),
                   bairro     = txt_bairroResp.Text.Trim(),
                   cidade     = txt_cidadeResp.Text.Trim();
            char   sexo       = ' ';
            string Ano        = "";

            Ano = msk_nascResp.Text.Trim();
            Ano = Ano[6].ToString() + Ano[7].ToString() + Ano[8].ToString() +
                  Ano[9].ToString();

            if (Verifica.Vazio(nome) && Verifica.RG(rg) &&
                Verifica.CPF(cpf) && Verifica.DDDeTelefone(dddResp, telResp) &&
                Verifica.DDDeTelefoneALT(dddAltResp, telAltResp) &&
                Verifica.Vazio(endereco) && Verifica.Vazio(bairro) &&
                Verifica.Vazio(cidade) && Verifica.Maior(nasc) &&
                rd_F.Checked || rd_M.Checked)
            {
                if (rd_F.Checked)
                {
                    sexo = 'f';
                }
                if (rd_M.Checked)
                {
                    sexo = 'm';
                }

                string telefone    = dddResp + telResp,
                       telefoneAlt = dddAltResp + telAltResp;

                if (GerenciadorBanco.CadastrarResponsavel(nome, rg, cpf, nasc, sexo, telefone,
                                                          telefoneAlt, endereco, bairro, cidade))
                {
                    MessageBox.Show("Responsável cadastrado com sucesso!");
                    codResp = GerenciadorBanco.GetCodResp();
                    this.Close();
                    return;
                }
                else
                {
                    MessageBox.Show("Erro ao cadastrar responsável!", "Erro!", MessageBoxButtons.OK,
                                    MessageBoxIcon.Exclamation);
                }
            }
            else
            {
                MessageBox.Show("Verifique se todos os campos foram preenchidos corretamente " +
                                "e se nenhum campo obrigatório foi deixado em branco",
                                "Erro!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
        }
        private void btn_salvar_Click(object sender, EventArgs e)
        {
            if (cmb_codTurma.SelectedIndex < 0)
            {
                MessageBox.Show("Selecione uma turma válida da lista!", "Erro");
                return;
            }

            if (cmb_aluno.SelectedIndex < 0)
            {
                MessageBox.Show("Selecione um aluno válido da lista!", "Erro");
                return;
            }
            string[] codTurma = cmb_codTurma.SelectedItem.ToString().Split('|');
            string[] codAluno = cmb_aluno.SelectedItem.ToString().Split('|');

            if (Verifica.AlunoCadastrado(codAluno[0].Trim(), codTurma[0].Trim()))
            {
                MessageBox.Show("Aluno já matriculado nesta turma.", "Impossível cadastrar!");
                return;
            }

            if (!(Verifica.PodeMatricular(codTurma[0].Trim())))
            {
                MessageBox.Show("Limite máximo de alunos atingidos.", "Impossível cadastrar!");
                return;
            }

            if (GerenciadorBanco.CadastrarMatricula(int.Parse(codTurma[0]), int.Parse(codAluno[0])))
            {
                MessageBox.Show("Aluno matriculado com sucesso!");
            }
        }
 private void cmb_professor_Leave(object sender, EventArgs e)
 {
     if (Verifica.ProfessorExiste(cmb_professor.SelectedText))
     {
         MessageBox.Show("Professor não cadastrado!");
         return;
     }
 }
Esempio n. 5
0
        private void btn_salvarProf_Click(object sender, EventArgs e)
        {
            if (!(txt_nomeProf.Text.Trim().Length > 0 && Verifica.RG(msk_rgProf.Text.Trim()) &&
                  Verifica.Email(txt_emailProf.Text.Trim()) &&
                  Verifica.DDDeTelefone(msk_dddProf.Text.Trim(), msk_telProf.Text.Trim()) &&
                  Verifica.DDDeTelefoneALT(msk_dddAltProf.Text.Trim(), msk_telAltProf.Text.Trim()) &&
                  msk_admissaoProf.Text.Trim().Length == 10 &&
                  Verifica.Maior(msk_nascProf.Text.Trim()) &&
                  (rd_F.Checked || rd_M.Checked)))
            {
                MessageBox.Show("Verifique se todos os campos foram preenchidos corretamente " +
                                "e se nenhum campo obrigatório foi deixado em branco",
                                "Erro! Campos com erros!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }

            string nome     = txt_nomeProf.Text.Trim(),
                   rg       = msk_rgProf.Text.Trim(),
                   cpf      = msk_cpfProf.Text.Trim(),
                   nasc     = msk_nascProf.Text.Trim(),
                   email    = txt_emailProf.Text.Trim(),
                   ddd      = msk_dddProf.Text.Trim(),
                   tel      = msk_telProf.Text.Trim(),
                   dddAlt   = msk_dddAltProf.Text.Trim(),
                   telAlt   = msk_telAltProf.Text.Trim(),
                   endereco = txt_enderecoProf.Text.Trim(),
                   bairro   = txt_bairroProf.Text.Trim(),
                   cidade   = txt_cidadeProf.Text.Trim(),
                   admissao = msk_admissaoProf.Text.Trim();
            char sexo       = ' ';

            if (rd_F.Checked)
            {
                sexo = 'f';
            }
            if (rd_M.Checked)
            {
                sexo = 'm';
            }

            string telefoneAlt = dddAlt + telAlt,
                   telefone    = ddd + tel;

            if (GerenciadorBanco.CadastrarProfessor(nome, rg, cpf, nasc, sexo, email, telefone, telefoneAlt,
                                                    endereco, bairro, cidade, admissao, caminhoImagem))
            {
                MessageBox.Show("Professor cadastrado com sucesso!");
                return;
            }
        }
        // Se o aluno for de menor, habilita o grupo de responsáveis
        private void msk_nascAluno_Leave(object sender, EventArgs e)
        {
            if (msk_nascAluno.Text.Trim().Length == 0)
            {
                return;
            }

            string Ano = GerenciadorBanco.GetAno(msk_nascAluno.Text.Trim());

            if (!Verifica.Maior(msk_nascAluno.Text.Trim()))
            {
                GrupoResponsaveisLegais.Enabled = true;
            }
            else
            {
                GrupoResponsaveisLegais.Enabled = false;
            }
        }
        private void btn_salvarAluno_Click(object sender, EventArgs e)
        {
            // Realiza as verificações obrigatórias
            if (!(txt_nomeAluno.Text.Trim().Length > 0 && msk_rgALuno.Text.Trim().Length > 0 &&
                  txt_emailAluno.Text.Trim().Length > 0 &&
                  Verifica.DDDeTelefone(msk_dddAluno.Text.Trim(), msk_telAluno.Text.Trim()) &&
                  Verifica.DDDeTelefoneALT(msk_dddAltAluno.Text.Trim(), msk_telAltAluno.Text.Trim()) &&
                  (rd_F.Checked || rd_M.Checked)))
            {
                MessageBox.Show("Verifique se todos os campos foram preenchidos corretamente " +
                                "e se nenhum campo obrigatório foi deixado em branco",
                                "Erro! Campos com erros!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }

            string nomeALuno   = txt_nomeAluno.Text.Trim(),
                   rg          = msk_rgALuno.Text.Trim(),
                   cpf         = msk_cpfAluno.Text.Trim(),
                   nasc        = msk_nascAluno.Text.Trim(),
                   email       = txt_emailAluno.Text.Trim(),
                   dddAluno    = msk_dddAluno.Text.Trim(),
                   telAluno    = msk_telAluno.Text.Trim(),
                   dddAltAluno = msk_dddAltAluno.Text.Trim(),
                   telAltAluno = msk_telAltAluno.Text.Trim(),
                   endereco    = txt_enderecoAluno.Text.Trim(),
                   bairro      = txt_bairroAluno.Text.Trim(),
                   cidade      = txt_cidadeAluno.Text.Trim(),
                   nomeMae     = txt_nomeMae.Text.Trim(),
                   dddMae      = msk_dddMae.Text.Trim(),
                   telMae      = msk_telMae.Text.Trim(),
                   nomePai     = txt_nomePai.Text.Trim(),
                   dddPai      = msk_dddPai.Text.Trim(),
                   telPai      = msk_telPai.Text.Trim();

            char sexo = ' ';

            if (rd_F.Checked)
            {
                sexo = 'f';
            }
            if (rd_M.Checked)
            {
                sexo = 'm';
            }

            // Verifica se o GroupBox está habilitado.
            //Se for maior de idade o GrupoResponsáveisLegais estará desabilitado.
            if (GrupoResponsaveisLegais.Enabled)
            {
                // Verifica se dados dos pais estão preenchidos
                if (nomeMae.Length == 0 && nomePai.Length == 0)
                {
                    MessageBox.Show("Informe dados de ao menos um responsável legal.",
                                    "Erro! Aluno menor de idade!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    return;
                }

                // Verifica dados da mãe
                if (nomeMae.Length != 0)
                {
                    if (!(nomeMae.Length > 0 && Verifica.DDDeTelefone(dddMae, telMae)))
                    {
                        MessageBox.Show("Dados da mãe incorretos e/ou incompletos!",
                                        "Erro!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                        return;
                    }
                }

                // Verifica dados do pai
                if (nomePai.Length != 0)
                {
                    if (!(nomePai.Length > 0 && Verifica.DDDeTelefone(dddPai, telPai)))
                    {
                        MessageBox.Show("Dados do pai incorretos ou incompletos!",
                                        "Erro!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                        return;
                    }
                }
            }

            // Verifica se o aluno é responsável financeiro
            if (rd_S.Checked)
            {
                if (!Verifica.Maior(nasc))
                {
                    MessageBox.Show("Não é permitido responsabilizar financeiramente " +
                                    "menores de idade", "Erro! Aluno menor de idade!",
                                    MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    return;
                }
                else
                {
                    string telefoneAlt = dddAltAluno + telAltAluno,
                           telefone    = dddAluno + telAluno;

                    if (GerenciadorBanco.CadastrarAluno(0, nomeALuno, rg, cpf, nasc, sexo,
                                                        email, telefone, telefoneAlt, endereco, bairro, cidade, nomeMae,
                                                        nomePai, telMae, telPai, caminhoImagem))
                    {
                        MessageBox.Show("Aluno cadastrado com sucesso!");
                        return;
                    }
                    else
                    {
                        MessageBox.Show("Erro ao cadastrar aluno!", "Erro",
                                        MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                        return;
                    }
                }
            }

            // Verifica se o aluno não é responsável financeiro
            if (rd_N.Checked)
            {
                DialogResult resultado =
                    MessageBox.Show("Deseja cadastrar um novo responsável financeiro?\n\n" +
                                    "Se clicar em Não uma página para pesquisar responsáveis " +
                                    "já cadastrados será exibida.", "Cadastrar novo responsável?",
                                    MessageBoxButtons.YesNoCancel);

                if (resultado.Equals(DialogResult.Yes))
                {
                    FormCadastrarResponsavel form = new FormCadastrarResponsavel();
                    form.ShowDialog();

                    string telefoneAlt = dddAltAluno + telAltAluno;
                    string telefone    = dddAluno + telAluno;

                    if (GerenciadorBanco.CadastrarAluno(form.codResp, nomeALuno, rg, cpf, nasc, sexo,
                                                        email, telefone, telefoneAlt, endereco, bairro, cidade, nomeMae,
                                                        nomePai, telMae, telPai, caminhoImagem))
                    {
                        MessageBox.Show("Aluno cadastrado com sucesso!");
                        this.Close();
                        return;
                    }
                    else
                    {
                        MessageBox.Show("Erro ao cadastrar aluno!", "Erro!",
                                        MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                        return;
                    }
                }

                if (resultado.Equals(DialogResult.No))
                {
                    FormConsultarResponsavel form = new FormConsultarResponsavel();
                    form.Show();
                    return;
                }
            }
        }