コード例 #1
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;
        }
コード例 #2
0
        internal static bool CheckDateTimeFill(NullableDateTimePicker picker, string name, StringBuilder strBuilder)
        {
            if (!picker.Value.HasValue)
            {
                if (strBuilder.Length > 0)
                {
                    strBuilder.AppendLine();
                }
                strBuilder.AppendFormat("Поле '{0}' не заполнено.", name);

                return(false);
            }

            return(true);
        }
コード例 #3
0
ファイル: SummaryTabView.cs プロジェクト: windygu/AW-master
        /// <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;
        }
コード例 #4
0
ファイル: DynamicFilters.cs プロジェクト: Palpid/supply
        /// <summary>
        /// Cargar los filtros que se han pasado desde otro formulario
        /// </summary>
        /// <param name="filters"></param>
        private void LoadPreFilter(List <ModelLinqFiltering> filters)
        {
            try
            {
                int i = 1;
                AddRowFilter();
                foreach (ModelLinqFiltering f in filters)
                {
                    ComboBox cmbField     = GetCmbRow(CMB_FIELD_NAME + i);
                    ComboBox cmbCondition = GetCmbRow(CMB_CONDITION_NAME + i);
                    TextBox  txtFilter    = GetTxtRow(TXT_FILTER_NAME + i);
                    CheckBox chkFilter    = GetChkRow(CHK_FILTER_NAME + i);
                    NullableDateTimePicker dateTimePickerFilter = GetNullDateRow(DATETIMEPICKER_FILTER_NAME + i);
                    ComboBox cmbUnion = GetCmbRow(CMB_UNION_NAME + i);

                    cmbField.SelectedIndex = -1;
                    cmbField.Text          = f.PropertyName;
                    cmbCondition.Text      = f.Condition;
                    cmbUnion.Text          = f.Union;

                    switch (f.PropertyType)
                    {
                    case "DateTime":
                        dateTimePickerFilter.Value = f.DateFilter;
                        break;

                    case "Boolean":
                        chkFilter.Checked = bool.Parse(f.Filter);
                        break;

                    default:
                        txtFilter.Text = f.Filter;
                        break;
                    }

                    i++;
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
コード例 #5
0
ファイル: FormUserDataEdit.cs プロジェクト: windygu/AW-master
        /// <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));
            }
        }
コード例 #6
0
 /// <summary>
 /// Here we get to work out how on earch we subscribe to changes...
 /// </summary>
 protected virtual void HookControl()
 {
     //listboxes and comboboxes need a special bit of co-ercing
     if (subject is CheckedListBox)
     {
         CheckedListBox tempCLB = (CheckedListBox)subject;
         tempCLB.ItemCheck += new ItemCheckEventHandler(tempCLB_ItemCheck);
     }
     else if (subject is ListControl)
     {
         ListControl tempLC = (ListControl)subject;
         tempLC.SelectedValueChanged += new EventHandler(subject_SelectedValueChanged);
     }
     else if (subject is CheckBox)
     {
         CheckBox tempCB = (CheckBox)subject;
         tempCB.CheckedChanged += new EventHandler(subject_CheckedChanged);
     }
     else if (subject is NumericUpDown)
     {
         NumericUpDown tempNUD = (NumericUpDown)subject;
         tempNUD.ValueChanged += new EventHandler(subject_NumericValueChanged);
     }
     else if (subject is NullableDateTimePicker)
     {
         NullableDateTimePicker tempDTP = (NullableDateTimePicker)subject;
         tempDTP.ValueChanged += new EventHandler(subject_NullDateValueChanged);
         tempDTP.CloseUp      += new EventHandler(subject_NullDateValueCloseUp);
     }
     else if (subject is DateTimePicker)
     {
         DateTimePicker tempDTP = (DateTimePicker)subject;
         tempDTP.ValueChanged += new EventHandler(subject_DateValueChanged);
         tempDTP.CloseUp      += new EventHandler(subject_DateValueCloseUp);
     }
     else
     {
         subject.TextChanged += new EventHandler(subject_TextChanged); //default
     }
 }
コード例 #7
0
        /// <summary>
        /// Pulls the data to "current". Used in cases where events aren't possible
        /// </summary>
        public virtual void Pull()
        {
            //if we are not attached to a control (for what ever reason - usually because
            //of "fake" contollery,  we'll fail here unless we bail. If the subject is null
            //we assume this to be the case.
            if (subject == null)
            {
                return;
            }

            //listboxes and comboboxes need a special bit of co-ercing
            if (subject is ListControl)
            {
                ListControl tempLC = (ListControl)subject;

                switch (listControlMapping)
                {
                case ListControlMapping.Text:
                    tempLC.Text = ConversionHelper.ToString(target.CurrentValue, String.Empty);
                    break;

                case ListControlMapping.Index:

                    tempLC.SelectedIndex = ConversionHelper.ToInt32(target.CurrentValue, -1);
                    break;

                case ListControlMapping.Value:
                default:
                    tempLC.SelectedValue = target.CurrentValue;
                    break;
                }
            }
            else if (subject is CheckBox)
            {
                CheckBox tempCB = (CheckBox)subject;
                tempCB.Checked = Convert.ToBoolean(target.CurrentValue);
            }
            else if (subject is NumericUpDown)
            {
                NumericUpDown tempNUD = (NumericUpDown)subject;
                Decimal       temp    = Convert.ToDecimal(target.CurrentValue);

                //handle overflows:
                if (temp > tempNUD.Maximum)
                {
                    tempNUD.Value = tempNUD.Maximum;
                }
                else if (temp < tempNUD.Minimum)
                {
                    tempNUD.Value = tempNUD.Minimum;
                }
                else
                {
                    tempNUD.Value = Convert.ToDecimal(target.CurrentValue);
                }
            }
            else if (subject is NullableDateTimePicker)
            {
                NullableDateTimePicker tempDTP = (NullableDateTimePicker)subject;
                try
                {
                    if (target.CurrentValue == null)
                    {
                        tempDTP.Value      = tempDTP.NullDate;
                        tempDTP.DateIsNull = true;
                    }
                    else
                    {
                        tempDTP.Value = Convert.ToDateTime(target.CurrentValue);
                    }
                }
                catch
                {
                    tempDTP.Value = tempDTP.NullDate;
                }
            }
            else if (subject is DateTimePicker)
            {
                DateTimePicker tempDTP = (DateTimePicker)subject;
                try
                {
                    tempDTP.Value = Convert.ToDateTime(target.CurrentValue);
                }
                catch
                {
                    tempDTP.Text = String.Empty; //set null date
                }
            }
            else
            {
                subject.Text = Convert.ToString(target.CurrentValue); //subject.TextChanged += new EventHandler(subject_TextChanged); //default
            }
        }
コード例 #8
0
ファイル: SummaryTabView.cs プロジェクト: windygu/AW-master
        /// <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);
            }
        }
