using System; using System.Linq; using System.Windows.Media.Imaging; using Comal.Classes; using InABox.Core; using InABox.DynamicGrid; using InABox.WPF; namespace PRSDesktop { internal class RequisitionItemHoldingGrid : DynamicGrid { public RequisitionItemHoldingGrid() { Options.Clear(); HiddenColumns.Add(x => x.ID); HiddenColumns.Add(x => x.Style.ID); HiddenColumns.Add(x => x.Dimensions.UnitSize); ActionColumns.Add(new DynamicImageColumn(HoldingImage, HoldingClick) { AllowHeaderClick = false }); } private BitmapImage HoldingImage(CoreRow arg) { return PRSDesktop.Resources.rightarrow.AsBitmapImage(); } private bool HoldingClick(CoreRow arg) { var dlg = new MultiSelectDialog( new Filter(x => x.Product.ID).IsEqualTo(arg.Get(c => c.Product.ID)) .And(x => x.Style.ID).IsEqualTo(arg.Get(c => c.Style.ID)) .And(x => x.Dimensions.UnitSize).IsEqualTo(arg.Get(c => c.Dimensions.UnitSize)), new Columns(x => x.Location.ID, x => x.Location.Code), false ); if (dlg.ShowDialog()) { var holding = dlg.Items().FirstOrDefault(); UpdateRow(arg, x => x.Location.ID, holding.Location.ID, false); UpdateRow(arg, x => x.Location.Code, holding.Location.Code, false); return true; } return false; } protected override DynamicGridColumns LoadColumns() { var result = new DynamicGridColumns(); result.Add(x => x.Product.Code, 200, "Code", "", Alignment.MiddleLeft); result.Add(x => x.Product.Name, 0, "Description", "", Alignment.MiddleLeft); result.Add(x => x.Style.Description, 0, "Style", "", Alignment.MiddleLeft); result.Add(x => x.Quantity, 100, "Quantity", "", Alignment.MiddleCenter); result.Add(x => x.Location.Code, 0, "Location", "", Alignment.MiddleLeft); return result; } protected override RequisitionItem LoadItem(CoreRow row) { return row.ToObject(); } protected override void Reload(Filters criteria, Columns columns, ref SortOrder sort, Action action) { action?.Invoke(MasterData, null); } public override void SaveItem(RequisitionItem item) { } protected override void DeleteItems(params CoreRow[] rows) { //throw new NotImplementedException(); } } }