public void WireUpForm1() { // SELECT DEFAULT VIEW aComboboxSortBy.SelectedIndex = 0; DGVUtilities.SetSortationDefault(5, SortOrder.Descending, aDataGridViewLicenses); }
private void MoveForm_Shown(object sender, EventArgs e) { // GET DEFAULT DATA LicensesDGV = DataAccess_GDataTable.GetAllData(Config.DBDir_Name); // PUT DATA INTO SORTABLE LIST BindingListView <License> SortableLicensesDGV = new BindingListView <License>(LicensesDGV); // SET DGV.DATASOURCE aDataGridViewLicenses.DataSource = SortableLicensesDGV; // SET DEFAULT SORTATION DGVUtilities.SetSortationDefault(5, SortOrder.Descending, aDataGridViewLicenses); Utilities.CloseSQLConnection(); }
private void ADataGridViewLicenses_CellEnter(object sender, DataGridViewCellEventArgs e) { try { // GET LICENSED MACHINES OF SELECTED LICENSE int IDOfSelectedLicense = (Convert.ToInt32(aDataGridViewLicenses[0, aDataGridViewLicenses.CurrentCell.RowIndex].FormattedValue)); LicensedMachinesDGV = DataAccess_LicensedMachinesTable.GetByLicenseID(IDOfSelectedLicense, Config.DBDir_Name); BindingListView <LicensedMachines> SortableLicensedMachinesDGV = new BindingListView <LicensedMachines>(LicensedMachinesDGV); aDataGridViewMachines.DataSource = SortableLicensedMachinesDGV; DGVUtilities.SetSortationDefault(2, SortOrder.Ascending, aDataGridViewMachines); Utilities.CloseSQLConnection(); } catch { } }
private void Form1_Load(object sender, EventArgs e) { try { // VERIFY INTEGRITY OF CONFIG & DATABASE | GET CONFIG INFO //Config = Utilities.GetConfigData(); Config = Class_Library.Config.Get(); // Check If DB is current Version Utilities.CheckDatabaseForUpdates(Config); // Check if Licenses are up for renewal InitializeLicensesTTR(); // #Finish Setup# // SELECT DEFAULT VIEW aComboboxSortBy.SelectedIndex = 0; DGVUtilities.SetSortationDefault(5, SortOrder.Descending, aDataGridViewLicenses); } catch (System.Data.SqlClient.SqlException err) { // General SQL error message string errorMessage = $"Error message:\n\"{err.Message}\" \n\nWould you like to re-configure your database settings?"; // SQL Login Failed error message if (err.Message.Contains("Login Failed")) { errorMessage = $"Error message:\n\"{err.Message}\" " + $"\n\n" + $"This is likely due to another machine accessing the databse file. Typically this can be resolved by restarting the application." + $"\n\n" + $"Would you like to re-configure your database settings?"; } DialogResult dresult = MessageBox.Show(errorMessage, "Error!", MessageBoxButtons.YesNo); // Unable to Access Database if (dresult == DialogResult.Yes) // If user wants to change database directory { // SETUP CONFIG FORM -- to re-configure database ConfigForm _configform = new ConfigForm(); DialogResult _Configform = _configform.ShowDialog(); if (_Configform == DialogResult.OK) { Application.Restart(); // If User saves changes to Database directory } else { Application.Exit(); // If user decides to change nothing } } else // If user does NOT want to change database directory { Application.Exit(); } } catch (Exception err) { MessageBox.Show(err.ToString()); } }