Beispiel #1
0
        public async Task <IActionResult> Index([FromQuery] Guid b)
        {
            if (b == Guid.Empty)
            {
                return(Redirect("/"));
            }

            ViewData["b"] = b;

            var conditionTask    = _facetRepository.GetConditionsAsync();
            var employeeTask     = _facetRepository.GetEmployeesAsync(b);
            var eventTask        = _facetRepository.GetEventsAsync(b);
            var hoursTask        = _facetRepository.GetOperationHoursAsync();
            var locationTask     = _facetRepository.GetLocationsAsync(b);
            var organizationTask = _facetRepository.GetOrganizationsAsync(b);
            var performerTask    = _facetRepository.GetPerformersAsync(b);
            var productTypeTask  = _facetRepository.GetProductTypesAsync(b);
            var salesTask        = _salesRepository.GetSalesByDateAsync(b, DateTime.Now);

            await Task.WhenAll(new Task[] {
                conditionTask,
                employeeTask,
                eventTask,
                hoursTask,
                locationTask,
                organizationTask,
                performerTask,
                productTypeTask,
                salesTask
            });

            var vm = new SalesEntryViewModel {
                Conditions     = conditionTask.Result,
                Employees      = employeeTask.Result,
                Events         = eventTask.Result,
                OperationHours = hoursTask.Result,
                Locations      = locationTask.Result,
                Organizations  = organizationTask.Result,
                Performers     = performerTask.Result,
                ProductTypes   = productTypeTask.Result,
                Sales          = salesTask.Result
            };

            return(View(vm));
        }
        public SalesEntry()
        {
            InitializeComponent();
            RoutedEventHandler handler = null;

            handler = (object sender, RoutedEventArgs e) =>
            {
                if (_salesViewModel.IsEditMode == false)
                {
                    CboCustomers.SelectedValue = _salesViewModel.DefaultCustomer.Id;
                }
                Loaded -= handler;
            };
            Loaded += handler;

            DataContextChanged += (sender, eventArgs) =>
            {
                _salesViewModel                    = this.DataContext as SalesEntryViewModel;
                custComboBoxCol.ItemsSource        = _salesViewModel.ProductsPriceList;
                custComboBoxCol.FilterPropertyName = "ProductName";
                _salesViewModel.Extensions         = SalesExtn.DataContext as IExtensions;
            };

            SalesDataGrid.PreviewKeyUp += (s, e) =>
            {
                if ((e.Key == Key.Enter) || (e.Key == Key.Return))
                {
                    var grid = s as Microsoft.Windows.Controls.DataGrid;

                    //if (grid.CurrentColumn.Header.ToString().Equals("Barcode", StringComparison.OrdinalIgnoreCase))
                    //{
                    //if (grid.SelectionUnit == DataGridSelectionUnit.Cell || grid.SelectionUnit == DataGridSelectionUnit.CellOrRowHeader)
                    //{
                    //var focusedElement = Keyboard.FocusedElement as UIElement;
                    //focusedElement.MoveFocus(new TraversalRequest(FocusNavigationDirection.Left));
                    //grid.SelectedIndex = grid.SelectedIndex + 1;
                    //grid.MoveFocus(new TraversalRequest(FocusNavigationDirection.Left));
                    //}

                    // get the selected row
                    //var selectedRow = grid.ItemContainerGenerator.ContainerFromItem(grid.SelectedItem) as DataGridRow;
                    //// selectedRow can be null due to virtualization
                    //if (selectedRow != null)
                    //{
                    // there should always be a selected cell
                    if (grid.SelectedCells.Count != 0)
                    {
                        // get the cell info
                        Microsoft.Windows.Controls.DataGridCellInfo currentCell = grid.SelectedCells[0];

                        // get the display index of the cell's column + 1 (for next column)
                        int columnDisplayIndex = currentCell.Column.DisplayIndex;

                        // if display index is valid
                        if (columnDisplayIndex < grid.Columns.Count)
                        {
                            // get the DataGridColumn instance from the display index
                            Microsoft.Windows.Controls.DataGridColumn nextColumn = grid.ColumnFromDisplayIndex(0);

                            // now telling the grid, that we handled the key down event
                            e.Handled = true;

                            // setting the current cell (selected, focused)
                            grid.CurrentCell = new Microsoft.Windows.Controls.DataGridCellInfo(grid.SelectedItem, nextColumn);

                            // tell the grid to initialize edit mode for the current cell
                            //grid.BeginEdit();
                        }
                    }
                    //grid.BeginEdit();
                    e.Handled = true;
                    //}
                }
            };

            //custComboBoxCol.comboBox.PreviewTextInput += ComboBox_PreviewTextInput;
            //custComboBoxCol.OnComboLoadedEvent += (txt) =>
            //{
            //    custComboBoxCol._cboTextBox.PreviewKeyUp += (s, e) =>
            //    {
            //        if (e.Key == System.Windows.Input.Key.Back && string.IsNullOrWhiteSpace(custComboBoxCol.comboBox.Text))
            //        {
            //            custComboBoxCol.comboBox.ItemsSource = _salesViewModel.ProductsPriceList;
            //        }
            //    };
            //};
        }