コード例 #9
0
ファイル: SummaryTabView.cs プロジェクト: windygu/AW-master
        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();
        }
コード例 #10
0
ファイル: DynamicFilters.cs プロジェクト: Palpid/supply
        /// <summary>
        /// Obtener los filtros que han indicado en la pantalla
        /// </summary>
        private void GetFilters()
        {
            try
            {
                for (int i = 1; i < tlpFilters.RowCount; i++)
                {
                    ComboBox cmbField     = GetCmbRow(CMB_FIELD_NAME + i);
                    ComboBox cmbCondition = GetCmbRow(CMB_CONDITION_NAME + i);
                    TextBox  txtFilter    = GetTxtRow(TXT_FILTER_NAME + i);
                    CheckBox chkFilter    = GetChkRow(CHK_FILTER_NAME + i);
                    NullableDateTimePicker dateTimePickerFilter = GetNullDateRow(DATETIMEPICKER_FILTER_NAME + i);
                    ComboBox cmbUnion = GetCmbRow(CMB_UNION_NAME + i);

                    if (cmbField.SelectedValue == null)
                    {
                        throw new Exception(string.Format("Select column value at row {0}", i.ToString()));
                    }

                    string type = _objectPropertiesTypesDic[cmbField.SelectedValue.ToString()];

                    string propertyName = cmbField.SelectedValue.ToString();
                    string condition    = cmbCondition.SelectedValue.ToString();
                    string union        = cmbUnion.SelectedValue.ToString();

                    string   filter     = "";
                    DateTime?dateFilter = null;
                    switch (type)
                    {
                    case "Decimal":
                    case "Double":
                    case "Single":
                    case "Int32":
                    case "Int16":
                    case "String":
                        filter = txtFilter.Text;
                        break;

                    case "DateTime":
                        dateFilter = (DateTime)dateTimePickerFilter.Value;
                        break;

                    case "Boolean":
                        filter = chkFilter.Checked.ToString();
                        break;
                    }

                    ModelLinqFiltering modelFiltering = new ModelLinqFiltering
                    {
                        PropertyName = propertyName,
                        PropertyType = type,
                        Condition    = condition,
                        Filter       = filter,
                        DateFilter   = dateFilter,
                        Union        = union,
                    };

                    if (modelFiltering.IsValidData())
                    {
                        _filterList.Add(modelFiltering);
                    }
                    else
                    {
                        throw new Exception(string.Format("Filter format error at row {0}", i.ToString()));
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
コード例 #11
0
ファイル: DynamicFilters.cs プロジェクト: Palpid/supply
        /// <summary>
        /// Asignar el datasource del combo de condición en función del tipo de campo seleccionado
        /// </summary>
        /// <param name="number"></param>
        /// <param name="type"></param>
        private void SetCmbConditionSource(string number, string type)
        {
            try
            {
                ComboBox cmb       = Controls.Find(CMB_CONDITION_NAME + number, true).FirstOrDefault() as ComboBox;
                TextBox  txtFilter = Controls.Find(TXT_FILTER_NAME + number, true).FirstOrDefault() as TextBox;
                CheckBox chkFilter = Controls.Find(CHK_FILTER_NAME + number, true).FirstOrDefault() as CheckBox;
                NullableDateTimePicker dateTimePickerFilter = Controls.Find(DATETIMEPICKER_FILTER_NAME + number, true).FirstOrDefault() as NullableDateTimePicker;

                txtFilter.Visible            = false;
                chkFilter.Visible            = false;
                dateTimePickerFilter.Visible = false;

                if (cmb != null)
                {
                    cmb.DataBindings.Clear();

                    switch (type)
                    {
                    case "Decimal":
                    case "Double":
                    case "Single":
                    case "Int32":
                    case "Int16":
                        cmb.Visible       = true;
                        cmb.DataSource    = new BindingSource(_numberConditionDic, null);
                        cmb.DisplayMember = "Value";
                        cmb.ValueMember   = "Key";

                        txtFilter.Visible = true;
                        break;

                    case "String":
                        cmb.Visible       = true;
                        cmb.DataSource    = new BindingSource(_stringConditionDic, null);
                        cmb.DisplayMember = "Value";
                        cmb.ValueMember   = "Key";

                        txtFilter.Visible = true;
                        break;

                    case "DateTime":
                        cmb.Visible       = true;
                        cmb.DataSource    = new BindingSource(_numberConditionDic, null);
                        cmb.DisplayMember = "Value";
                        cmb.ValueMember   = "Key";

                        dateTimePickerFilter.Visible = true;
                        break;

                    case "Boolean":
                        cmb.Visible       = false;
                        chkFilter.Visible = true;
                        break;
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
コード例 #12
0
ファイル: DynamicFilters.cs プロジェクト: Palpid/supply
        /// <summary>
        /// Agregar una fila al TableLayoutPanel
        /// </summary>
        private void AddRowFilter()
        {
            try
            {
                _isRowCreating = true;

                //***** Combo con las propiedades del objeto *****
                ComboBox cmbField = new ComboBox();
                cmbField.DataSource            = new BindingSource(_objectPropertiesDic, null);
                cmbField.DisplayMember         = "Value";
                cmbField.ValueMember           = "Key";
                cmbField.Name                  = CMB_FIELD_NAME + tlpFilters.RowCount.ToString();
                cmbField.Anchor                = (AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right);
                cmbField.SelectedIndexChanged += cmbField_SelectedIndexChanged;
                cmbField.DropDownStyle         = ComboBoxStyle.DropDownList;

                //***** Combo para las condiciones *****
                ComboBox cmbCondition = new ComboBox();
                cmbCondition.DataSource    = new BindingSource(_stringConditionDic, null);
                cmbCondition.DisplayMember = "Value";
                cmbCondition.ValueMember   = "Key";
                cmbCondition.Name          = CMB_CONDITION_NAME + tlpFilters.RowCount.ToString();
                cmbCondition.Anchor        = (AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right);
                cmbCondition.DropDownStyle = ComboBoxStyle.DropDownList;

                //***** Panel para los filtros en función del tipo de propiedad (texbox, checkbox, datePicker) *****
                Panel filterPanel = new Panel();
                filterPanel.Dock = DockStyle.Fill;

                TextBox txtFilter = new TextBox();
                txtFilter.Name    = TXT_FILTER_NAME + tlpFilters.RowCount.ToString();
                txtFilter.Anchor  = (AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right);
                txtFilter.Visible = false;

                CheckBox chkFilter = new CheckBox();
                chkFilter.Name    = CHK_FILTER_NAME + tlpFilters.RowCount.ToString();
                chkFilter.Visible = false;

                NullableDateTimePicker dateTimePickerFilter = new NullableDateTimePicker();
                dateTimePickerFilter.Name    = DATETIMEPICKER_FILTER_NAME + tlpFilters.RowCount.ToString();
                dateTimePickerFilter.Anchor  = (AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right);
                dateTimePickerFilter.Format  = DateTimePickerFormat.Short;
                dateTimePickerFilter.Visible = false;

                filterPanel.Controls.Add(txtFilter);
                filterPanel.Controls.Add(chkFilter);
                filterPanel.Controls.Add(dateTimePickerFilter);

                //***** Combo para el union *****
                ComboBox cmbUnion = new ComboBox();
                cmbUnion.DataSource            = new BindingSource(_unionDic, null);
                cmbUnion.DisplayMember         = "Value";
                cmbUnion.ValueMember           = "Key";
                cmbUnion.Name                  = CMB_UNION_NAME + tlpFilters.RowCount.ToString();
                cmbUnion.Anchor                = (AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right);
                cmbUnion.SelectedIndexChanged += cmbUnion_SelectedIndexChanged;
                cmbUnion.DropDownStyle         = ComboBoxStyle.DropDownList;


                tlpFilters.RowCount = tlpFilters.RowCount + 1;
                tlpFilters.RowStyles.Add(new RowStyle(SizeType.Absolute, 30F));
                tlpFilters.Controls.Add(cmbField, 0, tlpFilters.RowCount - 1);
                tlpFilters.Controls.Add(cmbCondition, 1, tlpFilters.RowCount - 1);
                tlpFilters.Controls.Add(filterPanel, 2, tlpFilters.RowCount - 1);
                tlpFilters.Controls.Add(cmbUnion, 3, tlpFilters.RowCount - 1);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                _isRowCreating = false;
            }
        }