public PDatabase OpenExistingDatabase(ref PDatabase pDatabase)
        {
            //reset Concrete
            ConcreteDb.Instance.resetConnection();
            try
            {
                //IList<PSchema> Schemas = new List<PSchema>();
                var Schemas = SchemaService.Instance().getAllScheme();
                pDatabase.Schemas = Schemas;

                //IList<PRelation> relations = new List<PRelation>();
                var relations = RelationService.Instance().getAllRelation();
                pDatabase.Relations = relations;

                //var querys = new List<PQuery>();
                var querys = QueryService.Instance().getAllQuery();
                pDatabase.Queries = querys;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Notification");

                return(null);
            }
            return(pDatabase);
        }
            public IList <PRelation> getAllRelation()
            {
                //"SELECT * FROM SystemRelation", "system_relation")

                var     relations = new List <PRelation>();
                DataSet dts       = new DataSet();

                try
                {
                    dts.Tables.Add(ConcreteDb.Instance.getDataTable("SELECT * FROM SystemRelation", "system_relation"));
                    foreach (DataRow row in dts.Tables["system_relation"].Rows)
                    {
                        string  relationname = row[1].ToString();
                        PSchema schema       = SchemaService.Instance().getSchemeById(Convert.ToInt16(row[2]));
                        var     tuple        = PTupleService.Instance().getAllTupleByRelationName(relationname, schema.Attributes);
                        if (tuple is null)
                        {
                            tuple = new List <PTuple>();
                        }
                        PRelation relation = new PRelation(Convert.ToInt16(row[0]), schema, relationname, tuple);
                        relations.Add(relation);
                    }
                }
                catch
                {
                }

                return(relations);
            }
 public PSchema Delete(PSchema pSchema)
 {
     return(SchemaService.Instance().Delete(pSchema));
 }
 public PSchema Update(PSchema pSchema)
 {
     return(SchemaService.Instance().Update(pSchema));
 }
 public PSchema Insert(PSchema pSchema)
 {
     return(SchemaService.Instance().Insert(pSchema));
 }
 public PSchema getSchemeById(int id)
 {
     return(SchemaService.Instance().getSchemeById(id));
 }
 public int getNextIdSch()
 {
     return(SchemaService.Instance().getNextIdSch());
 }