示例#1
0
        /// <summary>
        /// Modifies the column data value.
        /// </summary>
        /// <returns>Bool</returns>
        private bool ModifyColumnDataValue()
        {
            if (this.columnIndex >= 0)
            {
                //if (this.band.Columns[this.columnIndex].Key.Contains(this.FieldNameTextBox.Text.Trim()))
                //{
                //    MessageBox.Show(this, SharedFunctions.GetResourceString("ExistsColumnName"), ConfigurationWrapper.ApplicationName, MessageBoxButtons.OK, MessageBoxIcon.Information);
                //    return false;
                //}
                //else
                //{
                string columnName = this.FieldNameTextBox.Text;

                //try
                //{

                if (null == this.band.Columns[this.columnIndex].Layout.Grid.CalcManager)
                {
                    this.band.Columns[this.columnIndex].Layout.Grid.CalcManager = new UltraCalcManager();
                }

                try
                {
                    NewColCalcManager.Calculate(this.FormulaTextBox.Text);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(this, SharedFunctions.GetResourceString("F9035InvalidFormat"), ConfigurationWrapper.ApplicationName, MessageBoxButtons.OK, MessageBoxIcon.Information);
                    // this.createdColumn.DataType = null;
                    this.FormulaTextBox.Text = string.Empty;
                    return(false);
                    //// ExceptionManager.ManageException(ex, ExceptionManager.ActionType.Display, this);
                }
                finally
                {
                    this.Cursor = Cursors.Default;
                }

                this.ToSetBandvalues();

                this.band.Columns[this.columnIndex].Formula = this.FormulaTextBox.Text.Trim();
                //}
                //catch (Exception ex)
                //{
                //}
                this.band.Columns[this.columnIndex].Format = this.FormatTextBox.Text.Trim();
                this.band.Columns[this.columnIndex].Key    = this.FieldNameTextBox.Text.Trim();

                //this.ToSetBandvalues();
                return(true);
                //}
            }

            return(false);
        }
示例#2
0
        /// <summary>
        /// Creates the column based on currently input data. If a column was previously created
        /// then reuses that.
        /// </summary>
        /// <returns>if created Column returns true else return false </returns>
        private bool CreateColumnHelper()
        {
            try
            {
                ValueListItem item       = this.TypeCombo.SelectedItem;
                string        columnName = this.FieldNameTextBox.Text;
                if (null != columnName)
                {
                    columnName = columnName.Trim();
                }

                // // Don't allow empty string as the column name.
                if (null == columnName || columnName.Length <= 0)
                {
                    MessageBox.Show(this, SharedFunctions.GetResourceString("ColumnName"), ConfigurationWrapper.ApplicationName, MessageBoxButtons.OK, MessageBoxIcon.Information);
                    this.FieldNameTextBox.Focus();
                    //// MessageBox.Show(this, "Please enter a column name.", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return(false);
                }

                //// Make sure that a column by the same name doesn't exist already.
                if (this.band.Columns.Exists(columnName) &&
                    (null == this.createdColumn || this.createdColumn.Key != columnName))
                {
                    MessageBox.Show(this, SharedFunctions.GetResourceString("ExistsColumnName"), ConfigurationWrapper.ApplicationName, MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return(false);
                }

                // If we haven't already created the column then create one.
                if (null == this.createdColumn)
                {
                    if (!string.IsNullOrEmpty(this.FormulaTextBox.Text.Trim()))
                    {
                        NewColCalcManager.Calculate(this.FormulaTextBox.Text);
                    }
                    this.createdColumn = this.band.Columns.Add(columnName);
                }
                else
                {
                    // If we had already created the column then make sure that
                    // the key is the same.
                    this.createdColumn.Key = columnName;
                }

                // Assing the newly selected data tyle and formula if any.
                this.createdColumn.DataType = (Type)item.DataValue;
                this.createdColumn.Formula  = this.FormulaTextBox.Text;
                this.createdColumn.Format   = this.FormatTextBox.Text;
                if (!string.IsNullOrEmpty(this.FormulaTextBox.Text.Trim()))
                {
                    NewColCalcManager.Calculate(this.FormulaTextBox.Text);
                }

                ////For validate formula
                //if (null == this.createdColumn.Layout.Grid.CalcManager)
                //{
                //    this.createdColumn.Layout.Grid.CalcManager = new UltraCalcManager();
                //}

                //NewColCalcManager.Calculate(this.FormulaTextBox.Text);
                if (this.LeftRadioButton.Checked)
                {
                    this.createdColumn.CellAppearance.TextHAlign = Infragistics.Win.HAlign.Left;
                }
                else if (this.RightRadioButton.Checked)
                {
                    this.createdColumn.CellAppearance.TextHAlign = Infragistics.Win.HAlign.Right;
                }
                else if (this.CenterRadioButton.Checked)
                {
                    this.createdColumn.CellAppearance.TextHAlign = Infragistics.Win.HAlign.Center;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(this, SharedFunctions.GetResourceString("F9035InvalidFormat"), ConfigurationWrapper.ApplicationName, MessageBoxButtons.OK, MessageBoxIcon.Information);
                // this.createdColumn.DataType = null;
                // this.createdColumn.Formula = string.Empty;
                // this.createdColumn.Format = string.Empty;

                this.FormulaTextBox.Text = string.Empty;
                //// ExceptionManager.ManageException(ex, ExceptionManager.ActionType.Display, this);
            }
            finally
            {
                this.Cursor = Cursors.Default;
            }

            return(true);
        }