Fixed some UI bugs in the Category Manager form.
This commit is contained in:
@@ -28,10 +28,22 @@ namespace InventoryTest
|
||||
CategoryPropertyNameTextBox.TextChanged += CategoryPropertyNameTextBox_TextChanged;
|
||||
SubCategoryPropertyNameTextBox.TextChanged += SubCategoryNameTextBox_TextChanged;
|
||||
NewCategoryNameTextBox.TextChanged += NewCategoryNameTextBox_TextChanged;
|
||||
CategoryPropertiesListBox.SelectedIndexChanged += CategoryPropertiesListBox_SelectedIndexChanged;
|
||||
SubCategoryPropertiesListBox.SelectedIndexChanged += SubCategoryPropertiesListBox_SelectedIndexChanged;
|
||||
|
||||
LoadCategories();
|
||||
}
|
||||
|
||||
private void SubCategoryPropertiesListBox_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
DeleteSubCategoryPropertyButton.Enabled = SubCategoryPropertiesListBox.SelectedIndex >= 0;
|
||||
}
|
||||
|
||||
private void CategoryPropertiesListBox_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
DeleteCategoryPropertyButton.Enabled = CategoryPropertiesListBox.SelectedIndex >= 0;
|
||||
}
|
||||
|
||||
private void NewCategoryNameTextBox_TextChanged(object sender, EventArgs e)
|
||||
{
|
||||
CreateNewCategoryButton.Enabled = !string.IsNullOrEmpty(NewCategoryNameTextBox.Text);
|
||||
@@ -58,6 +70,8 @@ namespace InventoryTest
|
||||
SubCategoryComboBoxManager.Items.Clear();
|
||||
CategoryPropertiesListBox.Items.Clear();
|
||||
SubCategoryPropertiesListBox.Items.Clear();
|
||||
DeleteCategoryPropertyButton.Enabled = false;
|
||||
DeleteSubCategoryPropertyButton.Enabled = false;
|
||||
var id = CategoryIds[CategoryComboBoxManager.Text];
|
||||
SubCategoryIds.Clear();
|
||||
|
||||
@@ -140,6 +154,7 @@ namespace InventoryTest
|
||||
private void LoadSubCategoryProperties()
|
||||
{
|
||||
SubCategoryPropertiesListBox.Items.Clear();
|
||||
DeleteSubCategoryPropertyButton.Enabled = false;
|
||||
using var connection = new SqlConnection(ConnectionString);
|
||||
using var command = new SqlCommand("SELECT * FROM GetSubCategoryProperties(@ID)", connection);
|
||||
command.Parameters.AddWithValue("ID", SubCategoryIds[SubCategoryComboBoxManager.Text]);
|
||||
@@ -155,15 +170,12 @@ namespace InventoryTest
|
||||
private void ToggleSubCategoryProperty(bool enabled)
|
||||
{
|
||||
SubCategoryPropertyNameTextBox.Enabled = enabled;
|
||||
CreateSubCategoryButton.Enabled = enabled;
|
||||
DeleteSubCategoryButton.Enabled = enabled;
|
||||
}
|
||||
|
||||
private void ToggleCategoryProperty(bool enabled)
|
||||
{
|
||||
CategoryPropertyNameTextBox.Enabled = enabled;
|
||||
CreateCategoryPropertyButton.Enabled = enabled;
|
||||
DeleteCategoryButton.Enabled = enabled;
|
||||
}
|
||||
|
||||
private void CreateCategoryPropertyButton_Click(object sender, EventArgs e)
|
||||
@@ -210,7 +222,7 @@ namespace InventoryTest
|
||||
|
||||
CategoryIds.Add(NewCategoryNameTextBox.Text, Convert.ToInt32(command.ExecuteScalar()));
|
||||
|
||||
CategoryComboBoxManager.Items.Add(NewCategoryNameTextBox);
|
||||
CategoryComboBoxManager.Items.Add(NewCategoryNameTextBox.Text);
|
||||
|
||||
NewCategoryNameTextBox.Text = string.Empty;
|
||||
NewCategoryNameTextBox.Focus();
|
||||
@@ -237,6 +249,9 @@ namespace InventoryTest
|
||||
SubCategoryComboBoxManager.Enabled = true;
|
||||
|
||||
if (SubCategoryComboBoxManager.SelectedIndex == -1) SubCategoryComboBoxManager.SelectedIndex = 0;
|
||||
|
||||
SubCategoryPropertyNameTextBox.Enabled = true;
|
||||
DeleteSubCategoryButton.Enabled = true;
|
||||
}
|
||||
|
||||
private void DeleteCategoryButton_Click(object sender, EventArgs e)
|
||||
@@ -265,5 +280,10 @@ namespace InventoryTest
|
||||
SubCategoryIds.Remove(SubCategoryComboBoxManager.Text);
|
||||
SubCategoryComboBoxManager.Items.RemoveAt(SubCategoryComboBoxManager.SelectedIndex);
|
||||
}
|
||||
|
||||
private void DeleteCategoryPropertyButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user