// INSERE UMA NOVA INSCRIÇÃO NA TABELA DE INSCRIÇÃO DA SEMINFO public void insereInscricao(inscricaoSeminfo inscricao) { var strInsert = ""; strInsert += @"INSERT INTO tblInscSeminfo (dData, sCPF)"; strInsert += string.Format(@"VALUES ('{0}', '{1}')", inscricao.Data, inscricao.ParticipanteCpf); using (contexto = new Contexto()) { contexto.executaComando(strInsert); } }
// CONVERTE AS INFORMAÇÕES DO DATAREADER TRAGO PELO public List<inscricaoSeminfo>inscToDataReader(SqlDataReader reader) { // MÉTODO ACIMA EM UMA LISTA DO TIPO INSCRIÇÃO SEMINFO var inscricoes = new List<inscricaoSeminfo>(); while (reader.Read()) { var temp = new inscricaoSeminfo() { Codigo = int.Parse((reader["nCodSi"]).ToString()), Data = DateTime.Parse((reader["dData"]).ToString()), ParticipanteCpf = (reader["sCPF"].ToString()) }; inscricoes.Add(temp); } reader.Close(); return inscricoes; }
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); } }