Esempio n. 1
0
        private void salvarBtn_Click(object sender, EventArgs e)
        {
            try
            {
                validaControles = new isEmpty();
                foreach (Control child in this.Controls)
                {
                    string tag = validaControles.empty(child);
                    if (tag != "")
                    {
                        throw new Exception("O campo '" + tag + "' está vazio");
                    }
                    else
                    {
                        appInsc = new inscricaoEventoAplicacao();
                        appPart = new participanteAplicacao();
                        inscricao = new inscricaoEvento();
                        appInscSem = new inscricaoSeminfoAplicacao();
                        appEvento = new eventoAplicacao();
                        evento = new Evento();

                        if (!appInscSem.jaCadastrado(cpfMsk.Text))
                        {
                            throw new Exception("CPF ainda não cadastrado!!!");
                        }

                        if (appInsc.cadastradoEvento(appEvento.retornaCodEv(eventoCB.Text), cpfMsk.Text))
                        {
                            throw new Exception("CPF já cadastrado neste evento!!!");
                        }
                        evento = appEvento.selectEventoWhere(eventoCB.Text);
                        int codSeminfo = appInsc.retornoCodSeminfo(cpfMsk.Text);
                        if (appEvento.evSameTime(codSeminfo, evento.Data, evento.Hora))
                        {
                            throw new Exception("CPF já cadastrado em outro evento no mesmo horário");
                        }
                        else
                        {
                            inscricao.Evento = evento.Codigo;
                            inscricao.Data = evento.Data;
                            inscricao.codigoSeminfo = codSeminfo;
                            appInsc.salvar(inscricao);
                            MessageBox.Show("Espectador cadastrado com sucesso!");
                            break;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Esempio n. 2
0
 private void salvarBtn_Click(object sender, EventArgs e)
 {
     try
     {
         isEmpty validaControles = new isEmpty();
         foreach (Control child in this.Controls)
         {
             string tag = validaControles.empty(child);
             if (tag != "") {
                 throw new Exception("O campo '"+ tag + "' está vazio");
             }
             else
             { }
         }
         inscricaoSeminfoAplicacao appInsc = new inscricaoSeminfoAplicacao();
         if (appInsc.jaCadastrado(cpfMsk.Text))
         {
             throw new Exception("CPF já cadastrado na SEMINFO!");
         }
         else if (!appInsc.jaCadastrado(cpfMsk.Text))
         {
             throw new Exception("CPF inexistente!");
         }
         else
         {
             inscricaoSeminfo insc = new inscricaoSeminfo();
             insc.Data = DateTime.Parse(dataPck.Text);
             insc.ParticipanteCpf = cpfMsk.Text;
             appInsc.insereInscricao(insc);
             MessageBox.Show("Participante cadastrado com sucesso!!");
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }