1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859 |
- using System.Windows;
- using System.Windows.Controls;
- using Comal.Classes;
- using InABox.Clients;
- using InABox.Core;
- using InABox.Wpf;
- namespace PRSDesktop
- {
- /// <summary>
- /// Interaction logic for FactoryLostTimeChooser.xaml
- /// </summary>
- public partial class FactoryLostTimeChooser : ThemableWindow
- {
- public FactoryLostTimeChooser()
- {
- InitializeComponent();
- new Client<ManufacturingLostTime>().Query(
- LookupFactory.DefineFilter<ManufacturingLostTime>(),
- null, //LookupFactory.DefineColumns<ManufacturingLostTime>(),
- LookupFactory.DefineSort<ManufacturingLostTime>(),
- (o, e) => { Dispatcher.Invoke(() => { LoadLostTime(o); }); });
- }
- public ManufacturingLostTime SelectedLostTime { get; set; }
- private void LoadLostTime(CoreTable losttime)
- {
- foreach (var row in losttime.Rows)
- {
- LostTime.RowDefinitions.Add(new RowDefinition { Height = new GridLength(1, GridUnitType.Auto) });
- var label = new Label
- {
- Content = row.Get<ManufacturingLostTime, string>(x => x.Description), Margin = new Thickness(10),
- VerticalContentAlignment = VerticalAlignment.Center
- };
- label.SetValue(Grid.RowProperty, LostTime.RowDefinitions.Count - 1);
- label.SetValue(Grid.ColumnProperty, 0);
- LostTime.Children.Add(label);
- var button = new Button { Content = "Select", Margin = new Thickness(10, 0, 10, 20), MinWidth = 100, MinHeight = 50 };
- button.Tag = row.ToObject<ManufacturingLostTime>();
- button.Click += Button_Click;
- button.SetValue(Grid.RowProperty, LostTime.RowDefinitions.Count - 1);
- button.SetValue(Grid.ColumnProperty, 1);
- LostTime.Children.Add(button);
- }
- }
- private void Button_Click(object sender, RoutedEventArgs e)
- {
- SelectedLostTime = (sender as Button).Tag as ManufacturingLostTime;
- DialogResult = true;
- Close();
- }
- }
- }
|