Finalized the NamingConventionManager form, it can now insert/update and delete NamingConventions.
This commit is contained in:
+42
-4
@@ -376,9 +376,48 @@ namespace DataOrganizer
|
||||
}
|
||||
}
|
||||
|
||||
public void InsertNamingConvention(string name, string regex, string exampleText)
|
||||
{
|
||||
var query = @"INSERT INTO main.naming_pattern (name, regex, example_text) VALUES (@Name, @Regex, @Example)";
|
||||
|
||||
using(var connection = new SqliteConnection(ConnectionString))
|
||||
{
|
||||
using(var command = new SqliteCommand(query, connection))
|
||||
{
|
||||
command.Parameters.AddWithValue("Name", name);
|
||||
command.Parameters.AddWithValue("Regex", regex);
|
||||
command.Parameters.AddWithValue("Example", exampleText);
|
||||
|
||||
connection.Open();
|
||||
|
||||
command.ExecuteNonQuery();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void UpdateNamingConvention(int id, string name, string regex, string exampleText)
|
||||
{
|
||||
var query = @"UPDATE main.naming_pattern SET name = @Name, regex = @Regex, example_text = @Example WHERE pattern_id = @ID";
|
||||
|
||||
using (var connection = new SqliteConnection(ConnectionString))
|
||||
{
|
||||
using (var command = new SqliteCommand(query, connection))
|
||||
{
|
||||
command.Parameters.AddWithValue("ID", id);
|
||||
command.Parameters.AddWithValue("Name", name);
|
||||
command.Parameters.AddWithValue("Regex", regex);
|
||||
command.Parameters.AddWithValue("Example", exampleText);
|
||||
|
||||
connection.Open();
|
||||
|
||||
command.ExecuteNonQuery();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void DeleteNamingConvention(int id)
|
||||
{
|
||||
var query = @"UPDATE main.file SET pattern_override_id = 0 WHERE pattern_override_id = @ID";//@"DELETE FROM main.naming_pattern WHERE pattern_id = @Id";
|
||||
var query = $"UPDATE main.file SET pattern_override_id = 0 WHERE pattern_override_id = {id}";
|
||||
|
||||
using (var connection = new SqliteConnection(ConnectionString))
|
||||
{
|
||||
@@ -387,13 +426,12 @@ namespace DataOrganizer
|
||||
{
|
||||
using (var command = new SqliteCommand(query, connection, transaction))
|
||||
{
|
||||
command.Parameters.AddWithValue("ID", id);
|
||||
command.ExecuteNonQuery();
|
||||
|
||||
query = @"UPDATE main.folder_root SET pattern_id = 0 WHERE pattern_id = @ID";
|
||||
command.CommandText = $"UPDATE main.folder_root SET pattern_id = 0 WHERE pattern_id = {id}";
|
||||
command.ExecuteNonQuery();
|
||||
|
||||
query = @"DELETE FROM main.naming_pattern WHERE pattern_id = @ID";
|
||||
command.CommandText = $"DELETE FROM main.naming_pattern WHERE pattern_id = {id}";
|
||||
command.ExecuteNonQuery();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user