| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455 | 
							- using System;
 
- using System.Linq;
 
- using System.Windows;
 
- using System.Windows.Controls;
 
- using Comal.Classes;
 
- using InABox.Clients;
 
- using InABox.Core;
 
- using InABox.DynamicGrid;
 
- using InABox.WPF;
 
- namespace PRSDesktop
 
- {
 
-     internal class InvoiceLineGrid : DynamicDataGrid<InvoiceLine>
 
-     {
 
-         public InvoiceLineGrid()
 
-         {
 
-             Options.AddRange(DynamicGridOption.RecordCount, DynamicGridOption.AddRows, DynamicGridOption.DeleteRows, DynamicGridOption.EditRows,
 
-                 DynamicGridOption.SelectColumns, DynamicGridOption.MultiSelect);
 
-             AddButton("Calculate", PRSDesktop.Resources.costcentre.AsBitmapImage(), CalculateLines);
 
-         }
 
-         public Guid InvoiceID { get; set; }
 
-         private bool CalculateLines(Button sender, CoreRow[] rows)
 
-         {
 
-             var res = MessageBox.Show("Summarise Time and Materials?", "Confirm Action", MessageBoxButton.YesNoCancel, MessageBoxImage.Question,
 
-                 MessageBoxResult.Yes, MessageBoxOptions.None);
 
-             if (res == MessageBoxResult.Cancel)
 
-                 return false;
 
-             var invoice = new Client<Invoice>().Load(new Filter<Invoice>(x => x.ID).IsEqualTo(InvoiceID)).FirstOrDefault();
 
-             if (invoice != null)
 
-             {
 
-                 Utility.CalculateInvoice(invoice, res == MessageBoxResult.Yes);
 
-                 return true;
 
-             }
 
-             MessageBox.Show("Please Select or Create an Invoice First!");
 
-             return false;
 
-         }
 
-         protected override void Reload(Filters<InvoiceLine> criteria, Columns<InvoiceLine> columns, ref SortOrder<InvoiceLine> sort,
 
-             Action<CoreTable, Exception> action)
 
-         {
 
-             criteria.Add(new Filter<InvoiceLine>(x => x.InvoiceLink.ID).IsEqualTo(InvoiceID));
 
-             base.Reload(criteria, columns, ref sort, action);
 
-         }
 
-         protected override InvoiceLine CreateItem()
 
-         {
 
-             var result = base.CreateItem();
 
-             result.InvoiceLink.ID = InvoiceID;
 
-             return result;
 
-         }
 
-     }
 
- }
 
 
  |