Ejemplo n.º 1
0
        internal int[] WhereMatches(string ColumnName, ColumnMatchOperation Op, object Value)
        {
            Collection<int> cReturnValues = new Collection<int>();
            Reset();
            while (Read())
            {
                switch (Op)
                {
                    case ColumnMatchOperation.IsNull:
                        {
                            if (this[ColumnName] == null)
                                cReturnValues.Add(RowIndex);
                        }break;
                    case ColumnMatchOperation.IsNotNull:
                        {
                            if (this[ColumnName] != null)
                                cReturnValues.Add(RowIndex);
                        }break;
                    case ColumnMatchOperation.Equal:
                        {
                            if (this[ColumnName] == null)
                                cReturnValues.Add(RowIndex);
                            else
                            {
                                switch (_Table[ColumnName].GetColumnType)
                                {
                                    case ColumnType.BOOL:
                                        {
                                            if (Convert.ToBoolean(Value) == Convert.ToBoolean(this[ColumnName]))
                                                cReturnValues.Add(RowIndex);
                                        }break;
                                    case ColumnType.DATETIME:
                                        {
                                            if (Convert.ToDateTime(Value) == Convert.ToDateTime(this[ColumnName]))
                                                cReturnValues.Add(RowIndex);
                                        }break;
                                    case ColumnType.FLOAT:
                                        {
                                            if (((float)Convert.ToDouble(Value)) == ((float)Convert.ToDouble(this[ColumnName])))
                                                cReturnValues.Add(RowIndex);
                                        }break;
                                    case ColumnType.INTEGER:
                                        {
                                            if (Convert.ToInt64(Value) == Convert.ToInt64(this[ColumnName]))
                                                cReturnValues.Add(RowIndex);
                                        }break;
                                    case ColumnType.TEXT:
                                        {
                                            if (string.Compare(Convert.ToString(Value), Convert.ToString(this[ColumnName])) == 0)
                                                cReturnValues.Add(RowIndex);
                                        }break;
                                }
                            }
                        } break;
                    case ColumnMatchOperation.NotEqual:
                        {
                            if (this[ColumnName] != null)
                            {
                                switch (_Table[ColumnName].GetColumnType)
                                {
                                    case ColumnType.BOOL:
                                        {
                                            if (Convert.ToBoolean(Value) != Convert.ToBoolean(this[ColumnName]))
                                                cReturnValues.Add(RowIndex);
                                        }break;
                                    case ColumnType.DATETIME:
                                        {
                                            if (Convert.ToDateTime(Value) != Convert.ToDateTime(this[ColumnName]))
                                                cReturnValues.Add(RowIndex);
                                        }break;
                                    case ColumnType.FLOAT:
                                        {
                                            if (((float)Convert.ToDouble(Value)) != ((float)Convert.ToDouble(this[ColumnName])))
                                                cReturnValues.Add(RowIndex);
                                        }break;
                                    case ColumnType.INTEGER:
                                        {
                                            if (Convert.ToInt64(Value) != Convert.ToInt64(this[ColumnName]))
                                                cReturnValues.Add(RowIndex);
                                        }break;
                                    case ColumnType.TEXT:
                                        {
                                            if (string.Compare(Convert.ToString(Value), Convert.ToString(this[ColumnName])) != 0)
                                                cReturnValues.Add(RowIndex);
                                        }break;
                                }
                            }
                        } break;
                    case ColumnMatchOperation.LessThan:
                        {
                            if (this[ColumnName] != null)
                            {
                                switch (_Table[ColumnName].GetColumnType)
                                {
                                    case ColumnType.BOOL:
                                        {
                                            throw new Exception(" > Test Invalid For Boolean Type.");
                                        }
                                    case ColumnType.DATETIME:
                                        {
                                            if (Convert.ToDateTime(Value) > Convert.ToDateTime(this[ColumnName]))
                                                cReturnValues.Add(RowIndex);
                                        }break;
                                    case ColumnType.FLOAT:
                                        {
                                            if (((float)Convert.ToDouble(Value)) > ((float)Convert.ToDouble(this[ColumnName])))
                                                cReturnValues.Add(RowIndex);
                                        }break;
                                    case ColumnType.INTEGER:
                                        {
                                            if (Convert.ToInt64(Value) > Convert.ToInt64(this[ColumnName]))
                                                cReturnValues.Add(RowIndex);
                                        }break;
                                    case ColumnType.TEXT:
                                        {
                                            if (string.Compare(Convert.ToString(Value), Convert.ToString(this[ColumnName])) > 0)
                                                cReturnValues.Add(RowIndex);
                                        }break;
                                }
                            }
                        } break;
                    case ColumnMatchOperation.LessThanOrEqualTo:
                        {
                            if (this[ColumnName] != null)
                            {
                                switch (_Table[ColumnName].GetColumnType)
                                {
                                    case ColumnType.BOOL:
                                        {
                                            throw new Exception(" >= Test Invalid For Boolean Type.");
                                        }
                                    case ColumnType.DATETIME:
                                        {
                                            if (Convert.ToDateTime(Value) >= Convert.ToDateTime(this[ColumnName]))
                                                cReturnValues.Add(RowIndex);
                                        }break;
                                    case ColumnType.FLOAT:
                                        {
                                            if (((float)Convert.ToDouble(Value)) >= ((float)Convert.ToDouble(this[ColumnName])))
                                                cReturnValues.Add(RowIndex);
                                        }break;
                                    case ColumnType.INTEGER:
                                        {
                                            if (Convert.ToInt64(Value) >= Convert.ToInt64(this[ColumnName]))
                                                cReturnValues.Add(RowIndex);
                                        }break;
                                    case ColumnType.TEXT:
                                        {
                                            if (string.Compare(Convert.ToString(Value), Convert.ToString(this[ColumnName])) >= 0)
                                                cReturnValues.Add(RowIndex);
                                        }break;
                                }
                            }
                        } break;
                    case ColumnMatchOperation.GreaterThan:
                        {
                            if (this[ColumnName] != null)
                            {
                                switch (_Table[ColumnName].GetColumnType)
                                {
                                    case ColumnType.BOOL:
                                        {
                                            throw new Exception(" < Test Invalid For Boolean Type.");
                                        }
                                    case ColumnType.DATETIME:
                                        {
                                            if (Convert.ToDateTime(Value) < Convert.ToDateTime(this[ColumnName]))
                                                cReturnValues.Add(RowIndex);
                                        }break;
                                    case ColumnType.FLOAT:
                                        {
                                            if (((float)Convert.ToDouble(Value)) < ((float)Convert.ToDouble(this[ColumnName])))
                                                cReturnValues.Add(RowIndex);
                                        }break;
                                    case ColumnType.INTEGER:
                                        {
                                            if (Convert.ToInt64(Value) < Convert.ToInt64(this[ColumnName]))
                                                cReturnValues.Add(RowIndex);
                                        }break;
                                    case ColumnType.TEXT:
                                        {
                                            if (string.Compare(Convert.ToString(Value), Convert.ToString(this[ColumnName])) < 0)
                                                cReturnValues.Add(RowIndex);
                                        }break;
                                }
                            }
                        } break;
                    case ColumnMatchOperation.GreaterThanOrEqualTo:
                        {
                            if (this[ColumnName] != null)
                            {
                                switch (_Table[ColumnName].GetColumnType)
                                {
                                    case ColumnType.BOOL:
                                        {
                                            throw new Exception(" <= Test Invalid For Boolean Type.");
                                        }
                                    case ColumnType.DATETIME:
                                        {
                                            if (Convert.ToDateTime(Value) <= Convert.ToDateTime(this[ColumnName]))
                                                cReturnValues.Add(RowIndex); ;
                                        }break;
                                    case ColumnType.FLOAT:
                                        {
                                            if (((float)Convert.ToDouble(Value)) <= ((float)Convert.ToDouble(this[ColumnName])))
                                                cReturnValues.Add(RowIndex);
                                        }break;
                                    case ColumnType.INTEGER:
                                        {
                                            if (Convert.ToInt64(Value) <= Convert.ToInt64(this[ColumnName]))
                                                cReturnValues.Add(RowIndex);
                                        }break;
                                    case ColumnType.TEXT:
                                        {
                                            if (string.Compare(Convert.ToString(Value), Convert.ToString(this[ColumnName])) <= 0)
                                                cReturnValues.Add(RowIndex);
                                        }break;
                                }
                            }
                        } break;
                }
            }

            int[] rValue = new int[cReturnValues.Count];
            cReturnValues.CopyTo(rValue, 0);
            return rValue;
        }
