diff --git a/AyaNovaQBI/Form1.Designer.cs b/AyaNovaQBI/Form1.Designer.cs index 5b9070b..d5a87d1 100644 --- a/AyaNovaQBI/Form1.Designer.cs +++ b/AyaNovaQBI/Form1.Designer.cs @@ -198,6 +198,7 @@ this.cbCustomersWithInvoiceableWorkorders.Name = "cbCustomersWithInvoiceableWorkorders"; this.cbCustomersWithInvoiceableWorkorders.Size = new System.Drawing.Size(765, 21); this.cbCustomersWithInvoiceableWorkorders.TabIndex = 1; + this.cbCustomersWithInvoiceableWorkorders.SelectedIndexChanged += new System.EventHandler(this.cbCustomersWithInvoiceableWorkorders_SelectedIndexChanged); // // label1 // diff --git a/AyaNovaQBI/Form1.cs b/AyaNovaQBI/Form1.cs index 6dea710..67bb6f9 100644 --- a/AyaNovaQBI/Form1.cs +++ b/AyaNovaQBI/Form1.cs @@ -21,7 +21,7 @@ namespace AyaNovaQBI { cbCustomersWithInvoiceableWorkorders.DataSource = util.GetCustomersWithInvoiceableItems(); cbCustomersWithInvoiceableWorkorders.DisplayMember = "Name"; - grid.DataSource = util.GetInvoiceableItems(); + // grid.DataSource = util.GetInvoiceableItems(); } private void grid_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e) @@ -47,5 +47,16 @@ namespace AyaNovaQBI { Close(); } + + private void cbCustomersWithInvoiceableWorkorders_SelectedIndexChanged(object sender, EventArgs e) + { + if (cbCustomersWithInvoiceableWorkorders.SelectedValue != null) + { + var selectedNameIdItem = cbCustomersWithInvoiceableWorkorders.SelectedValue as NameIdItem; + grid.DataSource = util.GetInvoiceableItems(selectedNameIdItem.Name); + } + else + grid.DataSource = null; + } } } diff --git a/AyaNovaQBI/util.cs b/AyaNovaQBI/util.cs index a6fa7ea..0ff96ac 100644 --- a/AyaNovaQBI/util.cs +++ b/AyaNovaQBI/util.cs @@ -9,20 +9,21 @@ namespace AyaNovaQBI internal class util { - public static List GetInvoiceableItems() + public static List GetInvoiceableItems(string customerName) { var random = new Random(); var l = new List(); - for (int i = 1; i < 100; i++) - l.Add(new InvoiceableItem { CustomerId = 1, Linked = random.Next(2) == 1, Project = $"project {i}", ServiceDate = DateTime.Now.ToString("s"), ServiceNumber = (40+i).ToString(), Status = "Waiting to be invoiced and just sitting there otherwise", StatusColor = "FF00FFAA", WorkorderId = 4 }); + for (int i = 1; i < random.Next(3,100); i++) + l.Add(new InvoiceableItem { CustomerId = 1, Linked = random.Next(2) == 1, Project = $"project {i}", ServiceDate = DateTime.Now.ToString("s"), ServiceNumber = (40+i).ToString(), Status = $"Waiting to be invoiced ({customerName})", StatusColor = "FF00FFAA", WorkorderId = 4 }); return l; } public static List GetCustomersWithInvoiceableItems() { + var random = new Random(); var l = new List(); - for (int i = 1; i < 100; i++) + for (int i = 1; i < random.Next(5,100); i++) l.Add(new NameIdItem { Id = i, Name = $"Customer {i}"}); return l; }