1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
|
// Nous allons enregistrer dans la base les controles où le champs statut a été coché
for (int i = 0; i < dataGridView1.Rows.Count; i++)
{
DataGridViewCell statut = dataGridView1[5, i];
if (statut is DataGridViewCheckBoxCell)
{
bool cellChecked = false;//bool cocher pas cocher.
if (statut.Value != null)
{
cellChecked = Convert.ToBoolean(statut.Value);
string reket_code = "select count(code_tache) as counts from tableau_bord where code_tache='" + dataGridView1.Rows[i].Cells[0].Value.ToString().Replace("'", "''") + "' and statut_tache = 'False' and reference ='" + CONNEXION.reference + "' and service = '" + CONNEXION.service + "'";
OdbcDataReader lirereket_code = cls.ouvrirRequète(reket_code, maconnexion);
while (lirereket_code.Read())
{
int code = Convert.ToInt32(lirereket_code["counts"]);
if (code == 1)
{
if (cellChecked == true)
{
string reket2 = "update tableau_bord set observation_tache='" + dataGridView1.Rows[i].Cells[4].Value.ToString().Replace("'", "''").ToUpper() + "',statut_tache='" + cellChecked + "', user_tache='" + CONNEXION.login + "', heure_execution = '" + dataGridView1.Rows[i].Cells[3].Value.ToString().Replace("'", "''") + "', heure_saisie ='" + heure_t + "' where reference='" + CONNEXION.reference + "' and code_tache='" + dataGridView1.Rows[i].Cells[0].Value.ToString().Replace("'", "''") + "' and statut_tache='False' and service = '" + CONNEXION.service + "' ;";
OdbcDataReader lirereket2 = cls.ouvrirRequète(reket2, maconnexion);
}
}
else
{
string reket = "insert into tableau_bord(reference,periode,code_tache, tache_execute,user_tache,statut_tache,observation_tache, heure_execution, heure_saisie, service) values('" + CONNEXION.reference + "','" + dataGridView1.Rows[i].Cells[2].Value.ToString().Replace("'", "''").ToUpper() + "','" + dataGridView1.Rows[i].Cells[0].Value.ToString().Replace("'", "''") + "','" + dataGridView1.Rows[i].Cells[1].Value.ToString().Replace("'", "''") + "','" + user_tache + "', '" + Convert.ToString(cellChecked) + "','" + dataGridView1.Rows[i].Cells[4].Value.ToString().Replace("'", "''").ToUpper() + "','" + dataGridView1.Rows[i].Cells[3].Value.ToString() + "','" + heure_t + "', '" + CONNEXION.service + "')";
OdbcDataReader lire = cls.ouvrirRequète(reket, maconnexion);
string reket2 = "update tableau_bord set user_tache='" + null + "', heure_saisie ='" + null + "' where reference='" + CONNEXION.reference + "' and statut_tache='False' and service = '" + CONNEXION.service + "'";
OdbcDataReader lirereket2 = cls.ouvrirRequète(reket2, maconnexion);
}
}
}
//i++;
}
}
MessageBox.Show("Enregistrement effectue avec succès", "INFORMATION", MessageBoxButtons.OK); |
Partager