コード例 #1
0
        private void ButtonNext_Click(object sender, RoutedEventArgs e)
        {
            string message = string.Empty;

            if (!isSearchCompleted)
            {
                message = "Необходимо выполнить поиск и выбрать один или несколько договоров";
            }
            else if (ListViewSearchResults.SelectedItems.Count == 0)
            {
                message = "Необходимо выбрать один или несколько договоров для продолжения";
            }

            if (!string.IsNullOrEmpty(message))
            {
                MessageBox.Show(message, "", MessageBoxButton.OK, MessageBoxImage.Information);
                return;
            }

            List <ItemIC> itemsIc = new List <ItemIC>();

            foreach (ItemIC item in ListViewSearchResults.SelectedItems)
            {
                itemsIc.Add(item);
            }

            PageViewDiscounts pageViewDiscounts = new PageViewDiscounts(itemsIc);

            NavigationService.Navigate(pageViewDiscounts);
        }
コード例 #2
0
        private async void ButtonSearchAll_Click(object sender, RoutedEventArgs e)
        {
            List <ItemDiscount> itemsDiscount = null;

            Cursor = Cursors.Wait;

            await Task.Run(() => {
                itemsDiscount = SystemDataHandle.SelectDiscountsAll();
            });

            Cursor = Cursors.Arrow;

            if (itemsDiscount.Count == 0)
            {
                MessageBox.Show("Нет данных за выбранный диапазон дат", "", MessageBoxButton.OK, MessageBoxImage.Information);
                return;
            }

            PageViewDiscounts pageViewDiscounts = new PageViewDiscounts();

            NavigationService.Navigate(pageViewDiscounts);
        }
コード例 #3
0
        private async void ButtonSearchByDate_Click(object sender, RoutedEventArgs e)
        {
            bool showErrorMessage = false;

            if (DatePickerDateBegin.SelectedDate == null)
            {
                showErrorMessage = true;
            }

            if (CheckBoxDontSelectDateEnd.IsChecked == false)
            {
                if (RadioButtonDateSelect.IsChecked == true)
                {
                    if (DatePickerEnd.SelectedDate == null)
                    {
                        showErrorMessage = true;
                    }
                    else if (DatePickerEnd.SelectedDate.Value < DatePickerDateBegin.SelectedDate.Value)
                    {
                        showErrorMessage = true;
                    }
                }
            }

            if (showErrorMessage)
            {
                MessageBox.Show("Выберите корректный диапазон дат", "", MessageBoxButton.OK, MessageBoxImage.Information);
                return;
            }

            string sqlQuery          = Properties.Settings.Default.MisSqlSelectDiscountsByDatesTemplate + Environment.NewLine;
            bool   strongEqual       = RadioButtonStrongEqual.IsChecked ?? false;
            bool   dontSelectEndDate = CheckBoxDontSelectDateEnd.IsChecked ?? false;
            bool   endDateSelected   = RadioButtonDateSelect.IsChecked ?? false;

            if (dontSelectEndDate)
            {
                if (strongEqual)
                {
                    sqlQuery += Properties.Settings.Default.MisSqlSelectDiscountsByDateBeginStrongEqual;
                }
                else
                {
                    sqlQuery += Properties.Settings.Default.MisSqlSelectDiscountsByDateBeginWeakEqual;
                }
            }
            else
            {
                if (endDateSelected)
                {
                    if (strongEqual)
                    {
                        sqlQuery += Properties.Settings.Default.MisSqlSelectDiscountsByDateBeginEndStrongEqual;
                    }
                    else
                    {
                        sqlQuery += Properties.Settings.Default.MisSqlSelectDiscountsByDateBeginEndWeakEqual;
                    }
                }
                else
                {
                    if (strongEqual)
                    {
                        sqlQuery += Properties.Settings.Default.MisSqlSelectDiscountsByDateBeginEndlesslStrongEqual;
                    }
                    else
                    {
                        sqlQuery += Properties.Settings.Default.MisSqlSelectDiscountsByDateBeginEndlesslWeakEqual;
                    }
                }
            }

            DateTime?dateTimeEnd = null;

            if (!dontSelectEndDate && endDateSelected)
            {
                dateTimeEnd = DatePickerEnd.SelectedDate.Value;
            }

            Dictionary <string, string> parameters = new Dictionary <string, string>()
            {
                { "@dateBegin", DatePickerDateBegin.SelectedDate.Value.ToShortDateString() }
            };

            if (dateTimeEnd.HasValue)
            {
                parameters.Add("@dateEnd", dateTimeEnd.Value.ToShortDateString());
            }

            bool showClosesContracts          = CheckBoxShowClosedContracts.IsChecked ?? false;
            List <ItemDiscount> itemsDiscount = null;

            Cursor = Cursors.Wait;

            await Task.Run(() => {
                itemsDiscount = SystemDataHandle.SelectDiscoutByDates(sqlQuery, parameters, itemsFilial, showClosesContracts);
            });

            Cursor = Cursors.Arrow;

            if (itemsDiscount.Count == 0)
            {
                MessageBox.Show("Нет данных за выбранный диапазон дат", "", MessageBoxButton.OK, MessageBoxImage.Information);
                return;
            }

            PageViewDiscounts pageViewDiscounts = new PageViewDiscounts(sqlQuery, parameters, itemsFilial, showClosesContracts);

            NavigationService.Navigate(pageViewDiscounts);
        }