private static LogicFolderInfomation AddScore(LogicFolderInfomation parent, SongInformation si, string linkName) { if (parent == null || si == null || !parent.IsFolder || !si.IsPPDSong) { return(null); } PPDDatabase.DB.ExecuteDataTable("insert into LogicFolder(scoreid,isfolder,name,date) values(@scoreid,@isfolder,@name,@date);", new SQLiteParameter[] { new SQLiteParameter("@scoreid", si.ID), new SQLiteParameter("@isfolder", "0"), new SQLiteParameter("@name", linkName), new SQLiteParameter("@date", DateTime.Now.ToString(CultureInfo.InvariantCulture)) }); var newscore = new LogicFolderInfomation(); using (var reader = PPDDatabase.DB.ExecuteReader("select * from LogicFolder where ROWID = last_insert_rowid();", null)) { while (reader.Reader.Read()) { newscore.ID = reader.Reader.GetInt32(0); newscore.IsFolder = reader.Reader.GetInt32(2) == 1; newscore.Name = reader.Reader.GetString(3); newscore.ScoreID = reader.Reader.GetInt32(1); newscore.DateTime = DateTime.Parse(reader.Reader.GetString(5), CultureInfo.InvariantCulture); newscore.parent = parent; newscore.Depth = parent.Depth + 1; parent.ChildrenList.Add(newscore); break; } } if (newscore != null) { var ids = PPDDatabase.ParseStringToList(parent.ChildIDs); ids.Add(newscore.ID); parent.ChildIDs = PPDDatabase.ConverListToString(ids); UpdateChildIDs(parent.ChildIDs, parent.ID); } StaticAfterAdd?.Invoke(newscore, EventArgs.Empty); return(newscore); }
private static LogicFolderInfomation AddFolder(LogicFolderInfomation parent, string name) { if (parent == null || !parent.IsFolder) { return(null); } PPDDatabase.DB.ExecuteDataTable("insert into LogicFolder(isfolder,name,childids,date) values(@isfolder,@name,@childids,@date);", new SQLiteParameter[] { new SQLiteParameter("@isfolder", 1), new SQLiteParameter("@name", name), new SQLiteParameter("@childids", string.Empty), new SQLiteParameter("@date", DateTime.Now.ToString(CultureInfo.InvariantCulture)) }); var newfolder = new LogicFolderInfomation(); using (var reader = PPDDatabase.DB.ExecuteReader("select * from LogicFolder where ROWID = last_insert_rowid();", null)) { while (reader.Reader.Read()) { newfolder.ID = reader.Reader.GetInt32(0); newfolder.IsFolder = reader.Reader.GetInt32(2) == 1; newfolder.Name = reader.Reader.GetString(3); newfolder.ChildIDs = reader.Reader.GetString(4); newfolder.DateTime = DateTime.Parse(reader.Reader.GetString(5), CultureInfo.InvariantCulture); newfolder.parent = parent; newfolder.Depth = parent.Depth + 1; parent.ChildrenList.Add(newfolder); break; } } if (newfolder != null) { var ids = PPDDatabase.ParseStringToList(parent.ChildIDs); ids.Add(newfolder.ID); parent.ChildIDs = PPDDatabase.ConverListToString(ids); UpdateChildIDs(parent.ChildIDs, parent.ID); } StaticAfterAdd?.Invoke(newfolder, EventArgs.Empty); return(newfolder); }