Exemplo n.º 1
0
 private void userNameBox_KeyPress(object sender, KeyPressEventArgs e)
 {
     if (e.KeyChar == (char)13)
     {
         if (userNameBox.Focused)
         {
             PasswordBox.Focus();
         }
         else if (PasswordBox.Focused)
         {
             ConfirmButton.Focus();
         }
     }
 }
Exemplo n.º 2
0
 private void PopupWithTwoButtonsLoaded(object sender, RoutedEventArgs e)
 {
     ConfirmButton.Focus(FocusState.Pointer);
 }
Exemplo n.º 3
0
 private void AddEditPilotForm_Shown(object sender, EventArgs e)
 {
     ConfirmButton.Focus();
 }
        /// <summary>
        /// Отображение/скрытие соответсвующих полей окна, загрузка списов из БД (если нужно)
        /// </summary>
        private void AdditionalInitializeComponent()
        {
            const Visibility show = Visibility.Visible;
            const Visibility hide = Visibility.Collapsed;

            // Отображение/скрытие полей
            PeriodWrapperGrid.Visibility                           = _isPeriod ? show : hide;
            MonthOrYearWrapperGrid.Visibility                      = _isMonthOrYear ? show : hide;
            DateWrapperGrid.Visibility                             = _isDate ? show : hide;
            DatePeriodWrapperGrid.Visibility                       = _isDatePeriod ? show : hide;
            KoefTWrapperGrid.Visibility                            = _isKoefT ? show : hide;
            KoefZWrapperGrid.Visibility                            = _isKoefZ ? show : hide;
            CehWrapperGrid.Visibility                              = _isWorkGuild ? show : hide;
            AreaWrapperGrid.Visibility                             = _isArea ? show : hide;
            WorkGuildSpecifiedOrAllWrapperGrid.Visibility          = _isWorkGuildSpecifiedOrAll ? show : hide;
            ProductWrapperGrid.Visibility                          = _isProduct ? show : hide;
            DetailWrapperGrid.Visibility                           = _isDetail ? show : hide;
            ProductSpecifiedOrAllWrapperGrid.Visibility            = _isProductSpecifiedOrAll ? show : hide;
            AssemblyUnitWrapperGrid.Visibility                     = _isAssemblyUnit ? show : hide;
            MonthYearWrapperGrid.Visibility                        = _isMonthYear ? show : hide;
            TimeFundWrapperGrid.Visibility                         = _isTimeFund ? show : hide;
            ProcentageOfLossTimeWrapperGrid.Visibility             = _isProcentageOfLossTime ? show : hide;
            ProcentageOfPerformanceStandartsWrapperGrid.Visibility = _isProcentageOfPerformanceStandarts ? show : hide;
            AreaSpecifiedOrAllWrapperGrid.Visibility               = _isAreaSpecifiedOrAll ? show : hide;

            MessageLabel.Content = _hintMessage;

            // Если вводится [Дата] - значение по-умолчанию сегодняшняя
            if (_isDate)
            {
                DatePicker.SelectedDate = DateTime.Today;
            }

            if (_isWorkGuild)
            {
                try
                {
                    WorkGuildsComboBox.ItemsSource = WorkGuildsService.GetAll();
                }
                catch (StorageException ex)
                {
                    Common.ShowDetailExceptionMessage(ex);
                }
            }

            // Если вводится [Изделие] - загрузка списка из БД и заполнение Textbox
            if (_isProductSpecifiedOrAll)
            {
                try
                {
                    _searchProductStorage             = ProductsService.GetProducts();
                    SearchProductDataGrid.ItemsSource = _searchProductStorage;
                }
                catch (StorageException ex)
                {
                    Common.ShowDetailExceptionMessage(ex);
                    return;
                }
                ProductAllRadioButton.IsChecked = true;
            }

            // Если вводится [Цех] - загрузка списка из БД и заполнение ComboBox
            if (_isWorkGuildSpecifiedOrAll)
            {
                try
                {
                    WorkguildSpecifiedComboBox.ItemsSource = WorkGuildsService.GetAll();
                }
                catch (StorageException ex)
                {
                    Common.ShowDetailExceptionMessage(ex);
                    return;
                }
                WorkguildAllRadioButton.IsChecked = true;
            }

            // Если вводится [Участок] - загрузка списка из БД и заполнение ComboBox
            if (_isAreaSpecifiedOrAll)
            {
                try
                {
                    AreaSpecifiedComboBox.ItemsSource = AreasService.GetAll();
                }
                catch (StorageException ex)
                {
                    Common.ShowDetailExceptionMessage(ex);
                    return;
                }

                AreaAllRadioButton.IsChecked = true;
            }

            if (_isArea)
            {
                try
                {
                    AreaComboBox.ItemsSource = AreasService.GetAll();
                }
                catch (StorageException ex)
                {
                    Common.ShowDetailExceptionMessage(ex);
                }
            }

            // Если вводится [Изделие] - загрузка списка из БД и заполнение Textbox
            if (_isProduct)
            {
                try
                {
                    _searchProductStorage             = ProductsService.GetProducts();
                    SearchProductDataGrid.ItemsSource = _searchProductStorage;
                }
                catch (StorageException ex)
                {
                    Common.ShowDetailExceptionMessage(ex);
                }
            }

            // Если вводится [Деталь] - загрузка списка из БД и заполнение Textbox
            if (_isDetail)
            {
                try
                {
                    _searchDetailStorage             = DetailsService.GetAll();
                    SearchDetailDataGrid.ItemsSource = _searchDetailStorage;
                }
                catch (StorageException ex)
                {
                    Common.ShowDetailExceptionMessage(ex);
                }
            }

            // Если вводится [Сборочноя еденица] - загрузка списка из БД и заполнение Textbox
            if (_isAssemblyUnit)
            {
                try
                {
                    _searchProductStorage = ProductsService.GetAssemblyUnits();
                    SearchAssemblyUnitDataGrid.ItemsSource = _searchProductStorage;
                }
                catch (StorageException ex)
                {
                    Common.ShowDetailExceptionMessage(ex);
                }
            }

            // Если вводится [Месяц/Год] - получение Dictionary месяцев и заполнение ComboBox, год текущий
            // ReSharper disable once InvertIf
            if (_isMonthYear)
            {
                const int monthOffset = 1;
                var       today       = DateTime.Today;
                MonthComboBox.ItemsSource   = Common.MonthsFullNames();
                MonthComboBox.SelectedIndex = today.Month - monthOffset;
                YearIntegerUpDown.Value     = today.Year;
            }

            ConfirmButton.Focus();
        }
