public static string AddTeste(ResultadoTeste number) { string Saida = ""; using (var connection = DbConnection()) { using (var cmd = connection.CreateCommand()) { cmd.CommandText = "insert into TBTeste(Concurso,n01,n02,n03,n04,n05,n06,n07,n08,n09,n10,n11,n12,n13,n14,n15,n16,n17,n18,n19,n20,n21,n22,n23,n24,n25)" + " Values(@Concurso,@n01,@n02,@n03,@n04,@n05,@n06,@n07,@n08,@n09,@n10,@n11,@n12,@n13,@n14,@n15,@n16,@n17,@n18,@n19,@n20,@n21,@n22,@n23,@n24,@n25)"; cmd.Parameters.AddWithValue("@Concurso", number.Concurso); cmd.Parameters.AddWithValue("@n01", number.n01.ToString("D2")); cmd.Parameters.AddWithValue("@n02", number.n02.ToString("D2")); cmd.Parameters.AddWithValue("@n03", number.n03.ToString("D2")); cmd.Parameters.AddWithValue("@n04", number.n04.ToString("D2")); cmd.Parameters.AddWithValue("@n05", number.n05.ToString("D2")); cmd.Parameters.AddWithValue("@n06", number.n06.ToString("D2")); cmd.Parameters.AddWithValue("@n07", number.n07.ToString("D2")); cmd.Parameters.AddWithValue("@n08", number.n08.ToString("D2")); cmd.Parameters.AddWithValue("@n09", number.n09.ToString("D2")); cmd.Parameters.AddWithValue("@n10", number.n10.ToString("D2")); cmd.Parameters.AddWithValue("@n11", number.n11.ToString("D2")); cmd.Parameters.AddWithValue("@n12", number.n12.ToString("D2")); cmd.Parameters.AddWithValue("@n13", number.n13.ToString("D2")); cmd.Parameters.AddWithValue("@n14", number.n14.ToString("D2")); cmd.Parameters.AddWithValue("@n15", number.n15.ToString("D2")); cmd.Parameters.AddWithValue("@n16", number.n16.ToString("D2")); cmd.Parameters.AddWithValue("@n17", number.n17.ToString("D2")); cmd.Parameters.AddWithValue("@n18", number.n18.ToString("D2")); cmd.Parameters.AddWithValue("@n19", number.n19.ToString("D2")); cmd.Parameters.AddWithValue("@n20", number.n20.ToString("D2")); cmd.Parameters.AddWithValue("@n21", number.n21.ToString("D2")); cmd.Parameters.AddWithValue("@n22", number.n22.ToString("D2")); cmd.Parameters.AddWithValue("@n23", number.n23.ToString("D2")); cmd.Parameters.AddWithValue("@n24", number.n24.ToString("D2")); cmd.Parameters.AddWithValue("@n25", number.n25.ToString("D2")); if (VerificarExistencia(number.Concurso) == false) { try { number.Concurso = Convert.ToInt32(cmd.ExecuteNonQuery()); Saida = "Resultado Teste registrado com sucesso!"; } catch (Exception exc) { Saida = "Ocorreu um erro inesperado: " + exc.Message; } return Saida; } else { //If the Result is already registered, this code will return and nothing will be saved. Saida = "Resultado Teste já cadastrado."; return Saida; } } } }"] public static string AddTeste(ResultadoTeste number)
{
string Saida = "";
using (var connection = DbConnection())
{
using (var cmd = connection.CreateCommand())
{
cmd.CommandText = "insert into TBTeste(Concurso,n01,n02,n03,n04,n05,n06,n07,n08,n09,n10,n11,n12,n13,n14,n15,n16,n17,n18,n19,n20,n21,n22,n23,n24,n25)" +
" Values(@Concurso,@n01,@n02,@n03,@n04,@n05,@n06,@n07,@n08,@n09,@n10,@n11,@n12,@n13,@n14,@n15,@n16,@n17,@n18,@n19,@n20,@n21,@n22,@n23,@n24,@n25)";
cmd.Parameters.AddWithValue("@Concurso", number.Concurso);
cmd.Parameters.AddWithValue("@n01", number.n01.ToString("D2"));
cmd.Parameters.AddWithValue("@n02", number.n02.ToString("D2"));
cmd.Parameters.AddWithValue("@n03", number.n03.ToString("D2"));
cmd.Parameters.AddWithValue("@n04", number.n04.ToString("D2"));
cmd.Parameters.AddWithValue("@n05", number.n05.ToString("D2"));
cmd.Parameters.AddWithValue("@n06", number.n06.ToString("D2"));
cmd.Parameters.AddWithValue("@n07", number.n07.ToString("D2"));
cmd.Parameters.AddWithValue("@n08", number.n08.ToString("D2"));
cmd.Parameters.AddWithValue("@n09", number.n09.ToString("D2"));
cmd.Parameters.AddWithValue("@n10", number.n10.ToString("D2"));
cmd.Parameters.AddWithValue("@n11", number.n11.ToString("D2"));
cmd.Parameters.AddWithValue("@n12", number.n12.ToString("D2"));
cmd.Parameters.AddWithValue("@n13", number.n13.ToString("D2"));
cmd.Parameters.AddWithValue("@n14", number.n14.ToString("D2"));
cmd.Parameters.AddWithValue("@n15", number.n15.ToString("D2"));
cmd.Parameters.AddWithValue("@n16", number.n16.ToString("D2"));
cmd.Parameters.AddWithValue("@n17", number.n17.ToString("D2"));
cmd.Parameters.AddWithValue("@n18", number.n18.ToString("D2"));
cmd.Parameters.AddWithValue("@n19", number.n19.ToString("D2"));
cmd.Parameters.AddWithValue("@n20", number.n20.ToString("D2"));
cmd.Parameters.AddWithValue("@n21", number.n21.ToString("D2"));
cmd.Parameters.AddWithValue("@n22", number.n22.ToString("D2"));
cmd.Parameters.AddWithValue("@n23", number.n23.ToString("D2"));
cmd.Parameters.AddWithValue("@n24", number.n24.ToString("D2"));
cmd.Parameters.AddWithValue("@n25", number.n25.ToString("D2"));
if (VerificarExistencia(number.Concurso) == false)
{
try
{
number.Concurso = Convert.ToInt32(cmd.ExecuteNonQuery());
Saida = "Resultado Teste registrado com sucesso!";
}
catch (Exception exc)
{
Saida = "Ocorreu um erro inesperado: " + exc.Message;
}
return Saida;
}
else
{
//If the Result is already registered, this code will return and nothing will be saved.
Saida = "Resultado Teste já cadastrado.";
return Saida;
}
}
}
}