public GradeTyping(IGradeTyping defaultSettings, IGradeTyping userSettings) { this.defaultSettings = defaultSettings; this.userSettings = userSettings; }
/// <summary> /// Sets the grade typing. /// </summary> /// <param name="id">The id.</param> /// <param name="GradeTyping">The grade typing.</param> /// <remarks>Documented by Dev11, 2008-08-14</remarks> public void SetGradeTyping(int id, IGradeTyping GradeTyping) { using (NpgsqlConnection con = PostgreSQLConn.CreateConnection(Parent.CurrentUser)) { using (NpgsqlCommand cmd = con.CreateCommand()) { cmd.CommandText = "SELECT type_gradings FROM \"Settings\" WHERE id=:id"; cmd.Parameters.Add("id", id); int gtid = Convert.ToInt32(PostgreSQLConn.ExecuteScalar(cmd, Parent.CurrentUser)); if (gtid > 0) { using (NpgsqlCommand cmd2 = con.CreateCommand()) { cmd2.CommandText = "UPDATE \"TypeGradings\" SET all_correct=:a_c, half_correct=:h_c, none_correct=:n_c, prompt=:p WHERE id=:id"; cmd2.Parameters.Add("id", gtid); cmd2.Parameters.Add("a_c", GradeTyping.AllCorrect); cmd2.Parameters.Add("h_c", GradeTyping.HalfCorrect); cmd2.Parameters.Add("n_c", GradeTyping.NoneCorrect); cmd2.Parameters.Add("p", GradeTyping.Prompt); PostgreSQLConn.ExecuteNonQuery(cmd2, Parent.CurrentUser); //Save to Cache Parent.CurrentUser.Cache[ObjectLifetimeIdentifier.Create(CacheObject.SettingsTypeGradingsFk, id, Cache.DefaultSettingsValidationTime)] = gtid; Parent.CurrentUser.Cache[ObjectLifetimeIdentifier.Create(CacheObject.SettingsTypeGradingsAllCorrect, gtid, Cache.DefaultSettingsValidationTime)] = GradeTyping.AllCorrect; Parent.CurrentUser.Cache[ObjectLifetimeIdentifier.Create(CacheObject.SettingsTypeGradingsHalfCorrect, gtid, Cache.DefaultSettingsValidationTime)] = GradeTyping.HalfCorrect; Parent.CurrentUser.Cache[ObjectLifetimeIdentifier.Create(CacheObject.SettingsTypeGradingsNoneCorrect, gtid, Cache.DefaultSettingsValidationTime)] = GradeTyping.NoneCorrect; Parent.CurrentUser.Cache[ObjectLifetimeIdentifier.Create(CacheObject.SettingsTypeGradingsPrompt, gtid, Cache.DefaultSettingsValidationTime)] = GradeTyping.Prompt; } } else { using (NpgsqlCommand cmd3 = con.CreateCommand()) { cmd3.CommandText = "INSERT INTO \"TypeGradings\" (all_correct, half_correct, none_correct, prompt) VALUES " + "(:a_c, :h_c, :n_c, :p); UPDATE \"Settings\" SET type_gradings=currval('\"TypeGradings_id_seq\"') WHERE id=:id"; cmd3.Parameters.Add("id", id); cmd3.Parameters.Add("a_c", GradeTyping.AllCorrect); cmd3.Parameters.Add("h_c", GradeTyping.HalfCorrect); cmd3.Parameters.Add("n_c", GradeTyping.NoneCorrect); cmd3.Parameters.Add("p", GradeTyping.Prompt); int? gradeTypeingId = PostgreSQLConn.ExecuteScalar<int>(cmd3, Parent.CurrentUser); //Save to Cache Parent.CurrentUser.Cache[ObjectLifetimeIdentifier.Create(CacheObject.SettingsTypeGradingsFk, id, Cache.DefaultSettingsValidationTime)] = gradeTypeingId; Parent.CurrentUser.Cache[ObjectLifetimeIdentifier.Create(CacheObject.SettingsTypeGradingsAllCorrect, gradeTypeingId.Value, Cache.DefaultSettingsValidationTime)] = GradeTyping.AllCorrect; Parent.CurrentUser.Cache[ObjectLifetimeIdentifier.Create(CacheObject.SettingsTypeGradingsHalfCorrect, gradeTypeingId.Value, Cache.DefaultSettingsValidationTime)] = GradeTyping.HalfCorrect; Parent.CurrentUser.Cache[ObjectLifetimeIdentifier.Create(CacheObject.SettingsTypeGradingsNoneCorrect, gradeTypeingId.Value, Cache.DefaultSettingsValidationTime)] = GradeTyping.NoneCorrect; Parent.CurrentUser.Cache[ObjectLifetimeIdentifier.Create(CacheObject.SettingsTypeGradingsPrompt, gradeTypeingId.Value, Cache.DefaultSettingsValidationTime)] = GradeTyping.Prompt; } } } } }
/// <summary> /// Sets the grade typing. /// </summary> /// <param name="id">The id.</param> /// <param name="GradeTyping">The grade typing.</param> /// <remarks>Documented by Dev05, 2009-01-15</remarks> public void SetGradeTyping(int id, IGradeTyping GradeTyping) { SqlCeCommand cmd = MSSQLCEConn.CreateCommand(Parent.CurrentUser); cmd.CommandText = "SELECT type_gradings FROM \"Settings\" WHERE id=@id"; cmd.Parameters.Add("@id", id); int gtid = Convert.ToInt32(MSSQLCEConn.ExecuteScalar(cmd)); if (gtid > 0) { SqlCeCommand cmd2 = MSSQLCEConn.CreateCommand(Parent.CurrentUser); cmd2.CommandText = "UPDATE \"TypeGradings\" SET all_correct=@a_c, half_correct=@h_c, none_correct=@n_c, prompt=@p WHERE id=@id"; cmd2.Parameters.Add("@id", gtid); cmd2.Parameters.Add("@a_c", GradeTyping.AllCorrect); cmd2.Parameters.Add("@h_c", GradeTyping.HalfCorrect); cmd2.Parameters.Add("@n_c", GradeTyping.NoneCorrect); cmd2.Parameters.Add("@p", GradeTyping.Prompt); MSSQLCEConn.ExecuteNonQuery(cmd2); //Save to Cache Parent.CurrentUser.Cache[ObjectLifetimeIdentifier.Create(CacheObject.SettingsTypeGradingsFk, id, Cache.DefaultSettingsValidationTime)] = gtid; Parent.CurrentUser.Cache[ObjectLifetimeIdentifier.Create(CacheObject.SettingsTypeGradingsAllCorrect, gtid, Cache.DefaultSettingsValidationTime)] = GradeTyping.AllCorrect; Parent.CurrentUser.Cache[ObjectLifetimeIdentifier.Create(CacheObject.SettingsTypeGradingsHalfCorrect, gtid, Cache.DefaultSettingsValidationTime)] = GradeTyping.HalfCorrect; Parent.CurrentUser.Cache[ObjectLifetimeIdentifier.Create(CacheObject.SettingsTypeGradingsNoneCorrect, gtid, Cache.DefaultSettingsValidationTime)] = GradeTyping.NoneCorrect; Parent.CurrentUser.Cache[ObjectLifetimeIdentifier.Create(CacheObject.SettingsTypeGradingsPrompt, gtid, Cache.DefaultSettingsValidationTime)] = GradeTyping.Prompt; } else { SqlCeCommand cmd3 = MSSQLCEConn.CreateCommand(Parent.CurrentUser); cmd3.CommandText = "INSERT INTO \"TypeGradings\" (all_correct, half_correct, none_correct, prompt) VALUES " + "(@a_c, @h_c, @n_c, @p); UPDATE \"Settings\" SET type_gradings=@@IDENTITY WHERE id=@id; SELECT @@IDENTITY;"; cmd3.Parameters.Add("@id", id); cmd3.Parameters.Add("@a_c", GradeTyping.AllCorrect); cmd3.Parameters.Add("@h_c", GradeTyping.HalfCorrect); cmd3.Parameters.Add("@n_c", GradeTyping.NoneCorrect); cmd3.Parameters.Add("@p", GradeTyping.Prompt); int? gradeTypeingId = MSSQLCEConn.ExecuteScalar<int>(cmd3); //Save to Cache Parent.CurrentUser.Cache[ObjectLifetimeIdentifier.Create(CacheObject.SettingsTypeGradingsFk, id, Cache.DefaultSettingsValidationTime)] = gradeTypeingId; Parent.CurrentUser.Cache[ObjectLifetimeIdentifier.Create(CacheObject.SettingsTypeGradingsAllCorrect, gradeTypeingId.Value, Cache.DefaultSettingsValidationTime)] = GradeTyping.AllCorrect; Parent.CurrentUser.Cache[ObjectLifetimeIdentifier.Create(CacheObject.SettingsTypeGradingsHalfCorrect, gradeTypeingId.Value, Cache.DefaultSettingsValidationTime)] = GradeTyping.HalfCorrect; Parent.CurrentUser.Cache[ObjectLifetimeIdentifier.Create(CacheObject.SettingsTypeGradingsNoneCorrect, gradeTypeingId.Value, Cache.DefaultSettingsValidationTime)] = GradeTyping.NoneCorrect; Parent.CurrentUser.Cache[ObjectLifetimeIdentifier.Create(CacheObject.SettingsTypeGradingsPrompt, gradeTypeingId.Value, Cache.DefaultSettingsValidationTime)] = GradeTyping.Prompt; } }