Esempio n. 1
0
        private void aButtonManagePCs_Click(object sender, EventArgs e)
        {
            ManagePCsForm _ManagePCsForm = new ManagePCsForm();

            _ManagePCsForm.InputLicense = ChangedLicense; // Set License to be passed in
            DialogResult _form = _ManagePCsForm.ShowDialog();

            if (_form == DialogResult.OK) // When editform.Savebutton is clicked
            {
            }
        }
Esempio n. 2
0
        private void aButtonManagePCs_Click(object sender, EventArgs e)
        {
            ManagePCsForm _ManagePCsForm = new ManagePCsForm();

            _ManagePCsForm.InputLicense = InputLicense; // Set License to be passed in
            DialogResult _form = _ManagePCsForm.ShowDialog();

            if (_form == DialogResult.OK) // When editform.Savebutton is clicked
            {
                Utilities.GetMachineCount_toLabel(InputLicense.Id, Config.DBDir_Name, aLabelMachinesCount);
            }
        }
Esempio n. 3
0
 private void aButtonManagePCs_Click(object sender, EventArgs e)
 {
     try
     {
         ManagePCsForm _ManagePCsForm = new ManagePCsForm();
         _ManagePCsForm.InputLicense = InputLicense; // Set License to be passed in
         DialogResult _form = _ManagePCsForm.ShowDialog();
         if (_form == DialogResult.OK)               // When editform.Savebutton is clicked
         {
             Utilities.GetMachineCount_toLabel(InputLicense.Id, Config.DBDir_Name, aLabelMachinesCount);
         }
     }
     catch (System.Data.SqlClient.SqlException)
     {
         MessageBox.Show("There was a problem connecting to the database." +
                         "\nTo prevent any corruption, the program will restart.", "Login Failed!");
         Utilities.CloseSQLConnection();
         Application.Restart();
     }
 }
        private void aButtonAddLicense_Click(object sender, EventArgs e)
        {
            DataAccess_GDataTable db       = new DataAccess_GDataTable();
            License        NewLicense      = new License();
            AddLicenseForm _AddLicenseForm = new AddLicenseForm();
            DialogResult   _form           = _AddLicenseForm.ShowDialog();

            if (_form == DialogResult.Yes) // SAVE AND ADD MACHINES BUTTON
            {
                // GET NEW LICENSE INFO from add license form
                NewLicense = _AddLicenseForm.OutputLicense();

                // ADD NEW LICENSE TO SQL DB
                if (NewLicense != null)
                {
                    db.CreateNewLicense(NewLicense, Config.DBDir_Name);
                }

                InitializeLicensesTTR();

                // GET CREATED LICENSE FROM DB
                List <License> LatestEntry = new List <License>();
                LatestEntry = db.GetLatestEntry(Config.DBDir_Name);
                // CHECK FOR EMPTY LATESTENTRY
                if (LatestEntry[0].CompanyName == null || LatestEntry[0].FirstName == null && LatestEntry[0].LastName == null)
                {
                    MessageBox.Show("There was an error getting the most recently added license.", "Error!");
                    return;
                }

                // LOG LICENSE CREATION DATE
                List <string> changesmade = new List <string>();
                if (NewLicense.CompanyName == "")
                {
                    changesmade.Add($"License Created for '{LatestEntry[0].FirstName} {LatestEntry[0].LastName}'");
                }
                else
                {
                    changesmade.Add($"License Created for '{LatestEntry[0].CompanyName}'");
                }
                Utilities.CreateLog(changesmade, LatestEntry[0].Id);


                RefreshDashboard(this, e);

                // NEXT STEP: MANAGE MACHINES FORM
                ManagePCsForm _ManagePCsForm = new ManagePCsForm();
                _ManagePCsForm.InputLicense = LatestEntry[0]; // Set License to be passed in
                DialogResult _manageform = _ManagePCsForm.ShowDialog();
                if (_manageform == DialogResult.OK || _manageform == DialogResult.Cancel)
                {
                    RefreshDashboard(this, e);
                }
            }
            if (_form == DialogResult.OK) // SAVE BUTTON
            {
                // COLLECT DATA FROM CREATED LICENSE
                NewLicense = _AddLicenseForm.OutputLicense();

                // Update DB using UpdatedLicense
                if (NewLicense != null)
                {
                    db.CreateNewLicense(NewLicense, Config.DBDir_Name);
                }

                // GET LICENSE CREATED FROM DB
                List <License> NewLicense2 = new List <License>();
                NewLicense2 = db.GetLatestEntry(Config.DBDir_Name);

                // LOG LICENSE CREATION DATE
                List <string> changesmade = new List <string>();
                if (NewLicense.CompanyName == "")
                {
                    changesmade.Add($"License Created for '{NewLicense2[0].FirstName} {NewLicense2[0].LastName}'");
                }
                else
                {
                    changesmade.Add($"License Created for '{NewLicense2[0].CompanyName}'");
                }
                Utilities.CreateLog(changesmade, NewLicense2[0].Id);

                InitializeLicensesTTR();
                RefreshDashboard(this, e);
            }
        }