public static bool UpdateModulesInfo(ModuleData module, string selectModule) { string updateCommand = GetUpdateCommand(module, selectModule); using (SQLiteConnection conn = new SQLiteConnection(globalParameters.dbPath)) { conn.Open(); string sq0 = "PRAGMA foreign_keys = 'on';"; using (SQLiteCommand cmd = new SQLiteCommand(sq0, conn)) { cmd.ExecuteNonQuery(); } using (SQLiteCommand cmd = new SQLiteCommand(updateCommand, conn)) { cmd.ExecuteNonQuery(); } conn.Close(); } if (module.HasErrors) { module.Tables[ModuleData.MODULES_TABLE].GetErrors()[0].ClearErrors(); return(false); } else { module.AcceptChanges(); return(true); } }
public static bool InsertModulesInfo(ModuleData module) { bool check = CheckDuplication(module); if (!check) { return(false); } string insertCommand = GetInsertCommand(module); using (SQLiteConnection conn = new SQLiteConnection(globalParameters.dbPath)) { conn.Open(); using (SQLiteCommand cmd = new SQLiteCommand(insertCommand, conn)) { cmd.ExecuteNonQuery(); } conn.Close(); } if (module.HasErrors) { module.Tables[ModuleData.MODULES_TABLE].GetErrors()[0].ClearErrors(); return(false); } else { module.AcceptChanges(); return(true); } }