LoadFinancialBatchesGrid() публичный Метод

Loads the financial batches grid.
public LoadFinancialBatchesGrid ( ) : void
Результат void
Пример #1
0
        /// <summary>
        /// Handles the Click event of the btnLogin control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="RoutedEventArgs"/> instance containing the event data.</param>
        private void btnLogin_Click(object sender, RoutedEventArgs e)
        {
            lblLoginWarning.Visibility = Visibility.Hidden;
            txtUsername.Text           = txtUsername.Text.Trim();
            txtRockUrl.Text            = txtRockUrl.Text.Trim();
            Uri rockUrl      = new Uri(txtRockUrl.Text);
            var validSchemes = new string[] { Uri.UriSchemeHttp, Uri.UriSchemeHttps };

            if (!validSchemes.Contains(rockUrl.Scheme))
            {
                txtRockUrl.Text = "https://" + rockUrl.AbsoluteUri;
            }

            RockRestClient rockRestClient = new RockRestClient(txtRockUrl.Text);

            string userName = txtUsername.Text;
            string password = txtPassword.Password;

            if (string.IsNullOrWhiteSpace(userName))
            {
                lblLoginWarning.Content    = "Username cannot be blank";
                lblLoginWarning.Visibility = Visibility.Visible;
                return;
            }

            // start a background thread to Login since this could take a little while and we want a Wait cursor
            BackgroundWorker bw = new BackgroundWorker();

            bw.DoWork += delegate(object s, DoWorkEventArgs ee)
            {
                ee.Result = null;
                rockRestClient.Login(userName, password);
            };

            // when the Background Worker is done with the Login, run this
            bw.RunWorkerCompleted += delegate(object s, RunWorkerCompletedEventArgs ee)
            {
                this.Cursor        = null;
                btnLogin.IsEnabled = true;
                try
                {
                    if (ee.Error != null)
                    {
                        throw ee.Error;
                    }

                    Person     person     = rockRestClient.GetData <Person>(string.Format("api/People/GetByUserName/{0}", userName));
                    RockConfig rockConfig = RockConfig.Load();
                    rockConfig.RockBaseUrl = txtRockUrl.Text;
                    rockConfig.Username    = txtUsername.Text;
                    rockConfig.Password    = txtPassword.Password;
                    rockConfig.Save();

                    BatchPage batchPage = new BatchPage(person);

                    if (this.NavigationService.CanGoBack)
                    {
                        // if we got here from some other Page, go back
                        this.NavigationService.GoBack();
                    }
                    else
                    {
                        try
                        {
                            batchPage.LoadLookups();
                            batchPage.LoadFinancialBatchesGrid();
                        }
                        catch (HttpErrorException ex)
                        {
                            if (ex.Response != null && ex.Response.StatusCode.Equals(HttpStatusCode.Unauthorized))
                            {
                                lblLoginWarning.Content    = "Not Authorized for Financial Batches";
                                lblLoginWarning.Visibility = Visibility.Visible;
                                return;
                            }
                            else
                            {
                                throw ex;
                            }
                        }

                        this.NavigationService.Navigate(batchPage);
                    }
                }
                catch (WebException wex)
                {
                    // show WebException on the form, but any others should end up in the ExceptionDialog
                    HttpWebResponse response = wex.Response as HttpWebResponse;
                    if (response != null)
                    {
                        if (response.StatusCode.Equals(HttpStatusCode.Unauthorized))
                        {
                            lblLoginWarning.Content    = "Invalid Login";
                            lblLoginWarning.Visibility = Visibility.Visible;
                            return;
                        }
                    }

                    string message = wex.Message;
                    if (wex.InnerException != null)
                    {
                        message += "\n" + wex.InnerException.Message;
                    }

                    lblRockUrl.Visibility      = Visibility.Visible;
                    txtRockUrl.Visibility      = Visibility.Visible;
                    lblLoginWarning.Content    = message;
                    lblLoginWarning.Visibility = Visibility.Visible;
                    return;
                }
            };

            // set the cursor to Wait, disable the login button, and start the login background process
            this.Cursor        = Cursors.Wait;
            btnLogin.IsEnabled = false;
            bw.RunWorkerAsync();
        }
