This commit is contained in:
2022-06-18 02:29:49 +00:00
parent 6b4b25040d
commit aec5029993
3 changed files with 18 additions and 5 deletions

View File

@@ -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
//

View File

@@ -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;
}
}
}

View File

@@ -9,20 +9,21 @@ namespace AyaNovaQBI
internal class util
{
public static List<InvoiceableItem> GetInvoiceableItems()
public static List<InvoiceableItem> GetInvoiceableItems(string customerName)
{
var random = new Random();
var l = new List<InvoiceableItem>();
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<NameIdItem> GetCustomersWithInvoiceableItems()
{
var random = new Random();
var l = new List<NameIdItem>();
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;
}