Ejemplo n.º 1
0
        public Column(Column c)
        {
            obj = SetObject(c.obj);
            nulltype = c.nulltype;
            Style = c.Style;
            flags = c.flags;
            IsIdentity = c.IsIdentity;
            ownerTable = c.ownerTable;
            Name = c.Name;
            //            Value = c.Value;

            //SetType = c.SetType;
            if (c.fKey != null)
            {
                fKey = new ForeignKey(c.fKey);
            }

            Name_in_language = c.Name_in_language;
            //Name_in_language = new ltext();

            //int iCount = c.Name_in_language.sText.Length;
            //for (int i = 0; i < iCount; i++)
            //{
            //    Name_in_language.sText(i) = c.Name_in_language.sText(i);
            //}
        }
Ejemplo n.º 2
0
 public ForeignKey(ForeignKey srcfKey)
 {
     ID_ForeignKey = srcfKey.ID_ForeignKey;
     ReferenceTable = srcfKey.ReferenceTable;
     brefTableID = srcfKey.brefTableID;
     refInListOfTables = srcfKey.refInListOfTables;
     if (srcfKey.refInListOfTables != null)
     {
         fTable = new SQLTable(srcfKey.refInListOfTables);
     }
     ReferenceTable_Column = srcfKey.ReferenceTable_Column;
 }
Ejemplo n.º 3
0
 public ForeignKey(ForeignKey srcfKey, SQLTable DBm_owner_Tabel,List<SQLTable> lTable)
 {
     ID_ForeignKey = srcfKey.ID_ForeignKey;
     ReferenceTable = srcfKey.ReferenceTable;
     brefTableID = srcfKey.brefTableID;
     refInListOfTables = srcfKey.refInListOfTables;
     if (srcfKey.refInListOfTables != null)
     {
         fTable = new SQLTable(srcfKey.refInListOfTables, DBm_owner_Tabel, lTable);
         lTable.Add(fTable);
     }
     ReferenceTable_Column = srcfKey.ReferenceTable_Column;
 }
Ejemplo n.º 4
0
        public string GetColumnSQLiteDefinitionLine(DBTableControl dbTables, ref List<ForeignKey> m_Fkey, List<string> UniqueConstraintNameList, ref string sql_DBm, SQLTable DBm_owner_Table)
        {
            SQLTable refTable = null;
            SQLTable new_ref_Table = null;
            if (obj != null)
            {
                string columnName = StaticLib.Func.GetNameFromObjectType(obj);
                this.Name = columnName;
                string sBasicType = null;
                // complex types
                string strNull;
                if (nulltype == nullTYPE.NOT_NULL)
                {
                    strNull = " NOT NULL";
                }
                else
                {
                    strNull = " NULL";
                }

                string strUNIQUE;
                if ((this.flags & Flags.UNIQUE)!=0)
                {
                    strUNIQUE = " UNIQUE ";
                }
                else
                {
                    strUNIQUE = "";
                }

                if (obj.GetType() == typeof(ID))
                {
                    ID ID = (ID)obj;
                    return Globals.LeftMargin + "'" + columnName + "' INTEGER PRIMARY KEY AUTOINCREMENT";
                }
                else if (dbTables.IsMyTable(out refTable, obj.GetType()))
                {

                    if (DBtypesFunc.Is_DBm_Type(refTable.objTable))
                    {
                        if (DBm_owner_Table == null)
                        {
                            DBm_owner_Table = this.ownerTable;
                        }
                        new_ref_Table = new SQLTable(refTable, DBm_owner_Table, dbTables.items);
                        dbTables.items.Add(new_ref_Table);

                        string new_sql_DBm = new_ref_Table.SQLitecmd_CreateTable(dbTables, UniqueConstraintNameList, ref sql_DBm, DBm_owner_Table);
                        sql_DBm += new_sql_DBm;

                        refTable = new_ref_Table;
                        this.Name = refTable.TableName;
                        int iCount = this.Name_in_language.sText_Length;
                        for (int i = 0; i < iCount; i++)
                        {
                            this.Name_in_language.sText(i,refTable.lngTableName.sText(i) + ":" + this.Name_in_language.sText(i));
                        }
                    }
                    this.Name = this.Name + "_ID";
                    string str;
                    ForeignKey fk = new ForeignKey();
                    str = Globals.LeftMargin + AddForeignKeySQLite(ref m_Fkey, refTable, ref fk) + " INTEGER " + strNull + " REFERENCES " + refTable.TableName + "(ID)" + strUNIQUE;
                    fKey = fk;
                    return str;
                }
                else
                {
                    sBasicType = DBTypes.DBtypesFunc.GetBasicTypeSQLite(obj) + strUNIQUE;
                }

                return Globals.LeftMargin + "'" + columnName + "' " + sBasicType + strNull + strUNIQUE;
            }
            else
            {
                return "!!!Object Is Null!!!";
            }
        }
