OpenDashboard(UtilisateursRow selectedUser) { Hide(); using (frmDashboard modal = new frmDashboard(selectedUser)) modal.ShowDialog(); Show(); }
frmDashboard(UtilisateursRow user) { this.user = user; InitializeComponent(); FillTreeView(tvwProgress); administrationToolStripMenuItem.Enabled = (((user.codeUtil & 4) >> 2) & (((user.codeUtil & 2) >> 1) ^ (user.codeUtil & 1))) == 1; usernameToolStripMenuItem.Enabled = false; usernameToolStripMenuItem.Text = user.pnUtil + " " + user.nomUtil; }
UpdateUserProgress(UtilisateursRow user) { using (OleDbConnection connection = new OleDbConnection(Settings.Default.baseLangueConnectionString)) { connection.Open(); OleDbCommand command = connection.CreateCommand(); OleDbTransaction transaction; // Démarre la transaction (en local). transaction = connection.BeginTransaction(IsolationLevel.Chaos); command.Connection = connection; command.Transaction = transaction; try { command.CommandText = "UPDATE Utilisateurs\n" + "SET [codeExo] = @exercise, [codeLeçon] = @lesson, [codeCours] = @course\n" + "WHERE [codeUtil] = @id"; command.Parameters.AddWithValue("@exercise", user.codeExo); command.Parameters.AddWithValue("@lesson", user.codeLeçon); command.Parameters.AddWithValue("@course", user.codeCours); command.Parameters.AddWithValue("@id", user.codeUtil); if (command.ExecuteNonQuery() != 1) { throw new Exception("Y a un \"couac\""); } // Essaie de commit la transaction. transaction.Commit(); } catch (Exception) { transaction.Rollback(); } finally { connection.Close(); } } }