Esempio n. 1
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.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;
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Create a label and input control for a Numeric field
        /// </summary>
        protected void CreateNumberField(UserDataField dataField, out Label label, out Control control)
        {
            // Create the label;
            label = new Label {
                Text = dataField.Name, AutoSize = true, Size = new Size(labelWidth, 13)
            };

            NumericUpDown nup = new NumericUpDown {
                TextAlign = HorizontalAlignment.Left, Width = 110
            };

            control     = nup;
            nup.Maximum = Decimal.MaxValue;
            nup.Minimum = Decimal.MinValue;

            //NumericUpDown numericUpDown = (NumericUpDown)dataField.Tag;
            try
            {
                nup.Value = Convert.ToDecimal(dataField.GetValueFor(_installedApplication.ApplicationID));
            }
            catch (FormatException)
            {
                nup.Value = 0;
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Create a label and input control for a Date field
        /// </summary>
        protected void CreateDateField(UserDataField dataField, out Label label, out Control control)
        {
            // Create the label;
            label = new Label {
                Text = dataField.Name, AutoSize = true, Size = new Size(labelWidth, 13)
            };

            // Create a Date/Time Picker
            NullableDateTimePicker nullableDateTime = new NullableDateTimePicker();

            nullableDateTime.Value        = null;
            nullableDateTime.Format       = DateTimePickerFormat.Custom;
            nullableDateTime.CustomFormat = "yyyy-MM-dd";
            nullableDateTime.Width        = 110;

            try
            {
                DateTime value = Convert.ToDateTime(dataField.GetValueFor(_installedApplication.ApplicationID));
                nullableDateTime.Value = value;
            }
            catch (FormatException)
            {
                nullableDateTime.Value = null;
            }

            control = nullableDateTime;
        }
Esempio n. 4
0
        /// <summary>
        /// Create a label and input control for a Currency field
        /// </summary>
        protected void CreateCurrencyField(UserDataField dataField, out Label label, out Control control)
        {
            // Create the label;
            label = new Label {
                Text = dataField.Name, AutoSize = true, Size = new Size(labelWidth, 13)
            };

            // Create a Currency control
            UltraCurrencyEditor currencyEditor = new UltraCurrencyEditor();

            currencyEditor.Value        = 0;
            currencyEditor.MaskClipMode = MaskMode.Raw;
            currencyEditor.PromptChar   = ' ';
            currencyEditor.Width        = 110;
            control = currencyEditor;

            try
            {
                currencyEditor.Value = Convert.ToDecimal(dataField.GetValueFor(_installedApplication.ApplicationID));
            }
            catch (FormatException)
            {
                currencyEditor.Value = 0;
            }
        }
Esempio n. 5
0
        /// <summary>
        /// Gets all available data values for the specifed USER DATA field.  In this case we need to know
        /// for each asset any value specified for the supplied User Data field.
        /// </summary>
        /// <param name="reportColumn"></param>
        protected void GetUserDataFieldValues(AssetList cachedAssetList, AuditDataReportColumn reportColumn)
        {
            // the user data field name is formatted as User Data | Category | Field
            List <string> fieldParts   = Utility.ListFromString(reportColumn.FieldName, '|', true);
            string        categoryName = fieldParts[1];
            string        fieldName    = fieldParts[2];
            //
            UserDataCategory userDataCategory = _cachedUserDataList.FindCategory(categoryName);

            if (userDataCategory == null)
            {
                return;
            }
            //
            UserDataField userDataField = userDataCategory.FindField(fieldName);

            if (userDataField == null)
            {
                return;
            }

            // Query the database for the possible values for this user defined data field
            userDataField.PopulateValues();

            // ...now loop through the assets and get the fiekld value for each where available
            foreach (Asset asset in cachedAssetList)
            {
                string value = userDataField.GetValueFor(asset.AssetID);
                reportColumn.Values.Add(new AuditDataReportColumnValue(value, asset.Name, asset.AssetID, asset.Location));
            }
        }
Esempio n. 6
0
        /// <summary>
        /// Create a label and input control for a textual field
        /// </summary>
        protected void CreateTextField(UserDataField dataField, out Label label, out Control control)
        {
            // Create the label;
            label          = new Label();
            label.Text     = dataField.Name;
            label.AutoSize = true;
            label.Size     = new Size(labelWidth, 13);

            // Create a textbox and set any requirements
            TextBox textbox = new TextBox();

            control      = textbox;
            textbox.Size = new Size(textWidth, 20);
            textbox.Tag  = dataField.FieldID;

            switch (dataField.InputCase)
            {
            case "any":
                break;

            case "lower":
                textbox.CharacterCasing = CharacterCasing.Lower;
                break;

            case "upper":
                textbox.CharacterCasing = CharacterCasing.Upper;
                break;

            case "title":
                textbox.LostFocus += textBox_TextChanged;
                break;
            }
        }
Esempio n. 7
0
        /// <summary>
        /// Create a label and input control for a Numeric field
        /// </summary>
        /// <param name="dataField"></param>
        protected void CreateNumberField(UserDataField dataField, out Label label, out Control control)
        {
            // Create the label;
            label      = new Label();
            label.Text = dataField.Name;

            // Create a NumericUpDown field and set any limits
            NumericUpDown nup = new NumericUpDown();

            control     = nup;
            nup.Minimum = dataField.MinimumValue;
            nup.Maximum = dataField.MaximumValue;

            // Set its value
            decimal lValue = dataField.NumericValue(_asset.AssetID);

            if (lValue > nup.Maximum)
            {
                nup.Value = nup.Maximum;
            }
            else
            {
                nup.Value = lValue;
            }
        }
Esempio n. 8
0
        /// <summary>
        /// Update a specific user data field value
        /// </summary>
        /// <param name="field"></param>
        /// <param name="control"></param>
        private void UpdateUserDataFieldValue(UserDataField dataField)
        {
            string  newValue;
            Control control = dataField.Tag as Control;

            // The data value depends on the field type
            switch ((int)dataField.Type)
            {
            //case (int)UserDataField.FieldType.boolean:
            //    ComboBox comboBoolean = (ComboBox)control;
            //    newValue = (comboBoolean.SelectedIndex == -1) ? "" : comboBoolean.SelectedText;
            //    break;

            //case (int)UserDataField.FieldType.date:
            //    NullableDateTimePicker nullableDateTime = (NullableDateTimePicker)control;
            //    newValue = (nullableDateTime.Value == null) ? null : nullableDateTime.Value.ToString();
            //    break;

            case (int)UserDataField.FieldType.Number:
                NumericUpDown nup = (NumericUpDown)control;
                newValue = nup.Value.ToString();
                break;

            case (int)UserDataField.FieldType.Picklist:
                ComboBox comboPicklist = (ComboBox)control;
                newValue = (comboPicklist.SelectedIndex == -1) ? "" : comboPicklist.Text;
                break;

            case (int)UserDataField.FieldType.Text:
                TextBox textbox = (TextBox)control;
                newValue = textbox.Text;
                break;

            case (int)UserDataField.FieldType.Environment:
                TextBox textbox1 = (TextBox)control;
                newValue = textbox1.Text;
                break;

            case (int)UserDataField.FieldType.Registry:
                TextBox textbox2 = (TextBox)control;
                newValue = textbox2.Text;
                break;

            default:
                newValue = "";
                break;
            }

            // Has the value changed from that currently stored?
            if (newValue != dataField.GetValueFor(_asset.AssetID))
            {
                dataField.SetValueFor(_asset.AssetID, newValue, true);
            }
        }
Esempio n. 9
0
        public FormUserDataField(UserDataCategory category, UserDataField field, bool editing)
        {
            InitializeComponent();
            _category     = category;
            _field        = field;
            _editing      = editing;
            _existingType = field.Type;

            cbInteractiveInclude.Visible = cbMandatory.Visible = (_category.Scope != UserDataCategory.SCOPE.Application);

            InitializeForm();
        }
Esempio n. 10
0
        public dynamic CanWidthdraw(string email, double amount)
        {
            UserDataField sender = api.GetDashboardData(email);

            if (sender == null)     // unsuccessful
            {
                return("Network Connection, -1");
            }
            else
            {
                return(sender.Withdrawalable < amount ? "no" : "yes");
            }
        }
Esempio n. 11
0
        public dynamic GetDashboardData(string email)
        {
            UserDataField res = api.GetDashboardData(email);

            if (res == null)     // unsuccessful
            {
                return("Network Connection,-1");
            }
            else
            {
                return(res);
            }
        }
Esempio n. 12
0
        private void UpdateFieldsTabOrder()
        {
            UserDataDefinitionsDAO lUserDataDefinitionsDao = new UserDataDefinitionsDAO();

            for (int i = 0; i < ulvUserData.Items.Count; i++)
            {
                UserDataField udf = ulvUserData.Items[i].Tag as UserDataField;
                if (udf != null)
                {
                    udf.TabOrder = i;
                    lUserDataDefinitionsDao.UserDataFieldUpdate(udf);
                }
            }
        }
        /// <summary>
        /// Add a user defined data field and its value.
        ///
        /// First locate the specified asset (or create a new one if this does not exist)
        /// Locate the user defined data field (or create a new one if this does not exist)
        /// Set the value for the field given its ID and asset
        ///
        /// </summary>
        /// <param name="lvi"></param>
        private void AddUserDataField(UltraListViewItem lvi)
        {
            AssetDAO lwDataAccess = new AssetDAO();

            // Recover the data fields
            string assetName = lvi.Text;
            string category  = lvi.SubItems[2].Text;

            if (category == "Asset Data")
            {
                category = "General";
            }
            string fieldName  = lvi.SubItems[0].Text;
            string fieldValue = lvi.SubItems[1].Text;

            // Does the Asset exist?
            // Note that as we only have an asset name we can only possibly match on that
            int assetID = lwDataAccess.AssetFind(assetName);

            // If the asset exists then add the history record for it
            if (assetID != 0)
            {
                // Does the User Data Category exist?  If not create it also
                UserDataCategory parentCategory = _listCategories.FindCategory(category);
                if (parentCategory == null)
                {
                    parentCategory      = new UserDataCategory(UserDataCategory.SCOPE.Asset);
                    parentCategory.Name = category;
                    parentCategory.Add();
                    _listCategories.Add(parentCategory);
                }


                // Now look at the User Data Field and see if we have one already with this name
                UserDataField thisField = parentCategory.FindField(fieldName);
                if (thisField == null)
                {
                    // No existing field of this name in the General Category so add it
                    thisField          = new UserDataField();
                    thisField.ParentID = parentCategory.CategoryID;
                    thisField.Name     = fieldName;
                    thisField.Add();
                    parentCategory.Add(thisField);
                }

                // ...and set the value for the asset both here and in the database
                thisField.SetValueFor(assetID, fieldValue, true);
            }
        }
Esempio n. 14
0
        /// <summary>
        /// Create a label and input control for a Boolean field
        /// </summary>
        protected void CreateBooleanField(UserDataField dataField, out Label label, out Control control)
        {
            // Create the label;
            label = new Label {
                Text = dataField.Name, Size = new Size(labelWidth, 13)
            };

            // Create a combobox with True and False values
            ComboBox combo = new ComboBox();

            control             = combo;
            combo.DropDownStyle = ComboBoxStyle.DropDownList;
            combo.Items.Add("True");
            combo.Items.Add("False");
        }
Esempio n. 15
0
        /// <summary>
        /// Create a label and input control for a textual field
        /// </summary>
        protected void CreateEnvironmentOrRegistryField(UserDataField dataField, out Label label, out Control control)
        {
            // Create the label;
            label = new Label {
                Text = dataField.Name, AutoSize = true, Size = new Size(labelWidth, 13)
            };

            // Create a textbox and set any requirements
            TextBox textbox = new TextBox();

            control         = textbox;
            textbox.Size    = new Size(textWidth, 20);
            textbox.Tag     = dataField.FieldID;
            textbox.Enabled = false;
        }
Esempio n. 16
0
        /// <summary>
        /// Create a label and input control for a Numeric field
        /// </summary>
        protected void CreateNumberField(UserDataField dataField, out Label label, out Control control)
        {
            // Create the label;
            label = new Label {
                Text = dataField.Name, AutoSize = true, Size = new Size(labelWidth, 13)
            };

            NumericUpDown nup = new NumericUpDown {
                TextAlign = HorizontalAlignment.Left, Width = 110
            };

            nup.Maximum = Decimal.MaxValue;
            nup.Minimum = Decimal.MinValue;
            control     = nup;
        }
Esempio n. 17
0
        /// <summary>
        /// Create a label and input control for a Currency field
        /// </summary>
        protected void CreateCurrencyField(UserDataField dataField, out Label label, out Control control)
        {
            // Create the label;
            label = new Label {
                Text = dataField.Name, AutoSize = true, Size = new Size(labelWidth, 13)
            };

            // Create a Currency control
            UltraCurrencyEditor currencyEditor = new UltraCurrencyEditor();

            currencyEditor.Value        = 0;
            currencyEditor.MaskClipMode = MaskMode.Raw;
            currencyEditor.PromptChar   = ' ';
            currencyEditor.Width        = 110;
            control = currencyEditor;
        }
Esempio n. 18
0
        /// <summary>
        /// Create a label and input control for a Date field
        /// </summary>
        protected void CreateDateField(UserDataField dataField, out Label label, out Control control)
        {
            // Create the label;
            label = new Label {
                Text = dataField.Name, AutoSize = true, Size = new Size(labelWidth, 13)
            };

            // Create a Date/Time Picker
            NullableDateTimePicker nullableDateTime = new NullableDateTimePicker();

            nullableDateTime.Value        = null;
            nullableDateTime.Format       = DateTimePickerFormat.Custom;
            nullableDateTime.CustomFormat = "yyyy-MM-dd";
            nullableDateTime.Width        = 110;

            control = nullableDateTime;
        }
Esempio n. 19
0
        /// <summary>
        /// Create a label and input control for a Boolean field
        /// </summary>
        /// <param name="dataField"></param>
        protected void CreateBooleanField(UserDataField dataField, out Label label, out Control control)
        {
            // Create the label;
            label      = new Label();
            label.Text = dataField.Name;

            // Create a combobox with True and False values
            ComboBox combo = new ComboBox();

            control             = combo;
            combo.DropDownStyle = ComboBoxStyle.DropDownList;
            combo.Items.Add("True");
            combo.Items.Add("False");

            // Set its value
            combo.SelectedIndex = (dataField.BooleanValue(_asset.AssetID)) ? 0 : 1;
        }
Esempio n. 20
0
        /// <summary>
        /// Add a new User Data Field
        /// </summary>
        protected void AddUserDataField()
        {
            if (_activeItem != null)
            {
                UserDataCategory userDataCategory = _activeItem.Tag as UserDataCategory;
                UserDataField    field            = new UserDataField();
                field.Name        = "<new field>";
                field.ParentID    = userDataCategory.CategoryID;
                field.ParentScope = userDataCategory.Scope;

                // ...and display a foerm to create this new field
                FormUserDataField form = new FormUserDataField(userDataCategory, field, false);
                if (form.ShowDialog() == DialogResult.OK)
                {
                    RefreshTab();
                }
            }
        }
Esempio n. 21
0
        /// <summary>
        /// Create a label and input control for a Boolean field
        /// </summary>
        /// <param name="dataField"></param>
        protected void CreateBooleanField(UserDataField dataField, out Label label, out Control control)
        {
            // Create the label;
            label      = new Label();
            label.Text = dataField.Name;
            label.Size = new System.Drawing.Size(labelWidth, 13);

            // Create a combobox with True and False values
            ComboBox combo = new ComboBox();

            control             = combo;
            combo.DropDownStyle = ComboBoxStyle.DropDownList;
            combo.Items.Add("True");
            combo.Items.Add("False");

            // Set its value
            combo.SelectedIndex = (dataField.BooleanValue(_installedApplication.ApplicationID)) ? 0 : 1;
        }
Esempio n. 22
0
 public override bool PrepareRun(Database.DBCon db, string tableName)
 {
     _value         = 0.0;
     _option        = Option.Value;
     _userDataField = UserDataField.UserData;
     if (Values.Count > 0)
     {
         _value = Utils.Conversion.StringToDouble(Values[0]);
     }
     if (Values.Count > 1)
     {
         _option = (Option)Enum.Parse(typeof(Option), Values[1]);
     }
     if (Values.Count > 2)
     {
         _userDataField = (UserDataField)Enum.Parse(typeof(UserDataField), Values[2]);
     }
     return(base.PrepareRun(db, tableName));
 }
 public override bool PrepareRun(Database.DBCon db, string tableName)
 {
     _value         = "";
     _option        = Option.Contains;
     _userDataField = UserDataField.UserData;
     if (Values.Count > 0)
     {
         _value = Values[0];
     }
     if (Values.Count > 1)
     {
         _option = (Option)Enum.Parse(typeof(Option), Values[1]);
     }
     if (Values.Count > 2)
     {
         _userDataField = (UserDataField)Enum.Parse(typeof(UserDataField), Values[2]);
     }
     return(base.PrepareRun(db, tableName));
 }
Esempio n. 24
0
        /// <summary>
        /// Create a label and input control for a Date field
        /// </summary>
        /// <param name="dataField"></param>
        protected void CreateDateField(UserDataField dataField, out Label label, out Control control)
        {
            // Create the label;
            label          = new Label();
            label.Text     = dataField.Name;
            label.AutoSize = true;

            // Create a Date/Time Picker
            NullableDateTimePicker nullableDateTime = new NullableDateTimePicker();

            nullableDateTime.Value = null;
            control = nullableDateTime;

            // Set its value
            if (dataField.DateValue(_asset.AssetID) != "")
            {
                nullableDateTime.Value = Convert.ToDateTime(dataField.DateValue(_asset.AssetID));
            }
        }
Esempio n. 25
0
        /// <summary>
        /// Delete the selected user data field(s)
        /// </summary>
        protected void DeleteUserDataField()
        {
            if (ulvUserData.SelectedItems.Count == 0)
            {
                return;
            }

            // Confirm the deletion
            if (MessageBox.Show(
                    "Are you sure that you want to delete this User Data Field? " + Environment.NewLine + Environment.NewLine +
                    "Deleting the field will remove the definition and will delete all instances of this field from all assets.",
                    "Confirm Delete", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) !=
                DialogResult.Yes)
            {
                return;
            }

            // Delete this user data field
            UltraListViewItem lvi   = ulvUserData.SelectedItems[0];
            UserDataField     field = lvi.Tag as UserDataField;

            if (field != null)
            {
                if (!field.Delete())
                {
                    MessageBox.Show("Failed to delete the selected User Data Field", "Delete Failed");
                }
                else
                {
                    if (_activeItem != null)
                    {
                        UserDataCategory userDataCategory = _activeItem.Tag as UserDataCategory;
                        if (userDataCategory != null)
                        {
                            userDataCategory.Remove(field);
                            RefreshList(userDataCategory);
                            UpdateFieldsTabOrder();
                        }
                    }
                }
            }
        }
Esempio n. 26
0
        public dynamic TransferAmount(string emailfrom, string emailto, string customerIDto, double amount)
        {
            //1- get withdrawalable amount of sender
            //2-  substract it from current withdrawalable
            //3-     add it to the receiver's withdrawalable; having customerID && emailto

            if (CanWidthdraw(emailfrom, amount) == "no")
            {
                return("Not possibile to withdraw!");
            }

            if (api.ValidReceiver(emailto, customerIDto) == null)
            {
                return("Invalid Receiver infomation");
            }


            // step#1-to-2 => updateWithdrawal
            // step# => update Receiver's withdrawal

            UserDataField sender   = api.GetDashboardData(emailfrom);
            UserDataField receiver = api.GetDashboardData(emailto);

            if (sender == null)     // unsuccessful
            {
                return("Network Connection, -1");
            }
            if (receiver == null)
            {
                return("Network connection, -1");
            }

            double SenderUpdatedWithdrawalableAmount = sender.Withdrawalable - amount;                  // 70
            var    res1 = api.UpdateWithdrawalableAmount(emailfrom, SenderUpdatedWithdrawalableAmount); //step#1,2


            double ReceiverUpdatedWithdrawalableAmount = receiver.Withdrawalable + amount;
            var    res2 = api.UpdateWithdrawalableAmount(emailto, ReceiverUpdatedWithdrawalableAmount); // get the oldWithdrawal then add this amount and then update


            return("Successfully tranfered amount Rs. " + amount + " from " + emailfrom + " To " + emailto + " having " + customerIDto);
        }
Esempio n. 27
0
        /// <summary>
        /// Called to edit the currently selected user data field definition
        /// </summary>
        protected void EditUserDataField()
        {
            if (ulvUserData.SelectedItems.Count == 0)
            {
                return;
            }

            // Get the currently selected user data field
            if (_activeItem != null)
            {
                UserDataCategory  userDataCategory = _activeItem.Tag as UserDataCategory;
                UltraListViewItem lvi   = ulvUserData.SelectedItems[0];
                UserDataField     field = lvi.Tag as UserDataField;

                // ...and display it's properties
                FormUserDataField form = new FormUserDataField(userDataCategory, field, true);
                if (form.ShowDialog() == DialogResult.OK)
                {
                    RefreshTab();
                }
            }
        }
Esempio n. 28
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;
            }
        }
 public override bool PrepareRun(Database.DBCon db, string tableName)
 {
     _value = 0.0;
     _option = Option.Value;
     _userDataField = UserDataField.UserData;
     if (Values.Count > 0)
     {
         _value = Utils.Conversion.StringToDouble(Values[0]);
     }
     if (Values.Count > 1)
     {
         _option = (Option)Enum.Parse(typeof(Option), Values[1]);
     }
     if (Values.Count > 2)
     {
         _userDataField = (UserDataField)Enum.Parse(typeof(UserDataField), Values[2]);
     }
     return base.PrepareRun(db, tableName);
 }
