public FrmDelSchema(FProbDatabaseBLL probDatabase)
 {
     // TODO: Complete member initialization
     InitializeComponent();
     this.probDatabase = probDatabase;
     this.list         = this.probDatabase.ListOfSchemeNameToLower();
 }
 public FrmEditSchema(FProbDatabaseBLL probDatabase, string scheme)
 {
     // TODO: Complete member initialization
     InitializeComponent();
     this.probDatabase = probDatabase;
     this.scheme       = scheme;
 }
Beispiel #3
0
 public FrmRenameRelation(FProbDatabaseBLL probDatabase, string relationName)
 {
     // TODO: Complete member initialization
     InitializeComponent();
     this.relationName = relationName;
     this.probDatabase = probDatabase;
 }
Beispiel #4
0
 public FrmDelQuery(FProbDatabaseBLL probDatabase, string QueryName)
 {
     // TODO: Complete member initialization
     InitializeComponent();
     this.probDatabase = probDatabase;
     this.QueryName    = QueryName;
     QueryNameRemove   = "";
 }
Beispiel #5
0
 public FrmRenameQuery(FProbDatabaseBLL probDatabase, string queryName)
 {
     // TODO: Complete member initialization
     this.probDatabase = probDatabase;
     listNameQuery.AddRange(this.probDatabase.ListOfQueryNameToLower());
     InitializeComponent();
     this.queryName = queryName;
 }
 internal static bool CreateNewDatabase(FProbDatabaseBLL probDatabase)
 {
     try
     {
         SQLiteConnection.CreateFile(probDatabase.DbPath);
         DataBase db     = new DataBase(probDatabase.ConnectString);
         string   strSQL = "";
         // Record set of schemes to the database system
         strSQL += "CREATE TABLE SystemScheme ( ID INT, SchemeName NVARCHAR(255) );";
         if (!db.CreateTable(strSQL))
         {
             throw new Exception(db.errorMessage);
         }
         // Record set of relations to the database system
         strSQL  = "";
         strSQL += "CREATE TABLE SystemRelation (ID INT,RelationName NVARCHAR(255), SchemeID INT );";
         if (!db.CreateTable(strSQL))
         {
             throw new Exception(db.errorMessage);
         }
         // Record set of attributes to the database system
         strSQL  = "";
         strSQL += "CREATE TABLE SystemAttribute (ID INT,PrimaryKey NVARCHAR(10),AttributeName NVARCHAR(255),DataType NVARCHAR(255),Domain TEXT,Description TEXT,SchemeID INT ); ";
         if (!db.CreateTable(strSQL))
         {
             throw new Exception(db.errorMessage);
         }
         // Record set of queries to the database system
         strSQL  = "";
         strSQL += "CREATE TABLE SystemQuery (ID INT,QueryName NVARCHAR(255),QueryString TEXT );";
         if (!db.CreateTable(strSQL))
         {
             XtraMessageBox.Show("Error : " + db.errorMessage + " please try again!", "Notification", MessageBoxButtons.OK, MessageBoxIcon.Error);
             return(false);
         }
     }
     catch (Exception Ex)
     {
         XtraMessageBox.Show(Ex.Message);
         return(false);
     }
     return(true);
 }
        internal static FProbDatabaseBLL OpenExistingDatabase(FProbDatabaseBLL probDatabase)
        {
            FProbDatabaseBLL newProbDatabase = new FProbDatabaseBLL(probDatabase);

            try
            {
                List <FProbSchemaBLL> Schemes = new List <FProbSchemaBLL>();
                Schemes = new FProbSchemaBLL().getAllScheme();
                newProbDatabase.FproSchemas = Schemes;

                List <FProbRelationBLL> relations = new List <FProbRelationBLL>();
                relations = new FProbRelationBLL().getAllRelation();
                newProbDatabase.FproRelations = relations;

                List <FProbQueryBLL> querys = new List <FProbQueryBLL>();
                querys = new FProbQueryBLL().getAllQuery();
                newProbDatabase.FproQueries = querys;
            }
            catch (Exception)
            {
                return(null);
            }
            return(newProbDatabase);
        }
Beispiel #8
0
 public FrmRenameDB(FProbDatabaseBLL probDatabase)
 {
     // TODO: Complete member initialization
     InitializeComponent();
     this.probDatabase = probDatabase;
 }
        internal static bool SaveDatabase(FProbDatabaseBLL probDatabase)
        {
            try
            {
                //Drop data base
                DropDatabaseData();
                int schemeID    = 0;
                int attributeID = 0;

                #region Save Scheme
                foreach (FProbSchemaBLL scheme in probDatabase.FproSchemas)
                {
                    /// Save Schemes
                    schemeID++;
                    scheme.SchemaName = scheme.SchemaName.ToLower().Trim();
                    scheme.IdSchema   = schemeID;
                    scheme.Insert();

                    ///Save attributes of the scheme to the System Attribute Table
                    foreach (FProbAttributeBLL attr in scheme.FproAttributes)
                    {
                        attributeID++;
                        attr.FproSchema    = scheme;
                        attr.AttributeName = attr.AttributeName.Trim();
                        attr.IdAttribute   = attributeID;
                        attr.Insert();
                    }
                }
                #endregion

                #region Save Relations
                int relationID = 0;
                foreach (FProbRelationBLL relation in probDatabase.FproRelations)
                {
                    relationID++;
                    relation.IdRelation   = relationID;
                    relation.RelationName = relation.RelationName.ToLower().Trim();
                    relation.InsertSystemRelation();

                    /// Create Table <Relation> //
                    relation.CreateTableRelation();

                    // Insert tuples into Talbe <Relation> //
                    relation.InsertTupleIntoTableRelation();
                }
                #endregion

                #region Save Query
                int queryID = 0;
                foreach (FProbQueryBLL item in probDatabase.FproQueries)
                {
                    queryID++;
                    item.QueryName = item.QueryName.ToLower().Trim();
                    item.IdQuery   = queryID;
                    item.Insert();
                }
                #endregion
            }
            catch (Exception Ex)
            {
                XtraMessageBox.Show(Ex.Message);
                return(false);
            }
            return(true);
        }