Exemplo n.º 1
0
        public void InitializeLicensesTTR() // Determine if licenses are up for renewal
        {
            List <License>        AllLicenses = new List <License>();
            DataAccess_GDataTable db          = new DataAccess_GDataTable();

            try
            {
                AllLicenses = db.GetAllData(Config.DBDir_Name);
            }
            catch (Exception err) // GetAllData failed
            {
            }


            foreach (License _License in AllLicenses)
            {
                //DateTime ExpDate = DateTime.Parse(_License.ExpirationDate);
                if (DateTime.Now >= _License.ExpirationDate.AddDays(-(Convert.ToInt32(Config.TimeToRenew))) && _License.Active == true && _License.RenewalStatus == "Renewed") // If it expires within 21 days and is currently active
                {
                    _License.ReviewStatus  = "Open";
                    _License.RenewalStatus = "";
                    db.UpdateLicenseData(_License, Config.DBDir_Name);
                }
            }
            Utilities.CloseSQLConnection();
        }
Exemplo n.º 2
0
        private void aComboboxSortBy_SelectedIndexChanged(object sender, EventArgs e)
        {
            DataAccess_GDataTable db = new DataAccess_GDataTable();

            Class_Library.DataGridView.DGVSortInfo SavedSortation = new Class_Library.DataGridView.DGVSortInfo();
            SavedSortation = DGVUtilities.GetSortation(aDataGridViewLicenses);
            if (aComboboxSortBy.SelectedItem.ToString() == "Opened Licenses")
            {
                Utilities.EnableSearch(aButtonSearch, aTextBoxSearch, aLabelSearch, false);
                LicensesDGV = db.GetByReviewStatus("Open", Config.DBDir_Name);
                BindingListView <License> SortableLicensesDGV = new BindingListView <License>(LicensesDGV);
                aDataGridViewLicenses.DataSource = SortableLicensesDGV;
                aLabelLicenseFoundInt.Text       = aDataGridViewLicenses.Rows.Count.ToString();
            }
            if (aComboboxSortBy.SelectedItem.ToString() == @"Search by Name\Id")
            {
                Utilities.EnableSearch(aButtonSearch, aTextBoxSearch, aLabelSearch, true);
            }
            if (aComboboxSortBy.SelectedItem.ToString() == "Search by Machine Name")
            {
                Utilities.EnableSearch(aButtonSearch, aTextBoxSearch, aLabelSearch, true);
            }
            if (aComboboxSortBy.SelectedItem.ToString() == "All Licenses")
            {
                Utilities.EnableSearch(aButtonSearch, aTextBoxSearch, aLabelSearch, false);

                LicensesDGV = db.GetAllData(Config.DBDir_Name);
                BindingListView <License> SortableLicensesDGV = new BindingListView <License>(LicensesDGV);
                aDataGridViewLicenses.DataSource = SortableLicensesDGV;
                aLabelLicenseFoundInt.Text       = aDataGridViewLicenses.Rows.Count.ToString();
            }
            DGVUtilities.SetSortation(SavedSortation, aDataGridViewLicenses);
            Utilities.CloseSQLConnection();
        }
Exemplo n.º 3
0
        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();
        }
        /// <summary>
        /// This is only used when the DB structure has changed.
        /// </summary>
        /// <param name="OldDBDir"></param>
        /// <param name="NewDBDir"></param>
        public void MoveDBtoNewDB(string OldDBDir, string NewDBDir)
        {
            DataAccess_GDataTable db             = new DataAccess_GDataTable();
            List <License>        OldLicenseData = db.GetAllData(OldDBDir);


            for (int i = 0; i < OldLicenseData.Count; i++)
            {
                foreach (License _Lic in OldLicenseData)
                {
                    if (_Lic.Id == i)
                    {
                        string   _CompanyName      = Utilities.CorrectApostropheForSQL(_Lic.CompanyName);
                        string   _FirstName        = Utilities.CorrectApostropheForSQL(_Lic.FirstName);
                        string   _LastName         = Utilities.CorrectApostropheForSQL(_Lic.LastName);
                        string   _ReviewStatus     = _Lic.ReviewStatus;
                        DateTime ExpDate           = _Lic.ExpirationDate;
                        int      _PCCount          = _Lic.PCCount;
                        string   _RenewalStatus    = _Lic.RenewalStatus;
                        bool     _Active           = _Lic.Active;
                        string   _Notes            = Utilities.CorrectApostropheForSQL(_Lic.Notes);
                        int      _ID               = _Lic.Id;
                        bool     _ChkBxWillCancel  = _Lic.ChkBxWillCancel;
                        bool     _ChkBxUninstalled = _Lic.ChkBxUninstalled;
                        bool     _ChkBxDeleted     = _Lic.ChkBxDeleted;

                        // Create command for SQL server
                        SqlConnection sqlConnection1 = new SqlConnection((Helper.CnnValCustom(NewDBDir)));
                        SqlDataReader reader;
                        SqlCommand    command = new SqlCommand();
                        command.CommandText = $"INSERT INTO GDataTable (ReviewStatus, CompanyName, FirstName, LastName, ExpirationDate, PCCount, RenewalStatus, Active, Notes) VALUES ('{_ReviewStatus}', '{_CompanyName}', '{_FirstName}', '{_LastName}', '{ExpDate}', '{_PCCount}', '{_RenewalStatus}', '{_Active}', '{_Notes}','{_ChkBxWillCancel}','{_ChkBxUninstalled}','{_ChkBxDeleted}')";
                        command.CommandType = CommandType.Text;
                        command.Connection  = sqlConnection1;

                        sqlConnection1.Open();
                        reader = command.ExecuteReader();

                        sqlConnection1.Close();
                    }
                }
            }
        }