示例#1
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;

                }
示例#2
0
        public System.Collections.Generic.List <Lfx.Data.Relation> ListaRelaciones()
        {
            System.Collections.Generic.List <Lfx.Data.Relation> Res = new List <Lfx.Data.Relation>();
            foreach (Lfx.Data.ConstraintDefinition Cons in Lfx.Workspace.Master.Structure.Constraints.Values)
            {
                if (Cons.ReferenceTable == TablaOriginal && Cons.ReferenceColumn == CampoIdOriginal)
                {
                    Lfx.Data.Relation Rel = new Lfx.Data.Relation(CampoIdOriginal, Cons.TableName, Cons.Column, null);
                    Res.Add(Rel);
                }
            }

            foreach (Lfx.Data.TableStructure Tab in Lfx.Workspace.Master.Structure.Tables.Values)
            {
                if (Tab.Name != TablaOriginal)
                {
                    foreach (Lfx.Data.ColumnDefinition Col in Tab.Columns.Values)
                    {
                        if (Col.Name == CampoIdOriginal)
                        {
                            bool Found = false;
                            foreach (Lfx.Data.Relation Rel in Res)
                            {
                                if (Rel.ReferenceTable == Tab.Name && Rel.ReferenceColumn == Col.Name)
                                {
                                    Found = true;
                                    break;
                                }
                            }
                            if (Found == false)
                            {
                                System.Console.WriteLine("El cammpo " + Tab.Name + "." + Col.Name + " puede ser una referencia no declarada como clave foránea.");
                            }
                        }
                    }
                }
            }

            return(Res);
        }
示例#3
0
文件: Join.cs 项目: njmube/lazaro
 public Join(Lfx.Data.Relation relation)
     : this(relation.ReferenceTable, relation.Column + "=" + relation.ReferenceTable + "." + relation.ReferenceColumn)
 {
 }
示例#4
0
 public Field(string name, string label, int width, Lfx.Data.Relation relation)
     : this(name, label, Lfx.Data.InputFieldTypes.Relation, width)
 {
     this.Relation = relation;
 }
示例#5
0
                public System.Collections.Generic.List<Lfx.Data.Relation> ListaRelaciones()
                {
                        System.Collections.Generic.List<Lfx.Data.Relation> Res = new List<Lfx.Data.Relation>();
                        foreach (Lfx.Data.ConstraintDefinition Cons in Lfx.Workspace.Master.Structure.Constraints.Values) {
                                if (Cons.ReferenceTable == TablaOriginal && Cons.ReferenceColumn == CampoIdOriginal) {
                                        Lfx.Data.Relation Rel = new Lfx.Data.Relation(CampoIdOriginal, Cons.TableName, Cons.Column, null);
                                        Res.Add(Rel);
                                }
                        }

                        foreach (Lfx.Data.TableStructure Tab in Lfx.Workspace.Master.Structure.Tables.Values) {
                                if (Tab.Name != TablaOriginal) {
                                        foreach (Lfx.Data.ColumnDefinition Col in Tab.Columns.Values) {
                                                if (Col.Name == CampoIdOriginal) {
                                                        bool Found = false;
                                                        foreach (Lfx.Data.Relation Rel in Res) {
                                                                if (Rel.ReferenceTable == Tab.Name && Rel.ReferenceColumn == Col.Name) {
                                                                        Found = true;
                                                                        break;
                                                                }
                                                        }
                                                        if (Found == false)
                                                                System.Console.WriteLine("El cammpo " + Tab.Name + "." + Col.Name + " puede ser una referencia no declarada como clave foránea.");
                                                }
                                        }
                                }
                        }

                        return Res;
                }
示例#6
0
 public RelationFilter(string label, Lfx.Data.Relation relation, qGen.Where filter)
     : this(label, relation)
 {
     this.Filter = filter;
 }
示例#7
0
 public RelationFilter(string label, Lfx.Data.Relation relation)
     : this(label, relation.Column)
 {
     this.Relation = relation;
 }
示例#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;
            }
        }