Exemple #1
0
        private void buttonAdd_Click(object sender, EventArgs e)
        {
            IField field = ((IField)comboBoxDefaultFields.SelectedItem).Clone() as IField;

            if (field is CustomField)
            {
                field = new CustomField()
                {
                    Header = textBoxHeader.Text
                };
                if (_useSpecficLenght)
                {
                    try
                    {
                        field.Length = Convert.ToInt32(textNumericUserControl1.Text);
                    }
                    catch
                    {
                        field.Length = 0;
                    }
                }

                CustomFieldPropertiesForm frm = new CustomFieldPropertiesForm {
                    CustomField = field as CustomField
                };
                if (frm.ShowDialog() == DialogResult.OK)
                {
                    _addField(frm.CustomField);
                }
            }
            else
            {
                field.Header = textBoxHeader.Text;
                if (_useSpecficLenght)
                {
                    try
                    {
                        field.Length = Convert.ToInt32(textNumericUserControl1.Text);
                    }
                    catch
                    {
                        field.Length = ((Field)field).DefaultLength;
                    }
                }
                _addField(field);
            }
        }
 private void buttonProperties_Click(object sender, EventArgs e)
 {
     if (olvSelectedFields.SelectedObject != null)
     {
         IField selectedField = (IField)olvSelectedFields.SelectedObject;
         if (selectedField is Field)
         {
             if (((Field)selectedField).FieldType is StringFieldType)
             {
                 StringFieldPropertiesForm frm = new StringFieldPropertiesForm { StringFieldType = ((Field)selectedField).FieldType as StringFieldType };
                 if (frm.ShowDialog() == DialogResult.OK)
                     ((Field)selectedField).FieldType = frm.StringFieldType;
             }
             else if (((Field)selectedField).FieldType is DateFieldType)
             {
                 DateFieldPropertiesForm frm = new DateFieldPropertiesForm { DateFieldType = ((Field)selectedField).FieldType as DateFieldType };
                 if (frm.ShowDialog() == DialogResult.OK)
                     ((Field)selectedField).FieldType = frm.DateFieldType;
             }
             else if (((Field)selectedField).FieldType is DecimalFieldType)
             {
                 DecimalFieldPropertiesForm frm = new DecimalFieldPropertiesForm { DecimalFieldType = ((Field)selectedField).FieldType as DecimalFieldType };
                 if (frm.ShowDialog() == DialogResult.OK)
                     ((Field)selectedField).FieldType = frm.DecimalFieldType;
             }
             else if (((Field)selectedField).FieldType is IntegerFieldType)
             {
                 IntegerFieldPropertiesForm frm = new IntegerFieldPropertiesForm { IntegerFieldType = ((Field)selectedField).FieldType as IntegerFieldType };
                 if (frm.ShowDialog() == DialogResult.OK)
                     ((Field)selectedField).FieldType = frm.IntegerFieldType;
             }
         }
         else if (selectedField is ComplexField)
         {
             ComplexFieldPropertiesForm frm = new ComplexFieldPropertiesForm
             {
                 DefaultFields = _defaultList,
                 ComplexField = selectedField as ComplexField,
                 UseSpecificLength = _useSpecficLenght,
                 ExportMode = this.ExportMode
             };
             if (frm.ShowDialog() == DialogResult.OK)
             {
                ((ComplexField)olvSelectedFields.SelectedObject).DisplayName = frm.ComplexField.DisplayName;
                ((ComplexField)olvSelectedFields.SelectedObject).Name = frm.ComplexField.Name;
                ((ComplexField)olvSelectedFields.SelectedObject).Fields = frm.ComplexField.Fields;
                ((ComplexField)olvSelectedFields.SelectedObject).Length = frm.ComplexField.Length;
                 olvSelectedFields.RefreshObject(olvSelectedFields.SelectedObject);
             }
         }
         else if (selectedField is CustomField)
         {
             CustomFieldPropertiesForm frm = new CustomFieldPropertiesForm { CustomField = selectedField as CustomField };
             if (frm.ShowDialog() == DialogResult.OK)
             {
                 var customField = frm.CustomField;
                 olvSelectedFields.RefreshObject(customField);
             }
         }
     }
 }
        private void buttonAdd_Click(object sender, EventArgs e)
        {
            IField field = ((IField)comboBoxDefaultFields.SelectedItem).Clone() as IField;
            if (field is CustomField)
            {
                field = new CustomField()
                {
                    Header = textBoxHeader.Text
                };
                if (_useSpecficLenght)
                    try
                    {
                        field.Length = Convert.ToInt32(textNumericUserControl1.Text);
                    }
                    catch
                    {
                        field.Length = 0;
                    }

                CustomFieldPropertiesForm frm = new CustomFieldPropertiesForm { CustomField = field as CustomField };
                if (frm.ShowDialog() == DialogResult.OK)
                {
                    _addField(frm.CustomField);
                }
            }
            else
            {
                field.Header = textBoxHeader.Text;
                if (_useSpecficLenght)
                    try
                    {
                        field.Length = Convert.ToInt32(textNumericUserControl1.Text);
                    }
                    catch
                    {
                        field.Length = ((Field)field).DefaultLength;
                    }
                _addField(field);
            }
        }
