Exemple #1
0
        private void aButtonSearch_Click(object sender, EventArgs e)
        {
            aTextBoxNotes.Text = "";
            //GET SORTATION
            Class_Library.DataGridView.DGVSortInfo SavedSortation = DGVUtilities.GetSortation(aDataGridViewLicenses);

            if (aComboboxSortBy.SelectedItem.ToString() == @"Search by Name\Id")
            {
                // GET DATA BY NAME
                LicensesDGV = DataAccess_GDataTable.GetByName(aTextBoxSearch.Text, Config.DBDir_Name);
            }
            else if (aComboboxSortBy.SelectedItem.ToString() == "Search by Machine Name")
            {
                // GET DATA BY MACHINE NAME
                List <LicensedMachines> LicenseFound = DataAccess_LicensedMachinesTable.GetByMachineName(aTextBoxSearch.Text, Config.DBDir_Name);
                try
                {
                    // FIND LICENSES BY MACHINE'S LICENSE ID
                    List <License> TempLicensesDGV = new List <License>();
                    foreach (LicensedMachines _Lic in LicenseFound)
                    {
                        // COMPILE LIST FOR DGV
                        TempLicensesDGV.Add(DataAccess_GDataTable.GetByID(_Lic.LicenseId, Config.DBDir_Name));
                    }
                    // MOVE LIST TO DGV
                    LicensesDGV = TempLicensesDGV;
                }
                catch (ArgumentOutOfRangeException)
                {
                }
            }

            // PUT DATA INTO SORTABLE LIST
            BindingListView <License> SortableLicensesDGV = new BindingListView <License>(LicensesDGV);

            // SET DGV.DATASOURCE
            aDataGridViewLicenses.DataSource = SortableLicensesDGV;
            aLabelLicenseFoundInt.Text       = aDataGridViewLicenses.Rows.Count.ToString();
            // SET SORTATION
            DGVUtilities.SetSortation(SavedSortation, aDataGridViewLicenses);
            Utilities.CloseSQLConnection();

            // If no licenses were found, clear the notes text box.
            if (aDataGridViewLicenses.RowCount == 0)
            {
                aTextBoxNotes.Text = "";
            }
        }
Exemple #2
0
        private void ATextBoxSearch_TextChanged(object sender, EventArgs e)
        {
            //GET SORTATION
            Class_Library.DataGridView.DGVSortInfo SavedSortation = DGVUtilities.GetSortation(aDataGridViewLicenses);

            // SEARCH FOR DATA
            LicensesDGV = DataAccess_GDataTable.GetByName(aTextBoxSearch.Text, Config.DBDir_Name);

            // PUT DATA INTO SORTABLE LIST
            BindingListView <License> SortableLicensesDGV = new BindingListView <License>(LicensesDGV);

            // SET DGV.DATASOURCE
            aDataGridViewLicenses.DataSource = SortableLicensesDGV;
            // SET SORTATION
            DGVUtilities.SetSortation(SavedSortation, aDataGridViewLicenses);
        }