E questo il code-behind (solo dei bottoni interessati, ovviamente il bottone funzionante è quello di test che è anche quello inutile!):
protected void ChiudiDiritto_Click(object sender, EventArgs e)
{
ChiudiOpzione();
ChiudiPrelazione();
SqlConnection conn = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["IntranetConnectionString"].ConnectionString);
conn.Open();
string sqlupdcap = "UPDATE Capitale SET diritto_confermato = 1";
SqlCommand cmdupdcap = new SqlCommand(sqlupdcap, conn);
cmdupdcap.CommandType = System.Data.CommandType.Text;
cmdupdcap.ExecuteNonQuery();
conn.Close();
Response.Write("<script>alert('Diritti chiusi correttamente.');</script>");
}
protected void ChiudiMercato_Click(object sender, EventArgs e)
{
string cod = "";
SqlConnection conn = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["IntranetConnectionString"].ConnectionString);
conn.Open();
string sql = "SELECT azioni, nominativo, codfis, comune, provincia, cap, indirizzo, dossier, conto, tel1, tel2, email FROM Cap_Mercato WHERE id_capitale IN (SELECT TOP 1 id FROM Capitale ORDER BY id DESC)";
SqlCommand cmd = new SqlCommand(sql, conn);
cmd.CommandType = System.Data.CommandType.Text;
SqlDataReader reader = cmd.ExecuteReader();
while (reader.Read())
{
cod = reader[2].ToString();
string sqlcount = "SELECT COUNT(*) FROM Soci2 WHERE cod_fis = '" + cod + "'";
SqlCommand cmdcount = new SqlCommand(sqlcount, conn);
cmdcount.CommandType = System.Data.CommandType.Text;
string risultato = cmdcount.ExecuteScalar().ToString();
if (risultato == "0")
{
NuovoSocio(reader[7].ToString(), reader<img src="/forum/skins/default/images/emo/png-blue/icon_smile_8ball.png" class="absmiddle emoticon" />.ToString(), reader[1].ToString(), reader[2].ToString(), reader[3].ToString(), reader[5].ToString(), reader[6].ToString(), reader[0].ToString(), reader[4].ToString(), reader[9].ToString(), reader[10].ToString(), reader[11].ToString());
}
else
{
AggiornaSocio(reader[0].ToString(), reader[2].ToString());
}
}
reader.Close();
string sqlupdcap = "UPDATE Capitale SET mercato_confermato = 1";
SqlCommand cmdupdcap = new SqlCommand(sqlupdcap, conn);
cmdupdcap.CommandType = System.Data.CommandType.Text;
cmdupdcap.ExecuteNonQuery();
conn.Close();
Response.Write("<script>alert('Mercato chiuso correttamente.');</script>");
}
protected void test_click(object sender, EventArgs e)
{
Response.Write("<script>alert('Qui funziona.');</script>");
}