123456789101112131415161718192021222324252627282930313233343536373839 |
- using System;
- using System.Linq;
- using System.Windows.Controls;
- using Comal.Classes;
- using InABox.Clients;
- using InABox.Core;
- using InABox.DynamicGrid;
- namespace PRSDesktop;
- public class JobFormDefinitionGrid : DynamicManyToManyGrid<JobFormDefinition, Job>
- {
- public JobFormDefinitionGrid()
- {
- AddButton("Add All", null, AddAllClick);
- HiddenColumns.Add(x => x.Form.ID);
- }
- private bool AddAllClick(Button arg1, CoreRow[] arg2)
- {
- var existingforms = ExtractValues(x => x.Form.ID, Selection.All).ToArray();
- var newforms = InABox.Clients.Client.Query(
- new Filter<DigitalForm>(x => x.Active).IsEqualTo(true)
- .And(x => x.AppliesTo).IsEqualTo("Job")
- .And(x => x.ID).NotInList(existingforms)
- );
- foreach (var row in newforms.Rows)
- {
- var newitem = CreateItem();
- newitem.Job.ID = Item.ID;
- newitem.Form.ID = row.Get<DigitalForm, Guid>(x => x.ID);
- newitem.Form.Synchronise(row.ToObject<DigitalForm>());
- SaveItem(newitem);
- }
- return true;
- }
- }
|