Exemplo n.º 5
0
 private void AddRouteForm_Shown(object sender, EventArgs e)
 {
     ConfirmButton.Focus();
 }
Exemplo n.º 6
0
        private void AddToCartButton_Click(object sender, EventArgs e)
        {
            // Code which changes visibility of the Billing Form.
            ClearButton.Visible           = false;
            DataGridViewPanel.Visible     = true;
            DataGridCart.Visible          = true;
            TotalCostValueTextBox.Visible = true;
            TotalcostLabel.Visible        = true;
            ProductPanel.Visible          = true;
            ButtonPanelOne.Visible        = true;
            ConfirmButton.Focus();
            ExitButtonTwo.Visible = false;


            try
            {
                // Local Variable declaration section.
                int QuantityEntered = int.Parse(QuantityValuesTextBox.Text);
                // Decision construct to check wetaher quantity entered is greater than 0.
                if (QuantityEntered > 0)
                {
                    // Local Variable declaration.
                    int BeerNameIndexSelected = int.Parse(BeerNamesListBox.SelectedIndex.ToString());
                    //Decision construct to check wetaher Beer Name is selected.
                    if (BeerNameIndexSelected >= 0)
                    {
                        // Local Variable declaration.
                        int BeerSizeIndexSelected = int.Parse(BeerSubTypeListBox.SelectedIndex.ToString());
                        //Decision construct to check wetaher Beer Type is selected.
                        if (BeerSizeIndexSelected >= 0)
                        {
                            //Decision construct to check wetaher selected Beer and Beer Type is available.
                            if (TempStockArray[BeerNameIndexSelected, BeerSizeIndexSelected] < QuantityEntered)
                            {
                                // If stock is not available.
                                DataGridViewPanel.Visible = false;
                                MessageBox.Show("Sorry the product is out of stock and Please select other product available", "Out of Stock Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            }

                            else
                            {
                                double InitialTotalCost = 0;

                                // If stock is available then reduce the quantity from stock available.
                                TempStockArray[BeerNameIndexSelected, BeerSizeIndexSelected] = TempStockArray[BeerNameIndexSelected, BeerSizeIndexSelected] - QuantityEntered;
                                //Code which calculates Basic cost.
                                InitialTotalCost = PriceArray[BeerNameIndexSelected, BeerSizeIndexSelected] * QuantityEntered;
                                ProductName      = BeerNameArray[BeerNameIndexSelected];
                                ProductType      = BeerSizeArray[BeerSizeIndexSelected];
                                //Calling Display method through call by value procedure.
                                DisplayDataGrid(ProductName, ProductType, QuantityEntered, InitialTotalCost);
                                FinalValue = FinalValue + InitialTotalCost;
                                TotalCostValueTextBox.Text = CURRENCY + FinalValue.ToString();
                            }
                        }
                        //decison construct if Beer Name is not selected from listbox.
                        else
                        {
                            ButtonPanelOne.Visible    = false;
                            DataGridViewPanel.Visible = false;
                            MessageBox.Show("Please select Beer Size Type", "Select Beer Type Error ", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                    }
                    //decison construct if Beer type is not selected from listbox.
                    else
                    {
                        ButtonPanelOne.Visible    = false;
                        DataGridViewPanel.Visible = false;
                        MessageBox.Show("Please select Beer Name", "Select Beer Name Error ", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
                //decison construct executed if quanity is less than 0.
                else
                {
                    ButtonPanelOne.Visible    = false;
                    DataGridViewPanel.Visible = false;
                    MessageBox.Show("Qunatity should be greater than 0", "Select Quantity eroor Error ", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            // catch block which catches the exception thrown by try block.
            catch
            {
                ButtonPanelOne.Visible    = false;
                DataGridViewPanel.Visible = false;

                MessageBox.Show("Please select Non Negative and greater than 0 Quantity", "Negative Qunatity Box Error ", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
 private void UserControl_Loaded(object sender, RoutedEventArgs e)
 {
     ConfirmButton.Focus();
 }