This commit is contained in:
@@ -150,35 +150,11 @@ namespace AyaNovaQBI
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#region WORKORDERS / INVOICING
|
#region WORKORDERS / INVOICING
|
||||||
|
|
||||||
|
private async void multipleWorkordersPerInvoiceToolStripMenuItem_Click(object sender, EventArgs e) => await InvoiceSelected(false);
|
||||||
|
|
||||||
|
private async void oneWorkOrderPerInvoiceToolStripMenuItem_Click(object sender, EventArgs e) => await InvoiceSelected(true);
|
||||||
private void multipleWorkordersPerInvoiceToolStripMenuItem_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
if (grid.SelectedRows.Count < 1)
|
|
||||||
{
|
|
||||||
MessageBox.Show("There are no rows selected, select one or more rows to invoice");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
MessageBox.Show($"STUB: MULTIPLEwoperinvoice {grid.SelectedRows.Count} rows selected");
|
|
||||||
}
|
|
||||||
|
|
||||||
private void oneWorkOrderPerInvoiceToolStripMenuItem_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
if (grid.SelectedRows.Count < 1)
|
|
||||||
{
|
|
||||||
MessageBox.Show("There are no rows selected, select one or more rows to invoice");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
MessageBox.Show($"STUB: onwoperinvoice {grid.SelectedRows.Count} rows selected");
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private async void fixProblemsToolStripMenuItem_Click(object sender, EventArgs e)
|
private async void fixProblemsToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
@@ -309,6 +285,113 @@ namespace AyaNovaQBI
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Invoice selected items
|
||||||
|
/// </summary>
|
||||||
|
private async Task InvoiceSelected(bool bOneWoPerInvoice)
|
||||||
|
{
|
||||||
|
if (grid.SelectedRows.Count < 1)
|
||||||
|
{
|
||||||
|
MessageBox.Show("There are no Work order rows selected\r\nSelect one or more rows to invoice");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
//An array list to hold the guid's of workorders being invoiced
|
||||||
|
ArrayList al = new ArrayList();
|
||||||
|
this.Refresh();
|
||||||
|
Cursor.Current = Cursors.WaitCursor;
|
||||||
|
ArrayList alErrors = new ArrayList();
|
||||||
|
Waiting w = new Waiting();
|
||||||
|
w.Show();
|
||||||
|
w.Ops = "Invoicing to QuickBooks...";
|
||||||
|
|
||||||
|
//work through selected items top to bottom
|
||||||
|
foreach (UltraGridRow r in grid.Selected.Rows)
|
||||||
|
{
|
||||||
|
//clear the workorder list
|
||||||
|
al.Clear();
|
||||||
|
|
||||||
|
//One lone workorder to be invoiced?
|
||||||
|
if (r.Band.Index == 1)
|
||||||
|
{
|
||||||
|
//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)
|
||||||
|
{
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}//end of foreach loop
|
||||||
|
|
||||||
|
w.Close();
|
||||||
|
|
||||||
|
//display errors if any
|
||||||
|
if (alErrors.Count != 0)
|
||||||
|
{
|
||||||
|
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
sb.Append("Invoicing completed with some errors:\r\n\r\n");
|
||||||
|
foreach (object o in alErrors)
|
||||||
|
{
|
||||||
|
sb.Append((string)o);
|
||||||
|
sb.Append("\r\n************\r\n");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
CopyableMessageBox cb = new CopyableMessageBox(sb.ToString());
|
||||||
|
cb.ShowDialog();
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
//refresh display
|
||||||
|
InitInvoices();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#endregion workorders / invoicing
|
#endregion workorders / invoicing
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user