Exemple #4
0
 private void buttonProperties_Click(object sender, EventArgs e)
 {
     if (olvSelectedFields.SelectedObject != null)
     {
         IField selectedField = (IField)olvSelectedFields.SelectedObject;
         if (selectedField is Field)
         {
             if (((Field)selectedField).FieldType is StringFieldType)
             {
                 StringFieldPropertiesForm frm = new StringFieldPropertiesForm {
                     StringFieldType = ((Field)selectedField).FieldType as StringFieldType
                 };
                 if (frm.ShowDialog() == DialogResult.OK)
                 {
                     ((Field)selectedField).FieldType = frm.StringFieldType;
                 }
             }
             else if (((Field)selectedField).FieldType is DateFieldType)
             {
                 DateFieldPropertiesForm frm = new DateFieldPropertiesForm {
                     DateFieldType = ((Field)selectedField).FieldType as DateFieldType
                 };
                 if (frm.ShowDialog() == DialogResult.OK)
                 {
                     ((Field)selectedField).FieldType = frm.DateFieldType;
                 }
             }
             else if (((Field)selectedField).FieldType is DecimalFieldType)
             {
                 DecimalFieldPropertiesForm frm = new DecimalFieldPropertiesForm {
                     DecimalFieldType = ((Field)selectedField).FieldType as DecimalFieldType
                 };
                 if (frm.ShowDialog() == DialogResult.OK)
                 {
                     ((Field)selectedField).FieldType = frm.DecimalFieldType;
                 }
             }
             else if (((Field)selectedField).FieldType is IntegerFieldType)
             {
                 IntegerFieldPropertiesForm frm = new IntegerFieldPropertiesForm {
                     IntegerFieldType = ((Field)selectedField).FieldType as IntegerFieldType
                 };
                 if (frm.ShowDialog() == DialogResult.OK)
                 {
                     ((Field)selectedField).FieldType = frm.IntegerFieldType;
                 }
             }
         }
         else if (selectedField is ComplexField)
         {
             ComplexFieldPropertiesForm frm = new ComplexFieldPropertiesForm
             {
                 DefaultFields     = _defaultList,
                 ComplexField      = selectedField as ComplexField,
                 UseSpecificLength = _useSpecficLenght,
                 ExportMode        = this.ExportMode
             };
             if (frm.ShowDialog() == DialogResult.OK)
             {
                 ((ComplexField)olvSelectedFields.SelectedObject).DisplayName = frm.ComplexField.DisplayName;
                 ((ComplexField)olvSelectedFields.SelectedObject).Name        = frm.ComplexField.Name;
                 ((ComplexField)olvSelectedFields.SelectedObject).Fields      = frm.ComplexField.Fields;
                 ((ComplexField)olvSelectedFields.SelectedObject).Length      = frm.ComplexField.Length;
                 olvSelectedFields.RefreshObject(olvSelectedFields.SelectedObject);
             }
         }
         else if (selectedField is CustomField)
         {
             CustomFieldPropertiesForm frm = new CustomFieldPropertiesForm {
                 CustomField = selectedField as CustomField
             };
             if (frm.ShowDialog() == DialogResult.OK)
             {
                 var customField = frm.CustomField;
                 olvSelectedFields.RefreshObject(customField);
             }
         }
     }
 }