Esempio n. 30
0
        /// <summary>
        /// Create a label and input control for a textual field
        /// </summary>
        /// <param name="dataField"></param>
        protected void CreateTextField(UserDataField dataField, out Label label, out Control control)
        {
            // Create the label;
            label          = new Label();
            label.Text     = dataField.Name;
            label.AutoSize = true;

            // Create a textbox and set any requirements
            TextBox textbox = new TextBox();

            control = textbox;

            // Do we have a maximum length specified
            if (dataField.Length != 0)
            {
                textbox.MaxLength = dataField.Length;
            }

            // What about case?
            //switch ((int)dataField.InputCase)
            //{
            //    case (int)UserDataField.FieldCase.any:
            //        break;

            //    case (int)UserDataField.FieldCase.lower:
            //        textbox.CharacterCasing = CharacterCasing.Lower;
            //        break;

            //    case (int)UserDataField.FieldCase.upper:
            //        textbox.CharacterCasing = CharacterCasing.Upper;
            //        break;

            //    case (int)UserDataField.FieldCase.title:
            //        textbox.TextChanged += new EventHandler(textBox_TextChanged);
            //        break;
            //}

            switch (dataField.InputCase)
            {
            case "any":
                break;

            case "lower":
                textbox.CharacterCasing = CharacterCasing.Lower;
                break;

            case "upper":
                textbox.CharacterCasing = CharacterCasing.Upper;
                break;

            case "title":
                textbox.LostFocus += new EventHandler(textBox_TextChanged);
                break;
            }

            // Set the current value
            textbox.Text  = dataField.GetValueFor(_asset.AssetID);
            textbox.Width = 300;

            if ((dataField.Type == UserDataField.FieldType.Environment) || (dataField.Type == UserDataField.FieldType.Registry))
            {
                textbox.Enabled = false;
            }
        }
