| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677 |
- using Comal.Classes;
- using InABox.Clients;
- using InABox.Core;
- using InABox.DynamicGrid;
- using System;
- using System.Linq;
- namespace PRSDesktop
- {
- internal class CustomerGrid : DynamicDataGrid<Customer>
- {
- public CustomerGrid()
- {
- ActionColumns.Add(new DynamicScheduleEditorColumn<Customer>());
- HiddenColumns.Add(x => x.ActiveSchedules);
- ;
- ActionColumns.Add(new DynamicMapColumn<Customer>(this, x => x.Delivery.Location));
- PostUtils.AddPostColumn(this);
- // HiddenColumns.Add(x => x.Delivery.Location.Timestamp);
- //HiddenColumns.Add(x => x.Delivery.Location.Latitude);
- //HiddenColumns.Add(x => x.Delivery.Location.Longitude);
- }
- public override Customer CreateItem()
- {
- var item = base.CreateItem();
- item.CustomerStatus.ID = Client.Query(
- new Filter<CustomerStatus>(x => x.Default).IsEqualTo(true),
- Columns.None<CustomerStatus>().Add(x => x.ID))
- .ToObjects<CustomerStatus>().FirstOrDefault()?.ID ?? Guid.Empty;
- return item;
- }
- protected override void DoReconfigure(DynamicGridOptions options)
- {
- base.DoReconfigure(options);
- options.SelectColumns = true;
- options.MultiSelect = true;
- options.FilterRows = true;
- options.ExportData = true;
- options.AddRows = true;
- options.EditRows = true;
- options.DeleteRows = true;
- }
- public Customer[] Customers { get; private set; }
- //private bool HasLocation(int row)
- //{
- // if (row.Equals(-1))
- // return true;
- // DateTime dt = Data.Rows[row].Get<Customer, DateTime>(x => x.Delivery.Location.Timestamp);
- // return !dt.IsEmpty();
- //}
- //private BitmapImage MapImage(int row)
- //{
- // return HasLocation(row) ? PRSDesktop.Resources.milestone.AsBitmapImage() : null;
- //}
- //private bool MapClick(DataRow row)
- //{
- // int index = Data.Rows.IndexOf(row);
- // if (HasLocation(index))
- // {
- // MapForm form = new MapForm(row.Get<Customer, double>(x => x.Delivery.Location.Latitude), row.Get<Customer, double>(x => x.Delivery.Location.Longitude));
- // form.ShowDialog();
- // }
- // return false;
- //}
- }
- }
|