Пример #2
0
        /// <summary>
        /// Handles the Click event of the btnSave control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="RoutedEventArgs"/> instance containing the event data.</param>
        private void btnSave_Click(object sender, RoutedEventArgs e)
        {
            _rockConfig.CaptureAmountOnScan = chkCaptureAmountOnScan.IsChecked == true;

            _rockConfig.RequireControlAmount    = chkRequireControlAmount.IsChecked == true;
            _rockConfig.RequireControlItemCount = chkRequireControlItemCount.IsChecked == true;
            AddAccountsForAmountsToSave();
            if (_rockConfig.CaptureAmountOnScan && _rockConfig.SelectedAccountForAmountsIds.Count() == 0)
            {
                MessageBox.Show("Please select at least one account", "Warning", MessageBoxButton.OK, MessageBoxImage.Warning);
                return;
            }
            try
            {
                txtRockUrl.Text = txtRockUrl.Text.Trim();
                Uri rockUrl      = new Uri(txtRockUrl.Text);
                var validSchemes = new string[] { Uri.UriSchemeHttp, Uri.UriSchemeHttps };
                if (!validSchemes.Contains(rockUrl.Scheme))
                {
                    txtRockUrl.Text = "http://" + rockUrl.AbsoluteUri;
                }

                RockRestClient client = new RockRestClient(txtRockUrl.Text);
                client.Login(_rockConfig.Username, _rockConfig.Password);
                BatchPage.LoggedInPerson = client.GetData <Person>(string.Format("api/People/GetByUserName/{0}", _rockConfig.Username));
            }
            catch (WebException wex)
            {
                HttpWebResponse response = wex.Response as HttpWebResponse;
                if (response != null)
                {
                    if (response.StatusCode == HttpStatusCode.Unauthorized)
                    {
                        // valid URL but invalid login, so navigate back to the LoginPage
                        _rockConfig.RockBaseUrl = txtRockUrl.Text;
                        _rockConfig.Save();
                        LoginPage loginPage = new LoginPage(true);
                        this.NavigationService.Navigate(loginPage);
                        return;
                    }
                }

                lblAlert.Content    = wex.Message;
                lblAlert.Visibility = Visibility.Visible;
                return;
            }
            catch (Exception ex)
            {
                App.LogException(ex);
                lblAlert.Content    = ex.Message;
                lblAlert.Visibility = Visibility.Visible;
                return;
            }

            _rockConfig.RockBaseUrl = txtRockUrl.Text;

            switch (cboScannerInterfaceType.SelectedItem as string)
            {
            case "MagTek COM":
                _rockConfig.ScannerInterfaceType = RockConfig.InterfaceType.MICRImageRS232;
                break;

            case "MagTek Image Safe":
                _rockConfig.ScannerInterfaceType = RockConfig.InterfaceType.MagTekImageSafe;
                break;

            default:
                _rockConfig.ScannerInterfaceType = RockConfig.InterfaceType.RangerApi;
                break;
            }

            string imageOption = cboImageOption.SelectedValue as string;

            _rockConfig.Sensitivity = txtSensitivity.Text.Trim().AsInteger().ToString();
            _rockConfig.Plurality   = txtPlurality.Text.Trim().AsInteger().ToString();

            switch (imageOption)
            {
            case "Grayscale":
                _rockConfig.ImageColorType = RangerImageColorTypes.ImageColorTypeGrayscale;
                break;

            case "Color":
                _rockConfig.ImageColorType = RangerImageColorTypes.ImageColorTypeColor;
                break;

            default:
                _rockConfig.ImageColorType = RangerImageColorTypes.ImageColorTypeBitonal;
                break;
            }

            string comPortName = cboMagTekCommPort.SelectedItem as string;

            if (!string.IsNullOrWhiteSpace(comPortName))
            {
                _rockConfig.MICRImageComPort = short.Parse(comPortName.Replace("COM", string.Empty));
            }

            var campusFilter = cboCampusFilter.SelectedItem as Campus;

            _rockConfig.CampusIdFilter = campusFilter?.Id;

            _rockConfig.Save();
            BatchPage.LoadLookups();

            // shutdown the scanner so that options will be reloaded when the batch page loads
            if (BatchPage.rangerScanner != null)
            {
                BatchPage.rangerScanner.ShutDown();
            }

            BatchPage.UnbindAllEvents();
            BatchPage.BindDeviceToPage();
            BatchPage.ConnectToScanner();
            BatchPage.LoadFinancialBatchesGrid();
            BatchPage.UpdateBatchUI(BatchPage.SelectedFinancialBatch);

            this.NavigationService.Navigate(BatchPage);
        }
