This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
@@ -252,13 +253,13 @@ namespace AyaNovaQBI
|
||||
var v = r.ObjectResponse["data"].ToObject<List<WorkOrderAccountingListItem>>();
|
||||
|
||||
foreach (WorkOrderAccountingListItem z in v)
|
||||
{
|
||||
{
|
||||
w.Step = "WO: " + z.Serial;
|
||||
DataRow row = _GridTable.NewRow();
|
||||
row["CustomerName"] = z.CustomerName;
|
||||
row["Serial"] = z.Serial;
|
||||
if (z.ServiceDate != null)
|
||||
row["ServiceDate"] = ((DateTime)z.ServiceDate).ToLocalTime();
|
||||
row["ServiceDate"] = ((DateTime)z.ServiceDate).ToLocalTime();
|
||||
row["WorkorderStatusName"] = z.WorkorderStatusName;
|
||||
row["ProjectName"] = z.ProjectName;
|
||||
row["Color"] = z.Color;
|
||||
@@ -297,7 +298,7 @@ namespace AyaNovaQBI
|
||||
}
|
||||
|
||||
//An array list to hold the guid's of workorders being invoiced
|
||||
ArrayList al = new ArrayList();
|
||||
List<long> al = new List<long>();
|
||||
this.Refresh();
|
||||
Cursor.Current = Cursors.WaitCursor;
|
||||
ArrayList alErrors = new ArrayList();
|
||||
@@ -306,66 +307,37 @@ namespace AyaNovaQBI
|
||||
w.Ops = "Invoicing to QuickBooks...";
|
||||
|
||||
//work through selected items top to bottom
|
||||
foreach (UltraGridRow r in grid.Selected.Rows)
|
||||
foreach (DataGridViewRow r in grid.SelectedRows)
|
||||
{
|
||||
//clear the workorder list
|
||||
al.Clear();
|
||||
|
||||
//One lone workorder to be invoiced?
|
||||
if (r.Band.Index == 1)
|
||||
|
||||
if ((bool)r.Cells["Linked"].Value == true)
|
||||
{
|
||||
//it's a child so see if it's parent is selected and if so then ignore it
|
||||
//as it will be invoiced with the parent or more likely already has been
|
||||
if (r.ParentRow.Selected)
|
||||
continue;
|
||||
|
||||
//It's a stand alone single workorder selected to be invoiced on it's own
|
||||
//with no parent invoice row selected, so invoice it out now
|
||||
|
||||
// but check to see if it's all linked first:
|
||||
if ((bool)r.Cells["Linked"].Value == false)
|
||||
continue;
|
||||
|
||||
al.Add((Guid)r.Cells["WorkorderID"].Value);
|
||||
w.Step = "Invoicing single workorder ";
|
||||
util.Invoice(al, alErrors);
|
||||
continue;
|
||||
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
//A group of workorders to be invoiced?
|
||||
if (r.Band.Index == 0 && r.Selected)
|
||||
al.Add((long)r.Cells["id"].Value);
|
||||
//case 1604
|
||||
if (bOneWoPerInvoice)
|
||||
{
|
||||
foreach (UltraGridRow rchild in r.ChildBands[0].Rows)
|
||||
{
|
||||
if ((bool)rchild.Cells["Linked"].Value == true)
|
||||
{
|
||||
al.Add((Guid)rchild.Cells["WorkorderID"].Value);
|
||||
//case 1604
|
||||
if (bOneWoPerInvoice)
|
||||
{
|
||||
//then invoice it out now
|
||||
w.Step = "Invoicing single workorder ";
|
||||
Util.Invoice(al, alErrors);
|
||||
//and clear al workorders list
|
||||
al.Clear();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
if (al.Count > 0)
|
||||
{
|
||||
w.Step = "Invoicing " + al.Count.ToString() + ((al.Count > 1) ? " Workorders" : " Workorder");
|
||||
Util.Invoice(al, alErrors);
|
||||
}
|
||||
|
||||
//then invoice it out now
|
||||
w.Step = "Invoicing single workorder ";
|
||||
await util.Invoice(al, alErrors);
|
||||
//and clear al workorders list
|
||||
al.Clear();
|
||||
}
|
||||
}
|
||||
}//end of foreach loop
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}//end of foreach loop
|
||||
{
|
||||
w.Step = "Invoicing " + al.Count.ToString() + ((al.Count > 1) ? " Workorders" : " Workorder");
|
||||
await util.Invoice(al, alErrors);
|
||||
}
|
||||
w.Close();
|
||||
|
||||
//display errors if any
|
||||
@@ -388,7 +360,7 @@ namespace AyaNovaQBI
|
||||
}
|
||||
|
||||
//refresh display
|
||||
InitInvoices();
|
||||
await InitInvoices();
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user