コード例 #1
0
ファイル: MoodlightData.cs プロジェクト: TheNaked/Firewind
        internal void UpdatePreset(int Preset, string Color, int Intensity, bool BgOnly)
        {
            if (!IsValidColor(Color) || !IsValidIntensity(Intensity))
            {
                return;
            }

            string Pr;

            switch (Preset)
            {
            case 3:

                Pr = "three";
                break;

            case 2:

                Pr = "two";
                break;

            case 1:
            default:

                Pr = "one";
                break;
            }

            using (IQueryAdapter dbClient = FirewindEnvironment.GetDatabaseManager().getQueryreactor())
            {
                dbClient.setQuery("UPDATE items_moodlight SET preset_" + Pr + " = '@color," + Intensity + "," + FirewindEnvironment.BoolToEnum(BgOnly) + "' WHERE item_id = " + ItemId);
                dbClient.addParameter("color", Color);
                dbClient.runQuery();
            }

            GetPreset(Preset).ColorCode      = Color;
            GetPreset(Preset).ColorIntensity = Intensity;
            GetPreset(Preset).BackgroundOnly = BgOnly;
        }