| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374 |
- using System;
- using System.Linq;
- using System.Threading.Tasks;
- using System.Windows;
- using System.Windows.Controls;
- using Comal.Classes;
- using InABox.Core;
- using InABox.DynamicGrid;
- using InABox.WPF;
- namespace PRSDesktop
- {
- public class KitGrid : DynamicDataGrid<Kit>
- {
- private bool bShowAll;
- private Task<Kit[]> result;
- public KitGrid()
- {
- Options.AddRange(DynamicGridOption.RecordCount, DynamicGridOption.FilterRows, DynamicGridOption.SelectColumns,
- DynamicGridOption.MultiSelect);
- AddButton("Clone", PRSDesktop.Resources.clone.AsBitmapImage(), CloneKit);
- AddButton("Show All", null, ToggleVisible);
- AddButton("Cost Sheets", PRSDesktop.Resources.kit.AsBitmapImage(), ShowCostSheets);
- HiddenColumns.Add(x => x.LastUpdate);
- HiddenColumns.Add(x => x.Code);
- }
- private bool CloneKit(Button sender, CoreRow[] rows)
- {
- if (rows == null || rows.Length != 1)
- {
- MessageBox.Show("Please select a single kit to duplicate!");
- return false;
- }
- return Duplicate(rows.First(), x => x.Code, new[] { typeof(KitProduct) });
- }
- private bool ShowCostSheets(Button sender, CoreRow[] rows)
- {
- if (rows == null || rows.Length != 1)
- {
- MessageBox.Show("Please select a single row!");
- return false;
- }
- var kitid = rows.First().Get<Kit, Guid>(x => x.ID);
- var msd = new MultiSelectDialog<CostSheetKit>(
- new Filter<CostSheetKit>(x => x.Kit.ID).IsEqualTo(kitid),
- new Columns<CostSheetKit>()
- );
- msd.ShowDialog();
- return false;
- }
- private bool ToggleVisible(Button arg1, CoreRow[] arg2)
- {
- bShowAll = !bShowAll;
- arg1.Content = bShowAll ? "Active Only" : "Show All";
- return true;
- }
- protected override void Reload(Filters<Kit> criteria, Columns<Kit> columns, ref SortOrder<Kit> sort, Action<CoreTable, Exception> action)
- {
- if (!bShowAll)
- criteria.Add(new Filter<Kit>(x => x.Active).IsEqualTo(true));
- base.Reload(criteria, columns, ref sort, action);
- }
- }
- }
|