Beispiel #1
0
        private async void InvoiceList_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            InvoiceListViewModel invoiceListVM = (InvoiceListViewModel)DataContext;

            if (invoiceListVM.MultiSelect)
            {
                invoiceListVM.InvoiceCount = InvoiceList.SelectedItems.Count.ToString();
                return;
            }
            if (ApplicationView.Value == ApplicationViewState.Snapped)
            {
                ApplicationView.TryUnsnap();
            }
            try
            {
                if (invoiceListVM.SelectedInvoice > -1)
                {
                    if (canCallServer)
                    {
                        bool selectionSuccess = await invoiceListVM.SetSummary(invoiceListVM.InvoiceDetails[invoiceListVM.SelectedInvoice].InvoiceId);

                        if (selectionSuccess)
                        {
                            previousSelectedInvoice = invoiceListVM.SelectedInvoice;
                        }
                        else
                        {
                            invoiceListVM.SelectedInvoice = previousSelectedInvoice;
                        }
                        if (invoiceListVM.SelectedInvoice == -1)
                        {
                            if (invoiceListVM.InvoiceDetails.Count > 0)
                            {
                                UserPreference.Instance.SelectedInvoiceId = 0;
                                InvoiceList.ScrollIntoView(InvoiceList.Items[0], ScrollIntoViewAlignment.Default);
                            }
                        }
                        else
                        {
                            UserPreference.Instance.SelectedInvoiceId = invoiceListVM.InvoiceDetails[invoiceListVM.SelectedInvoice].InvoiceId;
                            InvoiceList.ScrollIntoView(InvoiceList.Items[invoiceListVM.SelectedInvoice], ScrollIntoViewAlignment.Default);
                        }
                    }
                    else
                    {
                        canCallServer = true;
                    }
                    invoiceListVM.HasSelectedInvoice = Visibility.Visible;
                }
                if (invoiceListVM.SelectedInvoice == -1)
                {
                    invoiceListVM.HasSelectedInvoice = Visibility.Collapsed;
                }
            }
            catch (T360Exception ex)
            {
                if (T360ErrorCodes.NotInReviewerQueue.Equals(ex.ErrorCodes[0].Code))
                {
                    invoiceListVM.ReloadList(-1);
                }
                else
                {
                    string msg = invoiceListVM.getErrorMessages(ex);
                    invoiceListVM.showErrorMessages(msg);
                }
            }
        }