예제 #1
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;
            }
        }
예제 #2
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;
        }
예제 #3
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);
            }
        }
예제 #4
0
        private void FillUserDefinedData()
        {
            foreach (UserDataCategory category in _listCategories)
            {
                foreach (UserDataField userDataField in category)
                {
                    switch ((int)userDataField.Type)
                    {
                    case (int)UserDataField.FieldType.Number:

                        NumericUpDown numericUpDown = (NumericUpDown)userDataField.Tag;
                        try
                        {
                            numericUpDown.Value = Convert.ToDecimal(userDataField.GetValueFor(_asset.AssetID));
                        }
                        catch (FormatException)
                        {
                            numericUpDown.Value = 0;
                        }

                        break;

                    case (int)UserDataField.FieldType.Picklist:
                        ComboBox combo = (ComboBox)userDataField.Tag;
                        int      index = combo.FindStringExact(userDataField.GetValueFor(_asset.AssetID));
                        combo.SelectedIndex = (index != -1) ? index : -1;
                        break;

                    case (int)UserDataField.FieldType.Date:

                        NullableDateTimePicker dateTimePicker = (NullableDateTimePicker)userDataField.Tag;
                        try
                        {
                            DateTime value = Convert.ToDateTime(userDataField.GetValueFor(_asset.AssetID));
                            dateTimePicker.Value        = value;
                            dateTimePicker.CustomFormat = "yyyy-MM-dd";
                        }
                        catch (FormatException)
                        {
                            dateTimePicker.Value = null;
                        }

                        break;

                    case (int)UserDataField.FieldType.Currency:

                        UltraCurrencyEditor currencyEditor = (UltraCurrencyEditor)userDataField.Tag;
                        try
                        {
                            currencyEditor.Value = Convert.ToDecimal(userDataField.GetValueFor(_asset.AssetID));
                        }
                        catch (FormatException)
                        {
                            currencyEditor.Value = 0;
                        }

                        break;

                    default:
                        TextBox textBox = (TextBox)userDataField.Tag;
                        textBox.Text = userDataField.GetValueFor(_asset.AssetID);
                        break;
                    }
                }
            }

            HideNotApplicableTabs();
        }