diff --git a/.vs/InventoryTest/DesignTimeBuild/.dtbcache.v2 b/.vs/InventoryTest/DesignTimeBuild/.dtbcache.v2 index 2d93fa4..dd31158 100644 Binary files a/.vs/InventoryTest/DesignTimeBuild/.dtbcache.v2 and b/.vs/InventoryTest/DesignTimeBuild/.dtbcache.v2 differ diff --git a/.vs/InventoryTest/v16/.suo b/.vs/InventoryTest/v16/.suo index a04aa4e..93d785a 100644 Binary files a/.vs/InventoryTest/v16/.suo and b/.vs/InventoryTest/v16/.suo differ diff --git a/InventoryTest/CategoryManager.Designer.cs b/InventoryTest/CategoryManager.Designer.cs index d19e9fd..0b6302e 100644 --- a/InventoryTest/CategoryManager.Designer.cs +++ b/InventoryTest/CategoryManager.Designer.cs @@ -32,8 +32,6 @@ namespace InventoryTest this.MainLayoutPanel = new System.Windows.Forms.TableLayoutPanel(); this.menuStrip1 = new System.Windows.Forms.MenuStrip(); this.groupBox1 = new System.Windows.Forms.GroupBox(); - this.SubCategoryComboBox = new System.Windows.Forms.ComboBox(); - this.CategoryComboBox = new System.Windows.Forms.ComboBox(); this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel(); this.groupBox7 = new System.Windows.Forms.GroupBox(); this.CreateNewSubCategoryButton = new System.Windows.Forms.Button(); @@ -114,8 +112,6 @@ namespace InventoryTest // // groupBox1 // - this.groupBox1.Controls.Add(this.SubCategoryComboBox); - this.groupBox1.Controls.Add(this.CategoryComboBox); this.groupBox1.Dock = System.Windows.Forms.DockStyle.Fill; this.groupBox1.Location = new System.Drawing.Point(267, 28); this.groupBox1.Name = "groupBox1"; @@ -124,20 +120,6 @@ namespace InventoryTest this.groupBox1.TabStop = false; this.groupBox1.Text = "Category Selection"; // - // SubCategoryComboBox - // - this.SubCategoryComboBox.Location = new System.Drawing.Point(0, 0); - this.SubCategoryComboBox.Name = "SubCategoryComboBox"; - this.SubCategoryComboBox.Size = new System.Drawing.Size(121, 23); - this.SubCategoryComboBox.TabIndex = 0; - // - // CategoryComboBox - // - this.CategoryComboBox.Location = new System.Drawing.Point(0, 0); - this.CategoryComboBox.Name = "CategoryComboBox"; - this.CategoryComboBox.Size = new System.Drawing.Size(121, 23); - this.CategoryComboBox.TabIndex = 1; - // // tableLayoutPanel1 // this.tableLayoutPanel1.ColumnCount = 3; @@ -644,8 +626,6 @@ namespace InventoryTest private System.Windows.Forms.TableLayoutPanel MainLayoutPanel; private System.Windows.Forms.MenuStrip menuStrip1; private System.Windows.Forms.GroupBox groupBox1; - private System.Windows.Forms.ComboBox SubCategoryComboBox; - private System.Windows.Forms.ComboBox CategoryComboBox; private System.Windows.Forms.TableLayoutPanel tableLayoutPanel1; private System.Windows.Forms.GroupBox groupBox2; private System.Windows.Forms.ComboBox CategoryComboBoxManager; diff --git a/InventoryTest/Form1.Designer.cs b/InventoryTest/Form1.Designer.cs index 0e5b2ff..895e9be 100644 --- a/InventoryTest/Form1.Designer.cs +++ b/InventoryTest/Form1.Designer.cs @@ -36,6 +36,7 @@ namespace InventoryTest this.toolsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.ManageCategoriesToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.groupBox1 = new System.Windows.Forms.GroupBox(); + this.CreateItemButton = new System.Windows.Forms.Button(); this.label2 = new System.Windows.Forms.Label(); this.label1 = new System.Windows.Forms.Label(); this.SubCategorySelectionComboBox = new System.Windows.Forms.ComboBox(); @@ -43,32 +44,32 @@ namespace InventoryTest this.groupBox2 = new System.Windows.Forms.GroupBox(); this.ItemListView = new System.Windows.Forms.ListView(); this.groupBox3 = new System.Windows.Forms.GroupBox(); - this.label3 = new System.Windows.Forms.Label(); - this.label4 = new System.Windows.Forms.Label(); - this.label5 = new System.Windows.Forms.Label(); - this.label6 = new System.Windows.Forms.Label(); - this.groupBox4 = new System.Windows.Forms.GroupBox(); - this.groupBox5 = new System.Windows.Forms.GroupBox(); - this.label7 = new System.Windows.Forms.Label(); - this.CorePropertySoldCheckBox = new System.Windows.Forms.CheckBox(); - this.label8 = new System.Windows.Forms.Label(); - this.label9 = new System.Windows.Forms.Label(); - this.CorePropertyNameTextBox = new System.Windows.Forms.TextBox(); - this.CorePropertyValueTextBox = new System.Windows.Forms.TextBox(); - this.CorePropertyBoughtForTextBox = new System.Windows.Forms.TextBox(); - this.CorePropertyDateAquiredDateTimePicker = new System.Windows.Forms.DateTimePicker(); - this.CorePropertySoldForTextBox = new System.Windows.Forms.TextBox(); - this.CorePropertyDateSoldDateTimePicker = new System.Windows.Forms.DateTimePicker(); this.CorePropertySoldToTextBox = new System.Windows.Forms.TextBox(); + this.CorePropertyDateSoldDateTimePicker = new System.Windows.Forms.DateTimePicker(); + this.CorePropertySoldForTextBox = new System.Windows.Forms.TextBox(); + this.CorePropertyDateAquiredDateTimePicker = new System.Windows.Forms.DateTimePicker(); + this.CorePropertyBoughtForTextBox = new System.Windows.Forms.TextBox(); + this.CorePropertyValueTextBox = new System.Windows.Forms.TextBox(); + this.CorePropertyNameTextBox = new System.Windows.Forms.TextBox(); + this.label9 = new System.Windows.Forms.Label(); + this.label8 = new System.Windows.Forms.Label(); + this.CorePropertySoldCheckBox = new System.Windows.Forms.CheckBox(); + this.label7 = new System.Windows.Forms.Label(); + this.label6 = new System.Windows.Forms.Label(); + this.label5 = new System.Windows.Forms.Label(); + this.label4 = new System.Windows.Forms.Label(); + this.label3 = new System.Windows.Forms.Label(); + this.CorePropertyCommentGroupBox = new System.Windows.Forms.GroupBox(); this.CorePropertyCommentTextBox = new System.Windows.Forms.TextBox(); + this.CorePropertyNotesGroupBox = new System.Windows.Forms.GroupBox(); this.CorePropertyNotesTextBox = new System.Windows.Forms.TextBox(); this.MainLayoutPanel.SuspendLayout(); this.menuStrip1.SuspendLayout(); this.groupBox1.SuspendLayout(); this.groupBox2.SuspendLayout(); this.groupBox3.SuspendLayout(); - this.groupBox4.SuspendLayout(); - this.groupBox5.SuspendLayout(); + this.CorePropertyCommentGroupBox.SuspendLayout(); + this.CorePropertyNotesGroupBox.SuspendLayout(); this.SuspendLayout(); // // MainLayoutPanel @@ -82,8 +83,8 @@ namespace InventoryTest this.MainLayoutPanel.Controls.Add(this.groupBox1, 0, 1); this.MainLayoutPanel.Controls.Add(this.groupBox2, 0, 2); this.MainLayoutPanel.Controls.Add(this.groupBox3, 0, 3); - this.MainLayoutPanel.Controls.Add(this.groupBox4, 1, 3); - this.MainLayoutPanel.Controls.Add(this.groupBox5, 1, 4); + this.MainLayoutPanel.Controls.Add(this.CorePropertyCommentGroupBox, 1, 3); + this.MainLayoutPanel.Controls.Add(this.CorePropertyNotesGroupBox, 1, 4); this.MainLayoutPanel.Dock = System.Windows.Forms.DockStyle.Fill; this.MainLayoutPanel.Location = new System.Drawing.Point(0, 0); this.MainLayoutPanel.Name = "MainLayoutPanel"; @@ -138,6 +139,7 @@ namespace InventoryTest // // groupBox1 // + this.groupBox1.Controls.Add(this.CreateItemButton); this.groupBox1.Controls.Add(this.label2); this.groupBox1.Controls.Add(this.label1); this.groupBox1.Controls.Add(this.SubCategorySelectionComboBox); @@ -150,6 +152,16 @@ namespace InventoryTest this.groupBox1.TabStop = false; this.groupBox1.Text = "Category Selection"; // + // CreateItemButton + // + this.CreateItemButton.Enabled = false; + this.CreateItemButton.Location = new System.Drawing.Point(235, 113); + this.CreateItemButton.Name = "CreateItemButton"; + this.CreateItemButton.Size = new System.Drawing.Size(75, 23); + this.CreateItemButton.TabIndex = 4; + this.CreateItemButton.Text = "button1"; + this.CreateItemButton.UseVisualStyleBackColor = true; + // // label2 // this.label2.AutoSize = true; @@ -233,72 +245,73 @@ namespace InventoryTest this.groupBox3.TabStop = false; this.groupBox3.Text = "Core Properties"; // - // label3 + // CorePropertySoldToTextBox // - this.label3.AutoSize = true; - this.label3.Location = new System.Drawing.Point(3, 19); - this.label3.Name = "label3"; - this.label3.Size = new System.Drawing.Size(42, 15); - this.label3.TabIndex = 0; - this.label3.Text = "Name:"; + this.CorePropertySoldToTextBox.Location = new System.Drawing.Point(94, 209); + this.CorePropertySoldToTextBox.Name = "CorePropertySoldToTextBox"; + this.CorePropertySoldToTextBox.Size = new System.Drawing.Size(216, 23); + this.CorePropertySoldToTextBox.TabIndex = 14; // - // label4 + // CorePropertyDateSoldDateTimePicker // - this.label4.AutoSize = true; - this.label4.Location = new System.Drawing.Point(6, 46); - this.label4.Name = "label4"; - this.label4.Size = new System.Drawing.Size(38, 15); - this.label4.TabIndex = 1; - this.label4.Text = "Value:"; + this.CorePropertyDateSoldDateTimePicker.Location = new System.Drawing.Point(94, 179); + this.CorePropertyDateSoldDateTimePicker.Name = "CorePropertyDateSoldDateTimePicker"; + this.CorePropertyDateSoldDateTimePicker.Size = new System.Drawing.Size(216, 23); + this.CorePropertyDateSoldDateTimePicker.TabIndex = 13; // - // label5 + // CorePropertySoldForTextBox // - this.label5.AutoSize = true; - this.label5.Location = new System.Drawing.Point(6, 73); - this.label5.Name = "label5"; - this.label5.Size = new System.Drawing.Size(69, 15); - this.label5.TabIndex = 2; - this.label5.Text = "Bought For:"; + this.CorePropertySoldForTextBox.Location = new System.Drawing.Point(94, 124); + this.CorePropertySoldForTextBox.Name = "CorePropertySoldForTextBox"; + this.CorePropertySoldForTextBox.Size = new System.Drawing.Size(216, 23); + this.CorePropertySoldForTextBox.TabIndex = 12; // - // label6 + // CorePropertyDateAquiredDateTimePicker // - this.label6.AutoSize = true; - this.label6.Location = new System.Drawing.Point(6, 100); - this.label6.Name = "label6"; - this.label6.Size = new System.Drawing.Size(79, 15); - this.label6.TabIndex = 3; - this.label6.Text = "Date Aquired:"; + this.CorePropertyDateAquiredDateTimePicker.Location = new System.Drawing.Point(94, 97); + this.CorePropertyDateAquiredDateTimePicker.Name = "CorePropertyDateAquiredDateTimePicker"; + this.CorePropertyDateAquiredDateTimePicker.Size = new System.Drawing.Size(216, 23); + this.CorePropertyDateAquiredDateTimePicker.TabIndex = 11; // - // groupBox4 + // CorePropertyBoughtForTextBox // - this.groupBox4.Controls.Add(this.CorePropertyCommentTextBox); - this.groupBox4.Dock = System.Windows.Forms.DockStyle.Fill; - this.groupBox4.Location = new System.Drawing.Point(325, 324); - this.groupBox4.Name = "groupBox4"; - this.groupBox4.Size = new System.Drawing.Size(316, 142); - this.groupBox4.TabIndex = 4; - this.groupBox4.TabStop = false; - this.groupBox4.Text = "Comment"; + this.CorePropertyBoughtForTextBox.Location = new System.Drawing.Point(94, 70); + this.CorePropertyBoughtForTextBox.Name = "CorePropertyBoughtForTextBox"; + this.CorePropertyBoughtForTextBox.Size = new System.Drawing.Size(216, 23); + this.CorePropertyBoughtForTextBox.TabIndex = 10; // - // groupBox5 + // CorePropertyValueTextBox // - this.groupBox5.Controls.Add(this.CorePropertyNotesTextBox); - this.groupBox5.Dock = System.Windows.Forms.DockStyle.Fill; - this.groupBox5.Location = new System.Drawing.Point(325, 472); - this.groupBox5.Name = "groupBox5"; - this.groupBox5.Size = new System.Drawing.Size(316, 143); - this.groupBox5.TabIndex = 5; - this.groupBox5.TabStop = false; - this.groupBox5.Text = "Notes"; + this.CorePropertyValueTextBox.Location = new System.Drawing.Point(94, 43); + this.CorePropertyValueTextBox.Name = "CorePropertyValueTextBox"; + this.CorePropertyValueTextBox.Size = new System.Drawing.Size(216, 23); + this.CorePropertyValueTextBox.TabIndex = 9; // - // label7 + // CorePropertyNameTextBox // - this.label7.AutoSize = true; - this.label7.Location = new System.Drawing.Point(6, 127); - this.label7.Name = "label7"; - this.label7.Size = new System.Drawing.Size(53, 15); - this.label7.TabIndex = 4; - this.label7.Text = "Sold For:"; + this.CorePropertyNameTextBox.Enabled = false; + this.CorePropertyNameTextBox.Location = new System.Drawing.Point(94, 16); + this.CorePropertyNameTextBox.Name = "CorePropertyNameTextBox"; + this.CorePropertyNameTextBox.Size = new System.Drawing.Size(216, 23); + this.CorePropertyNameTextBox.TabIndex = 8; + // + // label9 + // + this.label9.AutoSize = true; + this.label9.Location = new System.Drawing.Point(6, 212); + this.label9.Name = "label9"; + this.label9.Size = new System.Drawing.Size(48, 15); + this.label9.TabIndex = 7; + this.label9.Text = "Sold To:"; + // + // label8 + // + this.label8.AutoSize = true; + this.label8.Location = new System.Drawing.Point(6, 185); + this.label8.Name = "label8"; + this.label8.Size = new System.Drawing.Size(60, 15); + this.label8.TabIndex = 6; + this.label8.Text = "Date Sold:"; // // CorePropertySoldCheckBox // @@ -311,72 +324,61 @@ namespace InventoryTest this.CorePropertySoldCheckBox.Text = "?Sold"; this.CorePropertySoldCheckBox.UseVisualStyleBackColor = true; // - // label8 + // label7 // - this.label8.AutoSize = true; - this.label8.Location = new System.Drawing.Point(6, 185); - this.label8.Name = "label8"; - this.label8.Size = new System.Drawing.Size(60, 15); - this.label8.TabIndex = 6; - this.label8.Text = "Date Sold:"; + this.label7.AutoSize = true; + this.label7.Location = new System.Drawing.Point(6, 127); + this.label7.Name = "label7"; + this.label7.Size = new System.Drawing.Size(53, 15); + this.label7.TabIndex = 4; + this.label7.Text = "Sold For:"; // - // label9 + // label6 // - this.label9.AutoSize = true; - this.label9.Location = new System.Drawing.Point(6, 212); - this.label9.Name = "label9"; - this.label9.Size = new System.Drawing.Size(48, 15); - this.label9.TabIndex = 7; - this.label9.Text = "Sold To:"; + this.label6.AutoSize = true; + this.label6.Location = new System.Drawing.Point(6, 100); + this.label6.Name = "label6"; + this.label6.Size = new System.Drawing.Size(79, 15); + this.label6.TabIndex = 3; + this.label6.Text = "Date Aquired:"; // - // CorePropertyNameTextBox + // label5 // - this.CorePropertyNameTextBox.Location = new System.Drawing.Point(94, 16); - this.CorePropertyNameTextBox.Name = "CorePropertyNameTextBox"; - this.CorePropertyNameTextBox.Size = new System.Drawing.Size(216, 23); - this.CorePropertyNameTextBox.TabIndex = 8; + this.label5.AutoSize = true; + this.label5.Location = new System.Drawing.Point(6, 73); + this.label5.Name = "label5"; + this.label5.Size = new System.Drawing.Size(69, 15); + this.label5.TabIndex = 2; + this.label5.Text = "Bought For:"; // - // CorePropertyValueTextBox + // label4 // - this.CorePropertyValueTextBox.Location = new System.Drawing.Point(94, 43); - this.CorePropertyValueTextBox.Name = "CorePropertyValueTextBox"; - this.CorePropertyValueTextBox.Size = new System.Drawing.Size(216, 23); - this.CorePropertyValueTextBox.TabIndex = 9; + this.label4.AutoSize = true; + this.label4.Location = new System.Drawing.Point(6, 46); + this.label4.Name = "label4"; + this.label4.Size = new System.Drawing.Size(38, 15); + this.label4.TabIndex = 1; + this.label4.Text = "Value:"; // - // CorePropertyBoughtForTextBox + // label3 // - this.CorePropertyBoughtForTextBox.Location = new System.Drawing.Point(94, 70); - this.CorePropertyBoughtForTextBox.Name = "CorePropertyBoughtForTextBox"; - this.CorePropertyBoughtForTextBox.Size = new System.Drawing.Size(216, 23); - this.CorePropertyBoughtForTextBox.TabIndex = 10; + this.label3.AutoSize = true; + this.label3.Location = new System.Drawing.Point(3, 19); + this.label3.Name = "label3"; + this.label3.Size = new System.Drawing.Size(42, 15); + this.label3.TabIndex = 0; + this.label3.Text = "Name:"; // - // CorePropertyDateAquiredDateTimePicker + // CorePropertyCommentGroupBox // - this.CorePropertyDateAquiredDateTimePicker.Location = new System.Drawing.Point(94, 97); - this.CorePropertyDateAquiredDateTimePicker.Name = "CorePropertyDateAquiredDateTimePicker"; - this.CorePropertyDateAquiredDateTimePicker.Size = new System.Drawing.Size(216, 23); - this.CorePropertyDateAquiredDateTimePicker.TabIndex = 11; - // - // CorePropertySoldForTextBox - // - this.CorePropertySoldForTextBox.Location = new System.Drawing.Point(94, 124); - this.CorePropertySoldForTextBox.Name = "CorePropertySoldForTextBox"; - this.CorePropertySoldForTextBox.Size = new System.Drawing.Size(216, 23); - this.CorePropertySoldForTextBox.TabIndex = 12; - // - // CorePropertyDateSoldDateTimePicker - // - this.CorePropertyDateSoldDateTimePicker.Location = new System.Drawing.Point(94, 179); - this.CorePropertyDateSoldDateTimePicker.Name = "CorePropertyDateSoldDateTimePicker"; - this.CorePropertyDateSoldDateTimePicker.Size = new System.Drawing.Size(216, 23); - this.CorePropertyDateSoldDateTimePicker.TabIndex = 13; - // - // CorePropertySoldToTextBox - // - this.CorePropertySoldToTextBox.Location = new System.Drawing.Point(94, 209); - this.CorePropertySoldToTextBox.Name = "CorePropertySoldToTextBox"; - this.CorePropertySoldToTextBox.Size = new System.Drawing.Size(216, 23); - this.CorePropertySoldToTextBox.TabIndex = 14; + this.CorePropertyCommentGroupBox.Controls.Add(this.CorePropertyCommentTextBox); + this.CorePropertyCommentGroupBox.Dock = System.Windows.Forms.DockStyle.Fill; + this.CorePropertyCommentGroupBox.Location = new System.Drawing.Point(325, 324); + this.CorePropertyCommentGroupBox.Name = "CorePropertyCommentGroupBox"; + this.CorePropertyCommentGroupBox.Size = new System.Drawing.Size(316, 142); + this.CorePropertyCommentGroupBox.TabIndex = 4; + this.CorePropertyCommentGroupBox.TabStop = false; + this.CorePropertyCommentGroupBox.Text = "Comment"; // // CorePropertyCommentTextBox // @@ -388,6 +390,17 @@ namespace InventoryTest this.CorePropertyCommentTextBox.Size = new System.Drawing.Size(310, 120); this.CorePropertyCommentTextBox.TabIndex = 0; // + // CorePropertyNotesGroupBox + // + this.CorePropertyNotesGroupBox.Controls.Add(this.CorePropertyNotesTextBox); + this.CorePropertyNotesGroupBox.Dock = System.Windows.Forms.DockStyle.Fill; + this.CorePropertyNotesGroupBox.Location = new System.Drawing.Point(325, 472); + this.CorePropertyNotesGroupBox.Name = "CorePropertyNotesGroupBox"; + this.CorePropertyNotesGroupBox.Size = new System.Drawing.Size(316, 143); + this.CorePropertyNotesGroupBox.TabIndex = 5; + this.CorePropertyNotesGroupBox.TabStop = false; + this.CorePropertyNotesGroupBox.Text = "Notes"; + // // CorePropertyNotesTextBox // this.CorePropertyNotesTextBox.Dock = System.Windows.Forms.DockStyle.Fill; @@ -416,10 +429,10 @@ namespace InventoryTest this.groupBox2.ResumeLayout(false); this.groupBox3.ResumeLayout(false); this.groupBox3.PerformLayout(); - this.groupBox4.ResumeLayout(false); - this.groupBox4.PerformLayout(); - this.groupBox5.ResumeLayout(false); - this.groupBox5.PerformLayout(); + this.CorePropertyCommentGroupBox.ResumeLayout(false); + this.CorePropertyCommentGroupBox.PerformLayout(); + this.CorePropertyNotesGroupBox.ResumeLayout(false); + this.CorePropertyNotesGroupBox.PerformLayout(); this.ResumeLayout(false); } @@ -448,8 +461,8 @@ namespace InventoryTest private System.Windows.Forms.Label label5; private System.Windows.Forms.Label label4; private System.Windows.Forms.Label label3; - private System.Windows.Forms.GroupBox groupBox4; - private System.Windows.Forms.GroupBox groupBox5; + private System.Windows.Forms.GroupBox CorePropertyCommentGroupBox; + private System.Windows.Forms.GroupBox CorePropertyNotesGroupBox; private System.Windows.Forms.TextBox CorePropertySoldToTextBox; private System.Windows.Forms.DateTimePicker CorePropertyDateSoldDateTimePicker; private System.Windows.Forms.TextBox CorePropertySoldForTextBox; @@ -459,6 +472,7 @@ namespace InventoryTest private System.Windows.Forms.TextBox CorePropertyNameTextBox; private System.Windows.Forms.TextBox CorePropertyCommentTextBox; private System.Windows.Forms.TextBox CorePropertyNotesTextBox; + private System.Windows.Forms.Button CreateItemButton; } } diff --git a/InventoryTest/Form1.cs b/InventoryTest/Form1.cs index 3f2c119..1f9c9be 100644 --- a/InventoryTest/Form1.cs +++ b/InventoryTest/Form1.cs @@ -13,7 +13,12 @@ namespace InventoryTest { public partial class Form1 : Form { - private static string ConnectionString { get; } = "Server=DESKTOP-HJES64T;Database=Inventory;Integrated Security=true;"; + private string ConnectionString { get; } = "Server=DESKTOP-HJES64T;Database=Inventory;Integrated Security=true;"; + private int CommentsMaxLength { get; } = 3072; + private int NotesMaxLength { get; } = 3072; + private Dictionary CategoryIds { get; } = new(); + private Dictionary SubCategoryIds { get; } = new(); + private Dictionary PropertyTypeIds { get; } = new(); public Form1() { @@ -21,6 +26,103 @@ namespace InventoryTest ManageCategoriesToolStripMenuItem.Click += ShowCategoryManagerForm; exitToolStripMenuItem.Click += ExitToolStripMenuItem_Click; + CorePropertyCommentTextBox.TextChanged += CorePropertyCommentTextBox_TextChanged; + CorePropertyCommentTextBox.MaxLength = CommentsMaxLength; + CorePropertyCommentGroupBox.Text = $"Comments (Remaing Characters: {CorePropertyCommentTextBox.MaxLength - CorePropertyCommentTextBox.TextLength})"; + CorePropertyNotesTextBox.TextChanged += CorePropertyNotesTextBox_TextChanged; + CorePropertyNotesTextBox.MaxLength = NotesMaxLength; + CorePropertyNotesGroupBox.Text = $"Notes (Remaing Characters: {CorePropertyNotesTextBox.MaxLength - CorePropertyNotesTextBox.TextLength})"; + CorePropertyNameTextBox.TextChanged += ToggleCreateItemButton; + CorePropertyBoughtForTextBox.TextChanged += ToggleCreateItemButton; + CorePropertySoldForTextBox.TextChanged += ToggleCreateItemButton; + CorePropertyValueTextBox.TextChanged += ToggleCreateItemButton; + + CategorySelectionComboBox.SelectedIndexChanged += CategorySelectionComboBox_SelectedIndexChanged; + SubCategorySelectionComboBox.SelectedIndexChanged += SubCategorySelectionComboBox_SelectedIndexChanged; + + LoadCategories(); + } + + private void SubCategorySelectionComboBox_SelectedIndexChanged(object sender, EventArgs e) + { + //throw new NotImplementedException(); + } + + private void CategorySelectionComboBox_SelectedIndexChanged(object sender, EventArgs e) + { + SubCategoryIds.Clear(); + SubCategorySelectionComboBox.Items.Clear(); + + using var connection = new SqlConnection(ConnectionString); + using var command = new SqlCommand("SELECT ID, Name FROM dbo.GetCategorySubCategories(@ID)", connection); + command.Parameters.AddWithValue("ID", CategoryIds[CategorySelectionComboBox.Text]); + + connection.Open(); + + var reader = command.ExecuteReader(); + + while (reader.Read()) + { + SubCategoryIds.Add(reader["Name"].ToString(), Convert.ToInt32(reader["ID"])); + SubCategorySelectionComboBox.Items.Add(reader["Name"].ToString()); + } + + if (SubCategorySelectionComboBox.Items.Count > 0) + { + SubCategorySelectionComboBox.Enabled = true; + SubCategorySelectionComboBox.SelectedIndex = 0; + } + else SubCategorySelectionComboBox.Enabled = false; + } + + private void LoadCategories() + { + CategoryIds.Clear(); + + using var connection = new SqlConnection(ConnectionString); + using var command = new SqlCommand("SELECT [Category ID], [Category Name] FROM Category", connection); + + connection.Open(); + + var reader = command.ExecuteReader(); + + while (reader.Read()) + { + CategoryIds.Add(reader["Category Name"].ToString(), Convert.ToInt32(reader["Category ID"])); + CategorySelectionComboBox.Items.Add(reader["Category Name"]); + } + + reader.Close(); + + if (CategorySelectionComboBox.Items.Count > 0) + { + CategorySelectionComboBox.SelectedIndex = 0; + CorePropertyNameTextBox.Enabled = true; + } + else CorePropertyNameTextBox.Enabled = false; + } + + private void ToggleCreateItemButton(object sender, EventArgs e) + { + var valueValid = CorePropertyValueTextBox.Text.Trim().Length == 0; + var boughtForValid = CorePropertyBoughtForTextBox.Text.Trim().Length == 0; + var soldForValid = CorePropertySoldForTextBox.Text.Trim().Length == 0; + + if (!valueValid) valueValid = decimal.TryParse(CorePropertyValueTextBox.Text, out decimal _); + if (!boughtForValid) boughtForValid = decimal.TryParse(CorePropertyBoughtForTextBox.Text, out decimal _); + if (!soldForValid) soldForValid = decimal.TryParse(CorePropertySoldForTextBox.Text, out decimal _); + + CreateItemButton.Enabled = CorePropertyNameTextBox.Text.Trim().Length > 0 && valueValid && boughtForValid && soldForValid; + } + + private void CorePropertyNotesTextBox_TextChanged(object sender, EventArgs e) + { + CorePropertyNotesGroupBox.Text = $"Notes (Remaing Characters: {CorePropertyNotesTextBox.MaxLength - CorePropertyNotesTextBox.TextLength})"; + } + + private void CorePropertyCommentTextBox_TextChanged(object sender, EventArgs e) + { + CorePropertyCommentGroupBox.Text = $"Comments (Remaing Characters: {CorePropertyCommentTextBox.MaxLength - CorePropertyCommentTextBox.TextLength})"; } private void ExitToolStripMenuItem_Click(object sender, EventArgs e) @@ -33,5 +135,13 @@ namespace InventoryTest var form = new CategoryManager(ConnectionString); form.ShowDialog(); } + + private struct ItemPropertyPairing + { + public int PropertyID; + public int ItemID; + public int PropertyTypeID; + public string Value; + } } }