CustomerGrid.cs 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. using Comal.Classes;
  2. using InABox.Clients;
  3. using InABox.Core;
  4. using InABox.DynamicGrid;
  5. using System;
  6. using System.Linq;
  7. namespace PRSDesktop
  8. {
  9. internal class CustomerGrid : DynamicDataGrid<Customer>
  10. {
  11. public CustomerGrid()
  12. {
  13. ActionColumns.Add(new DynamicScheduleEditorColumn<Customer>());
  14. HiddenColumns.Add(x => x.ActiveSchedules);
  15. ;
  16. ActionColumns.Add(new DynamicMapColumn<Customer>(this, x => x.Delivery.Location));
  17. PostUtils.AddPostColumn(this);
  18. // HiddenColumns.Add(x => x.Delivery.Location.Timestamp);
  19. //HiddenColumns.Add(x => x.Delivery.Location.Latitude);
  20. //HiddenColumns.Add(x => x.Delivery.Location.Longitude);
  21. }
  22. public override Customer CreateItem()
  23. {
  24. var item = base.CreateItem();
  25. item.CustomerStatus.ID = Client.Query(
  26. new Filter<CustomerStatus>(x => x.Default).IsEqualTo(true),
  27. Columns.None<CustomerStatus>().Add(x => x.ID))
  28. .ToObjects<CustomerStatus>().FirstOrDefault()?.ID ?? Guid.Empty;
  29. return item;
  30. }
  31. protected override void DoReconfigure(DynamicGridOptions options)
  32. {
  33. base.DoReconfigure(options);
  34. options.SelectColumns = true;
  35. options.MultiSelect = true;
  36. options.FilterRows = true;
  37. options.ExportData = true;
  38. options.AddRows = true;
  39. options.EditRows = true;
  40. options.DeleteRows = true;
  41. }
  42. public Customer[] Customers { get; private set; }
  43. //private bool HasLocation(int row)
  44. //{
  45. // if (row.Equals(-1))
  46. // return true;
  47. // DateTime dt = Data.Rows[row].Get<Customer, DateTime>(x => x.Delivery.Location.Timestamp);
  48. // return !dt.IsEmpty();
  49. //}
  50. //private BitmapImage MapImage(int row)
  51. //{
  52. // return HasLocation(row) ? PRSDesktop.Resources.milestone.AsBitmapImage() : null;
  53. //}
  54. //private bool MapClick(DataRow row)
  55. //{
  56. // int index = Data.Rows.IndexOf(row);
  57. // if (HasLocation(index))
  58. // {
  59. // MapForm form = new MapForm(row.Get<Customer, double>(x => x.Delivery.Location.Latitude), row.Get<Customer, double>(x => x.Delivery.Location.Longitude));
  60. // form.ShowDialog();
  61. // }
  62. // return false;
  63. //}
  64. }
  65. }