Ejemplo n.º 1
0
        /// <summary>
        ///   Constructor, which sets all member values
        /// </summary>
        public ValidationDetails(String oldvalue, String val, String range, PIC pic, MgControlBase control)
            : this()
        {
            _picData  = pic;
            _oldvalue = oldvalue; // old value of the field
            _val      = val;      // new  inserted value of the field
            _range    = range;
            _control  = control;

            switch (pic.getAttr())
            {
            case StorageAttribute.NUMERIC:
                _pictureReal   = new StringBuilder(_picData.getMaskSize());
                _pictureEnable = new StringBuilder(_picData.getMaskSize());
                getRealNumericPicture();
                break;

            case StorageAttribute.BOOLEAN:
                if (_range == null)
                {
                    _range = "True,False"; // default range value for Logical
                }
                goto case StorageAttribute.DATE;

            case StorageAttribute.DATE:
            case StorageAttribute.TIME:
            case StorageAttribute.ALPHA:
            case StorageAttribute.BLOB:
            case StorageAttribute.BLOB_VECTOR:
            case StorageAttribute.UNICODE:
                break;

            default:
                Events.WriteExceptionToLog("ValidationDetails.ValidationDetails: There is no type " +
                                           _picData.getAttr());
                break;
            }
            // get Range for the picture:
            if (_range != null)
            {
                fillRange();
            }

            // free memory
            range = null;
        }
Ejemplo n.º 2
0
        /// <summary>
        ///   ***********************Numeric*****************************************
        /// </summary>
        private void getRealNumericPicture()
        {
            String mask             = _picData.getMask();
            int    dec_             = _picData.getDec();
            int    whole_           = _picData.getWholes();
            bool   decimal_         = _picData.withDecimal();
            bool   dec_pnt_in_first = _picData.decInFirstPos();
            bool   isNegative       = _picData.isNegative();
            bool   isFirstPic_N     = true;
            bool   isPointInserted  = false;

            int currChar;

            for (int i = 0; i < _picData.getMaskSize(); i++)
            {
                currChar = mask[i]; // it's ASCII of the char
                switch (currChar)
                {
                case PICInterface.PIC_N:
                    if (isFirstPic_N)
                    {
                        if (isNegative)
                        {
                            setPictures('-', '0');
                        }

                        if (dec_pnt_in_first)
                        {
                            setPictures('.', '1');
                            isPointInserted = true;
                        }
                        else if (whole_ > 0)
                        {
                            whole_--;
                            setPictures('#', '0');
                        }
                        isFirstPic_N = false;
                        break;
                    }

                    if (decimal_)
                    {
                        if (whole_ > 0)
                        {
                            whole_--;
                            setPictures('#', '0');
                        }
                        else if (whole_ == 0 && !isPointInserted)
                        {
                            setPictures('.', '1');
                            isPointInserted = true;
                        }
                        else if (dec_ > 0)
                        {
                            dec_--;
                            setPictures('#', '0');
                        }
                    }
                    else
                    {
                        if (whole_ > 0)
                        {
                            whole_--;
                            setPictures('#', '0');
                        }
                    }
                    break;

                default: // const string in Alpha
                    setPictures((char)currChar, '1');
                    break;
                }
            }
            Events.WriteDevToLog(_pictureReal.ToString());
            Events.WriteDevToLog(_pictureEnable.ToString());
        }