Esempio n. 31
0
        /// <summary>
        /// Update a specific user data field value
        /// </summary>
        private void UpdateUserDataFieldValue(UserDataField dataField)
        {
            string  newValue = "";
            Control control  = dataField.Tag as Control;

            // The data value depends on the field type
            switch ((int)dataField.Type)
            {
            case (int)UserDataField.FieldType.Number:
                NumericUpDown nup = (NumericUpDown)control;
                if (nup != null)
                {
                    newValue = nup.Value.ToString();
                }
                break;

            case (int)UserDataField.FieldType.Picklist:
                ComboBox comboPicklist = (ComboBox)control;
                if (comboPicklist != null)
                {
                    newValue = (comboPicklist.SelectedIndex == -1) ? "" : comboPicklist.Text;
                }
                break;

            case (int)UserDataField.FieldType.Text:
                TextBox textbox = (TextBox)control;
                if (textbox != null)
                {
                    newValue = textbox.Text;
                }
                break;

            case (int)UserDataField.FieldType.Environment:
                TextBox textbox1 = (TextBox)control;
                if (textbox1 != null)
                {
                    newValue = textbox1.Text;
                }
                break;

            case (int)UserDataField.FieldType.Registry:
                TextBox textbox2 = (TextBox)control;
                if (textbox2 != null)
                {
                    newValue = textbox2.Text;
                }
                break;

            case (int)UserDataField.FieldType.Date:
                NullableDateTimePicker dateTimePicker = (NullableDateTimePicker)control;
                if (dateTimePicker != null)
                {
                    newValue = dateTimePicker.Text;
                }
                break;

            case (int)UserDataField.FieldType.Currency:
                UltraCurrencyEditor currencyEditor = (UltraCurrencyEditor)control;
                if (currencyEditor != null)
                {
                    newValue = currencyEditor.Value.ToString();
                }
                break;

            default:
                newValue = "";
                break;
            }

            // Has the value changed from that currently stored?
            if (newValue != dataField.GetValueFor(_asset.AssetID))
            {
                dataField.SetValueFor(_asset.AssetID, newValue, true);
            }
        }
 public override bool PrepareRun(Database.DBCon db, string tableName)
 {
     _value = "";
     _option = Option.Contains;
     _userDataField = UserDataField.UserData;
     if (Values.Count > 0)
     {
         _value = Values[0];
     }
     if (Values.Count > 1)
     {
         _option = (Option)Enum.Parse(typeof(Option), Values[1]);
     }
     if (Values.Count > 2)
     {
         _userDataField = (UserDataField)Enum.Parse(typeof(UserDataField), Values[2]);
     }
     return base.PrepareRun(db, tableName);
 }