Finalized the NamingConventionManager form, it can now insert/update and delete NamingConventions.
This commit is contained in:
@@ -12,16 +12,8 @@ namespace DataOrganizer
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
var db = new DB();
|
||||
NamingConventionPatternsComboBox.Items.Add("Add New Pattern");
|
||||
NamingConventionPatternsComboBox.SelectedIndex = 0;
|
||||
RefreshNamingConventions();
|
||||
|
||||
foreach(var pattern in db.GetNamingConventions())
|
||||
{
|
||||
NamingConventionPatternsComboBox.Items.Add(pattern.Name);
|
||||
}
|
||||
|
||||
NamingConventionPatternsComboBox.SelectedIndexChanged += NamingConventionPatternsComboBox_SelectedIndexChanged;
|
||||
NameTextBox.TextChanged += TextChanged;
|
||||
RegexTextBox.TextChanged += TextChanged;
|
||||
ExampleTextBox.TextChanged += TextChanged;
|
||||
@@ -93,7 +85,9 @@ namespace DataOrganizer
|
||||
var db = new DB();
|
||||
db.DeleteNamingConvention(ActivePatternId);
|
||||
|
||||
NamingConventionPatternsComboBox.SelectedIndex = 0;
|
||||
ClearForm();
|
||||
|
||||
RefreshNamingConventions();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -129,5 +123,39 @@ namespace DataOrganizer
|
||||
RegexResultsTextBox.Text = $"Error:{Environment.NewLine}{ex.Message}";
|
||||
}
|
||||
}
|
||||
|
||||
private void AddUpdateButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
var db = new DB();
|
||||
|
||||
if(ActivePatternId == 0)
|
||||
{
|
||||
db.InsertNamingConvention(NameTextBox.Text, RegexTextBox.Text, ExampleTextBox.Text);
|
||||
ClearForm();
|
||||
RefreshNamingConventions();
|
||||
}
|
||||
else
|
||||
{
|
||||
db.UpdateNamingConvention(ActivePatternId, NameTextBox.Text, RegexTextBox.Text, ExampleTextBox.Text);
|
||||
PatternIdLabel.Text = $"Pattern ID: {ActivePatternId} (Updated)";
|
||||
}
|
||||
}
|
||||
|
||||
private void RefreshNamingConventions()
|
||||
{
|
||||
NamingConventionPatternsComboBox.SelectedIndexChanged -= NamingConventionPatternsComboBox_SelectedIndexChanged;
|
||||
NamingConventionPatternsComboBox.Items.Clear();
|
||||
|
||||
var db = new DB();
|
||||
NamingConventionPatternsComboBox.Items.Add("Add New Pattern");
|
||||
NamingConventionPatternsComboBox.SelectedIndex = 0;
|
||||
|
||||
foreach (var pattern in db.GetNamingConventions())
|
||||
{
|
||||
NamingConventionPatternsComboBox.Items.Add(pattern.Name);
|
||||
}
|
||||
|
||||
NamingConventionPatternsComboBox.SelectedIndexChanged += NamingConventionPatternsComboBox_SelectedIndexChanged;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user