Beispiel #1
0
        private void FormUserDataEdit_Load(object sender, EventArgs e)
        {
            // Read the picklist definitions
            _listPickLists = new PickListList();
            _listPickLists.Populate();

            // Read ALL user data categories
            _userDataCategories.Populate();

            // Suspend layout of the tab control until we have finished
            dataTabControl.SuspendLayout();

            // Create a tab for each category which is pertinent for this asset
            foreach (UserDataCategory category in _userDataCategories)
            {
                // Is this category applicable to this asset?
                // If so add a new tab to the control
                if (category.CategoryAppliesTo(_asset))
                {
                    category.GetValuesFor(_asset.AssetID);
                    AddCategory(category);
                }
            }

            // Ensure that the first tab is selected
            dataTabControl.Tabs[0].Selected = true;

            // Resume layout
            dataTabControl.ResumeLayout();
        }
Beispiel #2
0
        /// <summary>
        /// Called as we try to save the picklist - ensure that the name specified does not duplicate an
        /// existing item and if OK save back to the database
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void bnOK_Click(object sender, EventArgs e)
        {
            // If the name is blank then it will be invalid
            if (this.tbPickListName.Text == "")
            {
                MessageBox.Show("Please specify a unique name for this picklist", "Enter Name", MessageBoxButtons.OK, MessageBoxIcon.Information);
                tbPickListName.Focus();
                this.DialogResult = DialogResult.None;
                return;
            }

            // Does the specified value dupliacte an existing picklist?
            PickListList listPickLists = new PickListList();

            listPickLists.Populate();
            //
            foreach (PickList list in listPickLists)
            {
                if (list.Name == this.tbPickListName.Text)
                {
                    // OK the names duplicate but is this in fact the same entry?
                    if (list.PicklistID == _pickList.PicklistID)
                    {
                        continue;
                    }

                    // Nope the name duplicates an existing entry so we can't save it
                    MessageBox.Show("The specified name matches that of an existing picklist, please specify a unique name for this picklist", "Invalid PickList Name");
                    tbPickListName.Focus();
                    this.DialogResult = DialogResult.None;
                    return;
                }
            }

            // All OK - update the picklist here and in the database and also any related user-defined data fields
            UserDataCategoryList listCategories = new UserDataCategoryList(UserDataCategory.SCOPE.Any);

            listCategories.Populate();

            foreach (UserDataCategory category in listCategories)
            {
                foreach (UserDataField field in category)
                {
                    if ((field.Type == UserDataField.FieldType.Picklist) && (field.Value1 == _pickList.Name))
                    {
                        field.Value1 = tbPickListName.Text;
                        field.Update();
                    }
                }
            }

            _pickList.Name = tbPickListName.Text;
            _pickList.Update();
        }
Beispiel #3
0
        private void UpdateInteractivePicklists()
        {
            auditScannerDefinition.InteractivePicklists.Clear();
            PickListList listPickLists = new PickListList();

            listPickLists.Populate();

            foreach (PickList picklist in listPickLists)
            {
                InteractivePickList lInteractivePickList = new InteractivePickList();
                lInteractivePickList.Name          = picklist.Name;
                lInteractivePickList.PickListItems = picklist;

                auditScannerDefinition.InteractivePicklists.Add(lInteractivePickList);
            }
        }
Beispiel #4
0
        /// <summary>
        /// Create a label and input control for a Boolean field
        /// </summary>
        protected void CreatePicklistField(UserDataField dataField, out Label label, out Control control)
        {
            // Do we already have the picklists read?  If not then do so now
            _listPickLists = new PickListList();
            _listPickLists.Populate();

            // Create the label;
            label = new Label {
                Text = dataField.Name, AutoSize = true, Size = new Size(labelWidth, 13)
            };

            // Create a combobox with values taken from the picklist
            ComboBox combo = new ComboBox();

            control             = combo;
            combo.DropDownStyle = ComboBoxStyle.DropDownList;

            // Get the picklist which is in use and add the pickitems to the combo
            PickList picklist = _listPickLists.FindPickList(dataField.Picklist);

            if (picklist != null)
            {
                int maxWidth = 0;
                foreach (PickItem pickitem in picklist)
                {
                    if ((pickitem.Name.Length * 7) > maxWidth)
                    {
                        maxWidth = pickitem.Name.Length * 7;
                    }
                    combo.Items.Add(pickitem);
                }

                combo.Width = maxWidth + 25;
            }

            int index = combo.FindStringExact(dataField.GetValueFor(_installedApplication.ApplicationID));

            combo.SelectedIndex = (index != -1) ? index : -1;
        }