Пример #3
0
        /// <summary>
        /// Handles the Click event of the btnLogin control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="RoutedEventArgs"/> instance containing the event data.</param>
        private void btnLogin_Click( object sender, RoutedEventArgs e )
        {
            lblLoginWarning.Visibility = Visibility.Hidden;
            txtUsername.Text = txtUsername.Text.Trim();
            txtRockUrl.Text = txtRockUrl.Text.Trim();
            Uri rockUrl = new Uri( txtRockUrl.Text );
            var validSchemes = new string[] { Uri.UriSchemeHttp, Uri.UriSchemeHttps };
            if ( !validSchemes.Contains( rockUrl.Scheme ) )
            {
                txtRockUrl.Text = "http://" + rockUrl.AbsoluteUri;
            }

            RockRestClient rockRestClient = new RockRestClient( txtRockUrl.Text );

            string userName = txtUsername.Text;
            string password = txtPassword.Password;

            if ( string.IsNullOrWhiteSpace( userName ) )
            {
                lblLoginWarning.Content = "Username cannot be blank";
                lblLoginWarning.Visibility = Visibility.Visible;
                return;
            }

            // start a background thread to Login since this could take a little while and we want a Wait cursor
            BackgroundWorker bw = new BackgroundWorker();
            bw.DoWork += delegate( object s, DoWorkEventArgs ee )
            {
                ee.Result = null;
                rockRestClient.Login( userName, password );
            };

            // when the Background Worker is done with the Login, run this
            bw.RunWorkerCompleted += delegate( object s, RunWorkerCompletedEventArgs ee )
            {
                this.Cursor = null;
                btnLogin.IsEnabled = true;
                try
                {
                    if ( ee.Error != null )
                    {
                        throw ee.Error;
                    }

                    Person person = rockRestClient.GetData<Person>( string.Format( "api/People/GetByUserName/{0}", userName ) );
                    RockConfig rockConfig = RockConfig.Load();
                    rockConfig.RockBaseUrl = txtRockUrl.Text;
                    rockConfig.Username = txtUsername.Text;
                    rockConfig.Password = txtPassword.Password;
                    rockConfig.Save();

                    BatchPage batchPage = new BatchPage( person );

                    if ( this.NavigationService.CanGoBack )
                    {
                        // if we got here from some other Page, go back
                        this.NavigationService.GoBack();
                    }
                    else
                    {
                        try
                        {
                            batchPage.LoadLookups();
                            batchPage.LoadFinancialBatchesGrid();
                        }
                        catch ( HttpErrorException ex )
                        {
                            if ( ex.Response != null && ex.Response.StatusCode.Equals( HttpStatusCode.Unauthorized ) )
                            {
                                lblLoginWarning.Content = "Not Authorized for Financial Batches";
                                lblLoginWarning.Visibility = Visibility.Visible;
                                return;
                            }
                            else
                            {
                                throw ex;
                            }
                        }

                        this.NavigationService.Navigate( batchPage );
                    }
                }
                catch ( WebException wex )
                {
                    // show WebException on the form, but any others should end up in the ExceptionDialog
                    HttpWebResponse response = wex.Response as HttpWebResponse;
                    if ( response != null )
                    {
                        if ( response.StatusCode.Equals( HttpStatusCode.Unauthorized ) )
                        {
                            lblLoginWarning.Content = "Invalid Login";
                            lblLoginWarning.Visibility = Visibility.Visible;
                            return;
                        }
                    }

                    string message = wex.Message;
                    if ( wex.InnerException != null )
                    {
                        message += "\n" + wex.InnerException.Message;
                    }

                    lblRockUrl.Visibility = Visibility.Visible;
                    txtRockUrl.Visibility = Visibility.Visible;
                    lblLoginWarning.Content = message;
                    lblLoginWarning.Visibility = Visibility.Visible;
                    return;
                }
            };

            // set the cursor to Wait, disable the login button, and start the login background process
            this.Cursor = Cursors.Wait;
            btnLogin.IsEnabled = false;
            bw.RunWorkerAsync();
        }