/// <summary>
        /// Inserts the specified value into the table at the given position. </summary>
        /// <param name="value"> the object to store in the table cell. </param>
        /// <param name="row"> the row of the cell in which to place the object. </param>
        /// <param name="col"> the column of the cell in which to place the object. </param>
        public virtual void setValueAt(object value, int row, int col)
        {
            if (_sortOrder != null)
            {
                row = _sortOrder[row];
            }
            double dval;
            int    ival;

            StateMod_WellRight wellr = (StateMod_WellRight)_data.get(row);

            // necessary for table models that display rights for 1+ wells so that
            // the -1st column (ID) can also be displayed.  By doing it this way,
            // code can be shared between the two kinds of table models and less
            // maintenance is necessary.
            if (!__singleWell)
            {
                col--;
            }

            switch (col)
            {
            case COL_WELL_ID:
                wellr.setCgoto((string)value);
                break;

            case COL_RIGHT_ID:
                wellr.setID((string)value);
                break;

            case COL_RIGHT_NAME:
                wellr.setName((string)value);
                break;

            case COL_STRUCT_ID:
                wellr.setCgoto((string)value);
                break;

            case COL_ADMIN_NUM:
                wellr.setIrtem((string)value);
                break;

            case COL_DCR_AMT:
                if (value is string)
                {
                    try
                    {
                        dval = (Convert.ToDouble((string)value));
                    }
                    catch (Exception e)
                    {
                        Message.printWarning(2, "setValue", e);
                        return;
                    }
                }
                else
                {
                    dval = ((double?)value).Value;
                }
                wellr.setDcrdivw(dval);
                break;

            case COL_ON_OFF:
                if (value is int?)
                {
                    ival = ((int?)value).Value;
                    wellr.setSwitch(ival);
                }
                else if (value is string)
                {
                    string onOff = (string)value;
                    int    index = onOff.IndexOf(" -", StringComparison.Ordinal);
                    ival = (Convert.ToInt32(onOff.Substring(0, index)));
                    wellr.setSwitch(ival);
                }
                break;
            }

            if (!__singleWell)
            {
                col++;
            }

            base.setValueAt(value, row, col);
        }
示例#2
0
        /// <summary>
        /// Inserts the specified value into the table at the given position. </summary>
        /// <param name="value"> the object to store in the table cell. </param>
        /// <param name="row"> the row of the cell in which to place the object. </param>
        /// <param name="col"> the column of the cell in which to place the object. </param>
        public virtual void setValueAt(object value, int row, int col)
        {
            if (_sortOrder != null)
            {
                row = _sortOrder[row];
            }
            double dval;
            int    ival;

            StateMod_WellRight wellr = (StateMod_WellRight)_data.get(row);

            switch (col)
            {
            case COL_RIGHT_ID:
                wellr.setID((string)value);
                break;

            case COL_RIGHT_NAME:
                wellr.setName((string)value);
                break;

            case COL_STRUCT_ID:
                wellr.setCgoto((string)value);
                break;

            case COL_ADMIN_NUM:
                wellr.setIrtem((string)value);
                break;

            case COL_DCR_AMT:
                if (value is string)
                {
                    try
                    {
                        dval = (Convert.ToDouble((string)value));
                    }
                    catch (Exception e)
                    {
                        Message.printWarning(2, "setValue", e);
                        return;
                    }
                }
                else
                {
                    dval = ((double?)value).Value;
                }
                wellr.setDcrdivw(dval);
                break;

            case COL_ON_OFF:
                if (value is int?)
                {
                    ival = ((int?)value).Value;
                    wellr.setSwitch(ival);
                }
                else if (value is string)
                {
                    string onOff = (string)value;
                    int    index = onOff.IndexOf(" -", StringComparison.Ordinal);
                    ival = (Convert.ToInt32(onOff.Substring(0, index)));
                    wellr.setSwitch(ival);
                }
                break;
            }

            base.setValueAt(value, row, col);
        }