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 PDatabase CreateNewDatabase(ref PDatabase dbInfo) { //reset Concrete ConcreteDb.Instance.resetConnection(); try { SQLiteConnection.CreateFile(dbInfo.DBPath); Parameter.connectionString = dbInfo.ConnectString; //chac chan param da mang value ConcreteDb db = ConcreteDb.Instance; 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)) { MessageBox.Show("Error : " + db.errorMessage + " please try again!", "Notification", MessageBoxButtons.OK, MessageBoxIcon.Error); return(null); } } catch (Exception Ex) { MessageBox.Show(Ex.Message); Parameter.connectionString = String.Empty; return(null); } //get full info before return(dbInfo); }
public PDatabase OpenDialogGetPDb(bool reload = false) { this.setupDialog(); if (reload) { if (String.IsNullOrEmpty(this.pDatabase.ConnectString)) { MessageBox.Show("Can not Reload Db", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } Parameter.connectionString = this.pDatabase.ConnectString; if (this.dbService.OpenExistingDatabase(ref this.pDatabase) == null) { MessageBox.Show("Error : Cannot connect to the database, please try again!", "Notification", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else #region forDebug if (ConfigurationManager.AppSettings["devmode"].ToString().Contains("1")) { //this.pDatabase = new PDatabase(@"D:\uni\2018-2019\KHOALUANTOTNGHIEP\Project PRDB\PRDB_Sqlite\PRDB_Sqlite.Presentation\CLINIC_DATABASE.pdb"); var constr = AppDomain.CurrentDomain.BaseDirectory + @"CLINIC_DATABASE.pdb"; this.pDatabase = new PDatabase(constr); Parameter.connectionString = this.pDatabase.ConnectString; if (this.dbService.OpenExistingDatabase(ref this.pDatabase) == null) { MessageBox.Show("Error : Cannot connect to the database, please try again!", "Notification", MessageBoxButtons.OK, MessageBoxIcon.Error); } } #endregion else { if (this.dialog.ShowDialog() == DialogResult.OK) { this.pDatabase = new PDatabase(this.dialog.FileName); Parameter.connectionString = this.pDatabase.ConnectString; if (this.dbService.OpenExistingDatabase(ref this.pDatabase) == null) { MessageBox.Show("Error : Cannot connect to the database, please try again!", "Notification", MessageBoxButtons.OK, MessageBoxIcon.Error); } } this.dialog.Dispose(); } return((this.pDatabase != null) ? this.pDatabase : null); }
public PDatabase CreateNewDb() { this.pDatabase = null; Parameter.connectionString = String.Empty; this.setupDialog(isNewDb: true); if (this.dialog.ShowDialog() == DialogResult.OK) { this.pDatabase = new PDatabase(dialog.FileName); Parameter.connectionString = pDatabase.ConnectString; if (this.dbService.CreateNewDatabase(ref this.pDatabase) == null) { MessageBox.Show("Error : Cannot create new database, please try again!", "Notification", MessageBoxButtons.OK, MessageBoxIcon.Error); } } this.dialog.Dispose(); return((this.pDatabase != null) ? this.pDatabase : null); }
protected MdlFileDialog() { dbService = DbFactory.GetDatabaseService(); this.pDatabase = null; this.dialog = null; }
public AddingSchema() { this.pDatabase = StaticParams.currentDb; InitializeComponent(); setUpDtg(); }