|
@@ -16,318 +16,316 @@ using InABox.DynamicGrid;
|
|
|
using InABox.WPF;
|
|
|
using InABox.Wpf;
|
|
|
|
|
|
-namespace PRSDesktop
|
|
|
+namespace PRSDesktop;
|
|
|
+
|
|
|
+public class EquipmentPanelSettings : BaseObject, IGlobalConfigurationSettings
|
|
|
+{
|
|
|
+ public bool CustomerFilterEnabled { get; set; }
|
|
|
+
|
|
|
+ public EquipmentPanelSettings()
|
|
|
+ {
|
|
|
+ CustomerFilterEnabled = false;
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+/// <summary>
|
|
|
+/// Interaction logic for EquipmentPanel.xaml
|
|
|
+/// </summary>
|
|
|
+public partial class EquipmentPanel : UserControl, IPanel<Equipment>
|
|
|
{
|
|
|
+
|
|
|
+ private EquipmentPanelSettings _settings = null;
|
|
|
|
|
|
+ private String _searchfilter = "";
|
|
|
|
|
|
- public class EquipmentPanelSettings : BaseObject, IGlobalConfigurationSettings
|
|
|
- {
|
|
|
- public bool CustomerFilterEnabled { get; set; }
|
|
|
+ public ObservableCollection<Tuple<string, Guid, BitmapImage>> GroupList { get; private set; }
|
|
|
|
|
|
- public EquipmentPanelSettings()
|
|
|
- {
|
|
|
- CustomerFilterEnabled = false;
|
|
|
- }
|
|
|
+ public bool IsReady { get; set; }
|
|
|
+
|
|
|
+ private String _customercode = "";
|
|
|
+ private List<Tuple<Guid, String, String>> _customers;
|
|
|
+
|
|
|
+ public EquipmentPanel()
|
|
|
+ {
|
|
|
+ GroupList = new ObservableCollection<Tuple<string, Guid, BitmapImage>>();
|
|
|
+
|
|
|
+ InitializeComponent();
|
|
|
}
|
|
|
|
|
|
- /// <summary>
|
|
|
- /// Interaction logic for EquipmentPanel.xaml
|
|
|
- /// </summary>
|
|
|
- public partial class EquipmentPanel : UserControl, IPanel<Equipment>
|
|
|
+ public Type DataType()
|
|
|
{
|
|
|
+ return typeof(Equipment);
|
|
|
+ }
|
|
|
|
|
|
- private EquipmentPanelSettings _settings = null;
|
|
|
-
|
|
|
- private String _searchfilter = "";
|
|
|
-
|
|
|
- public ObservableCollection<Tuple<string, Guid, BitmapImage>> GroupList { get; private set; }
|
|
|
|
|
|
- public bool IsReady { get; set; }
|
|
|
+ public event DataModelUpdateEvent? OnUpdateDataModel;
|
|
|
|
|
|
- private String _customercode = "";
|
|
|
- private List<Tuple<Guid, String, String>> _customers;
|
|
|
+ public Dictionary<string, object[]> Selected()
|
|
|
+ {
|
|
|
+ return new Dictionary<string, object[]> { { typeof(Equipment).EntityName(), _Equipment.SelectedRows } };
|
|
|
+ }
|
|
|
|
|
|
- public EquipmentPanel()
|
|
|
- {
|
|
|
- GroupList = new ObservableCollection<Tuple<string, Guid, BitmapImage>>();
|
|
|
+ public void Setup()
|
|
|
+ {
|
|
|
+
|
|
|
+ _Equipment.CustomerID = Guid.Empty;
|
|
|
+ _Equipment.GroupID = CoreUtils.FullGuid;
|
|
|
+
|
|
|
+ _settings = new GlobalConfiguration<EquipmentPanelSettings>().Load();
|
|
|
+ ReconfigurePanel();
|
|
|
+
|
|
|
+ _Equipment.Refresh(true, false);
|
|
|
+
|
|
|
+ GroupList.Add(new Tuple<string, Guid, BitmapImage>("All Items", CoreUtils.FullGuid, PRSDesktop.Resources.edit.AsBitmapImage()));
|
|
|
+ var groups = new Client<EquipmentGroup>().Query(
|
|
|
+ null,
|
|
|
+ Columns.None<EquipmentGroup>().Add(x=>x.ID)
|
|
|
+ .Add(x=>x.Description)
|
|
|
+ .Add(x=>x.Thumbnail.ID),
|
|
|
+ new SortOrder<EquipmentGroup>(x => x.Code)
|
|
|
+ );
|
|
|
|
|
|
- InitializeComponent();
|
|
|
- }
|
|
|
+ var ids = groups.ExtractValues<EquipmentGroup, Guid>(c => c.Thumbnail.ID).Distinct().Where(x => x != Guid.Empty).ToArray();
|
|
|
+ var Images = ids.Any()
|
|
|
+ ? new Client<Document>().Load(new Filter<Document>(x=>x.ID).InList(ids))
|
|
|
+ : new Document[] { };
|
|
|
|
|
|
- public Type DataType()
|
|
|
- {
|
|
|
- return typeof(Equipment);
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- public event DataModelUpdateEvent? OnUpdateDataModel;
|
|
|
-
|
|
|
- public Dictionary<string, object[]> Selected()
|
|
|
+ foreach (var row in groups.Rows)
|
|
|
{
|
|
|
- return new Dictionary<string, object[]> { { typeof(Equipment).EntityName(), _Equipment.SelectedRows } };
|
|
|
- }
|
|
|
-
|
|
|
- public void Setup()
|
|
|
- {
|
|
|
-
|
|
|
- _Equipment.CustomerID = Guid.Empty;
|
|
|
- _Equipment.GroupID = CoreUtils.FullGuid;
|
|
|
-
|
|
|
- _settings = new GlobalConfiguration<EquipmentPanelSettings>().Load();
|
|
|
- ReconfigurePanel();
|
|
|
-
|
|
|
- _Equipment.Refresh(true, false);
|
|
|
-
|
|
|
- GroupList.Add(new Tuple<string, Guid, BitmapImage>("All Items", CoreUtils.FullGuid, PRSDesktop.Resources.edit.AsBitmapImage()));
|
|
|
- var groups = new Client<EquipmentGroup>().Query(
|
|
|
- null,
|
|
|
- Columns.None<EquipmentGroup>().Add(x=>x.ID)
|
|
|
- .Add(x=>x.Description)
|
|
|
- .Add(x=>x.Thumbnail.ID),
|
|
|
- new SortOrder<EquipmentGroup>(x => x.Code)
|
|
|
+ var image = Images.FirstOrDefault(x => x.ID.Equals(row.Get<EquipmentGroup,Guid>(c=>c.Thumbnail.ID)));
|
|
|
+ var img = ImageUtils.LoadImage(image?.Data) ?? PRSDesktop.Resources.specifications.AsBitmapImage();
|
|
|
+
|
|
|
+ GroupList.Add(
|
|
|
+ new Tuple<string, Guid, BitmapImage>(
|
|
|
+ row.Get<EquipmentGroup,String>(c=>c.Description),
|
|
|
+ row.Get<EquipmentGroup,Guid>(c=>c.ID),
|
|
|
+ img
|
|
|
+ )
|
|
|
);
|
|
|
-
|
|
|
- var ids = groups.ExtractValues<EquipmentGroup, Guid>(c => c.Thumbnail.ID).Distinct().Where(x => x != Guid.Empty).ToArray();
|
|
|
- var Images = ids.Any()
|
|
|
- ? new Client<Document>().Load(new Filter<Document>(x=>x.ID).InList(ids))
|
|
|
- : new Document[] { };
|
|
|
-
|
|
|
- foreach (var row in groups.Rows)
|
|
|
- {
|
|
|
- var image = Images.FirstOrDefault(x => x.ID.Equals(row.Get<EquipmentGroup,Guid>(c=>c.Thumbnail.ID)));
|
|
|
- var img = ImageUtils.LoadImage(image?.Data) ?? PRSDesktop.Resources.specifications.AsBitmapImage();
|
|
|
-
|
|
|
- GroupList.Add(
|
|
|
- new Tuple<string, Guid, BitmapImage>(
|
|
|
- row.Get<EquipmentGroup,String>(c=>c.Description),
|
|
|
- row.Get<EquipmentGroup,Guid>(c=>c.ID),
|
|
|
- img
|
|
|
- )
|
|
|
- );
|
|
|
- }
|
|
|
-
|
|
|
- Groups.Visibility = groups.Rows.Any() ? Visibility.Visible : Visibility.Collapsed;
|
|
|
- Groups.ItemsSource = GroupList;
|
|
|
- Groups.SelectedIndex = 0;
|
|
|
}
|
|
|
+
|
|
|
+ Groups.Visibility = groups.Rows.Any() ? Visibility.Visible : Visibility.Collapsed;
|
|
|
+ Groups.ItemsSource = GroupList;
|
|
|
+ Groups.SelectedIndex = 0;
|
|
|
+ }
|
|
|
|
|
|
- public void Shutdown(CancelEventArgs? cancel)
|
|
|
- {
|
|
|
- }
|
|
|
-
|
|
|
- public void CreateToolbarButtons(IPanelHost host)
|
|
|
- {
|
|
|
- EquipmentSetupActions.TrackerTypes(host);
|
|
|
- EquipmentSetupActions.WebStickers(host);
|
|
|
- EquipmentSetupActions.DigitalKeys(host);
|
|
|
- EquipmentSetupActions.EquipmentGroups(host);
|
|
|
-
|
|
|
- host.CreateSetupSeparator();
|
|
|
+ public void Shutdown(CancelEventArgs? cancel)
|
|
|
+ {
|
|
|
+ }
|
|
|
|
|
|
- host.CreateSetupAction(new PanelAction() { Caption = "Equipment Settings", Image = PRSDesktop.Resources.specifications, OnExecute = EquipmentSettingsClick });
|
|
|
- host.CreateSetupAction(new PanelAction() { Caption = "EditGeofences", Image = PRSDesktop.Resources.map, OnExecute = EditGeofencesClick});
|
|
|
- }
|
|
|
+ public void CreateToolbarButtons(IPanelHost host)
|
|
|
+ {
|
|
|
+ EquipmentSetupActions.TrackerTypes(host);
|
|
|
+ EquipmentSetupActions.WebStickers(host);
|
|
|
+ EquipmentSetupActions.DigitalKeys(host);
|
|
|
+ EquipmentSetupActions.EquipmentGroups(host);
|
|
|
+ EquipmentSetupActions.FuelTypes(host);
|
|
|
|
|
|
- private void EditGeofencesClick(PanelAction obj)
|
|
|
- {
|
|
|
- new MasterList(typeof(GeoFence)).ShowDialog();
|
|
|
- }
|
|
|
+ host.CreateSetupSeparator();
|
|
|
|
|
|
- private void EquipmentSettingsClick(PanelAction obj)
|
|
|
- {
|
|
|
- var pages = new DynamicEditorPages();
|
|
|
- var buttons = new DynamicEditorButtons();
|
|
|
- buttons.Add(
|
|
|
- "",
|
|
|
- PRSDesktop.Resources.help.AsBitmapImage(),
|
|
|
- _settings,
|
|
|
- (f, i) =>
|
|
|
- {
|
|
|
- Process.Start(new ProcessStartInfo("https://prsdigital.com.au/wiki/index.php/" + typeof(Equipment).Name.SplitCamelCase().Replace(" ", "_"))
|
|
|
- { UseShellExecute = true });
|
|
|
- }
|
|
|
- );
|
|
|
- var propertyEditor = new DynamicEditorForm(typeof(EquipmentPanelSettings), pages, buttons);
|
|
|
+ host.CreateSetupAction("Equipment Settings", PRSDesktop.Resources.specifications, EquipmentSettingsClick);
|
|
|
+ host.CreateSetupAction("Edit Geofences", PRSDesktop.Resources.map, EditGeofencesClick);
|
|
|
+ }
|
|
|
|
|
|
- propertyEditor.Items = new BaseObject[] { _settings };
|
|
|
+ private void EditGeofencesClick(PanelAction obj)
|
|
|
+ {
|
|
|
+ new MasterList(typeof(GeoFence)).ShowDialog();
|
|
|
+ }
|
|
|
|
|
|
- if (propertyEditor.ShowDialog() == true)
|
|
|
+ private void EquipmentSettingsClick(PanelAction obj)
|
|
|
+ {
|
|
|
+ var pages = new DynamicEditorPages();
|
|
|
+ var buttons = new DynamicEditorButtons();
|
|
|
+ buttons.Add(
|
|
|
+ "",
|
|
|
+ PRSDesktop.Resources.help.AsBitmapImage(),
|
|
|
+ _settings,
|
|
|
+ (f, i) =>
|
|
|
{
|
|
|
- new GlobalConfiguration<EquipmentPanelSettings>().Save(_settings);
|
|
|
- ReconfigurePanel();
|
|
|
+ Process.Start(new ProcessStartInfo("https://prsdigital.com.au/wiki/index.php/" + typeof(Equipment).Name.SplitCamelCase().Replace(" ", "_"))
|
|
|
+ { UseShellExecute = true });
|
|
|
}
|
|
|
+ );
|
|
|
+ var propertyEditor = new DynamicEditorForm(typeof(EquipmentPanelSettings), pages, buttons);
|
|
|
|
|
|
- }
|
|
|
+ propertyEditor.Items = new BaseObject[] { _settings };
|
|
|
|
|
|
- private void ReconfigurePanel()
|
|
|
+ if (propertyEditor.ShowDialog() == true)
|
|
|
{
|
|
|
- CustomerLabel.Visibility = _settings.CustomerFilterEnabled ? Visibility.Visible : Visibility.Collapsed;
|
|
|
- Customer.Visibility = _settings.CustomerFilterEnabled ? Visibility.Visible : Visibility.Collapsed;
|
|
|
- CustomerSearch.Visibility = _settings.CustomerFilterEnabled ? Visibility.Visible : Visibility.Collapsed;
|
|
|
- CustomerName.Visibility = _settings.CustomerFilterEnabled ? Visibility.Visible : Visibility.Collapsed;
|
|
|
-
|
|
|
- if (!_settings.CustomerFilterEnabled)
|
|
|
- {
|
|
|
- _Equipment.CustomerID = CoreUtils.FullGuid;
|
|
|
- _customercode = "";
|
|
|
- Customer.Text = "";
|
|
|
- CustomerName.Text = "";
|
|
|
- }
|
|
|
- else if (_Equipment.CustomerID == CoreUtils.FullGuid)
|
|
|
- _Equipment.CustomerID = Guid.Empty;
|
|
|
-
|
|
|
- if (IsReady)
|
|
|
- _Equipment.Refresh(false,true);
|
|
|
+ new GlobalConfiguration<EquipmentPanelSettings>().Save(_settings);
|
|
|
+ ReconfigurePanel();
|
|
|
}
|
|
|
|
|
|
+ }
|
|
|
|
|
|
- public void Refresh()
|
|
|
+ private void ReconfigurePanel()
|
|
|
+ {
|
|
|
+ CustomerLabel.Visibility = _settings.CustomerFilterEnabled ? Visibility.Visible : Visibility.Collapsed;
|
|
|
+ Customer.Visibility = _settings.CustomerFilterEnabled ? Visibility.Visible : Visibility.Collapsed;
|
|
|
+ CustomerSearch.Visibility = _settings.CustomerFilterEnabled ? Visibility.Visible : Visibility.Collapsed;
|
|
|
+ CustomerName.Visibility = _settings.CustomerFilterEnabled ? Visibility.Visible : Visibility.Collapsed;
|
|
|
+
|
|
|
+ if (!_settings.CustomerFilterEnabled)
|
|
|
{
|
|
|
- _Equipment.Refresh(false, true);
|
|
|
+ _Equipment.CustomerID = CoreUtils.FullGuid;
|
|
|
+ _customercode = "";
|
|
|
+ Customer.Text = "";
|
|
|
+ CustomerName.Text = "";
|
|
|
}
|
|
|
+ else if (_Equipment.CustomerID == CoreUtils.FullGuid)
|
|
|
+ _Equipment.CustomerID = Guid.Empty;
|
|
|
+
|
|
|
+ if (IsReady)
|
|
|
+ _Equipment.Refresh(false,true);
|
|
|
+ }
|
|
|
|
|
|
- public string SectionName => "Equipment";
|
|
|
|
|
|
- public DataModel DataModel(Selection selection)
|
|
|
- {
|
|
|
- var ids = _Equipment?.ExtractValues(x => x.ID, selection)?.ToArray() ?? new Guid[] { };
|
|
|
- return new BaseDataModel<Equipment>(new Filter<Equipment>(x => x.ID).InList(ids));
|
|
|
- }
|
|
|
+ public void Refresh()
|
|
|
+ {
|
|
|
+ _Equipment.Refresh(false, true);
|
|
|
+ }
|
|
|
|
|
|
- public void Heartbeat(TimeSpan time)
|
|
|
- {
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- private bool _Equipment_OnFilterRecord(CoreRow row)
|
|
|
+ public string SectionName => "Equipment";
|
|
|
+
|
|
|
+ public DataModel DataModel(Selection selection)
|
|
|
+ {
|
|
|
+ var ids = _Equipment?.ExtractValues(x => x.ID, selection)?.ToArray() ?? new Guid[] { };
|
|
|
+ return new BaseDataModel<Equipment>(new Filter<Equipment>(x => x.ID).InList(ids));
|
|
|
+ }
|
|
|
+
|
|
|
+ public void Heartbeat(TimeSpan time)
|
|
|
+ {
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ private bool _Equipment_OnFilterRecord(CoreRow row)
|
|
|
+ {
|
|
|
+ if (!string.IsNullOrWhiteSpace(_searchfilter))
|
|
|
{
|
|
|
- if (!string.IsNullOrWhiteSpace(_searchfilter))
|
|
|
+ for (int i=0; i<row.Table.Columns.Count; i++)
|
|
|
{
|
|
|
- for (int i=0; i<row.Table.Columns.Count; i++)
|
|
|
+ if ((row.Table.Columns[i].DataType == typeof(String)))
|
|
|
{
|
|
|
- if ((row.Table.Columns[i].DataType == typeof(String)))
|
|
|
- {
|
|
|
- var value = row.Values[i] as string;
|
|
|
- if (!string.IsNullOrEmpty(value) && value.ToUpper().Contains(_searchfilter.ToUpper()))
|
|
|
- return true;
|
|
|
- }
|
|
|
+ var value = row.Values[i] as string;
|
|
|
+ if (!string.IsNullOrEmpty(value) && value.ToUpper().Contains(_searchfilter.ToUpper()))
|
|
|
+ return true;
|
|
|
}
|
|
|
-
|
|
|
- return false;
|
|
|
}
|
|
|
-
|
|
|
- return true;
|
|
|
|
|
|
+ return false;
|
|
|
}
|
|
|
+
|
|
|
+ return true;
|
|
|
|
|
|
- private void Groups_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
|
|
- {
|
|
|
- var sCur = _Equipment.GroupID;
|
|
|
- if (e.AddedItems.Count == 0 || Groups.SelectedIndex == 0)
|
|
|
- {
|
|
|
- _Equipment.GroupID = CoreUtils.FullGuid;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- var selected = (Tuple<string, Guid, BitmapImage>)e.AddedItems[0];
|
|
|
- _Equipment.GroupID = selected.Item2;
|
|
|
- }
|
|
|
+ }
|
|
|
|
|
|
- if (sCur != _Equipment.GroupID)
|
|
|
- _Equipment.Refresh(false, true);
|
|
|
+ private void Groups_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
|
|
+ {
|
|
|
+ var sCur = _Equipment.GroupID;
|
|
|
+ if (e.AddedItems.Count == 0 || Groups.SelectedIndex == 0)
|
|
|
+ {
|
|
|
+ _Equipment.GroupID = CoreUtils.FullGuid;
|
|
|
}
|
|
|
-
|
|
|
- private void Search_OnTextChanged(object sender, TextChangedEventArgs e)
|
|
|
+ else
|
|
|
{
|
|
|
- if (string.IsNullOrEmpty(Search.Text) && !string.Equals(Search.Text, _searchfilter))
|
|
|
- {
|
|
|
- _searchfilter = "";
|
|
|
- _Equipment.Refresh(false, false);
|
|
|
- }
|
|
|
+ var selected = (Tuple<string, Guid, BitmapImage>)e.AddedItems[0];
|
|
|
+ _Equipment.GroupID = selected.Item2;
|
|
|
}
|
|
|
|
|
|
- private void Search_OnKeyUp(object sender, KeyEventArgs e)
|
|
|
+ if (sCur != _Equipment.GroupID)
|
|
|
+ _Equipment.Refresh(false, true);
|
|
|
+ }
|
|
|
+
|
|
|
+ private void Search_OnTextChanged(object sender, TextChangedEventArgs e)
|
|
|
+ {
|
|
|
+ if (string.IsNullOrEmpty(Search.Text) && !string.Equals(Search.Text, _searchfilter))
|
|
|
{
|
|
|
- if (new Key[] { Key.Enter, Key.Return }.Contains(e.Key) && !String.Equals(Search.Text, _searchfilter))
|
|
|
- {
|
|
|
- _searchfilter = Search.Text;
|
|
|
- _Equipment.Refresh(false, false);
|
|
|
- }
|
|
|
+ _searchfilter = "";
|
|
|
+ _Equipment.Refresh(false, false);
|
|
|
}
|
|
|
+ }
|
|
|
|
|
|
- private void CheckCustomerCache()
|
|
|
+ private void Search_OnKeyUp(object sender, KeyEventArgs e)
|
|
|
+ {
|
|
|
+ if (new Key[] { Key.Enter, Key.Return }.Contains(e.Key) && !String.Equals(Search.Text, _searchfilter))
|
|
|
{
|
|
|
- if (_customers == null)
|
|
|
- {
|
|
|
- _customers = new Client<Customer>().Query(
|
|
|
- null,
|
|
|
- Columns.None<Customer>().Add(x => x.ID).Add(x => x.Code).Add(x => x.Name),
|
|
|
- new SortOrder<Customer>(x => x.Name)
|
|
|
- ).ToTuples<Customer,Guid,String,String>(x =>x.ID,x=>x.Code,x=>x.Name).ToList();
|
|
|
- }
|
|
|
+ _searchfilter = Search.Text;
|
|
|
+ _Equipment.Refresh(false, false);
|
|
|
}
|
|
|
-
|
|
|
- private void DoSearchCustomers()
|
|
|
+ }
|
|
|
+
|
|
|
+ private void CheckCustomerCache()
|
|
|
+ {
|
|
|
+ if (_customers == null)
|
|
|
{
|
|
|
- var dlg = new MultiSelectDialog<Customer>(
|
|
|
+ _customers = new Client<Customer>().Query(
|
|
|
null,
|
|
|
- Columns.None<Customer>().Add(x => x.ID).Add(x => x.Code).Add(x => x.Name), false);
|
|
|
- if (dlg.ShowDialog("Code",Customer.Text))
|
|
|
- {
|
|
|
- var customer = dlg.Items().First();
|
|
|
- _customercode = customer.Code;
|
|
|
- Customer.Text = customer.Code;
|
|
|
- CustomerName.Text = customer.Name;
|
|
|
- _Equipment.CustomerID = customer.ID;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- _customercode = "";
|
|
|
- Customer.Text = "";
|
|
|
- CustomerName.Text = "";
|
|
|
- _Equipment.CustomerID = Guid.Empty;
|
|
|
- }
|
|
|
-
|
|
|
- _Equipment.Refresh(false, true);
|
|
|
+ Columns.None<Customer>().Add(x => x.ID).Add(x => x.Code).Add(x => x.Name),
|
|
|
+ new SortOrder<Customer>(x => x.Name)
|
|
|
+ ).ToTuples<Customer,Guid,String,String>(x =>x.ID,x=>x.Code,x=>x.Name).ToList();
|
|
|
}
|
|
|
-
|
|
|
- private void CustomerSearch_OnClick(object sender, RoutedEventArgs e)
|
|
|
+ }
|
|
|
+
|
|
|
+ private void DoSearchCustomers()
|
|
|
+ {
|
|
|
+ var dlg = new MultiSelectDialog<Customer>(
|
|
|
+ null,
|
|
|
+ Columns.None<Customer>().Add(x => x.ID).Add(x => x.Code).Add(x => x.Name), false);
|
|
|
+ if (dlg.ShowDialog("Code",Customer.Text))
|
|
|
{
|
|
|
- DoSearchCustomers();
|
|
|
+ var customer = dlg.Items().First();
|
|
|
+ _customercode = customer.Code;
|
|
|
+ Customer.Text = customer.Code;
|
|
|
+ CustomerName.Text = customer.Name;
|
|
|
+ _Equipment.CustomerID = customer.ID;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ _customercode = "";
|
|
|
+ Customer.Text = "";
|
|
|
+ CustomerName.Text = "";
|
|
|
+ _Equipment.CustomerID = Guid.Empty;
|
|
|
}
|
|
|
|
|
|
-
|
|
|
- private void Customer_OnKeyUp(object sender, KeyEventArgs e)
|
|
|
+ _Equipment.Refresh(false, true);
|
|
|
+ }
|
|
|
+
|
|
|
+ private void CustomerSearch_OnClick(object sender, RoutedEventArgs e)
|
|
|
+ {
|
|
|
+ DoSearchCustomers();
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ private void Customer_OnKeyUp(object sender, KeyEventArgs e)
|
|
|
+ {
|
|
|
+ if (new Key[] { Key.Enter, Key.Return }.Contains(e.Key))
|
|
|
{
|
|
|
- if (new Key[] { Key.Enter, Key.Return }.Contains(e.Key))
|
|
|
- {
|
|
|
|
|
|
- if (!String.Equals(Customer.Text, _customercode))
|
|
|
+ if (!String.Equals(Customer.Text, _customercode))
|
|
|
+ {
|
|
|
+ CheckCustomerCache();
|
|
|
+ var lookup = _customers.FirstOrDefault(x => String.Equals(x.Item2, Customer.Text));
|
|
|
+ if (lookup != null)
|
|
|
{
|
|
|
- CheckCustomerCache();
|
|
|
- var lookup = _customers.FirstOrDefault(x => String.Equals(x.Item2, Customer.Text));
|
|
|
- if (lookup != null)
|
|
|
- {
|
|
|
- _customercode = lookup.Item2;
|
|
|
- CustomerName.Text = lookup.Item3;
|
|
|
- _Equipment.CustomerID = lookup.Item1;
|
|
|
- _Equipment.Refresh(false, true);
|
|
|
- }
|
|
|
- else
|
|
|
- DoSearchCustomers();
|
|
|
+ _customercode = lookup.Item2;
|
|
|
+ CustomerName.Text = lookup.Item3;
|
|
|
+ _Equipment.CustomerID = lookup.Item1;
|
|
|
+ _Equipment.Refresh(false, true);
|
|
|
}
|
|
|
+ else
|
|
|
+ DoSearchCustomers();
|
|
|
}
|
|
|
}
|
|
|
+ }
|
|
|
|
|
|
- private void Customer_OnTextChanged(object sender, TextChangedEventArgs e)
|
|
|
+ private void Customer_OnTextChanged(object sender, TextChangedEventArgs e)
|
|
|
+ {
|
|
|
+ if (String.IsNullOrEmpty(Customer.Text) && !String.Equals(Customer.Text, _customercode))
|
|
|
{
|
|
|
- if (String.IsNullOrEmpty(Customer.Text) && !String.Equals(Customer.Text, _customercode))
|
|
|
- {
|
|
|
- _Equipment.CustomerID = Guid.Empty;
|
|
|
- _customercode = "";
|
|
|
- CustomerName.Text = "";
|
|
|
- _Equipment.Refresh(false, true);
|
|
|
- }
|
|
|
+ _Equipment.CustomerID = Guid.Empty;
|
|
|
+ _customercode = "";
|
|
|
+ CustomerName.Text = "";
|
|
|
+ _Equipment.Refresh(false, true);
|
|
|
}
|
|
|
}
|
|
|
}
|