Ejemplo n.º 5
0
        public string GetColumnMySQLDefinitionLine(DBTableControl dbTables, ref List<ForeignKey> m_Fkey, List<string> UniqueConstraintNameList, ref string sql_DBm, SQLTable DBm_owner_Table)
        {
            SQLTable refTable = null;
            SQLTable new_ref_Table = null;
            if (obj != null)
            {
                string columnName = StaticLib.Func.GetNameFromObjectType(obj);
                this.Name = columnName;
                string sBasicType = null;
                // complex types
                string strNull;
                if (nulltype == nullTYPE.NOT_NULL)
                {
                    strNull = " NOT NULL";
                }
                else
                {
                    strNull = " NULL";
                }

                if (obj.GetType() == typeof(ID))
                {
                    ID ID = (ID)obj;
                    return Globals.LeftMargin + "`" + columnName + "` " + DBtypesFunc.GetBasicTypeMySQL(obj) +" unsigned NOT NULL AUTO_INCREMENT";
                }
                else if (dbTables.IsMyTable(out refTable, obj.GetType()))
                {
                    if (DBtypesFunc.Is_DBm_Type(refTable.objTable))
                    {
                        if (DBm_owner_Table == null)
                        {
                            DBm_owner_Table = this.ownerTable;
                        }
                        new_ref_Table = new SQLTable(refTable, DBm_owner_Table, dbTables.items);
                        dbTables.items.Add(new_ref_Table);

                        string new_sql_DBm = new_ref_Table.MySQLcmd_CreateTable(dbTables, UniqueConstraintNameList, ref sql_DBm, DBm_owner_Table);
                        sql_DBm += new_sql_DBm;

                        refTable = new_ref_Table;
                        this.Name = refTable.TableName;
                        int iCount = this.Name_in_language.sText_Length;
                        for (int i = 0; i < iCount; i++)
                        {
                            this.Name_in_language.sText(i,refTable.lngTableName.sText(i) + "_" + this.Name_in_language.sText(i));
                        }
                    }
                     this.Name =  this.Name  + "_ID";
                    string str;
                    ForeignKey fk = new ForeignKey();
                    object obj_reftable_id = refTable.FindIdentityObject();
                    string sIdentityType;
                    if (obj_reftable_id != null)
                    {
                        sIdentityType = " " + DBtypesFunc.GetBasicTypeMySQL(obj_reftable_id) + " ";
                    }
                    else
                    {
                        sIdentityType = " [" + Globals.m_IdentityIndexTYPE + "]";
                    }

                    str = Globals.LeftMargin + AddForeignKeyMySQL(ref m_Fkey, refTable, ref fk) + " " + sIdentityType + " unsigned " + strNull;
                    fKey = fk;
                    return str;
                }
                else
                {
                    sBasicType = DBTypes.DBtypesFunc.GetBasicTypeMySQL(obj);
                }
                return Globals.LeftMargin + "`" + columnName + "` " + sBasicType + strNull;
            }
            else
            {
                return "!!!Object Is Null!!!";
            }
        }
Ejemplo n.º 6
0
 public string AddForeignKeySQLite(ref List<ForeignKey> m_Fkey, SQLTable fTbl, ref ForeignKey fk)
 {
     string columnName = this.Name; //Func.GetNameFromObjectType(obj);
     fk.ID_ForeignKey = columnName;
     Name = columnName;
     fk.ReferenceTable = columnName;
     fk.ReferenceTable_Column = "ID";
     fk.refInListOfTables = fTbl;
     m_Fkey.Add(fk);
     return " " + fk.ID_ForeignKey + " ";
 }
Ejemplo n.º 7
0
        public Column(SQLTable owner,Object xObj, nullTYPE xType, Flags xflags, eStyle styl, ltext Name_in_lang)
        {
            Style = styl;
            fKey = null;
            obj = xObj;
            nulltype = xType;
            flags = xflags;
               // int i = 0;
            int iCount = Name_in_lang.sText_Length;
            this.ownerTable = owner;

            Name = StaticLib.Func.GetNameFromObjectType(obj);
            if (obj.GetType() == typeof(ID))
            {
                IsIdentity = true;
            }

            Name_in_language = Name_in_lang;
            //Name_in_language = new ltext();

            //for (i = 0; i < iCount; i++)
            //{
            //    Name_in_language.sText(i)=Name_in_lang.sText(i);
            //}
        }