Esempio n. 1
0
        /// <summary>
        /// Open window and do initial setup of datagrid and comboboxes
        /// </summary>
        /// <param name="mainWindow"></param>
        public SearchWindow(MainWindow mainWindow)
        {
            //store main window
            currentMain = mainWindow;

            //start up the search logic
            _searchLogic = new clsSearchLogic();

            //populate datagrid with initial unsorted invoices
            invoiceList = _searchLogic.GetAllItems();

            //populate comboboxes
            numberList = _searchLogic.Get <int>("InvoiceNum").Distinct().ToList();
            numberList.Sort();
            dateList = _searchLogic.Get <DateTime>("InvoiceDate").Distinct().ToList();
            dateList.Sort();
            costList = _searchLogic.Get <int>("TotalCost").Distinct().ToList();
            costList.Sort();


            //set up visual
            InitializeComponent();
            //disable select button to prevent selecting nothing
            selectButton.IsEnabled = false;

            //set up comboboxes
            numFilter.ItemsSource    = numberList;
            dateFilter.ItemsSource   = dateList;
            chargeFilter.ItemsSource = costList;

            //populate datagrid with Invoices
            listDisplay.ItemsSource = invoiceList;
        }
Esempio n. 2
0
        /// <summary>
        /// refill datagrid with filtered query
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void UpdateSearch(object sender, System.Windows.Controls.SelectionChangedEventArgs e)
        {
            //disable select button to prevent selecting nothing
            selectButton.IsEnabled = false;

            int?n = null;

            if (numFilter.SelectedIndex != -1)
            {
                n = numberList[numFilter.SelectedIndex];
            }
            DateTime?d = null;

            if (dateFilter.SelectedIndex != -1)
            {
                d = dateList[dateFilter.SelectedIndex];
            }
            int?c = null;

            if (chargeFilter.SelectedIndex != -1)
            {
                c = costList[chargeFilter.SelectedIndex];
            }

            /*
             * This would narrow down all comboboxes when one option is selected.
             * It's commented out because it can get annoying
             *
             * //populate comboboxes
             * numberList = _searchLogic.Get<int>("InvoiceNum",n,d,c).Distinct().ToList();
             * numberList.Sort();
             * dateList = _searchLogic.Get<DateTime>("InvoiceDate", n, d, c).Distinct().ToList();
             * dateList.Sort();
             * costList = _searchLogic.Get<int>("TotalCost", n, d, c).Distinct().ToList();
             * costList.Sort();
             *
             * //set up comboboxes
             * numFilter.ItemsSource = numberList;
             * dateFilter.ItemsSource = dateList;
             * chargeFilter.ItemsSource = costList;
             */

            //populate datagrid with sorted invoices
            invoiceList = _searchLogic.Get(n, d, c);

            //set up datagrid
            listDisplay.ItemsSource = invoiceList;
        }