Esempio n. 1
0
        public static void LogField(
            SqlCommand cmd,
            DataFieldControl dfc,
            string logDateTime,
            string logTable,
            int logStudyMeasID,
            int logMeasurePK,
            int logMasterPK
            )
        {
            string logEntryType = (dfc.VerifyError)?LogEntryType.FIELD_ERROR_VERIFY:LogEntryType.FIELD_ERROR_VALIDATE;
            string logText      = dfc.GetErrorText();

            WriteLog(
                cmd,
                string.Empty,
                logEntryType,
                logDateTime,
                logText,
                dfc.DatabaseField,
                logTable,
                logStudyMeasID,
                logMeasurePK,
                logMasterPK
                );
        }
Esempio n. 2
0
        protected bool CheckMax(DataFieldControl dfc)
        {
            bool   valid    = false;
            string sUserVal = dfc.FieldTextBoxText;
            string sMaxVal  = dfc.MaxVal;

            switch (dfc.FieldDataType)
            {
            case FieldDataType.INT:

                valid = (int.Parse(sUserVal) <= int.Parse(sMaxVal));
                break;

            case FieldDataType.FLOAT:
                valid = (float.Parse(sUserVal) <= float.Parse(sMaxVal));
                break;

            case FieldDataType.DATE:
                valid = (DateTime.Parse(sUserVal) <= DateTime.Parse(sMaxVal));

                break;

            case FieldDataType.TEXT:
                valid = (string.Compare(sUserVal, sMaxVal) <= 0);
                break;
            }             // end switch

            return(valid);
        }
Esempio n. 3
0
        }         //function

        /*
         * Return true if the user supplied value is within the range
         * specified by minVal and maxVal.
         *
         */
        protected bool CheckMinMaxBetween(DataFieldControl dfc)
        {
            bool valid = false;

            if (dfc.MaxVal != string.Empty && dfc.MinVal != string.Empty)
            {            //between
                valid = CheckBetween(dfc);
            }
            else if (dfc.MinVal != string.Empty)
            {             //check min
                valid = CheckMin(dfc);
            }
            else
            {             // check max
                valid = CheckMax(dfc);
            }
            return(valid);
        }
        protected void AddParameter(SqlParameterCollection pcol, DataFieldControl dfc)
        {
            object val = null;

            if (dfc.FieldTextBoxText.Trim() == string.Empty)
            {
                val = DBNull.Value;
            }
            else
            {
                switch (dfc.FieldDataType)
                {
                case FieldDataType.INT:
                    val = int.Parse(dfc.FieldTextBoxText);
                    break;

                case FieldDataType.FLOAT:
                    val = double.Parse(dfc.FieldTextBoxText);

                    break;

                case FieldDataType.TEXT:

                    // limit input to maxlength, if necessary.
                    // This is needed because maxLength doesn't apply to
                    // multiline text boxes
                    string sval = dfc.FieldTextBoxText.Trim();
                    if (sval.Length > dfc.FieldTextBoxMaxLength)
                    {
                        sval = sval.Substring(0, dfc.FieldTextBoxMaxLength);
                    }

                    val = sval;
                    break;

                case FieldDataType.DATE:
                    val = DateTime.Parse(dfc.FieldTextBoxText);
                    break;
                }
            }

            pcol.AddWithValue("@" + dfc.DatabaseField, val);
        }
Esempio n. 5
0
        /*
         * Compare the user entered value to the entries in validList.
         * Return FALSE if no match is found.
         *
         */
        protected bool CheckValidList(DataFieldControl dfc)
        {
            // loop over values in validlist and perform a type
            // specific comparision
            string [] split = dfc.ValidList.Split(new Char [] { ',' });
            bool      match = false;

            foreach (string sCheckVal in split)
            {
                match = false;
                string sUserVal = dfc.FieldTextBoxText;
                switch (dfc.FieldDataType)
                {
                case FieldDataType.INT:

                    match = (int.Parse(sUserVal) == int.Parse(sCheckVal));
                    break;

                case FieldDataType.FLOAT:
                    match = (float.Parse(sUserVal) == float.Parse(sCheckVal));
                    break;

                case FieldDataType.DATE:
                    match = (DateTime.Parse(sUserVal) == DateTime.Parse(sCheckVal));
                    break;

                case FieldDataType.TEXT:
                    match = (sUserVal.Trim() == sCheckVal.Trim());
                    break;
                }                 // end switch

                // leave loop of match found
                if (match)
                {
                    break;
                }
            }             // for loop

            return(match);
        }         // function