コード例 #1
0
        /// <summary>
        /// Called to delete the selected license type after confirmation
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void bnDeleteLicenseType_Click(object sender, EventArgs e)
        {
            // Sanity check - ensure that we have an item selected
            if (lvLicenseTypes.SelectedItems.Count == 0)
            {
                return;
            }

            // Get the database object
            LicensesDAO lwDataAccess = new LicensesDAO();

            // First ensure that we do not have any references to this license type as we
            // cannot delete it if we have
            LicenseType deleteLicenseType = lvLicenseTypes.SelectedItems[0].Tag as LicenseType;
            DataTable   references        = lwDataAccess.EnumerateLicenses(deleteLicenseType);

            if (references.Rows.Count != 0)
            {
                MessageBox.Show("Cannot delete this license type as Licenses exist which refer to it.", "Delete Failed");
                return;
            }

            // No references but we should still confirm the delete
            if (MessageBox.Show("Are you certain that you want to delete this license type?", "Confirm Delete", MessageBoxButtons.YesNo) == DialogResult.Yes)
            {
                LicenseTypesDAO licensesTypesDAO = new LicenseTypesDAO();
                licensesTypesDAO.LicenseTypeDelete(deleteLicenseType);
            }

            this.RefreshView();
        }
コード例 #2
0
        /// <summary>
        /// Initialize the data displayed on the license tab
        /// </summary>
        private void InitializeLicenseTab()
        {
            // Load the application license types
            // Populate the list view with the existing license types
            LicenseTypesDAO lwDataAccess      = new LicenseTypesDAO();
            DataTable       licenseTypesTable = lwDataAccess.EnumerateLicenseTypes();

            // Iterate through the returned items
            cbLicenseType.BeginUpdate();
            foreach (DataRow row in licenseTypesTable.Rows)
            {
                LicenseType licenseType = new LicenseType(row);
                cbLicenseType.Items.Add(licenseType, licenseType.Name);
            }
            cbLicenseType.SortStyle = ValueListSortStyle.Ascending;
            cbLicenseType.EndUpdate();

            // OK are we editing an existing definition or trying to create a new one?
            if (_applicationLicense.LicenseID == 0)
            {
                cbLicenseType.SelectedIndex = 0;
                footerPictureBox.Image      = Properties.Resources.application_license_add_corner;
                this.Text = "Add Application License";
            }
            else
            {
                footerPictureBox.Image = Properties.Resources.application_license_edit_corner;
                this.Text = "Edit Application License";
                cbLicenseType.SelectedIndex = cbLicenseType.FindStringExact(_applicationLicense.LicenseTypeName);
                nupLicenseCount.Value       = _applicationLicense.Count;
            }

            tbApplication.Text = _applicationName;
        }
コード例 #3
0
        /// <summary>
        /// Initialize the license types form
        /// </summary>
        private void InitializeLicenseTypes()
        {
            lvLicenseTypes.BeginUpdate();
            lvLicenseTypes.Items.Clear();

            // Populate the list view with the existing license types
            LicenseTypesDAO lwDataAccess      = new LicenseTypesDAO();
            DataTable       licenseTypesTable = lwDataAccess.EnumerateLicenseTypes();

            // Iterate through the returned items
            foreach (DataRow row in licenseTypesTable.Rows)
            {
                LicenseType            licenseType  = new LicenseType(row);
                UltraListViewSubItem[] subItemArray = new UltraListViewSubItem[1];
                subItemArray[0]       = new UltraListViewSubItem();
                subItemArray[0].Value = (licenseType.PerComputer) ? "Yes" : "No";
                UltraListViewItem item = new UltraListViewItem(licenseType.Name, subItemArray);
                item.Tag = licenseType;
                lvLicenseTypes.Items.Add(item);
            }
            lvLicenseTypes.EndUpdate();
        }
コード例 #4
0
ファイル: FormLicenseType.cs プロジェクト: windygu/AW-master
        /// <summary>
        /// Called as want to exit from this form potentially saving the definition or updating
        /// an existing entry
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void bnOK_Click(object sender, EventArgs e)
        {
            if (tbName.Text == "")
            {
                MessageBox.Show("You must enter a name for this new license type");
                DialogResult = DialogResult.None;
                return;
            }

            // If we are creating a new license type then we must ensure that we have specified a
            // name which does not already exist
            LicenseTypesDAO lwDataAccess = new LicenseTypesDAO();

            if (_licenseType.LicenseTypeID == 0)
            {
                int existingID = lwDataAccess.LicenseTypeFind(tbName.Text);
                if (existingID != 0)
                {
                    MessageBox.Show("The License Type " + tbName.Text + " already exists.  Please enter a different name for this new license type", "Duplicate Name");
                    DialogResult = DialogResult.None;
                    return;
                }

                // OK all valid so add this new entry
                _licenseType.Name        = tbName.Text;
                _licenseType.PerComputer = cbPerPC.Checked;
                //
                _licenseType.LicenseTypeID = lwDataAccess.LicenseTypeAdd(_licenseType);
            }

            else
            {
                // Update the existing definition
                _licenseType.PerComputer = cbPerPC.Checked;
                lwDataAccess.LicenseTypeUpdate(_licenseType);
            }
        }