Beispiel #1
0
        public static void CreateLog(List <string> ChangesMade, int AccountIdentifier)
        {
            // GET DB DIRECTORY W/ DB NAME
            ConfigClass Config = Class_Library.Config.Get();

            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.CreateNewLog(NewLog, Config.DBDir_Name);
            }
        }
        private void aButtonSave_Click(object sender, EventArgs e)
        {
            // VERIFY MACHINE DOESN'T EXIST ELSWHERE
            if (Utilities.MachineExist(aTextBoxMachineName.Text, Config.DBDir_Name, out List <int> LicenseIDofDupes) && Config.AllowDuplicateMachines == false)
            {
                // !ERROR!
                MessageBox.Show($"This machine name is already being used by License {LicenseIDofDupes[0].ToString()}. " +
                                $"\nNo duplicates are allowed at this time. Please rename the machine and try again.", "Duplicate!", MessageBoxButtons.OK);
                return;
            }
            else
            {
                LicensedMachines NewMachine = new LicensedMachines();

                // IF DATE INSTALLED IS ENABLED GET DATE
                NewMachine.InstallDate = aDateTimePickerInstalled.Enabled ? aDateTimePickerInstalled.Value.ToShortDateString() : null;

                // GET THE REST OF THE DATA
                NewMachine.MachineName  = aTextBoxMachineName.Text;
                NewMachine.MachineNotes = aTextBoxNotes.Text;
                NewMachine.LicenseId    = LicenseID;

                // UPDATE DATABASE
                DataAccess_LicensedMachinesTable.AddLicensedMachines(NewMachine, Config.DBDir_Name);

                // CREATE NEW MACHINE LOG
                LogClass NewLog = new LogClass();
                NewLog.LicenseId = LicenseID; // Identify which account had the changes.
                DateTime dt = DateTime.Now;   // Get current date/time
                NewLog.Date = dt;
                NewLog.Log  = $"New Machine added: '{NewMachine.MachineName}'";

                // SAVE NEW MACHINE LOG TO LOG DATABASE
                DataAccess_ChangeLogTable.CreateNewLog(NewLog, Config.DBDir_Name);
                Utilities.CloseSQLConnection();
                this.DialogResult = DialogResult.OK;
                this.Close();
            }
        }