Esempio n. 1
0
        public static void UpdateIcon(string _vid, BitmapSource _icon)
        {
            using (var command = new SQLiteCommand())
            {
                command.CommandText = @"Update [VideoRecords] Set [Icon] = @icon Where [Vid] = @vid;";
                command.Parameters.Add(new SQLiteParameter("@icon")
                {
                    DbType = DbType.Binary, Value = _icon.GetByteArray()
                });
                command.Parameters.Add(new SQLiteParameter("@vid")
                {
                    DbType = DbType.String, Value = _vid
                });

                accesser.ExecuteCommand(command);
            }
        }
Esempio n. 2
0
        public static void UpsertScreenlist(string _vid, BitmapSource _screenlist)
        {
            long id = 0;

            using (var command = new SQLiteCommand())
            {
                command.CommandText = @"Select [Id] From [VideoScreenlists] Where [Vid] = @vid;";
                command.Parameters.Add(new SQLiteParameter("@vid")
                {
                    DbType = DbType.String, Value = _vid
                });

                using (var reader = accesser.ExecuteReader(command))
                {
                    if (reader.HasRows)
                    {
                        reader.Read();
                        id = reader.GetInt64(0);
                    }
                }
            }

            if (id == 0)
            {
                using (var command = new SQLiteCommand())
                {
                    command.CommandText = @"Insert into [VideoScreenlists] ([Vid], [Screenlist], [Deleted]) Values (@vid, @screenlist, @deleted)";
                    command.Parameters.Add(new SQLiteParameter("@vid")
                    {
                        DbType = DbType.String, Value = _vid
                    });
                    command.Parameters.Add(new SQLiteParameter("@screenlist")
                    {
                        DbType = DbType.Binary, Value = _screenlist.GetByteArray()
                    });
                    command.Parameters.Add(new SQLiteParameter("@deleted")
                    {
                        DbType = DbType.Boolean, Value = 0
                    });

                    accesser.ExecuteCommand(command);
                }
            }
            else
            {
                using (var command = new SQLiteCommand())
                {
                    command.CommandText = @"Update [VideoScreenlists] Set [Screenlist] = @screenlist Where [Id] = @id;";
                    command.Parameters.Add(new SQLiteParameter("@id")
                    {
                        DbType = DbType.Int64, Value = id
                    });
                    command.Parameters.Add(new SQLiteParameter("@screenlist")
                    {
                        DbType = DbType.Binary, Value = _screenlist.GetByteArray()
                    });

                    accesser.ExecuteCommand(command);
                }
            }
        }