0
I have a cl_Calculo class that has a method that calls a table in sql by a CRUD class already created, and I want in a Form when clicking a button to call the method of this class passing the sql command and that presents the result in a Message box.
namespace Calculos {
public class cl_Calculos {
public int[] Dezenas(int jogo, string query) {
#
region Apresenta as Dezenas do concurso consultado
cl_GestorDB gestor = new cl_GestorDB();
//string query = "SELECT * FROM dbo.seq_concurso WHERE concurso = " + jogo;
DataTable dados = gestor.EXE_READER(query + "'" + jogo + "'");
//-------------------------------------------
int dezena_1 = Convert.ToInt32(dados.Rows[0]["01"].ToString());
int dezena_2 = Convert.ToInt32(dados.Rows[0]["02"].ToString());
int dezena_3 = Convert.ToInt32(dados.Rows[0]["03"].ToString());
int[] dezenas = new int[] {
dezena_1,
dezena_2,
dezena_3,
}; //Cria um array com as dezenas sorteadas
#
endregion
//--------------------------------------------------------------
return dezenas;
}
namespace WindowsFormsApp7 {
public partial class Form1: Form {
private void btn_Teste_Click(object sender, EventArgs e) {
cl_Calculos Jogo = new cl_Calculos(10, "SELECT* FROM dbo.seq_concurso WHERE concurso = ");
string toDisplay = string.Join(Environment.NewLine, Jogo.Dezenas);
MessageBox.Show(toDisplay);
}
//==================================================================