Exemplo n.º 1
0
        // ----------------------------------------------------------------------------------------
        /// <!-- CheckForErrors -->
        /// <summary>
        ///
        /// </summary>
        /// <param name="required"></param>
        /// <param name="field"></param>
        /// <param name="fieldName"></param>
        /// <param name="lookup"></param>
        /// <param name="errorCodeForColumnNameNotFound"></param>
        /// <param name="errorCodeForRequiredDataMissing"></param>
        /// <param name="errorCodeForValueIsNotAnInteger"></param>
        /// <param name="errorCodeForValueNotFoundInXref"></param>
        /// <returns></returns>
        public static string CheckForErrors(int required, DataRow field, string fieldName, NumericLookup lookup
                                            , string errorCodeForColumnNameNotFound, string errorCodeForRequiredDataMissing
                                            , string errorCodeForValueIsNotAnInteger, string errorCodeForValueNotFoundInXref, InfoAspect aspect)
        {
            string errorCode = string.Empty;

            if (field.Table.Columns.Contains(fieldName))
            {
                string str = field[fieldName].ToString();


                // ----------------------------------------------------------------------
                //  Check data validity
                // ----------------------------------------------------------------------
                if (!string.IsNullOrEmpty(str.Trim()) && str != "NULL")
                {
                    // ------------------------------------------------------------------
                    //  Check data validity
                    // ------------------------------------------------------------------
                    int id = 0;
                    if (int.TryParse(str, out id))
                    {
                        if (!lookup.ContainsKey(id))
                        {
                            errorCode = errorCodeForValueNotFoundInXref;
                        }
                    }
                    else
                    {
                        errorCode = errorCodeForValueIsNotAnInteger;
                    }
                }
                else
                {
                    if (required >= 2)
                    {
                        errorCode = errorCodeForRequiredDataMissing;
                    }
                }
            }
            else
            {
                errorCode = errorCodeForColumnNameNotFound;
            }

            return(errorCode);
        }
Exemplo n.º 2
0
        // ----------------------------------------------------------------------------------------
        /// <!-- CheckForError -->
        /// <summary>
        ///
        /// </summary>
        /// <param name="required"></param>
        /// <param name="field"></param>
        /// <param name="fieldName"></param>
        /// <param name="lookup"></param>
        /// <param name="errorCodeForColumnNameNotFound"></param>
        /// <param name="errorCodeForRequiredDataMissing"></param>
        /// <param name="errorCodeForValueIsNotAnInteger"></param>
        /// <param name="errorCodeForValueNotFoundInXref"></param>
        /// <returns></returns>
        public static string CheckForError(int required, DataRow field, string fieldName, NumericLookup lookup
                                           , string errorCodeForColumnNameNotFound, string errorCodeForRequiredDataMissing
                                           , string errorCodeForValueIsNotAnInteger, string errorCodeForValueNotFoundInXref)
        {
            string errorCode = string.Empty;

            if (field.Table.Columns.Contains(fieldName))                                  // Check column name existence
            {
                SqlInt32 num = InData.GetSqlInt32(field, fieldName);
                if (num.IsNull)                                                         // Check numeric type validity
                {
                    string strScore = field[fieldName].ToString();
                    if (string.IsNullOrEmpty(strScore))
                    {
                        if (required >= 2)
                        {
                            errorCode = errorCodeForRequiredDataMissing;
                        }                                                   // Check required data existence
                    }
                    else
                    {
                        errorCode = errorCodeForValueIsNotAnInteger;
                    }
                }
                else
                {
                    if (!lookup.ContainsKey((int)num))
                    {
                        errorCode = errorCodeForValueNotFoundInXref;
                    }
                }                                                      // Check data range validity
            }
            else
            {
                errorCode = errorCodeForColumnNameNotFound;
            }

            return(errorCode);
        }
Exemplo n.º 3
0
 public static SqlInt32 State_Lookup(SqlInt32 importStateId)
 {
     if (_state == null)
     {
         FillStates();
     }
     if (importStateId.IsNull)
     {
         return(SqlInt32.Null);
     }
     else
     {
         int key = (int)importStateId;
         if (_state.ContainsKey(key))
         {
             return(_state[key]);
         }
         else
         {
             return(SqlInt32.Null);
         }
     }
 }