From 38e52c9c6b2545f393fe88992d07cc12c524f72d Mon Sep 17 00:00:00 2001 From: John Cardinal Date: Sat, 9 Jul 2022 19:15:07 +0000 Subject: [PATCH] --- AyaNovaQBI/MainForm.Designer.cs | 3 - AyaNovaQBI/MainForm.cs | 97 ++++++++++++++++------- AyaNovaQBI/WorkOrderAccountingListItem.cs | 16 ++-- 3 files changed, 76 insertions(+), 40 deletions(-) diff --git a/AyaNovaQBI/MainForm.Designer.cs b/AyaNovaQBI/MainForm.Designer.cs index 065c5ba..d8f1f07 100644 --- a/AyaNovaQBI/MainForm.Designer.cs +++ b/AyaNovaQBI/MainForm.Designer.cs @@ -243,7 +243,6 @@ this.customer.HeaderText = "Customer"; this.customer.Name = "customer"; this.customer.ReadOnly = true; - this.customer.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable; // // wonumber // @@ -251,7 +250,6 @@ this.wonumber.HeaderText = "Service number"; this.wonumber.Name = "wonumber"; this.wonumber.ReadOnly = true; - this.wonumber.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable; // // ProjectName // @@ -273,7 +271,6 @@ this.status.HeaderText = "Status"; this.status.Name = "status"; this.status.ReadOnly = true; - this.status.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable; // // statuscolor // diff --git a/AyaNovaQBI/MainForm.cs b/AyaNovaQBI/MainForm.cs index 5e01483..d5b5469 100644 --- a/AyaNovaQBI/MainForm.cs +++ b/AyaNovaQBI/MainForm.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.ComponentModel; using System.Data; using System.Linq; using System.Reflection; @@ -388,7 +389,8 @@ namespace AyaNovaQBI */ - private List _WorkOrderGridListItems = new List(); + //private BindingList _WorkOrderGridListItems = new BindingList(); + private DataTable _GridTable = null; private List _MisMatches = new List(); private List _PartPriceOverrides = new List(); /// @@ -404,42 +406,78 @@ namespace AyaNovaQBI w.Ops = "Validating invoices..."; try { + if (_GridTable == null) + { + //datatable is required to support sorting in dgv without writing a lot of extra code + _GridTable = new DataTable(); + _GridTable.Columns.Add(new DataColumn("CustomerName")); + _GridTable.Columns.Add(new DataColumn("Serial")); + _GridTable.Columns.Add(new DataColumn("ServiceDate")); + _GridTable.Columns.Add(new DataColumn("WorkorderStatusName")); + _GridTable.Columns.Add(new DataColumn("ProjectName")); + _GridTable.Columns.Add(new DataColumn("Color")); + _GridTable.Columns.Add(new DataColumn("CustomerId")); + _GridTable.Columns.Add(new DataColumn("Id")); + _GridTable.Columns.Add(new DataColumn("Linked")); + } _MisMatches.Clear(); //[HttpGet("accounting-list-billable/{workOrderStatusId}")] var r = await util.GetAsync($"workorder/accounting-list-billable/{util.QDat.PreWOStatus}"); - var v = r.ObjectResponse["data"] - .ToObject>(); - _WorkOrderGridListItems = v - .Select(z => new WorkOrderGridListItem - { - Color = z.color, - CustomerId = z.customerId, - CustomerName = z.customerName, - Id = z.id, - ProjectName = z.projectName, - Serial = z.serial, - ServiceDate = z.serviceDate, - WorkorderStatusName = z.workorderStatusName - }) - .ToList(); + var v = r.ObjectResponse["data"].ToObject>(); - - - foreach (WorkOrderGridListItem i in _WorkOrderGridListItems) + foreach (WorkOrderAccountingListItem z in v) { - w.Step = "WO: " + i.Serial; - i.Linked = util.ScanLinksOK(i.Id, _MisMatches, _PartPriceOverrides); - //DataRow dri = InvoiceRowForClientID(i.ClientID); + w.Step = "WO: " + z.Serial; + DataRow row = _GridTable.NewRow(); + row["CustomerName"] = z.CustomerName; + row["Serial"] = z.Serial; + row["ServiceDate"] = z.ServiceDate; + row["WorkorderStatusName"] = z.WorkorderStatusName; + row["ProjectName"] = z.ProjectName; + row["Color"] = z.Color; + row["CustomerId"] = z.CustomerId; + row["Id"] = z.Id; + row["Linked"]= util.ScanLinksOK(z.Id, _MisMatches, _PartPriceOverrides); - //if (dri == null) - //{ - // dri = dtInvoice.NewRow(); - // dri["Client"] = i.Client; - // dri["ClientID"] = i.ClientID; - // dtInvoice.Rows.Add(dri); + _GridTable.Rows.Add(row); } + + + //foreach (WorkOrderAccountingListItem z in v) + //{ + // _WorkOrderGridListItems.Add(new WorkOrderGridListItem + // { + // Color = z.Color, + // CustomerId = z.CustomerId, + // CustomerName = z.CustomerName, + // Id = z.Id, + // ProjectName = z.ProjectName, + // Serial = z.Serial, + // ServiceDate = z.ServiceDate, + // WorkorderStatusName = z.WorkorderStatusName + // }); + //} + + + + + + //foreach (WorkOrderGridListItem i in _WorkOrderGridListItems) + //{ + // w.Step = "WO: " + i.Serial; + // i.Linked = util.ScanLinksOK(i.Id, _MisMatches, _PartPriceOverrides); + // //DataRow dri = InvoiceRowForClientID(i.ClientID); + + // //if (dri == null) + // //{ + // // dri = dtInvoice.NewRow(); + // // dri["Client"] = i.Client; + // // dri["ClientID"] = i.ClientID; + // // dtInvoice.Rows.Add(dri); + //} + //If any one single workorder is linked //then the invoice is flagged as linked because //you can invoice out anything under it that is linked and the @@ -509,7 +547,8 @@ namespace AyaNovaQBI private void InitializeGrid() { - grid.DataSource = _WorkOrderGridListItems; + + grid.DataSource = _GridTable; //grid.Columns["WorkingID"].Visible = false; //grid.Columns["ClientID"].Visible = false; //grid.Columns["Linked"].Visible = false; diff --git a/AyaNovaQBI/WorkOrderAccountingListItem.cs b/AyaNovaQBI/WorkOrderAccountingListItem.cs index 747e3e0..5fa1578 100644 --- a/AyaNovaQBI/WorkOrderAccountingListItem.cs +++ b/AyaNovaQBI/WorkOrderAccountingListItem.cs @@ -8,13 +8,13 @@ namespace AyaNovaQBI /// public class WorkOrderAccountingListItem { - public long id { get; set; } - public long customerId { get; set; } - public string customerName { get; set; } - public string workorderStatusName { get; set; } - public long serial { get; set; } - public DateTime? serviceDate { get; set; } - public string color { get; set; } - public string projectName { get; set; } + public long Id { get; set; } + public long CustomerId { get; set; } + public string CustomerName { get; set; } + public string WorkorderStatusName { get; set; } + public long Serial { get; set; } + public DateTime? ServiceDate { get; set; } + public string Color { get; set; } + public string ProjectName { get; set; } } }