Ejemplo n.º 2
0
 internal int[] WhereMatchesOr(string ColumnName, ColumnMatchOperation Op, object Value, int[] PrevResults)
 {
     Collection<int> cReturnValues = new Collection<int>();
     int[] NewResults = WhereMatches(ColumnName, Op, Value);
     return DbTableIter.OrResults(NewResults, PrevResults);
 }
Ejemplo n.º 3
0
 internal bool MatchesValue(string ColumnName, ColumnMatchOperation Op, object Value)
 {
     switch( Op )
     {
     case ColumnMatchOperation.IsNull:
     {
         if( this[ColumnName] == null )
             return true;
         return false;
     }
     case ColumnMatchOperation.IsNotNull:
     {
         if( this[ColumnName] != null )
             return true;
         return false;
     }
     case ColumnMatchOperation.Equal:
     {
         if( this[ColumnName] == null )
             return false;
         else
         {
             switch(_Table[ColumnName].GetColumnType)
             {
             case ColumnType.BOOL:
             {
                 if( Convert.ToBoolean(Value) == Convert.ToBoolean(this[ColumnName]) )
                     return true;
                 return false;
             }
             case ColumnType.DATETIME:
             {
                 if( Convert.ToDateTime(Value) == Convert.ToDateTime(this[ColumnName]) )
                     return true;
                 return false;
             }
             case ColumnType.FLOAT:
             {
                 if( ((float)Convert.ToDouble(Value)) == ((float)Convert.ToDouble(this[ColumnName])) )
                     return true;
                 return false;
             }
             case ColumnType.INTEGER:
             {
                 if( Convert.ToInt64(Value) == Convert.ToInt64(this[ColumnName]) )
                     return true;
                 return false;
             }
             case ColumnType.TEXT:
             {
                 if( string.Compare( Convert.ToString(Value), Convert.ToString(this[ColumnName]) ) == 0 )
                     return true;
                 return false;
             }
             }
         }
     }break;
     case ColumnMatchOperation.NotEqual:
     {
         if( this[ColumnName] == null )
             return false;
         else
         {
             switch(_Table[ColumnName].GetColumnType)
             {
             case ColumnType.BOOL:
             {
                 if( Convert.ToBoolean(Value) != Convert.ToBoolean(this[ColumnName]) )
                     return true;
                 return false;
             }
             case ColumnType.DATETIME:
             {
                 if( Convert.ToDateTime(Value) != Convert.ToDateTime(this[ColumnName]) )
                     return true;
                 return false;
             }
             case ColumnType.FLOAT:
             {
                 if( ((float)Convert.ToDouble(Value)) != ((float)Convert.ToDouble(this[ColumnName])) )
                     return true;
                 return false;
             }
             case ColumnType.INTEGER:
             {
                 if( Convert.ToInt64(Value) != Convert.ToInt64(this[ColumnName]) )
                     return true;
                 return false;
             }
             case ColumnType.TEXT:
             {
                 if( string.Compare( Convert.ToString(Value), Convert.ToString(this[ColumnName]) ) != 0 )
                     return true;
                 return false;
             }
             }
         }
     }break;
     case ColumnMatchOperation.LessThan:
     {
         if( this[ColumnName] == null )
             return false;
         else
         {
             switch(_Table[ColumnName].GetColumnType)
             {
             case ColumnType.BOOL:
             {
                 throw new Exception(" > Test Invalid For Boolean Type.");
             }
             case ColumnType.DATETIME:
             {
                 if( Convert.ToDateTime(Value) > Convert.ToDateTime(this[ColumnName]) )
                     return true;
                 return false;
             }
             case ColumnType.FLOAT:
             {
                 if( ((float)Convert.ToDouble(Value)) > ((float)Convert.ToDouble(this[ColumnName])) )
                     return true;
                 return false;
             }
             case ColumnType.INTEGER:
             {
                 if( Convert.ToInt64(Value) > Convert.ToInt64(this[ColumnName]) )
                     return true;
                 return false;
             }
             case ColumnType.TEXT:
             {
                 if( string.Compare( Convert.ToString(Value), Convert.ToString(this[ColumnName]) ) > 0 )
                     return true;
                 return false;
             }
             }
         }
     }break;
     case ColumnMatchOperation.LessThanOrEqualTo:
     {
         if( this[ColumnName] == null )
             return false;
         else
         {
             switch(_Table[ColumnName].GetColumnType)
             {
             case ColumnType.BOOL:
             {
                 throw new Exception(" >= Test Invalid For Boolean Type.");
             }
             case ColumnType.DATETIME:
             {
                 if( Convert.ToDateTime(Value) >= Convert.ToDateTime(this[ColumnName]) )
                     return true;
                 return false;
             }
             case ColumnType.FLOAT:
             {
                 if( ((float)Convert.ToDouble(Value)) >= ((float)Convert.ToDouble(this[ColumnName])) )
                     return true;
                 return false;
             }
             case ColumnType.INTEGER:
             {
                 if( Convert.ToInt64(Value) >= Convert.ToInt64(this[ColumnName]) )
                     return true;
                 return false;
             }
             case ColumnType.TEXT:
             {
                 if( string.Compare( Convert.ToString(Value), Convert.ToString(this[ColumnName]) ) >= 0 )
                     return true;
                 return false;
             }
             }
         }
     }break;
     case ColumnMatchOperation.GreaterThan:
     {
         if( this[ColumnName] == null )
             return false;
         else
         {
             switch(_Table[ColumnName].GetColumnType)
             {
             case ColumnType.BOOL:
             {
                 throw new Exception(" < Test Invalid For Boolean Type.");
             }
             case ColumnType.DATETIME:
             {
                 if( Convert.ToDateTime(Value) < Convert.ToDateTime(this[ColumnName]) )
                     return true;
                 return false;
             }
             case ColumnType.FLOAT:
             {
                 if( ((float)Convert.ToDouble(Value)) < ((float)Convert.ToDouble(this[ColumnName])) )
                     return true;
                 return false;
             }
             case ColumnType.INTEGER:
             {
                 if( Convert.ToInt64(Value) < Convert.ToInt64(this[ColumnName]) )
                     return true;
                 return false;
             }
             case ColumnType.TEXT:
             {
                 if( string.Compare( Convert.ToString(Value), Convert.ToString(this[ColumnName]) ) < 0 )
                     return true;
                 return false;
             }
             }
         }
     }break;
     case ColumnMatchOperation.GreaterThanOrEqualTo:
     {
         if( this[ColumnName] == null )
             return false;
         else
         {
             switch(_Table[ColumnName].GetColumnType)
             {
             case ColumnType.BOOL:
             {
                 throw new Exception(" <= Test Invalid For Boolean Type.");
             }
             case ColumnType.DATETIME:
             {
                 if( Convert.ToDateTime(Value) <= Convert.ToDateTime(this[ColumnName]) )
                     return true;
                 return false;
             }
             case ColumnType.FLOAT:
             {
                 if( ((float)Convert.ToDouble(Value)) <= ((float)Convert.ToDouble(this[ColumnName])) )
                     return true;
                 return false;
             }
             case ColumnType.INTEGER:
             {
                 if( Convert.ToInt64(Value) <= Convert.ToInt64(this[ColumnName]) )
                     return true;
                 return false;
             }
             case ColumnType.TEXT:
             {
                 if( string.Compare( Convert.ToString(Value), Convert.ToString(this[ColumnName]) ) <= 0 )
                     return true;
                 return false;
             }
             }
         }
     }break;
     }
     return false;
 }