Example #1
0
 public Field(string columnName, object value)
     : this(columnName)
 {
     this.Value = value;
     if (value is double || value is decimal)
     {
         this.DataType = DbTypes.Numeric;
     }
     else if (value is int || value is long)
     {
         this.DataType = DbTypes.Integer;
     }
     else if (value is DateTime)
     {
         this.DataType = DbTypes.DateTime;
     }
     else if (value is bool)
     {
         this.DataType = DbTypes.SmallInt;
     }
     else if (value is byte[])
     {
         this.DataType = DbTypes.Blob;
     }
 }
Example #2
0
                public Reemplazo(object buscar, object reemplazarCon)
                {
                        this.Buscar = buscar;
                        this.ReemplazarCon = reemplazarCon;

                        if(buscar is int)
                                this.Tipo = Lfx.Data.DbTypes.Integer;
                        else if (buscar is double || buscar is decimal)
                                this.Tipo = Lfx.Data.DbTypes.Numeric;
                        else if (buscar is DateTime)
                                this.Tipo = Lfx.Data.DbTypes.DateTime;
                }
Example #3
0
                public Tag(Connection dataBase, string tableName, Lfx.Data.Row fromRow)
                {
                        this.DataBase = dataBase;
                        this.TableName = tableName;
                        this.Id = System.Convert.ToInt32(fromRow["id_tag"]);
                        this.FieldName = fromRow["fieldname"].ToString();
                        this.Label = fromRow["label"].ToString();
                        if (fromRow["extra"] != null)
                                this.Extra = fromRow["extra"].ToString();
                        string FldType = fromRow["fieldtype"].ToString();
                        switch(FldType) {
                                case "relation":
                                        this.FieldType = DbTypes.Integer;
                                        string[] RelationFields = this.Extra.Split(new char[] { ',' });
                                        string ReferenceTable = RelationFields[0], ReferenceColumn, DetailColumn;
                                        
                                        if(RelationFields.Length >= 2)
                                                ReferenceColumn = RelationFields[1];
                                        else
                                                ReferenceColumn = dataBase.Tables[ReferenceTable].PrimaryKey;

                                        if(RelationFields.Length >= 3)
                                                DetailColumn = RelationFields[2];
                                        else
                                                DetailColumn = "nombre";

                                        this.Relation = new Relation(this.FieldName, ReferenceTable, ReferenceColumn, DetailColumn);

                                        if (RelationFields.Length >= 4)
                                                LblType = RelationFields[3];
                                        else
                                                LblType = null;
                                        break;
                                default:
                                        this.FieldType = Lfx.Data.Types.FromSqlType(FldType);
                                        break;
                        }

                        if (fromRow["inputtype"] != null && fromRow["inputtype"].ToString() != string.Empty)
                                this.InputFieldType = (Lfx.Data.InputFieldTypes)(Enum.Parse(typeof(Lfx.Data.InputFieldTypes), fromRow["inputtype"].ToString()));
                                                
                        this.Nullable = System.Convert.ToBoolean(fromRow["fieldnullable"]);
                        this.Internal = System.Convert.ToBoolean(fromRow["internal"]);
                        this.Access = System.Convert.ToInt32(fromRow["access"]);
                        this.DefaultValue = fromRow["fielddefault"];
                        if (this.DefaultValue is DBNull)
                                this.DefaultValue = null;

                }
Example #4
0
 public Field(string columnName, object value)
         : this(columnName)
 {
         this.Value = value;
         if (value is double || value is decimal)
                 this.DataType = DbTypes.Numeric;
         else if (value is int || value is long)
                 this.DataType = DbTypes.Integer;
         else if (value is DateTime)
                 this.DataType = DbTypes.DateTime;
         else if (value is bool)
                 this.DataType = DbTypes.SmallInt;
         else if (value is byte[])
                 this.DataType = DbTypes.Blob;
 }
Example #5
0
        public Reemplazo(object buscar, object reemplazarCon)
        {
            this.Buscar        = buscar;
            this.ReemplazarCon = reemplazarCon;

            if (buscar is int)
            {
                this.Tipo = Lfx.Data.DbTypes.Integer;
            }
            else if (buscar is double || buscar is decimal)
            {
                this.Tipo = Lfx.Data.DbTypes.Numeric;
            }
            else if (buscar is DateTime)
            {
                this.Tipo = Lfx.Data.DbTypes.DateTime;
            }
        }
Example #6
0
 public Field(string columnName, DbTypes fieldType, object fieldValue)
         : this(columnName, fieldValue)
 {
         this.DataType = fieldType;
 }
Example #7
0
 public Field(string columnName, DbTypes fieldType, object fieldValue)
     : this(columnName, fieldValue)
 {
     this.DataType = fieldType;
 }
Example #8
0
        public Tag(Connection dataBase, string tableName, Lfx.Data.Row fromRow)
        {
            this.DataBase  = dataBase;
            this.TableName = tableName;
            this.Id        = System.Convert.ToInt32(fromRow["id_tag"]);
            this.FieldName = fromRow["fieldname"].ToString();
            this.Label     = fromRow["label"].ToString();
            if (fromRow["extra"] != null)
            {
                this.Extra = fromRow["extra"].ToString();
            }
            string FldType = fromRow["fieldtype"].ToString();

            switch (FldType)
            {
            case "relation":
                this.FieldType = DbTypes.Integer;
                string[] RelationFields = this.Extra.Split(new char[] { ',' });
                string   ReferenceTable = RelationFields[0], ReferenceColumn, DetailColumn;

                if (RelationFields.Length >= 2)
                {
                    ReferenceColumn = RelationFields[1];
                }
                else
                {
                    ReferenceColumn = dataBase.Tables[ReferenceTable].PrimaryKey;
                }

                if (RelationFields.Length >= 3)
                {
                    DetailColumn = RelationFields[2];
                }
                else
                {
                    DetailColumn = "nombre";
                }

                this.Relation = new Relation(this.FieldName, ReferenceTable, ReferenceColumn, DetailColumn);

                if (RelationFields.Length >= 4)
                {
                    LblType = RelationFields[3];
                }
                else
                {
                    LblType = null;
                }
                break;

            default:
                this.FieldType = Lfx.Data.Types.FromSqlType(FldType);
                break;
            }

            if (fromRow["inputtype"] != null && fromRow["inputtype"].ToString() != string.Empty)
            {
                this.InputFieldType = (Lfx.Data.InputFieldTypes)(Enum.Parse(typeof(Lfx.Data.InputFieldTypes), fromRow["inputtype"].ToString()));
            }

            this.Nullable     = System.Convert.ToBoolean(fromRow["fieldnullable"]);
            this.Internal     = System.Convert.ToBoolean(fromRow["internal"]);
            this.Access       = System.Convert.ToInt32(fromRow["access"]);
            this.DefaultValue = fromRow["fielddefault"];
            if (this.DefaultValue is DBNull)
            {
                this.DefaultValue = null;
            }
        }