/// <summary> /// Create a new database and config file. /// </summary> /// <param name="NewDBConfig"></param> /// <returns></returns> public static void CreateNewDatabase(ConfigClass NewDBConfig) { try { // GET FILE NAME OF DATABASE string DBFileName = Path.GetFileName(NewDBConfig.DBDir_Name); // GET DIRECTORY OF DATABASE string DBDirectory = NewDBConfig.DBDir_Name.Replace(DBFileName, ""); // CREATE DIRECTORY FOR DATABASE Directory.CreateDirectory(DBDirectory); // CREATE DATABASE File.WriteAllBytes(NewDBConfig.DBDir_Name, Properties.Resources.GDataDatabase); } catch (Exception error) { MessageBox.Show(error.ToString()); } }
public static void CreateLog(List <string> ChangesMade, int AccountIdentifier) { // GET DB DIRECTORY W/ DB NAME ConfigClass Config = Utilities.GetConfigData(); foreach (string change in ChangesMade) { // CREATE NEW LOG LogClass NewLog = new LogClass(); NewLog.LicenseId = AccountIdentifier; // Identify which account had the changes. DateTime dt = DateTime.Now; // Get current date/time NewLog.Date = dt; NewLog.Log = change; // SAVE NEW LOG DataAccess_ChangeLogTable dbl = new DataAccess_ChangeLogTable(); dbl.CreateNewLog(NewLog, Config.DBDir_Name); } }
private void aButtonSave_Click(object sender, EventArgs e) { ConfigClass NewConfig = new ConfigClass(); try { // SAVE DATA TO CONFIG OBJECT NewConfig.DBDir_Name = aTextBoxDir.Text; NewConfig.TimeToRenew = aTextBoxTimeToRenew.Text; NewConfig.InstalledDirectory = Environment.CurrentDirectory; NewConfig.AllowDuplicateMachines = aCheckBoxAllowDupeMachines.Checked; Class_Library.Config.Update(NewConfig); } catch (Exception error) { MessageBox.Show(error.ToString()); } this.Close(); }
private void Form1_Load(object sender, EventArgs e) { try { // VERIFY INTEGRITY OF CONFIG & DATABASE | GET CONFIG INFO Config = Utilities.GetConfigData(); } catch (Exception err) { MessageBox.Show(err.ToString()); } try { InitializeLicensesTTR(); // Check if Licenses are up for renewal WireUpForm1(); } catch (System.Data.SqlClient.SqlException err) { DialogResult dresult = MessageBox.Show(err.Message, "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(); } } }
/// <summary> /// Update all Database Tables /// </summary> /// <param name="Config"></param> /// <param name="DBVer"></param> private static void UpdateDatabase(ConfigClass Config, string DBVer) { try { #region Update Licensed Machines Table DataAccess_LicensedMachinesTable.Update(Config.DBDir_Name, DBVer); #endregion #region Update GData Table #endregion #region Update Change Log Table #endregion } catch (Exception err) { MessageBox.Show($"The was an error! \n {err}"); } MessageBox.Show("Database updated successfully!"); }
/// <summary> /// Do not access this directly! Use Utilities.CheckDatabaseForUpdates /// </summary> /// <param name="Config"></param> /// <returns></returns> public static Version CheckForUpdates(ConfigClass Config) { Version CurrentVersion; // Declare Return Variable // Get the version of the program. The Database should reflect this version if up to date. Version SoftwareVersion = new Version(System.Reflection.Assembly.GetEntryAssembly().GetName().Version.ToString()); #region Check for v1.3 (Renamed 'DateAdded' Column to 'InstallDate') if (!DataAccess_LicensedMachinesTable.ColumnExists(Config.DBDir_Name, "InstallDate") && DataAccess_LicensedMachinesTable.ColumnExists(Config.DBDir_Name, "DateAdded")) { CurrentVersion = new Version("1.2.0.0"); return(CurrentVersion); } #endregion // Add more If's for newer version changes here. // else // Database Should be up to date { return(SoftwareVersion); } }
public bool RenewClicked = false; // Used for the "Renew 1 Yr" button. public EditForm() { InitializeComponent(); Config = Class_Library.Config.Get(); }
public static bool VerifyDatabaseExists(ConfigClass Config) { FileInfo DBFile = new FileInfo(Config.DBDir_Name); return(DBFile.Exists ? true : false); }
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()); } }
public EditForm() { InitializeComponent(); Config = Utilities.GetConfigData(); }