1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- using System;
- using System.Windows;
- using Comal.Classes;
- using InABox.Core;
- using InABox.DynamicGrid;
- namespace PRSDesktop
- {
- internal class CustomerInvoiceDeliveryItem : DynamicOneToManyGrid<Invoice, DeliveryItem>
- {
- protected override void DoAdd()
- {
- var invoice = Item;
- if (!invoice.JobLink.IsValid())
- {
- MessageBox.Show("Please select a job first!");
- return;
- }
- var dialog = new MultiSelectDialog<DeliveryItem>(
- new Filter<DeliveryItem>(x => x.InvoiceLink).NotLinkValid().And(x => x.JobLink.ID).IsEqualTo(invoice.JobLink.ID)
- , new Columns<DeliveryItem>(x => x.Title, x => x.Description) //new System.Linq.Expressions.Expression<Func<DeliveryItem, object>>[] { x => x.Title, x => x.Description }
- );
- if (dialog.ShowDialog())
- {
- var items = dialog.Items();
- foreach (var item in items)
- {
- item.InvoiceLink.ID = invoice.ID;
- SaveItem(item);
- }
- Refresh(false, true);
- }
- }
- protected override void DeleteItems(params CoreRow[] rows)
- {
- foreach (var row in rows)
- {
- var item = row.ToObject<DeliveryItem>();
- item.InvoiceLink.ID = Guid.Empty;
- SaveItem(item);
- }
- }
- }
- }
|