Exemplo n.º 1
0
        private void WorkSubsectionsListBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (WorkSubsectionsListBox.SelectedItem == null || WorkSubsectionsListBox.SelectedValue == null)
            {
                prop3Grid.DataContext = null;

                WorkOperationsListBox.ItemsSource = null;

                AdittProp3StackPanel.DataContext = null;

                WorkOperationsListBox_SelectionChanged(null, null);

                return;
            }

            prop3Grid.DataContext = WorkSubsectionsListBox.SelectedItem;

            DataView operationsDataView = _cc.GetWorkOperations();

            if (AdditOperationsChexkBox.IsChecked == true)
            {
                operationsDataView.RowFilter = String.Format("WorkSubsectionID  IN ({0}, -1) AND Visible = True", WorkSubsectionsListBox.SelectedValue);

                var operationsCollectionView =
                    new BindingListCollectionView(operationsDataView);

                if (operationsCollectionView.GroupDescriptions != null)
                {
                    operationsCollectionView.GroupDescriptions.Add(new PropertyGroupDescription("OperationTypeID",
                                                                                                new OperationTypeConverter()));
                    operationsCollectionView.SortDescriptions.Add(new SortDescription("OperationTypeID",
                                                                                      ListSortDirection.Ascending));

                    WorkOperationsListBox.SelectionChanged -= WorkOperationsListBox_SelectionChanged;
                    WorkOperationsListBox.ItemsSource       = operationsCollectionView;
                    WorkOperationsListBox.SelectionChanged += WorkOperationsListBox_SelectionChanged;
                }
            }
            else
            {
                operationsDataView.RowFilter = String.Format("WorkSubsectionID = {0} AND Visible = True", WorkSubsectionsListBox.SelectedValue);

                WorkOperationsListBox.SelectionChanged -= WorkOperationsListBox_SelectionChanged;
                WorkOperationsListBox.ItemsSource       = operationsDataView;
                WorkOperationsListBox.SelectionChanged += WorkOperationsListBox_SelectionChanged;

                WorkOperationsListBox.Items.Refresh();
            }



            WorkOperationsListBox.SelectedIndex = 0;
            WorkOperationsListBox.ScrollIntoView(WorkOperationsListBox.SelectedItem);
            WorkOperationsListBox_SelectionChanged(null, null);

            AdittProp3StackPanel.DataContext =
                Convert.ToInt32(((DataRowView)WorkSubsectionsListBox.SelectedItem)["SubsectionGroupID"]) == 2
                    ? _cc.GetMachineInfo(Convert.ToInt32(WorkSubsectionsListBox.SelectedValue))
                    : null;
        }