Beispiel #5
0
        /// <summary>
        /// Create a label and input control for a Boolean field
        /// </summary>
        /// <param name="dataField"></param>
        protected void CreatePicklistField(UserDataField dataField, out Label label, out Control control)
        {
            // Do we already have the picklists read?  If not then do so now
            if (_listPickLists == null)
            {
                _listPickLists = new PickListList();
                _listPickLists.Populate();
            }

            // Create the label;
            label          = new Label();
            label.Text     = dataField.Name;
            label.AutoSize = true;

            // Create a combobox with values taken from the picklist
            ComboBox combo = new ComboBox();

            control             = combo;
            combo.DropDownStyle = ComboBoxStyle.DropDownList;

            // Get the picklist which is in use and add the pickitems to the combo
            PickList picklist = _listPickLists.FindPickList(dataField.Picklist);

            if (picklist != null)
            {
                foreach (PickItem pickitem in picklist)
                {
                    combo.Items.Add(pickitem);
                }
            }

            // Set the current selection (if any)
            int index = combo.FindStringExact(dataField.GetValueFor(_asset.AssetID));

            if (index != -1)
            {
                combo.SelectedIndex = index;
            }
        }
Beispiel #6
0
        private void InitializeForm()
        {
            // Create the list of user data categories given the appropriate type from that supplied
            _listCategories = new UserDataCategoryList(_category.Scope);

            // Populate the 'Categories' combo with possible values
            _listCategories.Populate();
            foreach (UserDataCategory availableCategory in _listCategories)
            {
                ValueListItem item = cbCategories.Items.Add(availableCategory, availableCategory.Name);
                if (availableCategory.CategoryID == _category.CategoryID)
                {
                    cbCategories.SelectedItem = item;
                }
            }

            // Set the form title
            Text  = (_field.FieldID == 0) ? "New User Data Field" : "User Data Field Properties";
            Text += " [" + _category.ScopeAsString + "]";

            // Populate the 'Type' combo with possible types
            Dictionary <UserDataField.FieldType, string> fieldTypes = _field.FieldTypes;

            foreach (KeyValuePair <UserDataField.FieldType, string> kvp in fieldTypes)
            {
                cbFieldType.Items.Add(kvp.Key, kvp.Value);
            }

            // Populate the Case Combo with possible input cases
            Dictionary <UserDataField.FieldCase, string> fieldCases = _field.FieldInputCases;

            foreach (KeyValuePair <UserDataField.FieldCase, string> kvp in fieldCases)
            {
                InputCase.Items.Add(kvp.Key, kvp.Value);
            }
            InputCase.SelectedIndex = 0;

            // Populate the Picklists combo with the names of any picklists that have been defined
            PickListList picklists = new PickListList();

            picklists.Populate();
            foreach (PickList picklist in picklists)
            {
                Picklist.Items.Add(picklist, picklist.Name);
            }

            if (Picklist.Items.Count != 0)
            {
                Picklist.SelectedIndex = 0;
            }

            // Set the initial data
            tbFieldName.Text = _field.Name;

            //TabOrder.Value = field.TabOrder;
            cbMandatory.Checked          = _field.IsMandatory;
            cbInteractiveInclude.Checked = (_field.ParentScope == UserDataCategory.SCOPE.Asset);

            // Set the field type in the combo box
            int selectedIndex = cbFieldType.FindStringExact(fieldTypes[_field.Type]);

            cbFieldType.SelectedIndex = selectedIndex == -1 ? 0 : selectedIndex;

            // The remainder of the fields depend on the field type
            switch ((int)_field.Type)
            {
            // For text fields the input length is stored in 'Value1' and Input Case encoded into Value2
            case (int)UserDataField.FieldType.Text:

                selectedIndex           = InputCase.FindStringExact(_field.InputCase == "title" ? "TitleCase" : _field.InputCase);
                InputCase.SelectedIndex = (selectedIndex == -1) ? 0 : selectedIndex;
                break;

            // Numeric fields - Minimum is 'Value1' Maximum is 'Value2'
            case (int)UserDataField.FieldType.Number:
                break;

            // For a picklist, the name of the picklist (if any) is stored in 'Value1'
            case (int)UserDataField.FieldType.Picklist:
                selectedIndex          = (Picklist.FindStringExact(_field.Picklist));
                Picklist.SelectedIndex = (selectedIndex == -1) ? 0 : selectedIndex;
                break;

            // Environment Variable - the permitted length is stored as 'Value1' with the name of the variable
            // in question stored as 'Value2'
            case (int)UserDataField.FieldType.Environment:
                tbEnvironmentVariableName.Text = _field.EnvironmentVariable;
                break;

            // Registry Keys : The Key name is stored as value1 with the value name as Value2
            case (int)UserDataField.FieldType.Registry:
                tbRegistryKey.Text   = _field.RegistryKey;
                tbRegistryValue.Text = _field.RegistryValue;
                break;

            //// Boolean Fields - no additional fields required
            //case (int)UserDataField.FieldType.boolean:
            //    break;

            // Date Fields - no additional fields required
            case (int)UserDataField.FieldType.Date:
                break;

            // Currency Fields - no additional fields required
            case (int)UserDataField.FieldType.Currency:
                break;

            default:
                MessageBox.Show("An invalid type has been identified in the User Data Field Definition");
                break;
            }
        }